X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=common%2Fpython%2Frift%2Fmano%2Ftosca_translator%2Frwmano%2Ftosca%2Ftosca_initial_config.py;h=9b7cd0397bd115d59c67e61a611e771149a59c84;hb=refs%2Fchanges%2F30%2F1330%2F1;hp=7c03d564812592b4ff8cb3d77ba63dc4a2bd70c0;hpb=e178dc94f7ac4025f84685db11ea36e3a38a0b08;p=osm%2FSO.git diff --git a/common/python/rift/mano/tosca_translator/rwmano/tosca/tosca_initial_config.py b/common/python/rift/mano/tosca_translator/rwmano/tosca/tosca_initial_config.py index 7c03d564..9b7cd039 100644 --- a/common/python/rift/mano/tosca_translator/rwmano/tosca/tosca_initial_config.py +++ b/common/python/rift/mano/tosca_translator/rwmano/tosca/tosca_initial_config.py @@ -18,6 +18,7 @@ from rift.mano.tosca_translator.common.utils import _ from rift.mano.tosca_translator.common.utils import convert_keys_to_python from rift.mano.tosca_translator.rwmano.syntax.mano_resource import ManoResource +from toscaparser.functions import GetInput from toscaparser.common.exception import ValidationError @@ -29,18 +30,16 @@ TARGET_CLASS_NAME = 'ToscaInitialConfig' class ToscaInitialConfig(ManoResource): '''Translate TOSCA node type tosca.policies.InitialConfigPrimitive.''' - toscatype = 'tosca.policies.riftio.InitialConfigPrimitive' + toscatype = 'tosca.policies.nfv.riftio.initial_config_primitive' IGNORE_PROPS = [] - def __init__(self, log, primitive, metadata=None): + def __init__(self, log, policy, metadata=None): # TODO(Philip):Not inheriting for ManoResource, as there is no # instance from parser self.log = log - for name, details in primitive.items(): - self.name = name - self.details = details - break + self.name = policy.name + self.policy = policy self.type_ = 'initial-cfg' self.metadata = metadata self.properties = {} @@ -50,7 +49,7 @@ class ToscaInitialConfig(ManoResource): return "%s(%s)" % (self.name, self.type) def handle_properties(self, nodes, groups): - tosca_props = self.details + tosca_props = self.get_policy_props() self.log.debug(_("{0} with tosca properties: {1}"). format(self, tosca_props)) self.properties['name'] = tosca_props['name'] @@ -71,6 +70,14 @@ class ToscaInitialConfig(ManoResource): self.log.debug(_("{0} properties: {1}").format(self, self.properties)) + def get_policy_props(self): + tosca_props = {} + for prop in self.policy.get_properties_objects(): + if isinstance(prop.value, GetInput): + tosca_props[prop.name] = {'get_param': prop.value.input_name} + else: + tosca_props[prop.name] = prop.value + return tosca_props def get_yang_model_gi(self, nsd, vnfds): props = convert_keys_to_python(self.properties) try: