summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-04 08:58:48 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-04 08:58:48 +0800
commit6260dad1f2ca6be7b620543c936166011f558ad6 (patch)
tree59863b496cfe03b4ab9ff575a7e94bb30f515bdc
parent25dcd341387ce26bcea855fa7dab2781e3af09b6 (diff)
Add parser convert vnfd vl and cp
After parse the vnfd package, add get_all_vl and get_all_cp function to convert the vl and cp info. Change-Id: I4d752d2bfbeacb52549b1759f1b8f2733e2404cd Issue-ID: VFC-243 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/ns/tests/vnfs/tests.py4
-rw-r--r--lcm/pub/utils/toscaparser/basemodel.py6
-rw-r--r--lcm/pub/utils/toscaparser/vnfdmodel.py19
3 files changed, 29 insertions, 0 deletions
diff --git a/lcm/ns/tests/vnfs/tests.py b/lcm/ns/tests/vnfs/tests.py
index 73cecd96..64559ff1 100644
--- a/lcm/ns/tests/vnfs/tests.py
+++ b/lcm/ns/tests/vnfs/tests.py
@@ -294,6 +294,10 @@ class TestScaleVnfViews(TestCase):
"/api/ztevmanagerdriver/v1/1/vnfs/111/terminate":
[0, json.JSONEncoder().encode({"jobId": job_id}), '200']
}
+ def side_effect(*args):
+ return mock_vals[args[4]]
+ mock_call_req.side_effect = side_effect
+
NFManualScaleService(self.nf_inst_id, req_data).run()
nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
if nsIns:
diff --git a/lcm/pub/utils/toscaparser/basemodel.py b/lcm/pub/utils/toscaparser/basemodel.py
index 218f9336..c912b1f7 100644
--- a/lcm/pub/utils/toscaparser/basemodel.py
+++ b/lcm/pub/utils/toscaparser/basemodel.py
@@ -334,3 +334,9 @@ class BaseInfoModel(object):
if 'capabilities' in node and capabilityName in node['capabilities']:
return node['capabilities'][capabilityName]
return None
+
+ def get_node_vdu_id(self, node):
+ vdu_ids = map(lambda x: self.get_requirement_node_name(x), self.getVirtualbindings(node))
+ if len(vdu_ids) > 0:
+ return vdu_ids[0]
+ return ""
diff --git a/lcm/pub/utils/toscaparser/vnfdmodel.py b/lcm/pub/utils/toscaparser/vnfdmodel.py
index 59eab4e8..166690b8 100644
--- a/lcm/pub/utils/toscaparser/vnfdmodel.py
+++ b/lcm/pub/utils/toscaparser/vnfdmodel.py
@@ -37,6 +37,8 @@ class EtsiVnfdInfoModel(EtsiNsdInfoModel):
self.local_storages = self._get_all_local_storage(nodeTemplates)
self.volume_storages = self._get_all_volume_storage(nodeTemplates)
self.vdus = self._get_all_vdu(nodeTemplates)
+ self.vls = self.get_all_vl(nodeTemplates)
+ self.cps = self.get_all_cp(nodeTemplates)
def _get_all_services(self, nodeTemplates):
@@ -232,3 +234,20 @@ class EtsiVnfdInfoModel(EtsiNsdInfoModel):
ret['deploy_path'] = ''
rets.append(ret)
return rets
+
+ def get_all_cp(self, nodeTemplates):
+ cps = []
+ for node in nodeTemplates:
+ if self.isCp(node):
+ cp = {}
+ cp['cp_id'] = node['name']
+ cp['cpd_id'] = node['name']
+ cp['description'] = node['description']
+ cp['properties'] = node['properties']
+ cp['vl_id'] = self.get_node_vl_id(node)
+ cp['vdu_id'] = self.get_node_vdu_id(node)
+ vls = self.buil_cp_vls(node)
+ if len(vls) > 1:
+ cp['vls'] = vls
+ cps.append(cp)
+ return cps