Migrate lib/hypervisor/*.py from constants to pathutils
authorMichael Hanselmann <hansmi@google.com>
Mon, 17 Sep 2012 16:28:55 +0000 (18:28 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 18 Sep 2012 15:09:21 +0000 (17:09 +0200)
File system paths moved from constants to pathutils.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/hypervisor/hv_chroot.py
lib/hypervisor/hv_fake.py
lib/hypervisor/hv_kvm.py
lib/hypervisor/hv_lxc.py
lib/hypervisor/hv_xen.py

index 991bb73..bbc79b7 100644 (file)
@@ -32,6 +32,7 @@ from ganeti import constants
 from ganeti import errors # pylint: disable=W0611
 from ganeti import utils
 from ganeti import objects
+from ganeti import pathutils
 from ganeti.hypervisor import hv_base
 from ganeti.errors import HypervisorError
 
@@ -58,7 +59,7 @@ class ChrootManager(hv_base.BaseHypervisor):
     - instance alive check is based on whether any process is using the chroot
 
   """
-  _ROOT_DIR = constants.RUN_DIR + "/chroot-hypervisor"
+  _ROOT_DIR = pathutils.RUN_DIR + "/chroot-hypervisor"
 
   PARAMETERS = {
     constants.HV_INIT_SCRIPT: (True, utils.IsNormAbsPath,
index 6b7ab72..0f85e8c 100644 (file)
@@ -31,6 +31,7 @@ from ganeti import utils
 from ganeti import constants
 from ganeti import errors
 from ganeti import objects
+from ganeti import pathutils
 from ganeti.hypervisor import hv_base
 
 
@@ -43,7 +44,7 @@ class FakeHypervisor(hv_base.BaseHypervisor):
   """
   CAN_MIGRATE = True
 
-  _ROOT_DIR = constants.RUN_DIR + "/fake-hypervisor"
+  _ROOT_DIR = pathutils.RUN_DIR + "/fake-hypervisor"
 
   def __init__(self):
     hv_base.BaseHypervisor.__init__(self)
index 1ae01e4..e928c51 100644 (file)
@@ -49,12 +49,13 @@ from ganeti import serializer
 from ganeti import objects
 from ganeti import uidpool
 from ganeti import ssconf
-from ganeti.hypervisor import hv_base
 from ganeti import netutils
+from ganeti import pathutils
+from ganeti.hypervisor import hv_base
 from ganeti.utils import wrapper as utils_wrapper
 
 
-_KVM_NETWORK_SCRIPT = constants.SYSCONFDIR + "/ganeti/kvm-vif-bridge"
+_KVM_NETWORK_SCRIPT = pathutils.SYSCONFDIR + "/ganeti/kvm-vif-bridge"
 _KVM_START_PAUSED_FLAG = "-S"
 
 # TUN/TAP driver constants, taken from <linux/if_tun.h>
@@ -404,7 +405,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
   """
   CAN_MIGRATE = True
 
-  _ROOT_DIR = constants.RUN_DIR + "/kvm-hypervisor"
+  _ROOT_DIR = pathutils.RUN_DIR + "/kvm-hypervisor"
   _PIDS_DIR = _ROOT_DIR + "/pid" # contains live instances pids
   _UIDS_DIR = _ROOT_DIR + "/uid" # contains instances reserved uids
   _CTRL_DIR = _ROOT_DIR + "/ctrl" # contains instances control sockets
@@ -777,7 +778,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
       env["BRIDGE"] = nic.nicparams[constants.NIC_LINK]
 
-    result = utils.RunCmd([constants.KVM_IFUP, tap], env=env)
+    result = utils.RunCmd([pathutils.KVM_IFUP, tap], env=env)
     if result.failed:
       raise errors.HypervisorError("Failed to configure interface %s: %s."
                                    " Network configuration script output: %s" %
@@ -1195,10 +1196,10 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       if hvp[constants.HV_KVM_SPICE_USE_TLS]:
         spice_arg = ("%s,tls-port=%s,x509-cacert-file=%s" %
                      (spice_arg, instance.network_port,
-                      constants.SPICE_CACERT_FILE))
+                      pathutils.SPICE_CACERT_FILE))
         spice_arg = ("%s,x509-key-file=%s,x509-cert-file=%s" %
-                     (spice_arg, constants.SPICE_CERT_FILE,
-                      constants.SPICE_CERT_FILE))
+                     (spice_arg, pathutils.SPICE_CERT_FILE,
+                      pathutils.SPICE_CERT_FILE))
         tls_ciphers = hvp[constants.HV_KVM_SPICE_TLS_CIPHERS]
         if tls_ciphers:
           spice_arg = "%s,tls-ciphers=%s" % (spice_arg, tls_ciphers)
@@ -1824,7 +1825,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
 
     """
     if hvparams[constants.HV_SERIAL_CONSOLE]:
-      cmd = [constants.KVM_CONSOLE_WRAPPER,
+      cmd = [pathutils.KVM_CONSOLE_WRAPPER,
              constants.SOCAT_PATH, utils.ShellQuote(instance.name),
              utils.ShellQuote(cls._InstanceMonitor(instance.name)),
              "STDIO,%s" % cls._SocatUnixConsoleParams(),
index 49fd77a..2d96895 100644 (file)
@@ -32,6 +32,7 @@ from ganeti import constants
 from ganeti import errors # pylint: disable=W0611
 from ganeti import utils
 from ganeti import objects
+from ganeti import pathutils
 from ganeti.hypervisor import hv_base
 from ganeti.errors import HypervisorError
 
@@ -65,7 +66,7 @@ class LXCHypervisor(hv_base.BaseHypervisor):
       notify_on_release and release_agent feature of cgroups
 
   """
-  _ROOT_DIR = constants.RUN_DIR + "/lxc"
+  _ROOT_DIR = pathutils.RUN_DIR + "/lxc"
   _DEVS = [
     "c 1:3",   # /dev/null
     "c 1:5",   # /dev/zero
index 81adeb9..7274240 100644 (file)
@@ -32,6 +32,7 @@ from ganeti import utils
 from ganeti.hypervisor import hv_base
 from ganeti import netutils
 from ganeti import objects
+from ganeti import pathutils
 
 
 XEND_CONFIG_FILE = "/etc/xen/xend-config.sxp"
@@ -420,7 +421,7 @@ class XenHypervisor(hv_base.BaseHypervisor):
                                    kind=constants.CONS_SSH,
                                    host=instance.primary_node,
                                    user=constants.GANETI_RUNAS,
-                                   command=[constants.XM_CONSOLE_WRAPPER,
+                                   command=[pathutils.XM_CONSOLE_WRAPPER,
                                             instance.name])
 
   def Verify(self):
@@ -707,10 +708,10 @@ class XenHvmHypervisor(XenHypervisor):
   """Xen HVM hypervisor interface"""
 
   ANCILLARY_FILES = XenHypervisor.ANCILLARY_FILES + [
-    constants.VNC_PASSWORD_FILE,
+    pathutils.VNC_PASSWORD_FILE,
     ]
   ANCILLARY_FILES_OPT = XenHypervisor.ANCILLARY_FILES_OPT + [
-    constants.VNC_PASSWORD_FILE,
+    pathutils.VNC_PASSWORD_FILE,
     ]
 
   PARAMETERS = {