From 5420ffc91f71c548233fc346b535df97f8606697 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Thu, 21 May 2009 16:21:27 +0100
Subject: [PATCH] KVM: replace hardcoded network script path

Currently the kvm automatic network scripts accepts to be overridden by
an user supplied /etc/ganeti/kvm-vif-bridge script. We keep this
functionality but move the hardcoded path to a constant, dependent also
on SYSCONFDIR.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/constants.py         | 1 +
 lib/hypervisor/hv_kvm.py | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/constants.py b/lib/constants.py
index e5a210c4d..0bcf70a8a 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -101,6 +101,7 @@ RAPI_USERS_FILE = DATA_DIR + "/rapi_users"
 QUEUE_DIR = DATA_DIR + "/queue"
 ETC_HOSTS = "/etc/hosts"
 DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
+SYSCONFDIR = _autoconf.SYSCONFDIR
 
 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
 
diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index 38ed993b3..23946839d 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -76,6 +76,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
   _MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
                                     re.M | re.I)
 
+  _KVM_NETWORK_SCRIPT = constants.SYSCONFDIR + "/ganeti/kvm-vif-bridge"
+
   def __init__(self):
     hv_base.BaseHypervisor.__init__(self)
     # Let's make sure the directories we need exist, even if the RUN_DIR lives
@@ -148,9 +150,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     script.write("export BRIDGE=%s\n" % nic.bridge)
     script.write("export INTERFACE=$1\n")
     # TODO: make this configurable at ./configure time
-    script.write("if [ -x /etc/ganeti/kvm-vif-bridge ]; then\n")
+    script.write("if [ -x '%s' ]; then\n" % self._KVM_NETWORK_SCRIPT)
     script.write("  # Execute the user-specific vif file\n")
-    script.write("  /etc/ganeti/kvm-vif-bridge\n")
+    script.write("  %s\n" % self._KVM_NETWORK_SCRIPT)
     script.write("else\n")
     script.write("  # Connect the interface to the bridge\n")
     script.write("  /sbin/ifconfig $INTERFACE 0.0.0.0 up\n")
-- 
GitLab