diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-08-25 09:09:50 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-08-25 09:09:50 +0800 |
commit | 5611b879603e9bc915ef1b3f1df022bb93465ebd (patch) | |
tree | 0955974970f99b7c247c6b3b86212305364679e8 | |
parent | 4ade9ad1887d2ccdfa81596e9f22108cd90bf774 (diff) |
Add convert policies_scaling logic
After parse the nsd package, add
_get_policies_scaling function to convert
the policies_scaling info.
Change-Id: I74a2c52f4392e520efada09491eafbcc00a2b0c2
Issue-ID: VFC-164
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/pub/utils/toscaparser/nsdmodel.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lcm/pub/utils/toscaparser/nsdmodel.py b/lcm/pub/utils/toscaparser/nsdmodel.py index b58462c1..ce6a8aa5 100644 --- a/lcm/pub/utils/toscaparser/nsdmodel.py +++ b/lcm/pub/utils/toscaparser/nsdmodel.py @@ -26,6 +26,7 @@ class EtsiNsdInfoModel(BaseInfoModel): self.vnffgs = self._get_all_vnffg(tosca.topology_template.groups) 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) def buildInputs(self, top_inputs): @@ -300,4 +301,28 @@ class EtsiNsdInfoModel(BaseInfoModel): forward_cps.append({"key_name": key, "cpd_id": value[0]}) else: forward_cps.append({"key_name": key, "cpd_id": value}) - return forward_cps
\ No newline at end of file + return forward_cps + + def _get_policies_scaling(self, top_policies): + policies_scaling = [] + scaling_policies = self.get_scaling_policies(top_policies) + if len(scaling_policies) > 0: + policies_scaling.append({"scaling": scaling_policies}) + return policies_scaling + + def get_policies_by_keyword(self, top_policies, keyword): + ret = [] + for policy in top_policies: + if policy.type.upper().find(keyword) >= 0: + tmp = {} + tmp['policy_id'] = policy.name + tmp['description'] = policy.description + if 'properties' in policy.entity_tpl: + tmp['properties'] = policy.entity_tpl['properties'] + tmp['targets'] = policy.targets + ret.append(tmp) + + return ret + + def get_scaling_policies(self, top_policies): + return self.get_policies_by_keyword(top_policies, '.SCALING')
\ No newline at end of file |