implementation of vdu:interface:mgmt-interface for getting vdu ip address 77/6377/3 BUILD_v4.0.1_1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 23 Jul 2018 14:16:00 +0000 (16:16 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 24 Jul 2018 13:04:42 +0000 (15:04 +0200)
Change-Id: I3d7e0116b0fc6624846ccc0803c3f00f820e5bde
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
openmanod
osm_ro/nfvo.py
osm_ro/nfvo_db.py

index f3b2800..6cccf0e 100755 (executable)
--- a/openmanod
+++ b/openmanod
@@ -48,7 +48,7 @@ import osm_ro
 
 __author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
 __date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.5.73-r583"
+__version__ = "0.5.74-r584"
 version_date = "Jul 2018"
 database_version = 32      # expected database schema version
 
index 343685d..0241323 100644 (file)
@@ -1086,6 +1086,9 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor):
                                                 vnfd_id, vdu_id, iface.get("virtual-interface").get("type")),
                                             HTTP_Bad_Request)
 
+                    if iface.get("mgmt-interface"):
+                        db_interface["type"] = "mgmt"
+
                     if iface.get("external-connection-point-ref"):
                         try:
                             cp = vnfd.get("connection-point")[iface.get("external-connection-point-ref")]
index 11d7d37..0418de4 100644 (file)
@@ -982,19 +982,27 @@ class nfvo_db(db_base.db_base):
                     
                     # instance_vnfs
                     cmd = "SELECT iv.uuid as uuid, iv.vnf_id as vnf_id, sv.name as vnf_name, sce_vnf_id, datacenter_id"\
-                                " ,datacenter_tenant_id, v.mgmt_access, sv.member_vnf_index, v.osm_id as vnfd_osm_id "\
-                            " FROM instance_vnfs as iv left join sce_vnfs as sv "\
-                                "on iv.sce_vnf_id=sv.uuid join vnfs as v on iv.vnf_id=v.uuid" \
-                            " WHERE iv.instance_scenario_id='{}'" \
-                            " ORDER BY iv.created_at ".format(instance_dict['uuid'])
+                          ", datacenter_tenant_id, v.mgmt_access, sv.member_vnf_index, v.osm_id as vnfd_osm_id "\
+                          "FROM instance_vnfs as iv left join sce_vnfs as sv "\
+                          " on iv.sce_vnf_id=sv.uuid join vnfs as v on iv.vnf_id=v.uuid " \
+                          "WHERE iv.instance_scenario_id='{}' " \
+                          "ORDER BY iv.created_at ".format(instance_dict['uuid'])
                     self.logger.debug(cmd)
                     self.cur.execute(cmd)
                     instance_dict['vnfs'] = self.cur.fetchall()
                     for vnf in instance_dict['vnfs']:
-                        vnf_manage_iface_list=[]
-                        #instance vms
+
+                        vnf_mgmt_access_iface = None
+                        vnf_mgmt_access_vm = None
+                        if vnf["mgmt_access"]:
+                            vnf_mgmt_access = yaml.load(vnf["mgmt_access"])
+                            vnf_mgmt_access_iface = vnf_mgmt_access.get("interface_id")
+                            vnf_mgmt_access_vm = vnf_mgmt_access.get("vm_id")
+                            vnf["ip_address"] = vnf_mgmt_access.get("ip-address")
+
+                        # instance vms
                         cmd = "SELECT iv.uuid as uuid, vim_vm_id, status, error_msg, vim_info, iv.created_at as "\
-                               "created_at, name, vms.osm_id as vdu_osm_id, vim_name"\
+                               "created_at, name, vms.osm_id as vdu_osm_id, vim_name, vms.uuid as vm_uuid"\
                                 " FROM instance_vms as iv join vms on iv.vm_id=vms.uuid "\
                                 " WHERE instance_vnf_id='{}' ORDER BY iv.created_at".format(vnf['uuid'])
                         self.logger.debug(cmd)
@@ -1004,21 +1012,28 @@ class nfvo_db(db_base.db_base):
                             vm_manage_iface_list=[]
                             # instance_interfaces
                             cmd = "SELECT vim_interface_id, instance_net_id, internal_name,external_name, mac_address,"\
-                                  " ii.ip_address as ip_address, vim_info, i.type as type, sdn_port_id"\
+                                  " ii.ip_address as ip_address, vim_info, i.type as type, sdn_port_id, i.uuid"\
                                   " FROM instance_interfaces as ii join interfaces as i on ii.interface_id=i.uuid"\
                                   " WHERE instance_vm_id='{}' ORDER BY created_at".format(vm['uuid'])
                             self.logger.debug(cmd)
                             self.cur.execute(cmd )
                             vm['interfaces'] = self.cur.fetchall()
                             for iface in vm['interfaces']:
+                                if vnf_mgmt_access_iface and vnf_mgmt_access_iface == iface["uuid"]:
+                                    vnf["ip_address"] = iface["ip_address"]
                                 if iface["type"] == "mgmt" and iface["ip_address"]:
-                                    vnf_manage_iface_list.append(iface["ip_address"])
                                     vm_manage_iface_list.append(iface["ip_address"])
                                 if not verbose:
                                     del iface["type"]
-                            if vm_manage_iface_list: vm["ip_address"] = ",".join(vm_manage_iface_list)
-                        if vnf_manage_iface_list: vnf["ip_address"] = ",".join(vnf_manage_iface_list)
-                        
+                                del iface["uuid"]
+                            if vm_manage_iface_list:
+                                vm["ip_address"] = ",".join(vm_manage_iface_list)
+                                if vnf_mgmt_access_vm == vm["vm_uuid"]:
+                                    vnf["ip_address"] = vm["ip_address"]
+                                elif not vnf.get("ip_address"):
+                                    vnf["ip_address"] = vm["ip_address"]
+                            del vm["vm_uuid"]
+
                     #instance_nets
                     #select_text = "instance_nets.uuid as uuid,sce_nets.name as net_name,instance_nets.vim_net_id as net_id,instance_nets.status as status,instance_nets.external as external" 
                     #from_text = "instance_nets join instance_scenarios on instance_nets.instance_scenario_id=instance_scenarios.uuid " + \