Add parser convert vnfd local_storage 63/9263/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Wed, 30 Aug 2017 02:35:02 +0000 (10:35 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Wed, 30 Aug 2017 02:35:02 +0000 (10:35 +0800)
After parse the vnfd package, add
_get_all_local_storage function to convert
the local_storage info.

Change-Id: I56d617974e2fa710074ee254951f8fabf5224db1
Issue-ID: VFC-179
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
lcm/pub/utils/toscaparser/vnfdmodel.py

index a9b61b8..50dc7cf 100644 (file)
@@ -20,6 +20,7 @@ class EtsiVnfdInfoModel(EtsiNsdInfoModel):
         self.vcloud = self._get_all_vcloud(nodeTemplates)
         self.vcenter = self._get_all_vcenter(nodeTemplates)
         self.image_files = self._get_all_image_file(nodeTemplates)
+        self.local_storages = self._get_all_local_storage(nodeTemplates)
 
 
     def _get_all_services(self, nodeTemplates):
@@ -96,4 +97,21 @@ class EtsiVnfdInfoModel(EtsiNsdInfoModel):
         return rets
 
     def _isImageFile(self, node):
-        return node['nodeType'].upper().find('.IMAGEFILE.') >= 0 or node['nodeType'].upper().endswith('.IMAGEFILE')
\ No newline at end of file
+        return node['nodeType'].upper().find('.IMAGEFILE.') >= 0 or node['nodeType'].upper().endswith('.IMAGEFILE')
+
+    def _get_all_local_storage(self, nodeTemplates):
+        rets = []
+        for node in nodeTemplates:
+            if self._isLocalStorage(node):
+                ret = {}
+                ret['local_storage_id'] = node['name']
+                if 'description' in node:
+                    ret['description'] = node['description']
+                ret['properties'] = node['properties']
+
+                rets.append(ret)
+        return rets
+
+    def _isLocalStorage(self, node):
+        return node['nodeType'].upper().find('.LOCALSTORAGE.') >= 0 or node['nodeType'].upper().endswith(
+            '.LOCALSTORAGE')