From: tierno Date: Tue, 6 Oct 2020 08:19:21 +0000 (+0000) Subject: fix 1238: Allow individual cloud-init user-data at each VM X-Git-Tag: v8.0.3~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=9405d176348e44e435797bc144fee7f0088bd887;p=osm%2FRO.git fix 1238: Allow individual cloud-init user-data at each VM both for instantiation and scaling. In that way every VM will have individual jinja2 parsing with its own variables that includes among other the count_index Change-Id: I0cfdc9da2f71816273dbf37a03e418aa985d523c Signed-off-by: tierno --- diff --git a/RO/osm_ro/nfvo.py b/RO/osm_ro/nfvo.py index e346699a..ca73a097 100644 --- a/RO/osm_ro/nfvo.py +++ b/RO/osm_ro/nfvo.py @@ -4179,10 +4179,14 @@ def instantiate_vnf(mydb, sce_vnf, params, params_out, rollbackList): else: av_index = None for vm_index in range(0, vm.get('count', 1)): + if vm.get("instance_parameters") and vm["instance_parameters"].get("cloud_init"): + cloud_config_vm_ = unify_cloud_config(cloud_config_vm, + {"user-data": vm["instance_parameters"]["cloud_init"][vm_index]}) + vm_name = myVMDict['name'] + "-" + str(vm_index+1) vm_networks = deepcopy(myVMDict['networks']) task_params = (vm_name, myVMDict['description'], myVMDict.get('start', None), - myVMDict['imageRef'], myVMDict['flavorRef'], vm_networks, cloud_config_vm, + myVMDict['imageRef'], myVMDict['flavorRef'], vm_networks, cloud_config_vm_, myVMDict['disks'], av_index, vnf_availability_zones) vm_uuid = str(uuid4()) @@ -4927,6 +4931,11 @@ def instance_action(mydb,nfvo_tenant,instance_id, action_dict): db_vim_actions.append({"TO-UPDATE": {}, "WHERE": { "item": "instance_wim_nets", "item_id": db_vm_iface["instance_wim_net_id"]}}) task_params_copy = deepcopy(task_params) + cloud_config_vm = task_params_copy[6] or {} + cloud_config_vm.pop("user-data", None) + if vdu.get("cloud_init"): + cloud_config_vm_ = unify_cloud_config(cloud_config_vm, {"user-data": vdu["cloud_init"][index]}) + task_params_copy[6] = cloud_config_vm_ for iface in task_params_copy[5]: iface["uuid"] = iface2iface[iface["uuid"]] # increment ip_address diff --git a/RO/osm_ro/openmano_schemas.py b/RO/osm_ro/openmano_schemas.py index aa235ecb..14e334d4 100644 --- a/RO/osm_ro/openmano_schemas.py +++ b/RO/osm_ro/openmano_schemas.py @@ -56,6 +56,7 @@ port_schema={"type":"integer","minimum":1,"maximum":65534} object_schema={"type":"object"} schema_version_2={"type":"integer","minimum":2,"maximum":2} #schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]} +string_list = {"type": "array", "items": {"type": "string"}} log_level_schema={"type":"string", "enum":["DEBUG", "INFO", "WARNING","ERROR","CRITICAL"]} checksum_schema={"type":"string", "pattern":"^[0-9a-fA-F]{32}$"} size_schema={"type":"integer","minimum":1,"maximum":100} @@ -1033,8 +1034,9 @@ instance_scenario_create_schema_v01 = { "type": "object", "properties": { "name": name_schema, # overrides vdu name schema - "mgmt_keys": {"type": "array", "items": {"type": "string"}}, + "mgmt_keys": string_list, "vduImage": name_schema, + "cloud_init": string_list, "devices": { "type": "object", "patternProperties": { @@ -1172,7 +1174,8 @@ instance_scenario_action_schema = { "osm_vdu_id": name_schema, "member-vnf-index": name_schema, "count": integer1_schema, - "type": {"enum": ["create", "delete"]} + "type": {"enum": ["create", "delete"]}, + "cloud_init": string_list, }, "additionalProperties": False, "minProperties": 1,