def removeBond(self, bonding): if not self.owned_device(bonding.name): IfcfgAcquire.acquire_device(bonding.name) to_be_removed = self._ifaceDownAndCleanup(bonding) if to_be_removed: self.configApplier.removeBonding(bonding.name) if bonding.on_removal_just_detach_from_network: # Recreate the bond with ip and master info cleared bonding.ipv4 = address.IPv4() bonding.ipv6 = address.IPv6() bonding.master = None bonding.configure() else: for slave in bonding.slaves: slave.remove() if self.unifiedPersistence: self.runningConfig.removeBonding(bonding.name) else: set_mtu = self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value. # Note that ip link set dev bondX mtu Y sets Y on all its links if set_mtu is not None: ipwrapper.linkSet(bonding.name, ["mtu", str(set_mtu)]) # If the bond was bridged, we must remove BRIDGE parameter from its # ifcfg configuration file. if bonding.bridge: self.configApplier.dropBridgeParameter(bonding.name)
def removeNic(self, nic, remove_even_if_used=False): if not self.owned_device(nic.name): IfcfgAcquire.acquire_device(nic.name) # If the nic is top device we should ifdown it even if it is # used by a VLAN. Otherwise we would keep its IP address. remove_even_if_used |= nic.master is None to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used) if to_be_removed: self.configApplier.removeNic(nic.name) if nic.name in nics.nics(): _exec_ifup(nic) else: logging.warning('host interface %s missing', nic.name) else: set_mtu = self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value if set_mtu is not None: ipwrapper.linkSet(nic.name, ['mtu', str(set_mtu)]) # If the nic was bridged, we must remove BRIDGE parameter from its # ifcfg configuration file. if nic.bridge: self.configApplier.dropBridgeParameter(nic.name)
def removeBond(self, bonding): if not self.owned_device(bonding.name): IfcfgAcquire.acquire_device(bonding.name) to_be_removed = self._ifaceDownAndCleanup(bonding) if to_be_removed: self.configApplier.removeBonding(bonding.name) if bonding.on_removal_just_detach_from_network: # Recreate the bond with ip and master info cleared bonding.ipv4 = address.IPv4() bonding.ipv6 = address.IPv6() bonding.master = None bonding.configure() else: for slave in bonding.slaves: slave.remove() self.runningConfig.removeBonding(bonding.name) else: set_mtu = self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value. # Note that ip link set dev bondX mtu Y sets Y on all its links if set_mtu is not None: ipwrapper.linkSet(bonding.name, ['mtu', str(set_mtu)]) # If the bond was bridged, we must remove BRIDGE parameter from its # ifcfg configuration file. if bonding.bridge: self.configApplier.dropBridgeParameter(bonding.name)
def removeNic(self, nic, remove_even_if_used=False): to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used) if to_be_removed: self.configApplier.removeNic(nic.name) if nic.name in nics.nics(): _exec_ifup(nic) else: logging.warning('host interface %s missing', nic.name) else: set_mtu = self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value if set_mtu is not None: ipwrapper.linkSet(nic.name, ['mtu', str(set_mtu)])
def removeBond(self, bonding): toBeRemoved = not ifaceUsed(bonding.name) if toBeRemoved: if bonding.master is None: self.configApplier.removeIpConfig(bonding) DynamicSourceRoute.addInterfaceTracking(bonding) self._removeSourceRoute(bonding, DynamicSourceRoute) if bonding.on_removal_just_detach_from_network: self.configApplier.setIfaceMtu(bonding.name, mtus.DEFAULT_MTU) self.configApplier.ifdown(bonding) else: self._destroyBond(bonding) self.runningConfig.removeBonding(bonding.name) else: self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name))
def removeNic(self, nic, remove_even_if_used=False): """ Remove a nic from the kernel. By default, do nothing if the nic is used When remove_even_if_used=True, remove the nic anyway # FIXME the caller of this method is responsible to remove # the nic from its users (such as bond) """ toBeRemoved = not ifaceUsed(nic.name) or remove_even_if_used if toBeRemoved: if nic.master is None: self.configApplier.removeIpConfig(nic) DynamicSourceRoute.addInterfaceTracking(nic) self._removeSourceRoute(nic, DynamicSourceRoute) else: self.configApplier.setIfaceMtu(nic.name, mtus.DEFAULT_MTU) self.configApplier.ifdown(nic) else: self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name))
def removeNic(self, nic, remove_even_if_used=False): if not self.owned_device(nic.name): IfcfgAcquire.acquire_device(nic.name) to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used) if to_be_removed: self.configApplier.removeNic(nic.name) if nic.name in nics.nics(): _exec_ifup(nic) else: logging.warning("host interface %s missing", nic.name) else: set_mtu = self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value if set_mtu is not None: ipwrapper.linkSet(nic.name, ["mtu", str(set_mtu)]) # If the nic was bridged, we must remove BRIDGE parameter from its # ifcfg configuration file. if nic.bridge: self.configApplier.dropBridgeParameter(nic.name)
def removeNic(self, nic, remove_even_if_used=False): if not self.owned_device(nic.name): self.normalize_device_filename(nic.name) to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used) if to_be_removed: self.configApplier.removeNic(nic.name) if nic.name in nics.nics(): _exec_ifup(nic) else: logging.warning('host interface %s missing', nic.name) else: set_mtu = self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value if set_mtu is not None: ipwrapper.linkSet(nic.name, ['mtu', str(set_mtu)]) # If the nic was bridged, we must remove BRIDGE parameter from its # ifcfg configuration file. if nic.bridge: self.configApplier.dropBridgeParameter(nic.name)
def removeBond(self, bonding): to_be_removed = self._ifaceDownAndCleanup(bonding) if to_be_removed: self.configApplier.removeBonding(bonding.name) if bonding.on_removal_just_detach_from_network: # Recreate the bond with ip and master info cleared bonding.ipv4 = address.IPv4() bonding.ipv6 = address.IPv6() bonding.master = None bonding.configure() else: for slave in bonding.slaves: slave.remove() if self.unifiedPersistence: self.runningConfig.removeBonding(bonding.name) else: set_mtu = self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value. # Note that ip link set dev bondX mtu Y sets Y on all its links if set_mtu is not None: ipwrapper.linkSet(bonding.name, ['mtu', str(set_mtu)])
def removeBond(self, bonding): to_be_removed = self._ifaceDownAndCleanup(bonding) if to_be_removed: self.configApplier.removeBonding(bonding.name) if bonding.on_removal_just_detach_from_network: # Recreate the bond with ip and master info cleared bonding.ipv4 = IPv4() bonding.ipv6 = IPv6() bonding.master = None bonding.configure() else: for slave in bonding.slaves: slave.remove() if self.unifiedPersistence: self.runningConfig.removeBonding(bonding.name) else: set_mtu = self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name)) # Since we are not taking the device up again, ifcfg will not be # read at this point and we need to set the live mtu value. # Note that ip link set dev bondX mtu Y sets Y on all its links if set_mtu is not None: ipwrapper.linkSet(bonding.name, ['mtu', str(set_mtu)])