def unplug(self, vif, instance_info): """UnPlug using hybrid strategy Unhook port from OVS, unhook port from bridge, delete bridge, and delete both veth devices. """ if not hasattr(vif, "port_profile"): raise exception.MissingPortProfile() if not isinstance(vif.port_profile, objects.vif.VIFPortProfileOpenVSwitch): raise exception.WrongPortProfile( profile=vif.port_profile.__class__.__name__) v1_name, v2_name = self.get_veth_pair_names(vif) if linux_net.device_exists(vif.bridge_name): processutils.execute('brctl', 'delif', vif.bridge_name, v1_name, run_as_root=True) processutils.execute('ip', 'link', 'set', vif.bridge_name, 'down', run_as_root=True) processutils.execute('brctl', 'delbr', vif.bridge_name, run_as_root=True) linux_net.delete_ovs_vif_port(vif.network.bridge, v2_name, timeout=self.config.ovs_vsctl_timeout)
def _unplug_vhostuser(self, vif, instance_info): linux_net.delete_ovs_vif_port(vif.network.bridge, OvsPlugin.gen_port_name( constants.OVS_VHOSTUSER_PREFIX, vif.id), timeout=self.config.ovs_vsctl_timeout, ovsdb_connection=self.config.ovsdb_connection)
def test_delete_ovs_vif_port_delete_netdev(self, mock_vsctl, mock_delete_net_dev): bridge = 'fake-bridge' dev = 'fake-dev' timeout = 120 linux_net.delete_ovs_vif_port(bridge, dev, timeout=timeout) args = ['--', '--if-exists', 'del-port', bridge, dev] mock_vsctl.assert_called_with(args, timeout=timeout) mock_delete_net_dev.assert_called()
def _unplug_bridge(self, vif, instance_info): """UnPlug using hybrid strategy Unhook port from OVS, unhook port from bridge, delete bridge, and delete both veth devices. """ v1_name, v2_name = self.get_veth_pair_names(vif) linux_net.delete_bridge(vif.bridge_name, v1_name) linux_net.delete_ovs_vif_port(vif.network.bridge, v2_name, timeout=self.config.ovs_vsctl_timeout)
def _unplug_bridge(self, vif, instance_info): """UnPlug using hybrid strategy Unhook port from OVS, unhook port from bridge, delete bridge, and delete both veth devices. """ v1_name, v2_name = self.get_veth_pair_names(vif) linux_net.delete_bridge(vif.bridge_name, v1_name) linux_net.delete_ovs_vif_port(vif.network.bridge, v2_name, timeout=self.config.ovs_vsctl_timeout, ovsdb_connection=self.config.ovsdb_connection)
def test_delete_ovs_vif_port(self, mock_vsctl, mock_delete_net_dev): bridge = 'fake-bridge' dev = 'fake-dev' ovsdb_connection = None timeout = 120 linux_net.delete_ovs_vif_port(bridge, dev, ovsdb_connection=ovsdb_connection, timeout=timeout, delete_netdev=False) args = ['--', '--if-exists', 'del-port', bridge, dev] mock_vsctl.assert_called_with(args, ovsdb_connection=ovsdb_connection, timeout=timeout) mock_delete_net_dev.assert_not_called()
def _unplug_vf_passthrough(self, vif, instance_info): """Remove port from OVS.""" pci_slot = vif.dev_address pf_ifname = linux_net.get_ifname_by_pci_address(pci_slot, pf_interface=True, switchdev=True) vf_num = linux_net.get_vf_num_by_pci_address(pci_slot) representor = linux_net.get_representor_port(pf_ifname, vf_num) # The representor interface can't be deleted because it bind the # SR-IOV VF, therefore we just need to remove it from the ovs bridge # and set the status to down linux_net.delete_ovs_vif_port(vif.network.bridge, representor, delete_netdev=False) linux_net.set_interface_state(representor, 'down')
def unplug(self, vif): """UnPlug using hybrid strategy Unhook port from OVS, unhook port from bridge, delete bridge, and delete both veth devices. """ br_name = vif.br_name v1_name, v2_name = vif.veth_pair_names if linux_net.device_exists(br_name): processutils.execute('brctl', 'delif', br_name, v1_name, run_as_root=True) processutils.execute('ip', 'link', 'set', br_name, 'down', run_as_root=True) processutils.execute('brctl', 'delbr', br_name, run_as_root=True) linux_net.delete_ovs_vif_port(vif.bridge_name, v2_name)
def _post_unplug_wiring_delete_veth(instance, vif): """Wire/plug the virtual interface for the instance into the bridge that lxd is using. :param instance: the instance to plug into the bridge :type instance: ??? :param vif: the virtual interface to plug into the bridge :type vif: :class:`nova.network.model.VIF` """ v1_name = get_vif_devname(vif) try: if _is_ovs_vif_port(vif): linux_net.delete_ovs_vif_port(vif['network']['bridge'], v1_name, True) else: network_utils.delete_net_dev(v1_name) except processutils.ProcessExecutionError: LOG.exception("Failed to delete veth for vif {}".foramt(vif), instance=instance)
def _unplug_vif_windows(self, vif, instance_info): """Remove port from OVS.""" linux_net.delete_ovs_vif_port(vif.network.bridge, vif.id, timeout=self.config.ovs_vsctl_timeout, ovsdb_connection=self.config.ovsdb_connection)
def _unplug_vif_windows(self, vif, instance_info): """Remove port from OVS.""" linux_net.delete_ovs_vif_port(vif.network.bridge, vif.id, timeout=self.config.ovs_vsctl_timeout)
def _unplug_vhostuser(self, vif, instance_info): linux_net.delete_ovs_vif_port(vif.network.bridge, OvsPlugin.gen_port_name( constants.OVS_VHOSTUSER_PREFIX, vif.id), timeout=self.config.ovs_vsctl_timeout)
def _unplug_vhostuser(self, vif, instance_info): linux_net.delete_ovs_vif_port(vif.network.bridge, OvsPlugin.gen_port_name("vhu", vif.id), timeout=self.config.ovs_vsctl_timeout)