From: tierno Date: Thu, 2 Apr 2020 14:09:25 +0000 (+0000) Subject: fix ip address on vm scale X-Git-Tag: v7.1.0rc1~1^2~8 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=481ef5ea4584a5b2ab6dbf096413667fdc658723;p=osm%2FRO.git fix ip address on vm scale Change-Id: I596fd86120af668c7c9de5c551ea03de1c477def Signed-off-by: tierno --- diff --git a/RO/osm_ro/nfvo.py b/RO/osm_ro/nfvo.py index 25d8cc6c..9e48c4ae 100644 --- a/RO/osm_ro/nfvo.py +++ b/RO/osm_ro/nfvo.py @@ -4188,14 +4188,14 @@ def instantiate_vnf(mydb, sce_vnf, params, params_out, rollbackList): db_vm_iface_instance.update(db_vm_iface) if db_vm_iface_instance.get("ip_address"): # increment ip_address ip = db_vm_iface_instance.get("ip_address") - i = ip.rfind(".") - if i > 0: - try: + try: + i = ip.rfind(".") + if i > 0: i += 1 ip = ip[i:] + str(int(ip[:i]) + 1) db_vm_iface_instance["ip_address"] = ip - except: - db_vm_iface_instance["ip_address"] = None + except: + db_vm_iface_instance["ip_address"] = None db_instance_interfaces.append(db_vm_iface_instance) myVMDict['networks'][iface_index]["uuid"] = iface_uuid iface_index += 1 @@ -4908,16 +4908,16 @@ def instance_action(mydb,nfvo_tenant,instance_id, action_dict): for iface in task_params_copy[5]: iface["uuid"] = iface2iface[iface["uuid"]] # increment ip_address - if "ip_address" in iface: - ip = iface.get("ip_address") - i = ip.rfind(".") - if i > 0: - try: + if iface.get("ip_address"): + try: + ip = iface["ip_address"] + i = ip.rfind(".") + if i > 0: i += 1 ip = ip[i:] + str(int(ip[:i]) + 1) iface["ip_address"] = ip - except: - iface["ip_address"] = None + except: + iface["ip_address"] = None if vm_name: task_params_copy[0] = vm_name db_vim_action = {