From 6f918ba0a243d524273414296864dbd6fe8cbb72 Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Wed, 30 Aug 2017 08:59:31 +0800 Subject: [PATCH] Add parser convert vnfd all_flavour After parse the vnfd package, add get_all_flavour function to convert the all_flavour info. Change-Id: I487b0ff54bf587871ece6db4cc3a69c2e4e1934b Issue-ID: VFC-188 Signed-off-by: ying.yunlong --- lcm/pub/utils/toscaparser/nsdmodel.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lcm/pub/utils/toscaparser/nsdmodel.py b/lcm/pub/utils/toscaparser/nsdmodel.py index ce6a8aa5..9d2b5a40 100644 --- a/lcm/pub/utils/toscaparser/nsdmodel.py +++ b/lcm/pub/utils/toscaparser/nsdmodel.py @@ -27,6 +27,7 @@ class EtsiNsdInfoModel(BaseInfoModel): self.server_groups = self.get_all_server_group(tosca.topology_template.groups) self.ns_exposed = self.get_all_endpoint_exposed(tosca.topology_template) self.policies = self._get_policies_scaling(tosca.topology_template.policies) + self.ns_flavours = self.get_all_flavour(tosca.topology_template.groups) def buildInputs(self, top_inputs): @@ -325,4 +326,21 @@ class EtsiNsdInfoModel(BaseInfoModel): return ret def get_scaling_policies(self, top_policies): - return self.get_policies_by_keyword(top_policies, '.SCALING') \ No newline at end of file + return self.get_policies_by_keyword(top_policies, '.SCALING') + + def get_all_flavour(self, groups): + rets = [] + for group in groups: + if self._isFlavour(group): + ret = {} + ret['flavour_id'] = group.name + ret['description'] = group.description + if 'properties' in group.tpl: + ret['properties'] = group.tpl['properties'] + ret['members'] = group.members + + rets.append(ret) + return rets + + def _isFlavour(self, group): + return group.type.upper().find('FLAVOUR') >= 0 \ No newline at end of file -- 2.16.6