9 def setIPAddress(self, ip):
11 os.system("echo ifconfig eth0 %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
13 def setIPGateway(self, ip):
14 os.system("echo route add default gw %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
16 def setIPNameserver(self, ip):
17 resolvconf = file('/etc/resolv.conf', 'w')
18 resolvconf.write("nameserver %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
21 def setMACAddress(self, mac):
22 os.system("echo ifconfig eth0 %02x:%02x:%02x:%02x:%02x:%02x" % (mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]))
25 config.network = ConfigSubsection()
26 config.network.ip = configElement("config.network.ip", configSequence, [192,168,1,45], ("."))
27 config.network.gateway = configElement("config.network.gateway", configSequence, [192,168,1,3], ("."))
28 config.network.dns = configElement("config.network.dns", configSequence, [192,168,1,3], ("."))
29 config.network.mac = configElement("config.network.mac", configSequence, [00,11,22,33,44,55], (":"))
33 def setIPAddress(configElement):
34 iNetwork.setIPAddress(configElement.value)
36 def setIPGateway(configElement):
37 iNetwork.setIPGateway(configElement.value)
39 def setIPNameserver(configElement):
40 iNetwork.setIPNameserver(configElement.value)
42 def setMACAddress(configElement):
43 iNetwork.setMACAddress(configElement.value)
45 # this will call the "setup-val" initial
46 config.network.ip.addNotifier(setIPAddress)
47 config.network.gateway.addNotifier(setIPGateway)
48 config.network.dns.addNotifier(setIPNameserver)
49 config.network.mac.addNotifier(setMACAddress)