Ejemplo n.º 1
0
 def _getIfaceConfValues(iface):
     ipaddr, netmask, gateway, defaultRoute, ipv6addr, ipv6gateway, \
         ipv6defaultRoute, bootproto, async, ipv6autoconf, dhcpv6 = \
         iface.ipConfig
     defaultRoute = ConfigWriter._toIfcfgFormat(defaultRoute)
     mtu = iface.mtu
     if netinfo.ifaceUsed(iface.name):
         confParams = netinfo.getIfaceCfg(iface.name)
         if not ipaddr and bootproto != 'dhcp':
             ipaddr = confParams.get('IPADDR', None)
             netmask = confParams.get('NETMASK', None)
             gateway = confParams.get('GATEWAY', None)
             bootproto = bootproto or confParams.get('BOOTPROTO', None)
         defaultRoute = defaultRoute or confParams.get('DEFROUTE', None)
         if confParams.get('IPV6INIT', 'no') == 'yes':
             ipv6addr = confParams.get('IPV6ADDR', None)
             ipv6gateway = confParams.get('IPV6_DEFAULTGW', None)
             ipv6autoconf = (confParams.get('IPV6_AUTOCONF', 'no') == 'yes')
             dhcpv6 = (confParams.get('DHCPV6C', 'no') == 'yes')
         if not iface.mtu:
             mtu = confParams.get('MTU', None)
             if mtu:
                 mtu = int(mtu)
     ipconfig = IpConfig.ipConfig(ipaddr, netmask, gateway, defaultRoute,
                                  ipv6addr, ipv6gateway, ipv6defaultRoute,
                                  bootproto, async, ipv6autoconf, dhcpv6)
     return ipconfig, mtu
Ejemplo n.º 2
0
 def _getIfaceConfValues(iface):
     ipconfig = copy.deepcopy(iface.ipconfig)
     ipv4 = ipconfig.ipv4
     ipv6 = ipconfig.ipv6
     mtu = iface.mtu
     if netinfo.ifaceUsed(iface.name):
         confParams = netinfo.getIfaceCfg(iface.name)
         if not ipv4.address and ipconfig.bootproto != 'dhcp':
             ipv4.address = confParams.get('IPADDR')
             ipv4.netmask = confParams.get('NETMASK')
             ipv4.gateway = confParams.get('GATEWAY')
             if not ipconfig.bootproto:
                 ipconfig.bootproto = confParams.get('BOOTPROTO')
         if ipv4.defaultRoute is None and confParams.get('DEFROUTE'):
             ipv4.defaultRoute = _from_ifcfg_bool(confParams['DEFROUTE'])
         if confParams.get('IPV6INIT') == 'yes':
             ipv6.address = confParams.get('IPV6ADDR')
             ipv6.gateway = confParams.get('IPV6_DEFAULTGW')
             ipconfig.ipv6autoconf = (
                 confParams.get('IPV6_AUTOCONF') == 'yes')
             ipconfig.dhcpv6 = confParams.get('DHCPV6C') == 'yes'
         if not iface.mtu:
             mtu = confParams.get('MTU')
             if mtu:
                 mtu = int(mtu)
     return ipconfig, mtu
Ejemplo n.º 3
0
 def _getIfaceConfValues(iface):
     ipaddr, netmask, gateway, defaultRoute, ipv6addr, ipv6gateway, \
         ipv6defaultRoute, bootproto, async, ipv6autoconf, dhcpv6 = \
         iface.ipConfig
     defaultRoute = ConfigWriter._toIfcfgFormat(defaultRoute)
     mtu = iface.mtu
     if netinfo.ifaceUsed(iface.name):
         confParams = netinfo.getIfaceCfg(iface.name)
         if not ipaddr and bootproto != 'dhcp':
             ipaddr = confParams.get('IPADDR', None)
             netmask = confParams.get('NETMASK', None)
             gateway = confParams.get('GATEWAY', None)
             bootproto = bootproto or confParams.get('BOOTPROTO', None)
         defaultRoute = defaultRoute or confParams.get('DEFROUTE', None)
         if confParams.get('IPV6INIT', 'no') == 'yes':
             ipv6addr = confParams.get('IPV6ADDR', None)
             ipv6gateway = confParams.get('IPV6_DEFAULTGW', None)
             ipv6autoconf = (confParams.get('IPV6_AUTOCONF', 'no') == 'yes')
             dhcpv6 = (confParams.get('DHCPV6C', 'no') == 'yes')
         if not iface.mtu:
             mtu = confParams.get('MTU', None)
             if mtu:
                 mtu = int(mtu)
     ipconfig = IpConfig.ipConfig(ipaddr, netmask, gateway, defaultRoute,
                                  ipv6addr, ipv6gateway, ipv6defaultRoute,
                                  bootproto, async, ipv6autoconf, dhcpv6)
     return ipconfig, mtu
Ejemplo n.º 4
0
 def _getIfaceConfValues(iface):
     ipconfig = copy.deepcopy(iface.ipconfig)
     ipv4 = ipconfig.ipv4
     ipv6 = ipconfig.ipv6
     mtu = iface.mtu
     if netinfo.ifaceUsed(iface.name):
         confParams = netinfo.getIfaceCfg(iface.name)
         if not ipv4.address and ipconfig.bootproto != 'dhcp':
             ipv4.address = confParams.get('IPADDR')
             ipv4.netmask = confParams.get('NETMASK')
             ipv4.gateway = confParams.get('GATEWAY')
             if not ipconfig.bootproto:
                 ipconfig.bootproto = confParams.get('BOOTPROTO')
         if ipv4.defaultRoute is None and confParams.get('DEFROUTE'):
             ipv4.defaultRoute = _from_ifcfg_bool(confParams['DEFROUTE'])
         if confParams.get('IPV6INIT') == 'yes':
             ipv6.address = confParams.get('IPV6ADDR')
             ipv6.gateway = confParams.get('IPV6_DEFAULTGW')
             ipconfig.ipv6autoconf = (
                 confParams.get('IPV6_AUTOCONF') == 'yes')
             ipconfig.dhcpv6 = confParams.get('DHCPV6C') == 'yes'
         if not iface.mtu:
             mtu = confParams.get('MTU')
             if mtu:
                 mtu = int(mtu)
     return ipconfig, mtu
Ejemplo n.º 5
0
 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, StaticSourceRoute)
     return to_be_removed
Ejemplo n.º 6
0
    def configure(self, **opts):
        # in a limited condition, we should not touch the nic config
        if (self.vlan and netinfo.operstate(self.name) == netinfo.OPERSTATE_UP
                and netinfo.ifaceUsed(self.name)
                and self.mtu <= netinfo.getMtu(self.name)):
            return

        self.configurator.configureNic(self, **opts)
Ejemplo n.º 7
0
 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, StaticSourceRoute)
     return to_be_removed
Ejemplo n.º 8
0
def _uses_classes(device, root_qdisc_handle=None):
    """Returns true iff there's traffic classes in the device, ignoring the
    root class and a default unused class"""
    if root_qdisc_handle is None:
        root_qdisc_handle = _root_qdisc(tc._qdiscs(device))['handle']
    classes = [cls for cls in tc.classes(device, parent=root_qdisc_handle) if
               not cls.get('root')]
    return (classes and
            not(len(classes) == 1 and not netinfo.ifaceUsed(device) and
                classes[0]['handle'] == root_qdisc_handle + _DEFAULT_CLASSID))
Ejemplo n.º 9
0
    def removeNic(self, nic):
        toBeRemoved = not netinfo.ifaceUsed(nic.name)

        if toBeRemoved:
            if nic.master is None:
                self.configApplier.removeIpConfig(nic)
                DynamicSourceRoute.addInterfaceTracking(nic)
                self._removeSourceRoute(nic, DynamicSourceRoute)
            else:
                self.configApplier.setIfaceMtu(nic.name, netinfo.DEFAULT_MTU)
                self.configApplier.ifdown(nic)
        else:
            self._setNewMtu(nic, netinfo.vlanDevsForIface(nic.name))
Ejemplo n.º 10
0
    def configure(self, **opts):
        # When the bond is up and we are not changing the configuration that
        # is already applied in any way, we can skip the configuring.
        if (self.vlan and self.name in netinfo.bondings()
                and netinfo.operstate(self.name) == netinfo.OPERSTATE_UP
                and netinfo.ifaceUsed(self.name)
                and self.mtu <= netinfo.getMtu(self.name)
                and self.areOptionsApplied()
                and frozenset(slave.name
                              for slave in self.slaves) == frozenset(
                                  netinfo.slaves(self.name))):
            return

        self.configurator.configureBond(self, **opts)
Ejemplo n.º 11
0
    def configure(self, **opts):
        # When the bond is up and we are not changing the configuration that
        # is already applied in any way, we can skip the configuring.
        if (self.vlan and self.name in bonding.bondings()
                and (not self.configurator.unifiedPersistence
                     or self.name in self.configurator.runningConfig.bonds)
                and nics.operstate(self.name) == nics.OPERSTATE_UP
                and ifaceUsed(self.name) and self.mtu <= mtus.getMtu(self.name)
                and self.areOptionsApplied()
                and frozenset(slave.name
                              for slave in self.slaves) == frozenset(
                                  bonding.slaves(self.name))):
            return

        self.configurator.configureBond(self, **opts)
Ejemplo n.º 12
0
    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.destroyOnMasterRemoval:
                self._destroyBond(bonding)
                self.runningConfig.removeBonding(bonding.name)
            else:
                self.configApplier.setIfaceMtu(bonding.name,  mtus.DEFAULT_MTU)
                self.configApplier.ifdown(bonding)
        else:
            self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name))