diff options
-rw-r--r-- | lcm/pub/utils/toscaparser/__init__.py | 3 | ||||
-rw-r--r-- | lcm/pub/utils/toscaparser/nsdmodel.py | 38 |
2 files changed, 38 insertions, 3 deletions
diff --git a/lcm/pub/utils/toscaparser/__init__.py b/lcm/pub/utils/toscaparser/__init__.py index b224f4ef..919e95e2 100644 --- a/lcm/pub/utils/toscaparser/__init__.py +++ b/lcm/pub/utils/toscaparser/__init__.py @@ -13,10 +13,8 @@ # limitations under the License. import json -from lcm.pub.utils.toscaparser.convert import convert_nsd, convert_vnfd from lcm.pub.utils.toscaparser.nsdmodel import EtsiNsdInfoModel from lcm.pub.utils.toscaparser.vnfdmodel import EtsiVnfdInfoModel -from lcm.pub.utils.toscaparser.parser import parse_nsd_model, parse_vnfd_model def parse_nsd(path, input_parameters=[]): @@ -31,4 +29,3 @@ def parse_vnfd(path, input_parameters=[]): strResponse = json.dumps(tosca_obj, default=lambda obj: obj.__dict__) strResponse = strResponse.replace(': null', ': ""') return strResponse - diff --git a/lcm/pub/utils/toscaparser/nsdmodel.py b/lcm/pub/utils/toscaparser/nsdmodel.py index 1838014d..9c60029f 100644 --- a/lcm/pub/utils/toscaparser/nsdmodel.py +++ b/lcm/pub/utils/toscaparser/nsdmodel.py @@ -23,6 +23,8 @@ class EtsiNsdInfoModel(BaseInfoModel): self.cps = self.get_all_cp(nodeTemplates) self.routers = self.get_all_router(nodeTemplates) self.fps = self._get_all_fp(nodeTemplates) + self.vnffgs = self._get_all_vnffg(tosca.topology_template.groups) + self.server_groups = self.get_all_server_group(tosca.topology_template.groups) def buildInputs(self, top_inputs): @@ -235,3 +237,39 @@ class EtsiNsdInfoModel(BaseInfoModel): def get_node_by_req(self, node_templates, req): req_node_name = self.get_requirement_node_name(req) return self.get_node_by_name(node_templates, req_node_name) + + def _get_all_vnffg(self, groups): + vnffgs = [] + for group in groups: + if self._isVnffg(group): + vnffg = {} + vnffg['vnffg_id'] = group.name + vnffg['description'] = group.description + if 'properties' in group.tpl: + vnffg['properties'] = group.tpl['properties'] + vnffg['members'] = group.members + + vnffgs.append(vnffg) + return vnffgs + + def _isVnffg(self, group): + return group.type.upper().find('.VNFFG.') >= 0 or group.type.upper().find( + '.SFC.') >= 0 or group.type.upper().endswith('.VNFFG') or group.type.upper().endswith('.SFC') + + def get_all_server_group(self, groups): + rets = [] + for group in groups: + if self._isServerGroup(group): + ret = {} + ret['group_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 _isServerGroup(self, group): + return group.type.upper().find('.AFFINITYORANTIAFFINITYGROUP.') >= 0 or group.type.upper().endswith( + '.AFFINITYORANTIAFFINITYGROUP') |