import time
import tempfile
import errno
+import struct
import sioc
import modprobe
# Process ifcfg-$dev changes / additions
newdevs = []
+ table = 10
for (dev, details) in devices_map.iteritems():
(fd, tmpnam) = tempfile.mkstemp(dir=sysconfig)
f = os.fdopen(fd, "w")
# print the configuration values
for (key, val) in details.iteritems():
- if key not in ('IFNAME','ALIAS','CFGOPTIONS','DRIVER'):
+ if key not in ('IFNAME','ALIAS','CFGOPTIONS','DRIVER','GATEWAY'):
f.write('%s=%s\n' % (key, val))
# print the configuration specific option values (if any)
val=val.strip()
f.write('%s="%s"\n' % (key,val))
f.close()
- os.close(fd)
# compare whether two files are the same
def comparefiles(a,b):
src_route_changed = False
if ('PRIMARY' not in details and 'GATEWAY' in details and
details['GATEWAY'] != ''):
- i = len(dev) - 1
- while dev[i - 1].isdigit():
- i -= 1
- table = 10 + int(dev[i:])
+ table += 1
(fd, rule_tmpnam) = tempfile.mkstemp(dir=sysconfig)
os.write(fd, "from %s lookup %d\n" % (details['IPADDR'], table))
os.close(fd)
rule_dest = "%s/rule-%s" % (sysconfig, dev)
if not comparefiles(rule_tmpnam, rule_dest):
- os.unlink(rule_dest)
os.rename(rule_tmpnam, rule_dest)
- os.chmod(0644, rule_dest)
+ os.chmod(rule_dest, 0644)
src_route_changed = True
else:
os.unlink(rule_tmpnam)
os.close(fd)
route_dest = "%s/route-%s" % (sysconfig, dev)
if not comparefiles(route_tmpnam, route_dest):
- os.unlink(route_dest)
os.rename(route_tmpnam, route_dest)
- os.chmod(0644, route_dest)
+ os.chmod(route_dest, 0644)
src_route_changed = True
else:
os.unlink(route_tmpnam)
dest="program", default="plnet")
(options, args) = parser.parse_args()
if len(args) != 1 or options.root is None:
+ print sys.argv
print >>sys.stderr, "Missing root or node_id"
parser.print_help()
sys.exit(1)