From: tierno Date: Wed, 14 Oct 2020 14:59:36 +0000 (+0000) Subject: fix 1261: change parameter to int/bool according to data-type X-Git-Tag: release-v9.0-start~19 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F9877%2F1;p=osm%2FLCM.git fix 1261: change parameter to int/bool according to data-type when executing a VCA primitive, parameter values are always a string (defined at yang model), but key 'data-type' can indicate that this is a STRING, INTEGER or BOOLEAN. In case of not a string data is converted to the target type Change-Id: I77babb1859b99df9290373deb3568686663d2015 Signed-off-by: tierno --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 5b06c18..2a0e8b4 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -3557,6 +3557,14 @@ class NsLcm(LcmBase): width=256) elif isinstance(calculated_params[param_name], str) and calculated_params[param_name].startswith("!!yaml "): calculated_params[param_name] = calculated_params[param_name][7:] + if parameter.get("data-type") == "INTEGER": + try: + calculated_params[param_name] = int(calculated_params[param_name]) + except ValueError: # error converting string to int + raise LcmException( + "Parameter {} of primitive {} must be integer".format(param_name, primitive_desc["name"])) + elif parameter.get("data-type") == "BOOLEAN": + calculated_params[param_name] = not ((str(calculated_params[param_name])).lower() == 'false') # add always ns_config_info if primitive name is config if primitive_desc["name"] == "config":