RIFT-14562 Supprt of mngmt network overriding on VLDs 22/822/1
authorHashir Mohammed <hashir.mohammed@riftio.com>
Wed, 21 Dec 2016 20:08:18 +0000 (15:08 -0500)
committerHashir Mohammed <hashir.mohammed@riftio.com>
Wed, 21 Dec 2016 20:08:18 +0000 (15:08 -0500)
Signed-off-by: Hashir Mohammed <hashir.mohammed@riftio.com>
rwcal/plugins/vala/rwcal.vala
rwcal/plugins/vala/rwcal_aws/rwcal_aws.py
rwcal/plugins/vala/rwcal_cloudsim/rwcal_cloudsim.py
rwcal/plugins/vala/rwcal_cloudsimproxy/rwcal_cloudsimproxy.py
rwcal/plugins/vala/rwcal_mock/rwcal_mock.py
rwcal/plugins/vala/rwcal_openmano/rwcal_openmano.py
rwcal/plugins/vala/rwcal_openmano_vimconnector/rwcal_openmano_vimconnector.py
rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py
rwcal/plugins/vala/rwcal_vsphere/rwcal_vsphere.py
rwlaunchpad/plugins/rwresmgr/rift/tasklets/rwresmgrtasklet/rwresmgr_core.py
rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py

index a14388e..4229fa1 100644 (file)
@@ -236,6 +236,7 @@ namespace RwCal {
     public abstract RwTypes.RwStatus get_vdu(
       Rwcal.CloudAccount account,
       string vdu_id,
+      string? mgmt_network,
       out Rwcal.VDUInfoParams response);
     
     public abstract RwTypes.RwStatus get_vdu_list(
index 4f212d7..8854b17 100644 (file)
@@ -1071,7 +1071,7 @@ class RwcalAWSPlugin(GObject.Object, RwCal.Cloud):
 
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         """Get information about a virtual deployment unit.
 
         Arguments:
index 6da8a2e..ac81a3e 100644 (file)
@@ -1390,7 +1390,7 @@ class CloudSimPlugin(GObject.Object, RwCal.Cloud):
         return vdu
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         """Get information about a virtual deployment unit.
 
         Arguments:
index addb4d3..d81c6f3 100644 (file)
@@ -682,7 +682,7 @@ class CloudSimProxyPlugin(GObject.Object, RwCal.Cloud):
         return self._proxy_rpc_call("delete_vdu", vdu_id=vdu_id)
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         """Get information about a virtual deployment unit.
 
         Arguments:
index a1776d1..13cc403 100644 (file)
@@ -599,7 +599,7 @@ class MockPlugin(GObject.Object, RwCal.Cloud):
         logger.debug('deleted vdu: {}'.format(vdu_id))
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         vdu = self.resources[account.name].vdus[vdu_id]
         logger.debug('Returning vdu-info for : {}'.format(vdu_id))
         return vdu.copy()
index 1503d64..93d6d2f 100644 (file)
@@ -246,7 +246,7 @@ class RwcalOpenmanoPlugin(GObject.Object, RwCal.Cloud):
         raise NotImplementedError()
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         raise NotImplementedError()
 
     @rwstatus(ret_on_failure=[""])
index aa3d971..f39662c 100644 (file)
@@ -646,7 +646,7 @@ class RwcalOpenmanoVimConnector(GObject.Object, RwCal.Cloud):
         return vdu
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         with self._use_driver(account) as drv:
             vm_info = drv.get_vminstance(vdu_id)
         return  RwcalOpenmanoVimConnector._fill_vdu_info(drv,account,vm_info)
index 3bdf882..8f2678f 100644 (file)
@@ -431,8 +431,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         with self._use_driver(account) as drv:
             vm_id = drv.nova_server_create(**kwargs)
             if floating_ip:
-                self.prepare_vdu_on_boot(account, vm_id, floating_ip)
-
+                self.prepare_vdu_on_boot(account, vm_id, floating_ip, mgmt_network = None)
         return vm_id
 
     @rwstatus
@@ -501,7 +500,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         vm.state     = vm_info['status']
         for network_name, network_info in vm_info['addresses'].items():
             if network_info:
-                if network_name == mgmt_network:
+                if network_name == mgmt_network :
                     vm.public_ip = next((item['addr']
                                             for item in network_info
                                             if item['OS-EXT-IPS:type'] == 'floating'),
@@ -1228,7 +1227,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         return link
 
     @staticmethod
-    def _fill_vdu_info(vm_info, flavor_info, mgmt_network, port_list, server_group, volume_list = None):
+    def _fill_vdu_info(vm_info, flavor_info, mgmt_network, port_list, server_group, volume_list = None, overridden_mgmt_network = None):
         """Create a GI object for VDUInfoParams
 
         Converts VM information dictionary object returned by openstack
@@ -1247,13 +1246,14 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         vdu.name = vm_info['name']
         vdu.vdu_id = vm_info['id']
         for network_name, network_info in vm_info['addresses'].items():
-            if network_info and network_name == mgmt_network:
+            if network_info and network_name == mgmt_network or network_name == overridden_mgmt_network :
                 for interface in network_info:
-                    if 'OS-EXT-IPS:type' in interface:
-                        if interface['OS-EXT-IPS:type'] == 'fixed':
-                            vdu.management_ip = interface['addr']
-                        elif interface['OS-EXT-IPS:type'] == 'floating':
-                            vdu.public_ip = interface['addr']
+                    for interface in network_info:
+                        if 'OS-EXT-IPS:type' in interface:
+                            if interface['OS-EXT-IPS:type'] == 'fixed':
+                                vdu.management_ip = interface['addr']
+                            elif interface['OS-EXT-IPS:type'] == 'floating':
+                                vdu.public_ip = interface['addr']
 
         # Look for any metadata
         for key, value in vm_info['metadata'].items():
@@ -1874,7 +1874,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
                 raise OpenstackCALOperationFailure("Create-flavor operation failed for cloud account: %s" %(account.name))
             return flavor_id
 
-    def _create_vm(self, account, vduinfo, pci_assignement=None, server_group=None, port_list=None, network_list=None, imageinfo_list=None):
+    def _create_vm(self, account, vduinfo, pci_assignement=None, server_group=None, port_list=None, network_list=None, imageinfo_list=None, mgmt_network = None):
         """Create a new virtual machine.
 
         Arguments:
@@ -1969,7 +1969,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         with self._use_driver(account) as drv:
             vm_id = drv.nova_server_create(**kwargs)
             if floating_ip:
-                self.prepare_vdu_on_boot(account, vm_id, floating_ip)
+                self.prepare_vdu_on_boot(account, vm_id, floating_ip, mgmt_network)
 
         return vm_id
 
@@ -2017,6 +2017,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         """
         ### First create required number of ports aka connection points
         # Add the mgmt_ntwk by default.
+
         mgmt_network_id = None
         with self._use_driver(account) as drv:
             mgmt_network_id = drv._mgmt_network_id
@@ -2029,16 +2030,16 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
                 floating_ip = self._allocate_floating_ip(drv, pool_name)
             else:
                 floating_ip = None
-
         port_list = []
         network_list = []
         imageinfo_list = []
-        is_explicit_mgmt_defined = False
-        for c_point in vdu_init.connection_points:
+        explicit_mgmt_network = None
+        if vdu_init.get_mgmt_network() is not None:
+            explicit_mgmt_network = vdu_init.get_mgmt_network()
+
+        for c_point in reversed(vdu_init.connection_points):
             # if the user has specified explicit mgmt_network connection point
             # then remove the mgmt_network from the VM list
-            if c_point.virtual_link_id == mgmt_network_id:
-                is_explicit_mgmt_defined = True
             if c_point.virtual_link_id in network_list:
                 assert False, "Only one port per network supported. Refer: http://specs.openstack.org/openstack/nova-specs/specs/juno/implemented/nfv-multiple-if-1-net.html"
             else:
@@ -2100,7 +2101,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         with self._use_driver(account) as drv:
             ### Now Create VM
             vm_network_list = []
-            if not is_explicit_mgmt_defined:
+            if explicit_mgmt_network is None:
                 vm_network_list.append(drv._mgmt_network_id)
   
             if vdu_init.has_field('volumes'):
@@ -2137,8 +2138,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
             if pci_assignement != '':
                 vm.user_tags.pci_assignement = pci_assignement
 
-            vm_id = self._create_vm(account, vdu_init, pci_assignement=pci_assignement, server_group=server_group, port_list=port_list, network_list=vm_network_list, imageinfo_list = imageinfo_list)
-            self.prepare_vdu_on_boot(account, vm_id, floating_ip)
+            vm_id = self._create_vm(account, vdu_init, pci_assignement=pci_assignement, server_group=server_group, port_list=port_list, network_list=vm_network_list, imageinfo_list = imageinfo_list, mgmt_network = explicit_mgmt_network)           
             return vm_id
 
     def prepare_vpci_metadata(self, drv, vdu_init):
@@ -2184,13 +2184,22 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
 
 
 
-    def prepare_vdu_on_boot(self, account, server_id, floating_ip):
-        cmd = PREPARE_VM_CMD.format(auth_url     = account.openstack.auth_url,
+    def prepare_vdu_on_boot(self, account, server_id, floating_ip, mgmt_network = None):
+
+        if(mgmt_network is None):
+            cmd = PREPARE_VM_CMD.format(auth_url = account.openstack.auth_url,
                                     username     = account.openstack.key,
                                     password     = account.openstack.secret,
                                     tenant_name  = account.openstack.tenant,
                                     mgmt_network = account.openstack.mgmt_network,
                                     server_id    = server_id)
+        else:
+            cmd = PREPARE_VM_CMD.format(auth_url = account.openstack.auth_url,
+                                    username     = account.openstack.key,
+                                    password     = account.openstack.secret,
+                                    tenant_name  = account.openstack.tenant,
+                                    mgmt_network = mgmt_network,
+                                    server_id    = server_id)
 
         if floating_ip is not None:
             cmd += (" --floating_ip "+ floating_ip.ip)
@@ -2265,7 +2274,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
 
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         """Get information about a virtual deployment unit.
 
         Arguments:
@@ -2295,7 +2304,8 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
                                                            account.openstack.mgmt_network,
                                                            port_list,
                                                            server_group,
-                                                           volume_list = openstack_srv_volume_list)
+                                                           volume_list = openstack_srv_volume_list,
+                                                           overridden_mgmt_network = mgmt_network)
             if vdu_info.state == 'active':
                 try:
                     console_info = drv.nova_server_console(vdu_info.vdu_id)
index 2dcbd8c..cda3867 100644 (file)
@@ -230,7 +230,7 @@ class RwcalVspherePlugin(GObject.Object, RwCal.Cloud):
         raise NotImplementedError()
     
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id):
+    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
         raise NotImplementedError()
 
     @rwstatus(ret_on_failure=[""])
index a9fed38..bb087e6 100644 (file)
@@ -242,13 +242,14 @@ class ResourceMgrCALHandler(object):
             raise ResMgrCALOperationFailure("Virtual-compute-release operation failed for cloud account: %s. ResourceID: %s" %(self._account.name, compute_id))
 
     @asyncio.coroutine        
-    def get_virtual_compute_info(self, compute_id):
+    def get_virtual_compute_info(self, compute_id, mgmt_network = None):
         #rc, rs = self._rwcal.get_vdu(self._account, compute_id)
         self._log.debug("Calling get_vdu API with id: %s" %(compute_id))
         rc, rs = yield from self._loop.run_in_executor(self._executor,
                                                        self._rwcal.get_vdu,
                                                        self._account,
-                                                       compute_id)
+                                                       compute_id,
+                                                       mgmt_network)
         if rc != RwStatus.SUCCESS:
             self._log.error("Virtual-compute-info operation failed for cloud account: %s. ResourceID: %s",
                             self._account.name,
@@ -767,7 +768,7 @@ class ComputePool(ResourcePool):
 
     @asyncio.coroutine
     def get_resource_info(self, resource):
-        info = yield from self._cal.get_virtual_compute_info(resource.resource_id)
+        info = yield from self._cal.get_virtual_compute_info(resource.resource_id, resource.requested_params.mgmt_network)
 
         self._log.info("Successfully retrieved virtual-compute information from CAL with resource-id: %s. Info: %s",
                        resource.resource_id, str(info))
index e39a8ae..460b273 100755 (executable)
@@ -855,7 +855,6 @@ class VirtualDeploymentUnitRecord(object):
             if (query_action == rwdts.QueryAction.UPDATE or
                     query_action == rwdts.QueryAction.CREATE):
                 self._vm_resp = msg
-
                 if msg.resource_state == "active":
                     # Move this VDU to ready state
                     yield from self.vdu_is_active()
@@ -867,7 +866,6 @@ class VirtualDeploymentUnitRecord(object):
                 raise NotImplementedError(
                     "%s action on VirtualDeployementUnitRecord not supported",
                     query_action)
-
             xact_info.respond_xpath(rwdts.XactRspCode.ACK)
 
         try:
@@ -885,7 +883,6 @@ class VirtualDeploymentUnitRecord(object):
 
             vm_resp = yield from self.create_resource(xact, vnfr, config)
             self._vm_resp = vm_resp
-
             self._state = VDURecordState.RESOURCE_ALLOC_PENDING
             self._log.debug("Requested VM from resource manager response %s",
                             vm_resp)
@@ -1260,7 +1257,6 @@ class VirtualNetworkFunctionRecord(object):
 
         mgmt_intf = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_MgmtInterface()
         ip_address, port = self.mgmt_intf_info()
-
         if ip_address is not None:
             mgmt_intf.ip_address = ip_address
         if port is not None:
@@ -2478,7 +2474,7 @@ class VnfManager(object):
         # network
         for vld in nsr_obj.nsd.vld:
             if vld.mgmt_network:
-                return vld.name
+                return vld.vim_network_name
 
         return None