aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/ns/biz/ns_instant.py1
-rw-r--r--lcm/ns_pnfs/biz/create_pnf.py15
-rw-r--r--lcm/ns_pnfs/serializers/pnf_serializer.py4
-rw-r--r--lcm/ns_pnfs/tests/test_create_pnf.py22
-rw-r--r--lcm/pub/msapi/nslcm.py5
-rw-r--r--lcm/pub/msapi/sdc_run_catalog.py8
6 files changed, 38 insertions, 17 deletions
diff --git a/lcm/ns/biz/ns_instant.py b/lcm/ns/biz/ns_instant.py
index 1f72b329..419c4d58 100644
--- a/lcm/ns/biz/ns_instant.py
+++ b/lcm/ns/biz/ns_instant.py
@@ -267,7 +267,6 @@ class InstantNSService(object):
if pnfd["properties"]["descriptor_id"] == pnf["pnfdId"]:
k = pnfd["pnf_id"]
pnf["nsInstances"] = self.ns_inst_id
- # todo pnf["pnfdInfoId"]
pnfs[k] = {
"type": "CreatePnf",
"input": {
diff --git a/lcm/ns_pnfs/biz/create_pnf.py b/lcm/ns_pnfs/biz/create_pnf.py
index c9207135..342d637a 100644
--- a/lcm/ns_pnfs/biz/create_pnf.py
+++ b/lcm/ns_pnfs/biz/create_pnf.py
@@ -23,11 +23,11 @@ logger = logging.getLogger(__name__)
class CreatePnf(object):
def __init__(self, data):
- self.pnfId = data.get("pnfId"),
- self.pnfName = data.get("pnfName"),
- self.pnfdId = data.get("pnfdId"),
- self.pnfdInfoId = data.get("pnfdInfoId"),
- self.pnfProfileId = data.get("pnfProfileId"),
+ self.pnfId = data.get("pnfId")
+ self.pnfName = data.get("pnfName")
+ self.pnfdId = data.get("pnfdId")
+ self.pnfdInfoId = data.get("pnfdInfoId", "")
+ self.pnfProfileId = data.get("pnfProfileId", "")
self.cpInfo = data.get("cpInfo", "")
self.emsId = data.get("emsId", "")
self.nsInstances = data.get("nsInstances")
@@ -41,7 +41,7 @@ class CreatePnf(object):
return GetPnf({"pnfId": self.pnfId}, True).do_biz()
def check_pnfd_valid(self):
- pnf_package_info = query_pnf_descriptor({"pnfId": self.pnfdInfoId})
+ pnf_package_info = query_pnf_descriptor({"pnfdId": self.pnfdId})
if not pnf_package_info:
raise NSLCMException("Pnfd(%s) does not exist." % self.pnfdInfoId)
@@ -59,7 +59,8 @@ class CreatePnf(object):
if not pnfInstances.filter(nsInstances__contains=self.nsInstances):
for pnfInstance in pnfInstances:
new_nsInstances = pnfInstance.nsInstances + "," + self.nsInstances
- pnfInstance.update(nsInstances=new_nsInstances)
+ pnfInstance.nsInstances = new_nsInstances
+ pnfInstance.save()
else:
PNFInstModel(pnfId=self.pnfId,
pnfName=self.pnfName,
diff --git a/lcm/ns_pnfs/serializers/pnf_serializer.py b/lcm/ns_pnfs/serializers/pnf_serializer.py
index b3d7410b..1a5a9815 100644
--- a/lcm/ns_pnfs/serializers/pnf_serializer.py
+++ b/lcm/ns_pnfs/serializers/pnf_serializer.py
@@ -19,9 +19,9 @@ class PnfInstanceSerializer(serializers.Serializer):
pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True, allow_null=False)
pnfName = serializers.CharField(help_text="Name of the PNF.", required=True, allow_null=True)
pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True, allow_null=True)
- pnfdInfoId = serializers.CharField(help_text="Identifier of the PNFD information object related to this PNF.", required=True, allow_null=True)
+ pnfdInfoId = serializers.CharField(help_text="Identifier of the PNFD information object related to this PNF.", required=False, allow_null=True, allow_blank=True)
pnfProfileId = serializers.CharField(help_text="Identifier of the related PnfProfile in the NSD on which the PNF is based.", required=True, allow_null=True)
- cpInfo = serializers.CharField(help_text="Information on the external CP of the PNF.", required=True, allow_null=True)
+ cpInfo = serializers.CharField(help_text="Information on the external CP of the PNF.", required=False, allow_null=True, allow_blank=True)
class PnfInstancesSerializer(serializers.ListSerializer):
diff --git a/lcm/ns_pnfs/tests/test_create_pnf.py b/lcm/ns_pnfs/tests/test_create_pnf.py
index c248ecb5..d691e65b 100644
--- a/lcm/ns_pnfs/tests/test_create_pnf.py
+++ b/lcm/ns_pnfs/tests/test_create_pnf.py
@@ -83,7 +83,27 @@ class TestCreatePnfViews(TestCase):
}
],
"emsId": str(uuid.uuid4()),
- "nsInstances": str(uuid.uuid4()) + "," + str(uuid.uuid4())
+ "nsInstances": str(uuid.uuid4())
+ }
+
+ response = self.client.post("/api/nslcm/v1/pnfs", data=data, format='json')
+ self.assertEqual(status.HTTP_201_CREATED, response.status_code)
+
+ data = {
+ "pnfId": id,
+ "pnfName": "Test PNF",
+ "pnfdId": str(uuid.uuid4()),
+ "pnfdInfoId": str(uuid.uuid4()),
+ "pnfProfileId": str(uuid.uuid4()),
+ "cpInfo": [
+ {
+ "cpInstanceId": str(uuid.uuid4()),
+ "cpdId": "pnf_ext_cp01",
+ "cpProtocolData": []
+ }
+ ],
+ "emsId": str(uuid.uuid4()),
+ "nsInstances": str(uuid.uuid4())
}
response = self.client.post("/api/nslcm/v1/pnfs", data=data, format='json')
diff --git a/lcm/pub/msapi/nslcm.py b/lcm/pub/msapi/nslcm.py
index 921e03f7..4dd0d223 100644
--- a/lcm/pub/msapi/nslcm.py
+++ b/lcm/pub/msapi/nslcm.py
@@ -24,14 +24,15 @@ def call_from_ns_cancel_resource(res_type, instid):
method = "DELETE"
if res_type == 'vl':
uri = '/api/nslcm/v1/ns/vls/%s' % instid
-
elif res_type == 'sfc':
uri = '/api/nslcm/v1/ns/sfcs/%s' % instid
+ elif res_type == 'pnf':
+ uri = '/api/nslcm/v1/pnfs/%s' % instid
else:
# vnf
method = "POST"
uri = '/api/nslcm/v1/ns/terminatevnf/%s' % instid
req_param = {}
ret = req_by_msb(uri, method, json.dumps(req_param))
- logger.info("[NS terminate] call vnfm [%s] result:%s" % (res_type, ret))
+ logger.info("[NS terminate] call res_type [%s] result:%s" % (res_type, ret))
return ret
diff --git a/lcm/pub/msapi/sdc_run_catalog.py b/lcm/pub/msapi/sdc_run_catalog.py
index 547a542b..073b8332 100644
--- a/lcm/pub/msapi/sdc_run_catalog.py
+++ b/lcm/pub/msapi/sdc_run_catalog.py
@@ -59,11 +59,11 @@ def query_vnfpackage_by_id(csar_id):
def query_pnf_descriptor(filter=None):
if filter:
- pnfdInfoId = filter.get("pnfdInfoId")
- ret = req_by_msb("/api/catalog/v1/pnf_descriptors/%s" % pnfdInfoId, "GET")
+ pnfdId = filter.get("pnfdId")
+ ret = req_by_msb("/api/nsd/v1/pnf_descriptors?pnfdId=%s" % pnfdId, "GET")
else:
- ret = req_by_msb("/api/catalog/v1/pnf_descriptors", "GET")
+ ret = req_by_msb("/api/nsd/v1/pnf_descriptors", "GET")
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
- raise NSLCMException("Failed to query pnf descriptor(%s) from catalog." % pnfdInfoId)
+ raise NSLCMException("Failed to query pnf descriptor(%s) from catalog." % pnfdId)
return json.JSONDecoder().decode(ret[1])