def setUp(self, mock_moref, mock_session): super(DvsTestCase, self).setUp() cfg.CONF.set_override('dvs_name', 'fake_dvs', group='dvs') self._dvs = dvs.DvsManager() self.assertEqual(mock_moref.return_value, self._dvs._dvs_moref) mock_moref.assert_called_once_with(mock_session.return_value, 'fake_dvs')
def initialize(self): LOG.info("Starting VDS mech driver") try: self._dvs = dvs.SingleDvsManager() except Exception: # backward compatibility self._dvs = dvs.DvsManager()
def migrate_compute_ports_vms(resource, event, trigger, **kwargs): """Update the VMs ports on the backend after migrating nsx-v -> nsx-v3 After using api_replay to migrate the neutron data from NSX-V to NSX-T we need to update the VM ports to use OpaqueNetwork instead of DistributedVirtualPortgroup """ # Connect to the DVS manager, using the configuration parameters try: dvs_mng = dvs.DvsManager() except Exception as e: LOG.error( _LE("Cannot connect to the DVS: Please update the [dvs] " "section in the nsx.ini file: %s"), e) return # Go over all the compute ports from the plugin admin_cxt = neutron_context.get_admin_context() port_filters = {'device_owner': ['compute:None']} with PortsPlugin() as plugin: neutron_ports = plugin.get_ports(admin_cxt, filters=port_filters) for port in neutron_ports: device_id = port.get('device_id') # get the vm moref & spec from the DVS vm_moref = dvs_mng.get_vm_moref_obj(device_id) vm_spec = dvs_mng.get_vm_spec(vm_moref) # Go over the VM interfaces and check if it should be updated update_spec = False for prop in vm_spec.propSet: if (prop.name == 'network' and hasattr(prop.val, 'ManagedObjectReference')): for net in prop.val.ManagedObjectReference: if net._type == 'DistributedVirtualPortgroup': update_spec = True if not update_spec: LOG.info(_LI("No need to update the spec of vm %s"), device_id) continue # find the old interface by it's mac and delete it device = get_vm_network_device(dvs_mng, vm_moref, port['mac_address']) if device is None: LOG.warning(_LW("No device with MAC address %s exists on the VM"), port['mac_address']) continue device_type = device.__class__.__name__ LOG.info(_LI("Detaching old interface from VM %s"), device_id) dvs_mng.detach_vm_interface(vm_moref, device) # add the new interface as OpaqueNetwork LOG.info(_LI("Attaching new interface to VM %s"), device_id) nsx_net_id = get_network_nsx_id(admin_cxt.session, port['network_id']) dvs_mng.attach_vm_interface(vm_moref, port['id'], port['mac_address'], nsx_net_id, device_type)
def __init__(self): super(NsxDvsV2, self).__init__() LOG.debug('Driver support: DVS: %s' % dvs_utils.dvs_is_enabled()) neutron_extensions.append_api_extensions_path( [vmware_nsx.NSX_EXT_PATH]) self.cfg_group = 'dvs' # group name for dvs section in nsx.ini self._dvs = dvs.DvsManager() # Common driver code self.base_binding_dict = { pbin.VIF_TYPE: nsx_constants.VIF_TYPE_DVS, pbin.VIF_DETAILS: { # TODO(rkukura): Replace with new VIF security details pbin.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} self.setup_dhcpmeta_access()