mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
tools: get rid of hardcoded config dirs
Remove *all* hardcoded "/etc/xen" strings in python code.
Additionally, it removes pygrub_path from osdep.py. Its use has been
replaced with auxbin.pathTo("pygrub").
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
This commit is contained in:
1 parent
e7da8a7b69
commit
9f6d07bac9
20 files changed
+62
-45
No files matched your search
@@ -23,6 +23,8 @@ genpath:
|
||||
echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath}
|
||||
echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath}
|
||||
echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath}
|
||||
echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> ${xenpath}
|
||||
echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> ${xenpath}
|
||||
|
||||
buildpy: genpath
|
||||
CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
|
||||
|
||||
@@ -20,6 +20,7 @@ import os
|
||||
import os.path
|
||||
import sys
|
||||
from xen.util.path import SBINDIR,BINDIR,LIBEXEC,LIBDIR,PRIVATE_BINDIR
|
||||
from xen.util.path import XEN_CONFIG_DIR, XEN_SCRIPT_DIR
|
||||
|
||||
def execute(exe, args = None):
|
||||
exepath = pathTo(exe)
|
||||
@@ -45,3 +46,9 @@ def path():
|
||||
|
||||
def libpath():
|
||||
return LIBDIR
|
||||
|
||||
def xen_configdir():
|
||||
return XEN_CONFIG_DIR
|
||||
|
||||
def scripts_dir():
|
||||
return XEN_SCRIPT_DIR
|
||||
@@ -31,11 +31,11 @@ from xen.xend import XendConstants
|
||||
from xen.xend import XendOptions
|
||||
from xen.xend.XendLogging import log
|
||||
from xen.xend.XendError import VmError
|
||||
from xen.util import dictio, xsconstants
|
||||
from xen.util import dictio, xsconstants, auxbin
|
||||
from xen.xend.XendConstants import *
|
||||
|
||||
#global directories and tools for security management
|
||||
install_policy_dir_prefix = "/etc/xen/acm-security/policies"
|
||||
install_policy_dir_prefix = auxbin.xen_configdir() + "/acm-security/policies"
|
||||
security_dir_prefix = XendOptions.instance().get_xend_security_path()
|
||||
policy_dir_prefix = security_dir_prefix + "/policies"
|
||||
res_label_filename = policy_dir_prefix + "/resource_labels"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#============================================================================
|
||||
|
||||
from xen.xend.XendAPIConstants import *
|
||||
from xen.util import auxbin
|
||||
|
||||
#
|
||||
# Shutdown codes and reasons.
|
||||
@@ -129,7 +130,7 @@ DEV_MIGRATE_STEP3 = 3
|
||||
# VTPM-related constants
|
||||
#
|
||||
|
||||
VTPM_DELETE_SCRIPT = '/etc/xen/scripts/vtpm-delete'
|
||||
VTPM_DELETE_SCRIPT = auxbin.scripts_dir() + '/vtpm-delete'
|
||||
|
||||
#
|
||||
# Xenstore Constants
|
||||
|
||||
@@ -34,12 +34,12 @@ import traceback
|
||||
from types import StringTypes
|
||||
|
||||
import xen.lowlevel.xc
|
||||
from xen.util import asserts
|
||||
from xen.util import asserts, auxbin
|
||||
from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
|
||||
import xen.util.xsm.xsm as security
|
||||
from xen.util import xsconstants
|
||||
|
||||
from xen.xend import balloon, sxp, uuid, image, arch, osdep
|
||||
from xen.xend import balloon, sxp, uuid, image, arch
|
||||
from xen.xend import XendOptions, XendNode, XendConfig
|
||||
|
||||
from xen.xend.XendConfig import scrub_password
|
||||
@@ -2914,7 +2914,7 @@ class XendDomainInfo:
|
||||
else:
|
||||
# Boot using bootloader
|
||||
if not blexec or blexec == 'pygrub':
|
||||
blexec = osdep.pygrub_path
|
||||
blexec = auxbin.pathTo('pygrub')
|
||||
|
||||
blcfg = None
|
||||
disks = [x for x in self.info['vbd_refs']
|
||||
|
||||
@@ -32,6 +32,7 @@ import sys
|
||||
|
||||
from xen.xend import sxp, osdep, XendLogging
|
||||
from xen.xend.XendError import XendError
|
||||
from xen.util import auxbin
|
||||
|
||||
if os.uname()[0] == 'SunOS':
|
||||
from xen.lowlevel import scf
|
||||
@@ -40,10 +41,10 @@ class XendOptions:
|
||||
"""Configuration options."""
|
||||
|
||||
"""Where network control scripts live."""
|
||||
network_script_dir = osdep.scripts_dir
|
||||
network_script_dir = auxbin.scripts_dir()
|
||||
|
||||
"""Where block control scripts live."""
|
||||
block_script_dir = osdep.scripts_dir
|
||||
block_script_dir = auxbin.scripts_dir()
|
||||
|
||||
"""Default path to the log file. """
|
||||
logfile_default = "/var/log/xen/xend.log"
|
||||
@@ -115,7 +116,7 @@ class XendOptions:
|
||||
xend_vnc_tls = 0
|
||||
|
||||
"""x509 certificate directory for QEMU VNC server"""
|
||||
xend_vnc_x509_cert_dir = "/etc/xen/vnc"
|
||||
xend_vnc_x509_cert_dir = auxbin.xen_configdir() + "/vnc"
|
||||
|
||||
"""Verify incoming client x509 certs"""
|
||||
xend_vnc_x509_verify = 0
|
||||
@@ -355,7 +356,7 @@ class XendOptions:
|
||||
s = self.get_config_string('resource-label-change-script')
|
||||
if s:
|
||||
result = s.split(" ")
|
||||
result[0] = os.path.join(osdep.scripts_dir, result[0])
|
||||
result[0] = os.path.join(auxbin.scripts_dir(), result[0])
|
||||
return result
|
||||
else:
|
||||
return None
|
||||
@@ -386,7 +387,7 @@ class XendOptions:
|
||||
class XendOptionsFile(XendOptions):
|
||||
|
||||
"""Default path to the config file."""
|
||||
config_default = "/etc/xen/xend-config.sxp"
|
||||
config_default = auxbin.xen_configdir() + "/xend-config.sxp"
|
||||
|
||||
"""Environment variable used to override config_default."""
|
||||
config_var = "XEND_CONFIG"
|
||||
|
||||
@@ -25,6 +25,7 @@ from xen.xend.XendBase import XendBase
|
||||
from xen.xend.XendPIFMetrics import XendPIFMetrics
|
||||
from xen.xend.XendError import *
|
||||
from xen.xend import Vifctl
|
||||
from xen.util import auxbin
|
||||
|
||||
log = logging.getLogger("xend.XendPIF")
|
||||
log.setLevel(logging.TRACE)
|
||||
|
||||
@@ -20,21 +20,12 @@
|
||||
import os
|
||||
import commands
|
||||
|
||||
_scripts_dir = {
|
||||
"Linux": "/etc/xen/scripts",
|
||||
"SunOS": "/usr/lib/xen/scripts",
|
||||
}
|
||||
|
||||
_xend_autorestart = {
|
||||
"NetBSD": True,
|
||||
"Linux": True,
|
||||
"SunOS": False,
|
||||
}
|
||||
|
||||
_pygrub_path = {
|
||||
"SunOS": "/usr/lib/xen/bin/pygrub"
|
||||
}
|
||||
|
||||
_vif_script = {
|
||||
"SunOS": "vif-vnic"
|
||||
}
|
||||
@@ -221,9 +212,7 @@ _get_postfork = {
|
||||
def _get(var, default=None):
|
||||
return var.get(os.uname()[0], default)
|
||||
|
||||
scripts_dir = _get(_scripts_dir, "/etc/xen/scripts")
|
||||
xend_autorestart = _get(_xend_autorestart)
|
||||
pygrub_path = _get(_pygrub_path, "/usr/bin/pygrub")
|
||||
vif_script = _get(_vif_script, "vif-bridge")
|
||||
lookup_balloon_stat = _get(_balloon_stat, _linux_balloon_stat)
|
||||
get_cpuinfo = _get(_get_cpuinfo, _linux_get_cpuinfo)
|
||||
|
||||
@@ -24,7 +24,7 @@ from xen.util import blkif
|
||||
import xen.util.xsm.xsm as security
|
||||
from xen.xend.XendError import VmError
|
||||
from xen.xend.server.DevController import DevController
|
||||
from xen.util import xsconstants
|
||||
from xen.util import xsconstants, auxbin
|
||||
|
||||
class BlkifController(DevController):
|
||||
"""Block device interface controller. Handles all block devices
|
||||
@@ -40,7 +40,7 @@ class BlkifController(DevController):
|
||||
if protocol in ('phy', 'file', 'tap'):
|
||||
return True
|
||||
|
||||
return os.access('/etc/xen/scripts/block-%s' % protocol, os.X_OK)
|
||||
return os.access(auxbin.scripts_dir() + '/block-%s' % protocol, os.X_OK)
|
||||
|
||||
|
||||
def getDeviceDetails(self, config):
|
||||
|
||||
@@ -3,10 +3,11 @@ from xen.xend.XendError import XendError, VmError
|
||||
import sys
|
||||
import os.path
|
||||
from xen.xend.sxp import *
|
||||
from xen.util import auxbin
|
||||
|
||||
QUIRK_SYSFS_NODE = "/sys/bus/pci/drivers/pciback/quirks"
|
||||
QUIRK_CONFIG_FILE = "/etc/xen/xend-pci-quirks.sxp"
|
||||
PERMISSIVE_CONFIG_FILE = "/etc/xen/xend-pci-permissive.sxp"
|
||||
QUIRK_CONFIG_FILE = auxbin.xen_configdir() + "/xend-pci-quirks.sxp"
|
||||
PERMISSIVE_CONFIG_FILE = auxbin.xen_configdir() + "/xend-pci-permissive.sxp"
|
||||
PERMISSIVE_SYSFS_NODE = "/sys/bus/pci/drivers/pciback/permissive"
|
||||
|
||||
class PCIQuirk:
|
||||
|
||||
@@ -24,7 +24,7 @@ import sys
|
||||
|
||||
import xen.util.xsm.xsm as security
|
||||
from xen.xm.opts import OptionError
|
||||
from xen.util import xsconstants
|
||||
from xen.util import xsconstants, auxbin
|
||||
from xen.xm import main as xm_main
|
||||
from xen.xm.main import server
|
||||
|
||||
@@ -221,7 +221,7 @@ def main(argv):
|
||||
if argv[2].lower() == "dom":
|
||||
configfile = argv[3]
|
||||
if configfile[0] != '/':
|
||||
for prefix in [os.path.realpath(os.path.curdir), "/etc/xen"]:
|
||||
for prefix in [os.path.realpath(os.path.curdir), auxbin.xen_configdir()]:
|
||||
configfile = prefix + "/" + configfile
|
||||
if os.path.isfile(configfile):
|
||||
break
|
||||
|
||||
@@ -29,7 +29,6 @@ import xmlrpclib
|
||||
|
||||
from xen.xend import sxp
|
||||
from xen.xend import PrettyPrint as SXPPrettyPrint
|
||||
from xen.xend import osdep
|
||||
import xen.xend.XendClient
|
||||
from xen.xend.XendBootloader import bootloader
|
||||
from xen.xend.XendConstants import *
|
||||
@@ -38,7 +37,7 @@ from xen.util import blkif
|
||||
from xen.util import vscsi_util
|
||||
import xen.util.xsm.xsm as security
|
||||
from xen.xm.main import serverType, SERVER_XEN_API, get_single_vm
|
||||
from xen.util import utils
|
||||
from xen.util import utils, auxbin
|
||||
|
||||
from xen.xm.opts import *
|
||||
|
||||
@@ -72,7 +71,7 @@ gopts.opt('quiet', short='q',
|
||||
use="Quiet.")
|
||||
|
||||
gopts.opt('path', val='PATH',
|
||||
fn=set_value, default='.:/etc/xen',
|
||||
fn=set_value, default='.:' + auxbin.xen_configdir(),
|
||||
use="Search path for configuration scripts. "
|
||||
"The value of PATH is a colon-separated directory list.")
|
||||
|
||||
@@ -981,7 +980,7 @@ def make_config(vals):
|
||||
config_image = configure_image(vals)
|
||||
if vals.bootloader:
|
||||
if vals.bootloader == "pygrub":
|
||||
vals.bootloader = osdep.pygrub_path
|
||||
vals.bootloader = auxbin.pathTo(vals.bootloader)
|
||||
|
||||
config.append(['bootloader', vals.bootloader])
|
||||
if vals.bootargs:
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"""
|
||||
import sys, os, re
|
||||
import xen.util.xsm.xsm as security
|
||||
from xen.util import xsconstants
|
||||
from xen.util import xsconstants, auxbin
|
||||
from xen.xm.opts import OptionError
|
||||
from xen.xm import main as xm_main
|
||||
from xen.xm.main import server
|
||||
@@ -59,7 +59,7 @@ def get_domain_label(configfile):
|
||||
if configfile[0] == '/':
|
||||
fd = open(configfile, "rb")
|
||||
else:
|
||||
for prefix in [".", "/etc/xen"]:
|
||||
for prefix in [".", auxbin.xen_configdir() ]:
|
||||
abs_file = prefix + "/" + configfile
|
||||
if os.path.isfile(abs_file):
|
||||
fd = open(abs_file, "rb")
|
||||
|
||||
@@ -55,6 +55,7 @@ from xen.util.xmlrpcclient import ServerProxy
|
||||
import xen.util.xsm.xsm as security
|
||||
from xen.util.xsm.xsm import XSMError
|
||||
from xen.util.acmpolicy import ACM_LABEL_UNLABELED_DISPLAY
|
||||
from xen.util import auxbin
|
||||
|
||||
import XenAPI
|
||||
|
||||
@@ -72,7 +73,7 @@ if not hasattr(getopt, 'gnu_getopt'):
|
||||
getopt.gnu_getopt = getopt.getopt
|
||||
|
||||
XM_CONFIG_FILE_ENVVAR = 'XM_CONFIG_FILE'
|
||||
XM_CONFIG_FILE_DEFAULT = '/etc/xen/xm-config.xml'
|
||||
XM_CONFIG_FILE_DEFAULT = auxbin.xen_configdir + '/xm-config.xml'
|
||||
|
||||
# Supported types of server
|
||||
SERVER_LEGACY_XMLRPC = 'LegacyXMLRPC'
|
||||
|
||||
@@ -22,7 +22,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import xen.util.xsm.xsm as security
|
||||
from xen.util import xsconstants
|
||||
from xen.util import xsconstants, auxbin
|
||||
from xen.util.acmpolicy import ACM_LABEL_UNLABELED
|
||||
from xen.xm.opts import OptionError
|
||||
from xen.xm import main as xm_main
|
||||
@@ -81,7 +81,7 @@ def rm_domain_label(configfile):
|
||||
fil = configfile
|
||||
fd = open(fil, "rb")
|
||||
else:
|
||||
for prefix in [".", "/etc/xen"]:
|
||||
for prefix in [".", auxbin.xen_configdir() ]:
|
||||
fil = prefix + "/" + configfile
|
||||
if os.path.isfile(fil):
|
||||
fd = open(fil, "rb")
|
||||
|
||||
@@ -8,6 +8,7 @@ import xen.xend.XendOptions
|
||||
xen.xend.XendOptions.XendOptions.config_default = '/dev/null'
|
||||
|
||||
import xen.xm.create
|
||||
from xen.util import auxbin
|
||||
|
||||
|
||||
class test_create(unittest.TestCase):
|
||||
@@ -48,7 +49,7 @@ class test_create(unittest.TestCase):
|
||||
'boot' : 'c',
|
||||
'dhcp' : 'off',
|
||||
'interface' : 'eth0',
|
||||
'path' : '.:/etc/xen',
|
||||
'path' : '.:' + auxbin.xen_configdir(),
|
||||
'builder' : 'linux',
|
||||
'nics' : -1,
|
||||
'vncunused' : 1,
|
||||
@@ -99,7 +100,7 @@ on_crash = 'destroy'
|
||||
'boot' : 'c',
|
||||
'dhcp' : 'off',
|
||||
'interface' : 'eth0',
|
||||
'path' : '.:/etc/xen',
|
||||
'path' : '.:' + auxbin.xen_configdir(),
|
||||
'builder' : 'linux',
|
||||
|
||||
'vncunused' : 1,
|
||||
@@ -138,7 +139,7 @@ cpu_weight = 0.75
|
||||
'boot' : 'c',
|
||||
'dhcp' : 'off',
|
||||
'interface' : 'eth0',
|
||||
'path' : '.:/etc/xen',
|
||||
'path' : '.:' + auxbin.xen_configdir(),
|
||||
'builder' : 'linux',
|
||||
'nics' : -1,
|
||||
|
||||
@@ -195,7 +196,7 @@ ne2000=0
|
||||
'boot' : 'c',
|
||||
'dhcp' : 'off',
|
||||
'interface' : 'eth0',
|
||||
'path' : '.:/etc/xen',
|
||||
'path' : '.:' + auxbin.xen_configdir(),
|
||||
|
||||
'xauthority' : xen.xm.create.get_xauthority(),
|
||||
})
|
||||
|
||||