From 97eb236addd1c3d2cabe5d00def9dcee9368cf96 Mon Sep 17 00:00:00 2001 From: tierno Date: Wed, 14 Oct 2020 14:59:36 +0000 Subject: [PATCH] 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 --- osm_lcm/ns.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index dce1887..7439d26 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": -- 2.25.1