From 9d9bded1ab0e8ee7d224abbb307fa0f064c9a14f Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Mon, 17 Sep 2012 18:28:55 +0200
Subject: [PATCH] Migrate lib/hypervisor/*.py from constants to pathutils

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 |  3 ++-
 lib/hypervisor/hv_fake.py   |  3 ++-
 lib/hypervisor/hv_kvm.py    | 17 +++++++++--------
 lib/hypervisor/hv_lxc.py    |  3 ++-
 lib/hypervisor/hv_xen.py    |  7 ++++---
 5 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/lib/hypervisor/hv_chroot.py b/lib/hypervisor/hv_chroot.py
index 991bb7326..bbc79b7a4 100644
--- a/lib/hypervisor/hv_chroot.py
+++ b/lib/hypervisor/hv_chroot.py
@@ -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,
diff --git a/lib/hypervisor/hv_fake.py b/lib/hypervisor/hv_fake.py
index 6b7ab72c7..0f85e8cda 100644
--- a/lib/hypervisor/hv_fake.py
+++ b/lib/hypervisor/hv_fake.py
@@ -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)
diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index 1ae01e427..e928c51a1 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -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(),
diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py
index 49fd77a31..2d9689519 100644
--- a/lib/hypervisor/hv_lxc.py
+++ b/lib/hypervisor/hv_lxc.py
@@ -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
diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py
index 81adeb9ee..72742405b 100644
--- a/lib/hypervisor/hv_xen.py
+++ b/lib/hypervisor/hv_xen.py
@@ -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 = {
-- 
GitLab