Пример #1
0
 def unplug_vhostuser(self, instance, vif):
     ovs_plug = vif['details'].get(
         network_model.VIF_DETAILS_VHOSTUSER_OVS_PLUG, False)
     if ovs_plug:
         port_name = os.path.basename(
             vif['details'][network_model.VIF_DETAILS_VHOSTUSER_SOCKET])
         linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), port_name)
Пример #2
0
    def unplug(self, driver, instance, sdk_ve, vif):
        netdev = self.get_prl_dev(driver, sdk_ve, vif['address'])
        if not netdev:
            return

        prl_name = self.get_prl_name(sdk_ve, netdev)
        linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), prl_name)
Пример #3
0
    def unplug_ovs_hybrid(self, instance, vif):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """
        super(LibvirtGenericVIFDriver,
              self).unplug(instance, vif)

        try:
            br_name = self.get_br_name(vif['id'])
            v1_name, v2_name = self.get_veth_pair_names(vif['id'])

            if linux_net.device_exists(br_name):
                utils.execute('brctl', 'delif', br_name, v1_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', br_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', br_name,
                              run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                          v2_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
Пример #4
0
    def unplug_ovs_hybrid(self, instance, vif):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """
        super(LibvirtGenericVIFDriver,
              self).unplug(instance, vif)

        try:
            br_name = self.get_br_name(vif['id'])
            v1_name, v2_name = self.get_veth_pair_names(vif['id'])

            if linux_net.device_exists(br_name):
                utils.execute('brctl', 'delif', br_name, v1_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', br_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', br_name,
                              run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                          v2_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #5
0
    def unplug(self, vif, cna_w_list=None):
        """Unplugs a virtual interface (network) from a VM.

        Extends the base implementation, but before calling it will remove
        the adapter from the Open vSwitch and delete the trunk.

        :param vif: The virtual interface to plug into the instance.
        :param cna_w_list: (Optional, Default: None) The list of Client Network
                           Adapters from pypowervm.  Providing this input
                           allows for an improvement in operation speed.
        :return cna_w: The deleted Client Network Adapter.
        """
        # Need to find the adapters if they were not provided
        if not cna_w_list:
            cna_w_list = vm.get_cnas(self.adapter, self.instance)

        # Find the CNA for this vif.
        cna_w = self._find_cna_for_vif(cna_w_list, vif)
        if not cna_w:
            LOG.warning(
                'Unable to unplug VIF with mac %(mac)s for. The VIF '
                'was not found on the instance.', {'mac': vif['address']},
                instance=self.instance)
            return None

        # Find and delete the trunk adapters
        trunks = pvm_cna.find_trunks(self.adapter, cna_w)
        dev = self.get_trunk_dev_name(vif)
        linux_net.delete_ovs_vif_port(vif['network']['bridge'], dev)
        for trunk in trunks:
            trunk.delete()

        # Now delete the client CNA
        return super(PvmOvsVifDriver, self).unplug(vif, cna_w_list=cna_w_list)
Пример #6
0
    def unplug(self, driver, instance, sdk_ve, vif):
        netdev = self.get_prl_dev(driver, sdk_ve, vif['address'])
        if not netdev:
            return

        prl_name = self.get_prl_name(sdk_ve, netdev)
        linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), prl_name)
Пример #7
0
 def unplug_ovs(self, instance, vif):
     """Unplug the VIF by deleting the port from the bridge."""
     try:
         linux_net.delete_ovs_vif_port(vif['network']['bridge'],
                                       vif['devname'])
     except processutils.ProcessExecutionError:
         LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #8
0
 def unplug_ovs(self, instance, vif):
     """Unplug the VIF by deleting the port from the bridge."""
     try:
         linux_net.delete_ovs_vif_port(vif['network']['bridge'],
                                       vif['devname'])
     except processutils.ProcessExecutionError:
         LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #9
0
    def unplug(self, vif, cna_w_list=None):
        """Unplugs a virtual interface (network) from a VM.

        Extends the base implementation, but before calling it will remove
        the adapter from the Open vSwitch and delete the trunk.

        :param vif: The virtual interface to plug into the instance.
        :param cna_w_list: (Optional, Default: None) The list of Client Network
                           Adapters from pypowervm.  Providing this input
                           allows for an improvement in operation speed.
        :return cna_w: The deleted Client Network Adapter.
        """
        # Need to find the adapters if they were not provided
        if not cna_w_list:
            cna_w_list = vm.get_cnas(self.adapter, self.instance)

        # Find the CNA for this vif.
        cna_w = self._find_cna_for_vif(cna_w_list, vif)
        if not cna_w:
            LOG.warning(_LW('Unable to unplug VIF with mac %(mac)s for '
                            'instance %(inst)s.  The VIF was not found on '
                            'the instance.'),
                        {'mac': vif['address'], 'inst': self.instance.name})
            return None

        # Find and delete the trunk adapters
        trunks = pvm_cna.find_trunks(self.adapter, cna_w)
        dev = self.get_trunk_dev_name(vif)
        linux_net.delete_ovs_vif_port(vif['network']['bridge'], dev)
        for trunk in trunks:
            trunk.delete()

        # Now delete the client CNA
        return super(PvmOvsVifDriver, self).unplug(vif, cna_w_list=cna_w_list)
Пример #10
0
 def unplug(self, instance, vif):
     """Unplug the VIF by deleting the port from the bridge."""
     try:
         network, mapping = vif
         linux_net.delete_ovs_vif_port(self.get_bridge_name(network),
                                       self.get_vif_devname(mapping))
     except exception.ProcessExecutionError:
         LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #11
0
    def post_live_migrate_at_source(self, vif):
        """Performs the post live migrate on the source host.

        :param vif: The virtual interface of an instance.  This may be
                    called network_info in other portions of the code.
        """
        linux_net.delete_ovs_vif_port(vif['network']['bridge'],
                                      self.get_trunk_dev_name(vif))
Пример #12
0
 def unplug(self, instance, vif):
     """Unplug the VIF by deleting the port from the bridge."""
     try:
         network, mapping = vif
         linux_net.delete_ovs_vif_port(self.get_bridge_name(network),
                                       self.get_vif_devname(mapping))
     except exception.ProcessExecutionError:
         LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #13
0
    def unplug_ovs_ethernet(self, instance, vif):
        """Unplug the VIF by deleting the port from the bridge."""
        super(LibvirtGenericVIFDriver, self).unplug(instance, vif)

        try:
            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), self.get_vif_devname(vif))
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #14
0
    def unplug_ovs_ethernet(self, instance, vif):
        """Unplug the VIF by deleting the port from the bridge."""
        super(LibvirtGenericVIFDriver, self).unplug(instance, vif)

        try:
            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                          self.get_vif_devname(vif))
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #15
0
 def unplug_vhostuser(self, instance, vif):
     ovs_plug = vif['details'].get(
                     network_model.VIF_DETAILS_VHOSTUSER_OVS_PLUG,
                     False)
     if ovs_plug:
         port_name = os.path.basename(
                 vif['details'][network_model.VIF_DETAILS_VHOSTUSER_SOCKET])
         linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                       port_name)
Пример #16
0
 def _cleanup_orphan_adapters(self, vif, vswitch_name):
     """Finds and removes trunk VEAs that have no corresponding CNA."""
     # Find and delete orphan adapters with macs matching our vif
     orphans = pvm_cna.find_orphaned_trunks(self.adapter, vswitch_name)
     for orphan in orphans:
         if vm.norm_mac(orphan.mac) == vif['address']:
             linux_net.delete_ovs_vif_port(vif['network']['bridge'],
                                           self.get_trunk_dev_name(vif))
             orphan.delete()
Пример #17
0
def _post_unplug_wiring_delete_veth(instance, 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:
            linux_net.delete_net_dev(v1_name)
    except processutils.ProcessExecutionError:
        LOG.exception("Failed to delete veth for vif", vif=vif)
Пример #18
0
    def unplug_ovs_hybrid(
            self, instance, vif, ovsport_info, portgroup_instance_mapping):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """

        # now dirver use the configed nic eth0.100 instead
        ovs_nicport = ovsport_info['ovs_ethport']
        vlan_tag = str(portgroup_instance_mapping.vlan)
        nic_name = ovs_nicport + '.' + vlan_tag

        # remove the eth1 vlan config
        try:
            # try to delete the exists nic_name in whatever br
            utils.execute('vconfig', 'rem', nic_name, run_as_root=True)
        except Exception as exc:
            LOG.exception(exc, instance=instance)

        try:
            br_name = self.get_br_name(vif['id'])
            v1_name, v2_name = self.get_veth_pair_names(vif['id'])
            gbr_name = self.get_gbr_name(vif['id'])
            tap_name, taq_name = self.get_gveth_pair_names(vif['id'])

            if linux_net.device_exists(br_name):
                utils.execute('brctl', 'delif', br_name, v1_name,
                              run_as_root=True)
                utils.execute('brctl', 'delif', br_name, tap_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', br_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', br_name,
                              run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                          v2_name)

            if linux_net.device_exists(gbr_name):
                utils.execute('brctl', 'delif', gbr_name, taq_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', gbr_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', gbr_name,
                              run_as_root=True)

            # delete veth peer
            linux_net.delete_net_dev(v1_name)
            linux_net.delete_net_dev(v2_name)
            linux_net.delete_net_dev(tap_name)
            linux_net.delete_net_dev(taq_name)
        except Exception as exc:
            LOG.exception(exc, instance=instance)
Пример #19
0
    def rollback_live_migration_at_destination(self, vif, vea_vlan_mappings):
        """Rolls back the pre live migrate on the destination host.

        Will delete the TrunkAdapter that pre_live_migrate_at_destination
        created with its unique hypervisor VLAN.  This uses the
        vea_vlan_mappings to provide the information as to what TrunkAdapter
        it should remove.

        :param vif: The virtual interface that was being migrated.  This may be
                    called network_info in other portions of the code.
        :param vea_vlan_mappings: The VEA VLAN mappings.  Key is the vif
                                  mac address, value is the destination's
                                  target hypervisor VLAN.
        """
        LOG.warning("Rolling back the live migrate of VIF with mac %(mac)s.",
                    {'mac': vif['address']},
                    instance=self.instance)

        # We know that we just attached the VIF to the NovaLink VM.  Search
        # for a trunk adapter with the PVID and vSwitch that we specified
        # above.  This is guaranteed to be unique.
        vlan = int(vea_vlan_mappings[vif['address']])
        vswitch_id = pvm_net.VSwitch.search(
            self.adapter,
            parent_type=pvm_ms.System,
            one_result=True,
            name=CONF.powervm.pvm_vswitch_for_novalink_io).switch_id

        # Delete port from OVS
        linux_net.delete_ovs_vif_port(vif['network']['bridge'],
                                      self.get_trunk_dev_name(vif))

        # Find the trunk
        mgmt_wrap = pvm_par.get_this_partition(self.adapter)
        child_adpts = pvm_net.CNA.get(self.adapter, parent=mgmt_wrap)
        trunk = None
        for adpt in child_adpts:
            # We need a trunk adapter (so check trunk_pri).  Then the trunk
            # is unique by PVID and PowerVM vSwitch ID.
            if (adpt.pvid == vlan and adpt.vswitch_id == vswitch_id
                    and adpt.trunk_pri):
                trunk = adpt
                break

        if trunk:
            # Delete the peer'd trunk adapter.
            LOG.warning(
                "Deleting target side trunk adapter %(dev)s for "
                "rollback operation", {'dev': trunk.dev_name},
                instance=self.instance)
            trunk.delete()
Пример #20
0
    def unplug(self, driver, instance, sdk_ve, vif):
        iface_id = self.get_ovs_interfaceid(vif)
        br_name = self.get_br_name(vif['id'])
        v1_name, v2_name = self.get_veth_pair_names(vif['id'])

        netdev = self.get_prl_dev(driver, sdk_ve, vif['address'])
        if not netdev:
            return

        prl_name = self.get_prl_name(sdk_ve, netdev)

        linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), v2_name)
        utils.execute('ip', 'link', 'set', br_name, 'down', run_as_root=True)
        utils.execute('brctl', 'delbr', br_name, run_as_root=True)
Пример #21
0
    def unplug(self, driver, instance, sdk_ve, vif):
        iface_id = self.get_ovs_interfaceid(vif)
        br_name = self.get_br_name(vif['id'])
        v1_name, v2_name = self.get_veth_pair_names(vif['id'])

        netdev = self.get_prl_dev(driver, sdk_ve, vif['address'])
        if not netdev:
            return

        prl_name = self.get_prl_name(sdk_ve, netdev)

        linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), v2_name)
        utils.execute('ip', 'link', 'set', br_name, 'down', run_as_root=True)
        utils.execute('brctl', 'delbr', br_name, run_as_root=True)
Пример #22
0
    def post_live_migrate_at_source(self, vif):
        """Performs live migrate cleanup on the source host.

        This is optional, child classes do not need to implement this.

        :param vif: The virtual interface that was migrated.
        """
        # Deletes orphaned trunks
        orphaned_trunks = pvm_cna.find_orphaned_trunks(
            self.adapter, CONF.powervm.pvm_vswitch_for_novalink_io)
        dev = self.get_trunk_dev_name(vif)
        linux_net.delete_ovs_vif_port(vif['network']['bridge'], dev)
        for orphan in orphaned_trunks:
            orphan.delete()
Пример #23
0
 def unplug_ovs_acc(self, instance, vif):
     """No manual unplugging required."""
     # add by bob
     #if CONF.acc.nic_vender == 'netronome' or CONF.acc.nic_vender == 'Netronome':
     bridge = CONF.acc.ovs_bridge
     netro = NetronomeResourceManage(bridge_name=bridge)
     iface_id = self.get_ovs_interfaceid(vif)
     port_name = netro.get_port_name_by_bind_port(iface_id)
     if port_name:
         linux_net.delete_ovs_vif_port(bridge, port_name, False)
         LOG.debug("Success delete port:%s on bridge:%s" %
                   (port_name, bridge))
         port_id = netro.get_port_id(port_name)
         netro.unbind_port(port_id)
Пример #24
0
    def unplug_vhostuser_fp(self, instance, vif):
        """Delete a fp netdevice interface with a vhostuser socket"""
        dev = self.get_vif_devname(vif)
        ovs_plug = vif['details'].get(
            network_model.VIF_DETAILS_VHOSTUSER_OVS_PLUG, False)

        try:
            if ovs_plug:
                if vif.is_hybrid_plug_enabled():
                    self.unplug_ovs_hybrid(instance, vif)
                else:
                    linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                                  dev, False)
            linux_net.delete_fp_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
Пример #25
0
    def unplug_vhostuser_fp(self, instance, vif):
        """Delete a fp netdevice interface with a vhostuser socket"""
        dev = self.get_vif_devname(vif)
        ovs_plug = vif['details'].get(
                        network_model.VIF_DETAILS_VHOSTUSER_OVS_PLUG,
                        False)

        try:
            if ovs_plug:
                if vif.is_hybrid_plug_enabled():
                    self.unplug_ovs_hybrid(instance, vif)
                else:
                    linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                                  dev, False)
            linux_net.delete_fp_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
Пример #26
0
    def unplug_ovs_hybrid(self, instance, vif):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """
        try:
            br_name = self.get_br_name(vif["id"])
            v1_name, v2_name = self.get_veth_pair_names(vif["id"])

            if linux_net.device_exists(br_name):
                utils.execute("brctl", "delif", br_name, v1_name, run_as_root=True)
                utils.execute("ip", "link", "set", br_name, "down", run_as_root=True)
                utils.execute("brctl", "delbr", br_name, run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), v2_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"), instance=instance)
Пример #27
0
    def unplug_ovs_hybrid(self, instance, vif):
        try:
            br_name = self.get_br_name(vif['id'])
            v1_name, v2_name = self.get_veth_pair_names(vif['id'])

            if linux_net.device_exists(br_name):
                utils.execute('brctl', 'delif', br_name, v1_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', br_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', br_name,
                              run_as_root=True)

                linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                              v2_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
Пример #28
0
 def unplug_hw_veb(self, instance, vif):
     if vif['vnic_type'] == network_model.VNIC_TYPE_MACVTAP:
         # The ip utility doesn't accept the MAC 00:00:00:00:00:00.
         # Therefore, keep the MAC unchanged.  Later operations on
         # the same VF will not be affected by the existing MAC.
         linux_net.set_vf_interface_vlan(vif['profile']['pci_slot'],
                                         mac_addr=vif['address'])
     # add by bob
     if CONF.acc.nic_vender == 'netronome' or CONF.acc.nic_vender == 'Netronome':
         bridge = CONF.acc.ovs_bridge
         netro = NetronomeResourceManage(bridge_name=bridge)
         port_name = netro.get_port_name_by_pci_slot(
             vif['profile']['pci_slot'])
         if port_name:
             linux_net.delete_ovs_vif_port(bridge, port_name, False)
             LOG.debug("Success delete port:%s on bridge:%s" %
                       (port_name, bridge))
             port_id = netro.get_port_id(port_name)
             netro.unbind_port(port_id)
Пример #29
0
    def unplug(self, instance, vif):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """
        try:
            network, mapping = vif
            br_name = self.get_br_name(mapping['vif_uuid'])
            v1_name, v2_name = self.get_veth_pair_names(mapping['vif_uuid'])

            utils.execute('brctl', 'delif', br_name, v1_name, run_as_root=True)
            utils.execute('ip', 'link', 'set', br_name, 'down',
                          run_as_root=True)
            utils.execute('brctl', 'delbr', br_name, run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(network),
                                          v2_name)
        except exception.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #30
0
    def unplug_ovs_hybrid(self, instance, vif):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """
        super(LibvirtGenericVIFDriver, self).unplug(instance, vif)

        try:
            network, mapping = vif
            br_name = self.get_br_name(mapping["vif_uuid"])
            v1_name, v2_name = self.get_veth_pair_names(mapping["vif_uuid"])

            utils.execute("brctl", "delif", br_name, v1_name, run_as_root=True)
            utils.execute("ip", "link", "set", br_name, "down", run_as_root=True)
            utils.execute("brctl", "delbr", br_name, run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(network), v2_name)
        except exception.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #31
0
    def unplug_ovs_trunk(self, instance, vif):
        """UnPlug using trunk strategy

        Unhook port from OVS, unhook port from bridge,
        delete ovs port flow, and delete ovs port.
        """
        try:
            bridge_name = self.get_bridge_name(vif)
            br_name = self.get_trunk_br_name(vif['id'])
            patch_port1, patch_port2 = self.get_patch_pair_names(vif['id'])

            linux_net.delete_ovs_bridge(br_name)

            bridge_port_ofport = linux_net.get_ovs_port_ofport(patch_port2)

            linux_net.delete_ovs_flows(bridge_name, bridge_port_ofport)
            linux_net.delete_ovs_vif_port(bridge_name, patch_port2)

        except processutils.ProcessExecutionError:
            LOG.error(_LE("Failed while unplugging vif"),
                          instance=instance)
Пример #32
0
    def unplug_ovs(self, instance, vif):
        try:
            br_name = self.get_br_name(vif['id'])
            v1_name, v2_name = self.get_veth_pair_names(vif['id'])

            if linux_net.device_exists(br_name):
                utils.execute('brctl',
                              'delif',
                              br_name,
                              v1_name,
                              run_as_root=True)
                utils.execute('ip',
                              'link',
                              'set',
                              br_name,
                              'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', br_name, run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), v2_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #33
0
    def unplug_ovs_hybrid(self, instance, vif):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete ovs port.
        """

        try:
            br_name = self.get_br_name(vif['id'])
            vm_port_name = self.get_vm_ovs_port_name(vif['id'])

            if linux_net.device_exists(br_name):
                utils.execute('brctl', 'delif', br_name, vm_port_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', br_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', br_name,
                              run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                          vm_port_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
Пример #34
0
    def unplug(self, instance, vif):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """
        try:
            network, mapping = vif
            br_name = self.get_br_name(mapping['vif_uuid'])
            v1_name, v2_name = self.get_veth_pair_names(mapping['vif_uuid'])

            utils.execute('brctl', 'delif', br_name, v1_name, run_as_root=True)
            utils.execute('ip',
                          'link',
                          'set',
                          br_name,
                          'down',
                          run_as_root=True)
            utils.execute('brctl', 'delbr', br_name, run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(network),
                                          v2_name)
        except exception.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Пример #35
0
 def unplug_vhostuser_ovs(self, instance, vif):
     """Unplug a VIF_TYPE_VHOSTUSER into an ovs bridge"""
     port_name = os.path.basename(
         vif['details'][network_model.VIF_DETAILS_VHOSTUSER_SOCKET])
     linux_net.delete_ovs_vif_port(self.get_bridge_name(vif), port_name)
Пример #36
0
 def unplug_vhostuser_ovs(self, instance, vif):
     """Unplug a VIF_TYPE_VHOSTUSER into an ovs bridge"""
     port_name = os.path.basename(
         vif['details'][network_model.VIF_DETAILS_VHOSTUSER_SOCKET])
     linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                   port_name)