Add parser convert vnfd all_flavour 41/9241/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Wed, 30 Aug 2017 00:59:31 +0000 (08:59 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Wed, 30 Aug 2017 00:59:31 +0000 (08:59 +0800)
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 <ying.yunlong@zte.com.cn>
lcm/pub/utils/toscaparser/nsdmodel.py

index ce6a8aa..9d2b5a4 100644 (file)
@@ -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