diff options
author | Ben Pfaff <blp@nicira.com> | 2010-02-22 16:25:54 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-02-23 09:55:42 -0800 |
commit | 64ddb6fecfe21a7b50c5907dd88de67a87ec6eca (patch) | |
tree | ef8f329d041fd67dc7a4cfbd26626073b5d8fda7 /xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py | |
parent | 86e1bb44dadf886a34bfef00b5523873081f32fe (diff) |
xenserver: Add --root-prefix feature to interface-reconfigure.
This makes it easier to do unit tests (some of which will be added in an
upcoming commit) by allowing fake configuration files and scripts to be
added in a directory other than the real root.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py')
-rw-r--r-- | xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py index 783fad30..2a3aa8ce 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py @@ -15,7 +15,7 @@ from InterfaceReconfigure import * import sys import time -sysfs_bonding_masters = "/sys/class/net/bonding_masters" +sysfs_bonding_masters = root_prefix() + "/sys/class/net/bonding_masters" def open_pif_ifcfg(pif): pifrec = db().get_pif_record(pif) @@ -23,7 +23,7 @@ def open_pif_ifcfg(pif): interface = pif_netdev_name(pif) log("Configuring %s (%s)" % (interface, pifrec['MAC'])) - f = ConfigurationFile("/etc/sysconfig/network-scripts/ifcfg-%s" % interface) + f = ConfigurationFile("%s/etc/sysconfig/network-scripts/ifcfg-%s" % (root_prefix(), 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]))) @@ -69,7 +69,7 @@ def load_bonding_driver(): log("Failed to load bonding driver: %s" % e) def bonding_driver_loaded(): - lines = open("/proc/modules").read().split("\n") + lines = open(root_prefix() + "/proc/modules").read().split("\n") modules = [line.split(" ")[0] for line in lines] return "bonding" in modules @@ -226,7 +226,7 @@ def bring_down_interface(pif, destroy=False): def interface_is_up(pif): try: interface = pif_netdev_name(pif) - state = open("/sys/class/net/%s/operstate" % interface).read().strip() + state = open("%s/sys/class/net/%s/operstate" % (root_prefix(), interface)).read().strip() return state == "up" except: return False # interface prolly doesn't exist @@ -294,7 +294,7 @@ def pif_get_bond_slaves_sorted(pif): # which they were attached. The first slave attached must be the last detached since # the bond is using its MAC address. try: - attached_slaves = open("/sys/class/net/%s/bonding/slaves" % pifrec['device']).readline().split() + attached_slaves = open("%s/sys/class/net/%s/bonding/slaves" % (root_prefix(), pifrec['device'])).readline().split() for slave in attached_slaves: pifs = [p for p in db().get_pifs_by_device(slave) if not pif_is_vlan(p)] slave_pif = pifs[0] |