def _ifaceDownAndCleanup(self, iface, _netinfo): """Returns True iff the iface is to be removed.""" DynamicSourceRoute.addInterfaceTracking(iface) ifdown(iface.name) self._removeSourceRoute(iface) self.configApplier.removeIfaceCleanup(iface.name) return not _netinfo.ifaceUsers(iface.name)
def removeBridge(self, bridge): DynamicSourceRoute.addInterfaceTracking(bridge) ifdown(bridge.name) self._removeSourceRoute(bridge) utils.execCmd([constants.EXT_BRCTL, 'delbr', bridge.name]) self.configApplier.removeBridge(bridge.name) if bridge.port: bridge.port.remove()
def _addSourceRoute(self, netEnt, ipaddr, netmask, gateway, bootproto): # bootproto is None for both static and no bootproto if bootproto != 'dhcp' and netEnt.master is None: logging.debug("Adding source route %s, %s, %s, %s" % (netEnt.name, ipaddr, netmask, gateway)) StaticSourceRoute(netEnt.name, self).\ configure(ipaddr, netmask, gateway) DynamicSourceRoute.addInterfaceTracking(netEnt)
def _ifaceDownAndCleanup(self, iface): """Returns True iff the iface is to be removed.""" DynamicSourceRoute.addInterfaceTracking(iface) to_be_removed = not netinfo.ifaceUsed(iface.name) if to_be_removed: ifdown(iface.name) self._removeSourceRoute(iface) return to_be_removed
def removeBridge(self, bridge): DynamicSourceRoute.addInterfaceTracking(bridge) ifdown(bridge.name) self._removeSourceRoute(bridge) execCmd([constants.EXT_BRCTL, 'delbr', bridge.name]) self.configApplier.removeBridge(bridge.name) if bridge.port: bridge.port.remove()
def process_IN_CLOSE_WRITE_filePath(self, sourceRouteFilePath): logging.debug("Responding to DHCP response in %s" % sourceRouteFilePath) with open(sourceRouteFilePath, 'r') as sourceRouteFile: sourceRouteContents = sourceRouteFile.read().split() action = sourceRouteContents[0] device = sourceRouteContents[-1] sourceRoute = DynamicSourceRoute(device, configurator) if sourceRoute.isVDSMInterface(): if action == 'configure': ip = sourceRouteContents[1] mask = sourceRouteContents[2] gateway = sourceRouteContents[3] sourceRoute.configure(ip, mask, gateway) else: sourceRoute.remove() else: logging.info("interface %s is not a libvirt interface" % sourceRoute.device) DynamicSourceRoute.removeInterfaceTracking(device) os.remove(sourceRouteFilePath)
def removeVlan(self, vlan): DynamicSourceRoute.addInterfaceTracking(vlan) ifdown(vlan.name) self._removeSourceRoute(vlan) self.configApplier.removeVlan(vlan.name) vlan.device.remove()