9 def setDHCP(self, useDHCP):
12 config.network.ip.enabled = False
13 config.network.gateway.enabled = False
14 config.network.dns.enabled = False
16 print "NOT using DHCP"
17 config.network.ip.enabled = True
18 config.network.gateway.enabled = True
19 config.network.dns.enabled = True
21 def setIPAddress(self, ip):
23 os.system("echo ifconfig eth0 %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
25 def setIPGateway(self, ip):
26 os.system("echo route add default gw %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
28 def setIPNameserver(self, ip):
29 resolvconf = file('/etc/resolv.conf', 'w')
30 resolvconf.write("nameserver %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
33 def setMACAddress(self, mac):
34 os.system("echo ifconfig eth0 ether %02x:%02x:%02x:%02x:%02x:%02x" % (mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]))
37 config.network = ConfigSubsection()
38 config.network.dhcp = configElement("config.network.dhcp", configBoolean, 0, ("no", "yes"))
39 config.network.ip = configElement("config.network.ip", configSequence, [192,168,1,45], (("."), 3))
40 config.network.gateway = configElement("config.network.gateway", configSequence, [192,168,1,3], (("."), 3))
41 config.network.dns = configElement("config.network.dns", configSequence, [192,168,1,3], (("."), 3))
42 config.network.mac = configElement("config.network.mac", configSequence, [00,11,22,33,44,55], ((":"), 2))
46 def setDHCP(configElement):
47 iNetwork.setDHCP(configElement.value)
49 def setIPAddress(configElement):
50 iNetwork.setIPAddress(configElement.value)
52 def setIPGateway(configElement):
53 iNetwork.setIPGateway(configElement.value)
55 def setIPNameserver(configElement):
56 iNetwork.setIPNameserver(configElement.value)
58 def setMACAddress(configElement):
59 iNetwork.setMACAddress(configElement.value)
61 # this will call the "setup-val" initial
62 config.network.dhcp.addNotifier(setDHCP)
63 config.network.ip.addNotifier(setIPAddress)
64 config.network.gateway.addNotifier(setIPGateway)
65 config.network.dns.addNotifier(setIPNameserver)
66 config.network.mac.addNotifier(setMACAddress)