RIFT-14562 29/829/1 static_ip
authorHashir Mohammed <hashir.mohammed@riftio.com>
Thu, 22 Dec 2016 14:35:25 +0000 (09:35 -0500)
committerHashir Mohammed <hashir.mohammed@riftio.com>
Thu, 22 Dec 2016 14:35:34 +0000 (09:35 -0500)
 Minor changes
 *  Changed the logic to identify the conn_point of the overriding mgmt_network
 * Identation fixes
 * Refactored a method

Reviewer: TBD Philip

Signed-off-by: Hashir Mohammed <hashir.mohammed@riftio.com>
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/rift/rwcal/openstack/openstack_drv.py
rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py
rwcal/plugins/vala/rwcal_vsphere/rwcal_vsphere.py
rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py

index 8854b17..9a0ab09 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, mgmt_network = None):
+    def do_get_vdu(self, account, vdu_id, mgmt_network=None):
         """Get information about a virtual deployment unit.
 
         Arguments:
index ac81a3e..5cb9572 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, mgmt_network = None):
+    def do_get_vdu(self, account, vdu_id, mgmt_network=None):
         """Get information about a virtual deployment unit.
 
         Arguments:
index d81c6f3..4a9ba75 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, mgmt_network = None):
+    def do_get_vdu(self, account, vdu_id, mgmt_network=None):
         """Get information about a virtual deployment unit.
 
         Arguments:
index 13cc403..182e366 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, mgmt_network = None):
+    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 93d6d2f..5782700 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, mgmt_network = None):
+    def do_get_vdu(self, account, vdu_id, mgmt_network=None):
         raise NotImplementedError()
 
     @rwstatus(ret_on_failure=[""])
index f39662c..374f1a4 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, mgmt_network = None):
+    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 5f44e5e..e30919f 100644 (file)
@@ -1843,6 +1843,13 @@ class OpenstackDriver(object):
     def neutron_network_get(self, network_id):
         return self.neutron_drv.network_get(network_id)
 
+    def neutron_network_by_name(self, network_name):
+        networks = self.neutron_network_list()
+        for network in networks:
+            if network_name == network["name"]:
+                return network
+        return None
+        
     def neutron_network_create(self, **kwargs):
         return self.neutron_drv.network_create(**kwargs)
 
index 8f2678f..b430886 100644 (file)
@@ -500,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'),
@@ -1227,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, overridden_mgmt_network = None):
+    def _fill_vdu_info(vm_info, flavor_info, mgmt_network, port_list, server_group, volume_list=None):
         """Create a GI object for VDUInfoParams
 
         Converts VM information dictionary object returned by openstack
@@ -1246,7 +1246,7 @@ 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 or network_name == overridden_mgmt_network :
+            if network_info and network_name == mgmt_network:
                 for interface in network_info:
                     for interface in network_info:
                         if 'OS-EXT-IPS:type' in interface:
@@ -2034,10 +2034,25 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         network_list = []
         imageinfo_list = []
         explicit_mgmt_network = None
+        vdu_connection_points = []
+        #This check is to identify the c_point of overriding management network first
         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):
+            with self._use_driver(account) as drv:
+                overridding_mgmt_network = drv.neutron_network_by_name(explicit_mgmt_network)
+                mgmt_network_conn_point_names = []
+                for c_point in vdu_init.connection_points:
+                    if overridding_mgmt_network["id"] == c_point.virtual_link_id:
+                        vdu_connection_points.append(c_point)
+                        mgmt_network_conn_point_names.append(c_point.name)
+
+                for c_point in vdu_init.connection_points:
+                    if c_point.name not in mgmt_network_conn_point_names:
+                        vdu_connection_points.append(c_point)
+        else:
+            vdu_connection_points = vdu_init.connection_points
+       
+        for c_point in vdu_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 in network_list:
@@ -2274,7 +2289,7 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
 
 
     @rwstatus(ret_on_failure=[None])
-    def do_get_vdu(self, account, vdu_id, mgmt_network = None):
+    def do_get_vdu(self, account, vdu_id, mgmt_network=None):
         """Get information about a virtual deployment unit.
 
         Arguments:
@@ -2299,13 +2314,15 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
             openstack_group_list = drv.nova_server_group_list()
             server_group = [ i['name'] for i in openstack_group_list if vm['id'] in i['members']]
             openstack_srv_volume_list = drv.nova_volume_list(vm['id'])
+
+            if mgmt_network is None:
+                mgmt_network = account.openstack.mgmt_network
             vdu_info = RwcalOpenstackPlugin._fill_vdu_info(vm,
                                                            flavor_info,
-                                                           account.openstack.mgmt_network,
+                                                           mgmt_network,
                                                            port_list,
                                                            server_group,
-                                                           volume_list = openstack_srv_volume_list,
-                                                           overridden_mgmt_network = mgmt_network)
+                                                           volume_list = openstack_srv_volume_list)
             if vdu_info.state == 'active':
                 try:
                     console_info = drv.nova_server_console(vdu_info.vdu_id)
index cda3867..0a39ea0 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, mgmt_network = None):
+    def do_get_vdu(self, account, vdu_id, mgmt_network=None):
         raise NotImplementedError()
 
     @rwstatus(ret_on_failure=[""])
index 460b273..495491a 100755 (executable)
@@ -855,6 +855,7 @@ 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()
@@ -883,6 +884,7 @@ 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)
@@ -1257,6 +1259,7 @@ 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: