The users are about evently split between creating files in the
default path and elsewhere, so just specify an explicit path everywhere.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
diff -r ee79e2b286b1 -r bcbca445b898 scripts/interface-reconfigure
--- a/scripts/interface-reconfigure Fri Dec 18 14:16:32 2009 +0000
+++ b/scripts/interface-reconfigure Fri Dec 18 14:16:32 2009 +0000
@@ -54,7 +54,6 @@
management_pif = None
sysfs_bonding_masters = "/sys/class/net/bonding_masters"
-ifcfg = "/etc/sysconfig/network-scripts"
class Usage(Exception):
def __init__(self, msg):
@@ -65,6 +64,10 @@
def __init__(self, msg):
Exception.__init__(self)
self.msg = msg
+
+#
+# Configuration File Handling.
+#
class ConfigurationFile(object):
"""Write a file, tracking old and new versions.
@@ -77,15 +80,15 @@
"NOT-APPLIED":"NOT-APPLIED", "APPLIED":"APPLIED",
"REVERTED":"REVERTED", "COMMITTED": "COMMITTED"}
- def __init__(self, fname, dirname=ifcfg):
-
+ def __init__(self, path):
+ dirname,basename = os.path.split(path)
+
self.__state = self.__STATE['OPEN']
- self.__fname = fname
self.__children = []
- self.__path = os.path.join(dirname, fname)
- self.__oldpath = os.path.join(dirname, "." + fname + ".xapi-old")
- self.__newpath = os.path.join(dirname, "." + fname + ".xapi-new")
+ self.__path = os.path.join(dirname, basename)
+ self.__oldpath = os.path.join(dirname, "." + basename + ".xapi-old")
+ self.__newpath = os.path.join(dirname, "." + basename + ".xapi-new")
self.__unlink = False
self.__f = open(self.__newpath, "w")
@@ -134,7 +137,7 @@
for child in self.__children:
child.apply()
- log("Applying changes to %s configuration" % self.__fname)
+ log("Applying changes to %s configuration" % self.__path)
# Remove previous backup.
if os.access(self.__oldpath, os.F_OK):
@@ -164,7 +167,7 @@
for child in self.__children:
child.revert()
- log("Reverting changes to %s configuration" % self.__fname)
+ log("Reverting changes to %s configuration" % self.__path)
# Remove existing new configuration
if os.access(self.__newpath, os.F_OK):
@@ -191,7 +194,7 @@
for child in self.__children:
child.commit()
- log("Committing changes to %s configuration" % self.__fname)
+ log("Committing changes to %s configuration" % self.__path)
if os.access(self.__oldpath, os.F_OK):
os.unlink(self.__oldpath)
@@ -334,7 +337,6 @@
172.16.0.0/15 via 192.168.0.3 dev xenbr1
172.18.0.0/16 via 192.168.0.4 dev xenbr1
"""
- fname = "route-%s" % interface
if oc.has_key('static-routes'):
# The key is present - extract comma seperates entries
lines = oc['static-routes'].split(',')
@@ -342,7 +344,7 @@
# The key is not present, i.e. there are no static routes
lines = []
- child = ConfigurationFile(fname)
+ child = ConfigurationFile("/etc/sysconfig/network-scripts/route-%s" %
interface)
child.write("# DO NOT EDIT: This file (%s) was autogenerated by %s\n" % \
(os.path.basename(child.path()), os.path.basename(sys.argv[0])))
@@ -363,8 +365,7 @@
Opens the configuration file for interface, writes a header and
common options and returns the file object.
"""
- fname = "ifcfg-%s" % interface
- f = ConfigurationFile(fname)
+ f = ConfigurationFile("/etc/sysconfig/network-scripts/ifcfg-%s" %
interface)
f.write("# DO NOT EDIT: This file (%s) was autogenerated by %s\n" % \
(os.path.basename(f.path()), os.path.basename(sys.argv[0])))
@@ -723,7 +724,7 @@
f.write('PEERDNS=%s\n' % ((pif == peerdns_pif) and 'yes' or 'no'))
# Update gatewaydev
- fnetwork = ConfigurationFile("network", "/etc/sysconfig")
+ fnetwork = ConfigurationFile("/etc/sysconfig/network")
for line in fnetwork.readlines():
if line.lstrip().startswith('GATEWAY') :
continue
@@ -1359,7 +1360,7 @@
br.write("IPADDR=%s\n" % ip)
if gateway:
br.write("GATEWAY=%s\n" % gateway)
- fnetwork = ConfigurationFile("network", "/etc/sysconfig")
+ fnetwork = ConfigurationFile("/etc/sysconfig/network")
for line in fnetwork.readlines():
if line.lstrip().startswith('GATEWAY') :
continue
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|