예제 #1
0
파일: netinfo_test.py 프로젝트: mykaul/vdsm
    def testGetIfaceCfg(self):
        deviceName = "___This_could_never_be_a_device_name___"
        ifcfg = ('GATEWAY0=1.1.1.1\n' 'NETMASK=255.255.0.0\n')
        with namedTemporaryDir() as tempDir:
            ifcfgPrefix = os.path.join(tempDir, 'ifcfg-')
            filePath = ifcfgPrefix + deviceName

            with MonkeyPatchScope([(misc, 'NET_CONF_PREF', ifcfgPrefix)]):
                with open(filePath, 'w') as ifcfgFile:
                    ifcfgFile.write(ifcfg)
                self.assertEqual(
                    misc.getIfaceCfg(deviceName)['GATEWAY'], '1.1.1.1')
                self.assertEqual(
                    misc.getIfaceCfg(deviceName)['NETMASK'], '255.255.0.0')
예제 #2
0
    def testGetIfaceCfg(self):
        deviceName = "___This_could_never_be_a_device_name___"
        ifcfg = ('GATEWAY0=1.1.1.1\n' 'NETMASK=255.255.0.0\n')
        with namedTemporaryDir() as tempDir:
            ifcfgPrefix = os.path.join(tempDir, 'ifcfg-')
            filePath = ifcfgPrefix + deviceName

            with MonkeyPatchScope([(misc, 'NET_CONF_PREF', ifcfgPrefix)]):
                with open(filePath, 'w') as ifcfgFile:
                    ifcfgFile.write(ifcfg)
                self.assertEqual(
                    misc.getIfaceCfg(deviceName)['GATEWAY'], '1.1.1.1')
                self.assertEqual(
                    misc.getIfaceCfg(deviceName)['NETMASK'], '255.255.0.0')
예제 #3
0
파일: ifcfg.py 프로젝트: mykaul/vdsm
 def _getIfaceConfValues(iface):
     ipv4 = copy.deepcopy(iface.ipv4)
     ipv6 = copy.deepcopy(iface.ipv6)
     mtu = iface.mtu
     if ifaceUsed(iface.name):
         confParams = misc.getIfaceCfg(iface.name)
         if not ipv4.address and ipv4.bootproto != 'dhcp':
             ipv4.address = confParams.get('IPADDR')
             ipv4.netmask = confParams.get('NETMASK')
             ipv4.gateway = confParams.get('GATEWAY')
             if not ipv4.bootproto:
                 ipv4.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')
             ipv6.ipv6autoconf = confParams.get('IPV6_AUTOCONF') == 'yes'
             ipv6.dhcpv6 = confParams.get('DHCPV6C') == 'yes'
         if not iface.mtu:
             mtu = confParams.get('MTU')
             if mtu:
                 mtu = int(mtu)
     return ipv4, ipv6, mtu
예제 #4
0
파일: ifcfg.py 프로젝트: fancyKai/vdsm
 def _getIfaceConfValues(iface):
     ipv4 = copy.deepcopy(iface.ipv4)
     ipv6 = copy.deepcopy(iface.ipv6)
     mtu = iface.mtu
     if ifaceUsed(iface.name):
         confParams = misc.getIfaceCfg(iface.name)
         if not ipv4.address and ipv4.bootproto != "dhcp":
             ipv4.address = confParams.get("IPADDR")
             ipv4.netmask = confParams.get("NETMASK")
             ipv4.gateway = confParams.get("GATEWAY")
             if not ipv4.bootproto:
                 ipv4.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")
             ipv6.ipv6autoconf = confParams.get("IPV6_AUTOCONF") == "yes"
             ipv6.dhcpv6 = confParams.get("DHCPV6C") == "yes"
         if not iface.mtu:
             mtu = confParams.get("MTU")
             if mtu:
                 mtu = int(mtu)
     return ipv4, ipv6, mtu
예제 #5
0
 def _getIfaceConfValues(iface):
     ipv4 = copy.deepcopy(iface.ipv4)
     ipv6 = copy.deepcopy(iface.ipv6)
     mtu = iface.mtu
     if ifaceUsed(iface.name):
         confParams = misc.getIfaceCfg(iface.name)
         if not ipv4.address and ipv4.bootproto != 'dhcp':
             ipv4.address = confParams.get('IPADDR')
             ipv4.netmask = confParams.get('NETMASK')
             ipv4.gateway = confParams.get('GATEWAY')
             if not ipv4.bootproto:
                 ipv4.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')
             ipv6.ipv6autoconf = confParams.get('IPV6_AUTOCONF') == 'yes'
             ipv6.dhcpv6 = confParams.get('DHCPV6C') == 'yes'
         if not iface.mtu:
             mtu = confParams.get('MTU')
             if mtu:
                 mtu = int(mtu)
     return ipv4, ipv6, mtu