def disconnect(vif, instance_info, ifname, netns=None, report_health=None, container_id=None, **kwargs): driver = _get_binding_driver(vif) if report_health: report_health(driver.is_alive()) driver.disconnect(vif, ifname, netns, container_id) os_vif.unplug(vif, instance_info)
def test_unplug(self): plugin = mock.MagicMock() with mock.patch('stevedore.extension.ExtensionManager', return_value={'foobar': plugin}): os_vif.initialize() vif = objects.vif.VIF(id='uniq', plugin='foobar') os_vif.unplug(vif) plugin.unplug.assert_called_once_with(vif)
def disconnect(vif, instance_info, ifname, netns=None, container_id=None, **kwargs): driver = _get_binding_driver(vif) driver.disconnect(vif, ifname, netns, container_id) os_vif.unplug(vif, instance_info)
def _unplug_os_vif(self, instance, vif): instance_info = os_vif_util.nova_to_osvif_instance(instance) try: os_vif.unplug(vif, instance_info) except osv_exception.ExceptionBase as ex: msg = (_("Failure running os_vif plugin unplug method: %(ex)s") % {'ex': ex}) raise exception.InternalError(msg)
def unplug(self, instance, vif): vif_type = vif['type'] if vif_type == model.VIF_TYPE_HYPERV: self._vif_plugin.unplug(instance, vif) elif vif_type == model.VIF_TYPE_OVS: vif = os_vif_util.nova_to_osvif_vif(vif) instance = os_vif_util.nova_to_osvif_instance(instance) os_vif.unplug(vif, instance) else: reason = _("unexpected vif_type=%s") % vif_type raise exception.VirtualInterfaceUnplugException(reason=reason)
def unplug(self, instance, vif): vif_type = vif['type'] instance_info = os_vif_util.nova_to_osvif_instance(instance) # Try os-vif codepath first vif_obj = os_vif_util.nova_to_osvif_vif(vif) if vif_obj is not None: os_vif.unplug(vif_obj, instance_info) return # Legacy non-os-vif codepath func = getattr(self, 'unplug_%s' % vif_type, None) if not func: raise exception.InternalError("Unexpected vif_type=%s" % vif_type) func(instance, vif)
def test_unplug(self, mock_unplug): plg = extension.Extension(name="demo", entry_point="os-vif", plugin=DemoPlugin, obj=None) with mock.patch('stevedore.extension.ExtensionManager.names', return_value=['foobar']),\ mock.patch('stevedore.extension.ExtensionManager.__getitem__', return_value=plg): os_vif.initialize() info = objects.instance_info.InstanceInfo() vif = objects.vif.VIFBridge( id='9a12694f-f95e-49fa-9edb-70239aee5a2c', plugin='foobar') os_vif.unplug(vif, info) mock_unplug.assert_called_once_with(vif, info)
def test_unplug(self, mock_unplug): plg = extension.Extension(name="demo", entry_point="os-vif", plugin=NoOpPlugin, obj=None) with mock.patch('stevedore.extension.ExtensionManager.names', return_value=['foobar']),\ mock.patch('stevedore.extension.ExtensionManager.__getitem__', return_value=plg): os_vif.initialize() info = mock.sentinel.info vif = mock.MagicMock() vif.plugin_name = 'noop' os_vif.unplug(vif, info) mock_unplug.assert_called_once_with(vif, info)
def unplug(self, instance, vif): vif_type = vif['type'] instance_info = os_vif_util.nova_to_osvif_instance(instance) # Try os-vif codepath first vif_obj = os_vif_util.nova_to_osvif_vif(vif) if vif_obj is not None: os_vif.unplug(vif_obj, instance_info) else: # Legacy non-os-vif codepath func = getattr(self, 'unplug_%s' % vif_type, None) if not func: raise exception.InternalError( "Unexpected vif_type=%s" % vif_type ) func(instance, vif) _post_unplug_wiring(instance, vif)
def disconnect(vif, instance_info, ifname, netns=None, report_health=None): driver = _get_binding_driver(vif) if report_health: report_health(driver.is_healthy()) driver.disconnect(vif, ifname, netns) os_vif.unplug(vif, instance_info)
def disconnect(vif, instance_info, ifname, netns=None): driver = _get_binding_driver(vif) driver.disconnect(vif, ifname, netns) os_vif.unplug(vif, instance_info)
def unplug(self, instance, vif): instance_info = os_vif_util.nova_to_osvif_instance(instance) vif_obj = os_vif_util.nova_to_osvif_vif(vif) os_vif.unplug(vif_obj, instance_info)
subnets = vif_objects.SubnetList([subnet]) network = vif_objects.Network(label='tenantnet', subnets=subnets, multi_host=False, should_provide_vlan=False, should_provide_bridge=False) vif_uuid = uuid.uuid4() vif = vif_objects.VIFVHostUser(id=vif_uuid, address=None, network=network, plugin='vhostuser', mode=vif_objects.fields.VIFVHostUserMode.SERVER) # Now do the actual plug operations to connect the VIF to # the backing network interface. try: os_vif.plug(vif, instance_info) except vif_exc.PlugException as err: # Handle the failure... pass # If you are removing a virtual machine and its interfaces, # you would use the unplug() operation: try: os_vif.unplug(vif, instance_info) except vif_exc.UnplugException as err: # Handle the failure... pass