X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=blobdiff_plain;f=NG-RO%2Fosm_ng_ro%2Fns.py;fp=NG-RO%2Fosm_ng_ro%2Fns.py;h=84a800e22b55e9db9a0e3a79c2b170edb81c4b41;hp=6cea780027b6abd62071ffdbbf5fd7e8d25d8e3a;hb=a5233f8f1853cc5e8b71865ad4f26715a08b6eed;hpb=95e83692f42dfd338b7c7566281933fbfae32e4a diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 6cea7800..84a800e2 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -818,17 +818,23 @@ class Ns(object): db = kwargs.get("db") target_vdur = {} + for vnf in indata.get("vnf", []): + for vdur in vnf.get("vdur", []): + if vdur.get("ns-flavor-id") == target_flavor.get("id"): + target_vdur = vdur + + vim_flavor_id = ( + target_vdur.get("additionalParams", {}).get("OSM", {}).get("vim_flavor_id") + ) + if vim_flavor_id: # vim-flavor-id was passed so flavor won't be created + return {"find_params": {"vim_flavor_id": vim_flavor_id}} + flavor_data = { "disk": int(target_flavor["storage-gb"]), "ram": int(target_flavor["memory-mb"]), "vcpus": int(target_flavor["vcpu-count"]), } - for vnf in indata.get("vnf", []): - for vdur in vnf.get("vdur", []): - if vdur.get("ns-flavor-id") == target_flavor.get("id"): - target_vdur = vdur - if db and isinstance(indata.get("vnf"), list): vnfd_id = indata.get("vnf")[0].get("vnfd-id") vnfd = db.get_one("vnfds", {"_id": vnfd_id}) @@ -1522,12 +1528,12 @@ class Ns(object): vnf_preffix = "vnfrs:{}".format(vnfr_id) ns_preffix = "nsrs:{}".format(nsr_id) image_text = ns_preffix + ":image." + target_vdu["ns-image-id"] - extra_dict = {"depends_on": [image_text]} + flavor_text = ns_preffix + ":flavor." + target_vdu["ns-flavor-id"] + extra_dict = {"depends_on": [image_text, flavor_text]} net_list = [] persistent_root_disk = {} persistent_ordinary_disk = {} vdu_instantiation_volumes_list = [] - vdu_instantiation_flavor_id = None disk_list = [] vnfd_id = vnfr["vnfd-id"] vnfd = db.get_one("vnfds", {"_id": vnfd_id}) @@ -1566,17 +1572,6 @@ class Ns(object): vdu_instantiation_volumes_list = ( target_vdu.get("additionalParams").get("OSM", {}).get("vdu_volumes") ) - vdu_instantiation_flavor_id = ( - target_vdu.get("additionalParams").get("OSM", {}).get("vim_flavor_id") - ) - - # flavor id - if vdu_instantiation_flavor_id: - flavor_id = vdu_instantiation_flavor_id - else: - flavor_text = ns_preffix + ":flavor." + target_vdu["ns-flavor-id"] - flavor_id = "TASK-" + flavor_text - extra_dict["depends_on"].append(flavor_text) if vdu_instantiation_volumes_list: # Find the root volumes and add to the disk_list @@ -1624,7 +1619,7 @@ class Ns(object): "description": target_vdu["vdu-name"], "start": True, "image_id": "TASK-" + image_text, - "flavor_id": flavor_id, + "flavor_id": "TASK-" + flavor_text, "affinity_group_list": affinity_group_list, "net_list": net_list, "cloud_config": cloud_config or None,