ia64/xen-unstable

changeset 13484:a18ae238eb53

Rename XendRoot to XendOptions.

Signed-off-by: John Levon <john.levon@sun.com>
author Ewan Mellor <ewan@xensource.com>
date Thu Jan 18 15:03:06 2007 +0000 (2007-01-18)
parents fd0f2b4b7071
children 074170d7284c
files tools/python/xen/xend/Vifctl.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/XendNode.py tools/python/xen/xend/XendOptions.py tools/python/xen/xend/XendProtocol.py tools/python/xen/xend/XendRoot.py tools/python/xen/xend/balloon.py tools/python/xen/xend/image.py tools/python/xen/xend/server/DevController.py tools/python/xen/xend/server/SrvRoot.py tools/python/xen/xend/server/SrvServer.py tools/python/xen/xend/server/netif.py tools/python/xen/xend/server/relocate.py tools/python/xen/xend/server/tests/test_controllers.py tools/python/xen/xend/server/tpmif.py tools/python/xen/xend/server/vfbif.py tools/python/xen/xm/tests/test_create.py
line diff
     1.1 --- a/tools/python/xen/xend/Vifctl.py	Thu Jan 18 15:04:59 2007 +0000
     1.2 +++ b/tools/python/xen/xend/Vifctl.py	Thu Jan 18 15:03:06 2007 +0000
     1.3 @@ -20,7 +20,7 @@
     1.4  """
     1.5  import os
     1.6  
     1.7 -import XendRoot
     1.8 +import XendOptions
     1.9  
    1.10  
    1.11  def network(op):
    1.12 @@ -30,7 +30,7 @@ def network(op):
    1.13      """
    1.14      if op not in ['start', 'stop']:
    1.15          raise ValueError('Invalid operation: ' + op)
    1.16 -    script = XendRoot.instance().get_network_script()
    1.17 +    script = XendOptions.instance().get_network_script()
    1.18      if script:
    1.19          script.insert(1, op)
    1.20          os.spawnv(os.P_WAIT, script[0], script)
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Jan 18 15:04:59 2007 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Jan 18 15:03:06 2007 +0000
     2.3 @@ -32,7 +32,7 @@ import threading
     2.4  import xen.lowlevel.xc
     2.5  
     2.6  
     2.7 -from xen.xend import XendRoot, XendCheckpoint, XendDomainInfo
     2.8 +from xen.xend import XendOptions, XendCheckpoint, XendDomainInfo
     2.9  from xen.xend.PrettyPrint import prettyprint
    2.10  from xen.xend.XendConfig import XendConfig
    2.11  from xen.xend.XendError import XendError, XendInvalidDomain, VmError
    2.12 @@ -51,7 +51,7 @@ from xen.util import mkdir, security
    2.13  from xen.xend import uuid
    2.14  
    2.15  xc = xen.lowlevel.xc.xc()
    2.16 -xroot = XendRoot.instance() 
    2.17 +xoptions = XendOptions.instance() 
    2.18  
    2.19  __all__ = [ "XendDomain" ]
    2.20  
    2.21 @@ -214,7 +214,7 @@ class XendDomain:
    2.22          @rtype: String
    2.23          @return: Path.
    2.24          """
    2.25 -        dom_path = xroot.get_xend_domains_path()
    2.26 +        dom_path = xoptions.get_xend_domains_path()
    2.27          if domuuid:
    2.28              dom_path = os.path.join(dom_path, domuuid)
    2.29          return dom_path
    2.30 @@ -361,7 +361,7 @@ class XendDomain:
    2.31  
    2.32      def _setDom0CPUCount(self):
    2.33          """Sets the number of VCPUs dom0 has. Retreived from the
    2.34 -        Xend configuration, L{XendRoot}.
    2.35 +        Xend configuration, L{XendOptions}.
    2.36  
    2.37          @requires: Expects to be protected by domains_lock.
    2.38          @rtype: None
    2.39 @@ -369,7 +369,7 @@ class XendDomain:
    2.40          dom0 = self.privilegedDomain()
    2.41  
    2.42          # get max number of vcpus to use for dom0 from config
    2.43 -        target = int(xroot.get_dom0_vcpus())
    2.44 +        target = int(xoptions.get_dom0_vcpus())
    2.45          log.debug("number of vcpus to use is %d", target)
    2.46     
    2.47          # target == 0 means use all processors
    2.48 @@ -1164,7 +1164,7 @@ class XendDomain:
    2.49              dominfo.checkLiveMigrateMemory()
    2.50  
    2.51          if port == 0:
    2.52 -            port = xroot.get_xend_relocation_port()
    2.53 +            port = xoptions.get_xend_relocation_port()
    2.54          try:
    2.55              sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    2.56              sock.connect((dst, port))
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Jan 18 15:04:59 2007 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Jan 18 15:03:06 2007 +0000
     3.3 @@ -38,7 +38,7 @@ from xen.util.blkif import blkdev_uname_
     3.4  from xen.util import security
     3.5  
     3.6  from xen.xend import balloon, sxp, uuid, image, arch, osdep
     3.7 -from xen.xend import XendRoot, XendNode, XendConfig
     3.8 +from xen.xend import XendOptions, XendNode, XendConfig
     3.9  
    3.10  from xen.xend.XendConfig import scrub_password
    3.11  from xen.xend.XendBootloader import bootloader
    3.12 @@ -54,7 +54,7 @@ MIGRATE_TIMEOUT = 30.0
    3.13  BOOTLOADER_LOOPBACK_DEVICE = '/dev/xvdp'
    3.14  
    3.15  xc = xen.lowlevel.xc.xc()
    3.16 -xroot = XendRoot.instance()
    3.17 +xoptions = XendOptions.instance()
    3.18  
    3.19  log = logging.getLogger("xend.XendDomainInfo")
    3.20  #log.setLevel(logging.TRACE)
    3.21 @@ -739,7 +739,7 @@ class XendDomainInfo:
    3.22              'domid':              str(self.domid),
    3.23              'vm':                 self.vmpath,
    3.24              'name':               self.info['name_label'],
    3.25 -            'console/limit':      str(xroot.get_console_limit() * 1024),
    3.26 +            'console/limit':      str(xoptions.get_console_limit() * 1024),
    3.27              'memory/target':      str(self.info['memory_static_min'] * 1024)
    3.28              }
    3.29  
    3.30 @@ -976,7 +976,7 @@ class XendDomainInfo:
    3.31                           self.info['name_label'], self.domid)
    3.32                  self._writeVm(LAST_SHUTDOWN_REASON, 'crash')
    3.33  
    3.34 -                if xroot.get_enable_dump():
    3.35 +                if xoptions.get_enable_dump():
    3.36                      try:
    3.37                          self.dumpCore()
    3.38                      except XendError:
     4.1 --- a/tools/python/xen/xend/XendNode.py	Thu Jan 18 15:04:59 2007 +0000
     4.2 +++ b/tools/python/xen/xend/XendNode.py	Thu Jan 18 15:03:06 2007 +0000
     4.3 @@ -24,7 +24,7 @@ from xen.util import Brctl
     4.4  
     4.5  from xen.xend import uuid
     4.6  from xen.xend.XendError import XendError, NetworkAlreadyConnected
     4.7 -from xen.xend.XendRoot import instance as xendroot
     4.8 +from xen.xend.XendOptions import instance as xendoptions
     4.9  from xen.xend.XendStorageRepository import XendStorageRepository
    4.10  from xen.xend.XendLogging import log
    4.11  from xen.xend.XendPIF import *
    4.12 @@ -45,7 +45,7 @@ class XendNode:
    4.13          """
    4.14          
    4.15          self.xc = xen.lowlevel.xc.xc()
    4.16 -        self.state_store = XendStateStore(xendroot().get_xend_state_path())
    4.17 +        self.state_store = XendStateStore(xendoptions().get_xend_state_path())
    4.18  
    4.19          # load host state from XML file
    4.20          saved_host = self.state_store.load_state('host')
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/python/xen/xend/XendOptions.py	Thu Jan 18 15:03:06 2007 +0000
     5.3 @@ -0,0 +1,322 @@
     5.4 +#============================================================================
     5.5 +# This library is free software; you can redistribute it and/or
     5.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
     5.7 +# License as published by the Free Software Foundation.
     5.8 +#
     5.9 +# This library is distributed in the hope that it will be useful,
    5.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.12 +# Lesser General Public License for more details.
    5.13 +#
    5.14 +# You should have received a copy of the GNU Lesser General Public
    5.15 +# License along with this library; if not, write to the Free Software
    5.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.17 +#============================================================================
    5.18 +# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
    5.19 +# Copyright (C) 2005 XenSource Ltd
    5.20 +#============================================================================
    5.21 +
    5.22 +"""Xend root class.
    5.23 +Creates the servers and handles configuration.
    5.24 +
    5.25 +Other classes get config variables by importing this module,
    5.26 +using instance() to get a XendRoot instance, and then
    5.27 +the config functions (e.g. get_xend_port()) to get
    5.28 +configured values.
    5.29 +"""
    5.30 +
    5.31 +import os
    5.32 +import os.path
    5.33 +import string
    5.34 +import sys
    5.35 +
    5.36 +from xen.xend import sxp, osdep, XendLogging
    5.37 +from xen.xend.XendError import XendError
    5.38 +
    5.39 +class XendRoot:
    5.40 +    """Root of the management classes."""
    5.41 +
    5.42 +    """Default path to the config file."""
    5.43 +    config_default = "/etc/xen/xend-config.sxp"
    5.44 +
    5.45 +    """Environment variable used to override config_default."""
    5.46 +    config_var     = "XEND_CONFIG"
    5.47 +
    5.48 +    """Where network control scripts live."""
    5.49 +    network_script_dir = osdep.scripts_dir
    5.50 +
    5.51 +    """Where block control scripts live."""
    5.52 +    block_script_dir = osdep.scripts_dir
    5.53 +
    5.54 +    """Default path to the log file. """
    5.55 +    logfile_default = "/var/log/xen/xend.log"
    5.56 +
    5.57 +    """Default level of information to be logged."""
    5.58 +    loglevel_default = 'DEBUG'
    5.59 +
    5.60 +    """Default Xen-API server configuration. """
    5.61 +    xen_api_server_default = [['unix']]
    5.62 +
    5.63 +    """Default for the flag indicating whether xend should run an http server
    5.64 +    (deprecated)."""
    5.65 +    xend_http_server_default = 'no'
    5.66 +
    5.67 +    xend_tcp_xmlrpc_server_default = 'no'
    5.68 +
    5.69 +    xend_unix_xmlrpc_server_default = 'yes'
    5.70 +
    5.71 +    """Default interface address xend listens at. """
    5.72 +    xend_address_default      = ''
    5.73 +
    5.74 +    """Default for the flag indicating whether xend should run a relocation server."""
    5.75 +    xend_relocation_server_default = 'no'
    5.76 +
    5.77 +    """Default interface address the xend relocation server listens at. """
    5.78 +    xend_relocation_address_default = ''
    5.79 +
    5.80 +    """Default port xend serves HTTP at. """
    5.81 +    xend_port_default         = '8000'
    5.82 +
    5.83 +    """Default port xend serves relocation at. """
    5.84 +    xend_relocation_port_default = '8002'
    5.85 +
    5.86 +    xend_relocation_hosts_allow_default = ''
    5.87 +
    5.88 +    """Default for the flag indicating whether xend should run a unix-domain
    5.89 +    server (deprecated)."""
    5.90 +    xend_unix_server_default = 'no'
    5.91 +
    5.92 +    """Default external migration tool """
    5.93 +    external_migration_tool_default = ''
    5.94 +
    5.95 +    """Default path the unix-domain server listens at."""
    5.96 +    xend_unix_path_default = '/var/lib/xend/xend-socket'
    5.97 +
    5.98 +    dom0_min_mem_default = '0'
    5.99 +
   5.100 +    dom0_vcpus_default = '0'
   5.101 +
   5.102 +    vncpasswd_default = None
   5.103 +
   5.104 +    """Default interface to listen for VNC connections on"""
   5.105 +    xend_vnc_listen_default = '127.0.0.1'
   5.106 +
   5.107 +    """Default session storage path."""
   5.108 +    xend_domains_path_default = '/var/lib/xend/domains'
   5.109 +
   5.110 +    """Default xend management state storage."""
   5.111 +    xend_state_path_default = '/var/lib/xend/state'
   5.112 +
   5.113 +    components = {}
   5.114 +
   5.115 +    def __init__(self):
   5.116 +        self.config_path = None
   5.117 +        self.config = None
   5.118 +        self.configure()
   5.119 +
   5.120 +
   5.121 +    def _logError(self, fmt, *args):
   5.122 +        """Logging function to log to stderr. We use this for XendRoot log
   5.123 +        messages because they may be logged before the logger has been
   5.124 +        configured.  Other components can safely use the logger.
   5.125 +        """
   5.126 +        print >>sys.stderr, "xend [ERROR]", fmt % args
   5.127 +
   5.128 +
   5.129 +    def configure(self):
   5.130 +        self.set_config()
   5.131 +        XendLogging.init(self.get_config_value("logfile",
   5.132 +                                               self.logfile_default),
   5.133 +                         self.get_config_value("loglevel",
   5.134 +                                               self.loglevel_default))
   5.135 +
   5.136 +
   5.137 +    def set_config(self):
   5.138 +        """If the config file exists, read it. If not, ignore it.
   5.139 +
   5.140 +        The config file is a sequence of sxp forms.
   5.141 +        """
   5.142 +        self.config_path = os.getenv(self.config_var, self.config_default)
   5.143 +        if os.path.exists(self.config_path):
   5.144 +            try:
   5.145 +                fin = file(self.config_path, 'rb')
   5.146 +                try:
   5.147 +                    config = sxp.parse(fin)
   5.148 +                finally:
   5.149 +                    fin.close()
   5.150 +                if config is None:
   5.151 +                    config = ['xend-config']
   5.152 +                else:
   5.153 +                    config.insert(0, 'xend-config')
   5.154 +                self.config = config
   5.155 +            except Exception, ex:
   5.156 +                self._logError('Reading config file %s: %s',
   5.157 +                               self.config_path, str(ex))
   5.158 +                raise
   5.159 +        else:
   5.160 +            self._logError('Config file does not exist: %s',
   5.161 +                           self.config_path)
   5.162 +            self.config = ['xend-config']
   5.163 +
   5.164 +    def get_config(self, name=None):
   5.165 +        """Get the configuration element with the given name, or
   5.166 +        the whole configuration if no name is given.
   5.167 +
   5.168 +        @param name: element name (optional)
   5.169 +        @return: config or none
   5.170 +        """
   5.171 +        if name is None:
   5.172 +            val = self.config
   5.173 +        else:
   5.174 +            val = sxp.child(self.config, name)
   5.175 +        return val
   5.176 +
   5.177 +    def get_config_value(self, name, val=None):
   5.178 +        """Get the value of an atomic configuration element.
   5.179 +
   5.180 +        @param name: element name
   5.181 +        @param val:  default value (optional, defaults to None)
   5.182 +        @return: value
   5.183 +        """
   5.184 +        return sxp.child_value(self.config, name, val=val)
   5.185 +
   5.186 +    def get_config_bool(self, name, val=None):
   5.187 +        v = string.lower(str(self.get_config_value(name, val)))
   5.188 +        if v in ['yes', 'y', '1', 'on',  'true',  't']:
   5.189 +            return True
   5.190 +        if v in ['no',  'n', '0', 'off', 'false', 'f']:
   5.191 +            return False
   5.192 +        raise XendError("invalid xend config %s: expected bool: %s" % (name, v))
   5.193 +
   5.194 +    def get_config_int(self, name, val=None):
   5.195 +        v = self.get_config_value(name, val)
   5.196 +        try:
   5.197 +            return int(v)
   5.198 +        except Exception:
   5.199 +            raise XendError("invalid xend config %s: expected int: %s" % (name, v))
   5.200 +
   5.201 +    def get_xen_api_server(self):
   5.202 +        """Get the Xen-API server configuration.
   5.203 +        """
   5.204 +        return self.get_config_value('xen-api-server',
   5.205 +                                     self.xen_api_server_default)
   5.206 +
   5.207 +    def get_xend_http_server(self):
   5.208 +        """Get the flag indicating whether xend should run an http server.
   5.209 +        """
   5.210 +        return self.get_config_bool("xend-http-server", self.xend_http_server_default)
   5.211 +
   5.212 +    def get_xend_tcp_xmlrpc_server(self):
   5.213 +        return self.get_config_bool("xend-tcp-xmlrpc-server",
   5.214 +                                    self.xend_tcp_xmlrpc_server_default)
   5.215 +
   5.216 +    def get_xend_unix_xmlrpc_server(self):
   5.217 +        return self.get_config_bool("xend-unix-xmlrpc-server",
   5.218 +                                    self.xend_unix_xmlrpc_server_default)
   5.219 +
   5.220 +    def get_xend_relocation_server(self):
   5.221 +        """Get the flag indicating whether xend should run a relocation server.
   5.222 +        """
   5.223 +        return self.get_config_bool("xend-relocation-server",
   5.224 +                                    self.xend_relocation_server_default)
   5.225 +
   5.226 +    def get_xend_port(self):
   5.227 +        """Get the port xend listens at for its HTTP interface.
   5.228 +        """
   5.229 +        return self.get_config_int('xend-port', self.xend_port_default)
   5.230 +
   5.231 +    def get_xend_relocation_port(self):
   5.232 +        """Get the port xend listens at for connection to its relocation server.
   5.233 +        """
   5.234 +        return self.get_config_int('xend-relocation-port',
   5.235 +                                   self.xend_relocation_port_default)
   5.236 +
   5.237 +    def get_xend_relocation_hosts_allow(self):
   5.238 +        return self.get_config_value("xend-relocation-hosts-allow",
   5.239 +                                     self.xend_relocation_hosts_allow_default)
   5.240 +
   5.241 +    def get_xend_address(self):
   5.242 +        """Get the address xend listens at for its HTTP port.
   5.243 +        This defaults to the empty string which allows all hosts to connect.
   5.244 +        If this is set to 'localhost' only the localhost will be able to connect
   5.245 +        to the HTTP port.
   5.246 +        """
   5.247 +        return self.get_config_value('xend-address', self.xend_address_default)
   5.248 +
   5.249 +    def get_xend_relocation_address(self):
   5.250 +        """Get the address xend listens at for its relocation server port.
   5.251 +        This defaults to the empty string which allows all hosts to connect.
   5.252 +        If this is set to 'localhost' only the localhost will be able to connect
   5.253 +        to the relocation port.
   5.254 +        """
   5.255 +        return self.get_config_value('xend-relocation-address', self.xend_relocation_address_default)
   5.256 +
   5.257 +    def get_xend_unix_server(self):
   5.258 +        """Get the flag indicating whether xend should run a unix-domain server.
   5.259 +        """
   5.260 +        return self.get_config_bool("xend-unix-server", self.xend_unix_server_default)
   5.261 +
   5.262 +    def get_xend_unix_path(self):
   5.263 +        """Get the path the xend unix-domain server listens at.
   5.264 +        """
   5.265 +        return self.get_config_value("xend-unix-path", self.xend_unix_path_default)
   5.266 +
   5.267 +    def get_xend_domains_path(self):
   5.268 +        """ Get the path for persistent domain configuration storage
   5.269 +        """
   5.270 +        return self.get_config_value("xend-domains-path", self.xend_domains_path_default)
   5.271 +
   5.272 +    def get_xend_state_path(self):
   5.273 +        """ Get the path for persistent domain configuration storage
   5.274 +        """
   5.275 +        return self.get_config_value("xend-state-path", self.xend_state_path_default)    
   5.276 +
   5.277 +    def get_network_script(self):
   5.278 +        """@return the script used to alter the network configuration when
   5.279 +        Xend starts and stops, or None if no such script is specified."""
   5.280 +        
   5.281 +        s = self.get_config_value('network-script')
   5.282 +
   5.283 +        if s:
   5.284 +            result = s.split(" ")
   5.285 +            result[0] = os.path.join(self.network_script_dir, result[0])
   5.286 +            return result
   5.287 +        else:
   5.288 +            return None
   5.289 +
   5.290 +    def get_external_migration_tool(self):
   5.291 +        """@return the name of the tool to handle virtual TPM migration."""
   5.292 +        return self.get_config_value('external-migration-tool', self.external_migration_tool_default)
   5.293 +
   5.294 +    def get_enable_dump(self):
   5.295 +        return self.get_config_bool('enable-dump', 'no')
   5.296 +
   5.297 +    def get_vif_script(self):
   5.298 +        return self.get_config_value('vif-script', 'vif-bridge')
   5.299 +
   5.300 +    def get_dom0_min_mem(self):
   5.301 +        return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default)
   5.302 +
   5.303 +    def get_dom0_vcpus(self):
   5.304 +        return self.get_config_int('dom0-cpus', self.dom0_vcpus_default)
   5.305 +
   5.306 +    def get_console_limit(self):
   5.307 +        return self.get_config_int('console-limit', 1024)
   5.308 +
   5.309 +    def get_vnclisten_address(self):
   5.310 +        return self.get_config_value('vnc-listen', self.xend_vnc_listen_default)
   5.311 +
   5.312 +    def get_vncpasswd_default(self):
   5.313 +        return self.get_config_value('vncpasswd',
   5.314 +                                     self.vncpasswd_default)
   5.315 +
   5.316 +def instance():
   5.317 +    """Get an instance of XendRoot.
   5.318 +    Use this instead of the constructor.
   5.319 +    """
   5.320 +    global inst
   5.321 +    try:
   5.322 +        inst
   5.323 +    except:
   5.324 +        inst = XendRoot()
   5.325 +    return inst
     6.1 --- a/tools/python/xen/xend/XendProtocol.py	Thu Jan 18 15:04:59 2007 +0000
     6.2 +++ b/tools/python/xen/xend/XendProtocol.py	Thu Jan 18 15:03:06 2007 +0000
     6.3 @@ -24,7 +24,7 @@ import types
     6.4  from encode import *
     6.5  from xen.xend import sxp
     6.6  
     6.7 -from xen.xend import XendRoot
     6.8 +from xen.xend import XendOptions
     6.9  
    6.10  DEBUG = 0
    6.11  
    6.12 @@ -34,7 +34,7 @@ HTTP_ACCEPTED                        = 2
    6.13  HTTP_NO_CONTENT                      = 204
    6.14  
    6.15  
    6.16 -xroot = XendRoot.instance()
    6.17 +xoptions = XendOptions.instance()
    6.18  
    6.19  
    6.20  class XendError(RuntimeError):
    6.21 @@ -218,7 +218,7 @@ class UnixXendClientProtocol(HttpXendCli
    6.22  
    6.23      def __init__(self, path=None):
    6.24          if path is None:
    6.25 -            path = xroot.get_xend_unix_path()
    6.26 +            path = xoptions.get_xend_unix_path()
    6.27          self.path = path
    6.28  
    6.29      def makeConnection(self, _):
     7.1 --- a/tools/python/xen/xend/XendRoot.py	Thu Jan 18 15:04:59 2007 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,322 +0,0 @@
     7.4 -#============================================================================
     7.5 -# This library is free software; you can redistribute it and/or
     7.6 -# modify it under the terms of version 2.1 of the GNU Lesser General Public
     7.7 -# License as published by the Free Software Foundation.
     7.8 -#
     7.9 -# This library is distributed in the hope that it will be useful,
    7.10 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.11 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.12 -# Lesser General Public License for more details.
    7.13 -#
    7.14 -# You should have received a copy of the GNU Lesser General Public
    7.15 -# License along with this library; if not, write to the Free Software
    7.16 -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    7.17 -#============================================================================
    7.18 -# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
    7.19 -# Copyright (C) 2005 XenSource Ltd
    7.20 -#============================================================================
    7.21 -
    7.22 -"""Xend root class.
    7.23 -Creates the servers and handles configuration.
    7.24 -
    7.25 -Other classes get config variables by importing this module,
    7.26 -using instance() to get a XendRoot instance, and then
    7.27 -the config functions (e.g. get_xend_port()) to get
    7.28 -configured values.
    7.29 -"""
    7.30 -
    7.31 -import os
    7.32 -import os.path
    7.33 -import string
    7.34 -import sys
    7.35 -
    7.36 -from xen.xend import sxp, osdep, XendLogging
    7.37 -from xen.xend.XendError import XendError
    7.38 -
    7.39 -class XendRoot:
    7.40 -    """Root of the management classes."""
    7.41 -
    7.42 -    """Default path to the config file."""
    7.43 -    config_default = "/etc/xen/xend-config.sxp"
    7.44 -
    7.45 -    """Environment variable used to override config_default."""
    7.46 -    config_var     = "XEND_CONFIG"
    7.47 -
    7.48 -    """Where network control scripts live."""
    7.49 -    network_script_dir = osdep.scripts_dir
    7.50 -
    7.51 -    """Where block control scripts live."""
    7.52 -    block_script_dir = osdep.scripts_dir
    7.53 -
    7.54 -    """Default path to the log file. """
    7.55 -    logfile_default = "/var/log/xen/xend.log"
    7.56 -
    7.57 -    """Default level of information to be logged."""
    7.58 -    loglevel_default = 'DEBUG'
    7.59 -
    7.60 -    """Default Xen-API server configuration. """
    7.61 -    xen_api_server_default = [['unix']]
    7.62 -
    7.63 -    """Default for the flag indicating whether xend should run an http server
    7.64 -    (deprecated)."""
    7.65 -    xend_http_server_default = 'no'
    7.66 -
    7.67 -    xend_tcp_xmlrpc_server_default = 'no'
    7.68 -
    7.69 -    xend_unix_xmlrpc_server_default = 'yes'
    7.70 -
    7.71 -    """Default interface address xend listens at. """
    7.72 -    xend_address_default      = ''
    7.73 -
    7.74 -    """Default for the flag indicating whether xend should run a relocation server."""
    7.75 -    xend_relocation_server_default = 'no'
    7.76 -
    7.77 -    """Default interface address the xend relocation server listens at. """
    7.78 -    xend_relocation_address_default = ''
    7.79 -
    7.80 -    """Default port xend serves HTTP at. """
    7.81 -    xend_port_default         = '8000'
    7.82 -
    7.83 -    """Default port xend serves relocation at. """
    7.84 -    xend_relocation_port_default = '8002'
    7.85 -
    7.86 -    xend_relocation_hosts_allow_default = ''
    7.87 -
    7.88 -    """Default for the flag indicating whether xend should run a unix-domain
    7.89 -    server (deprecated)."""
    7.90 -    xend_unix_server_default = 'no'
    7.91 -
    7.92 -    """Default external migration tool """
    7.93 -    external_migration_tool_default = ''
    7.94 -
    7.95 -    """Default path the unix-domain server listens at."""
    7.96 -    xend_unix_path_default = '/var/lib/xend/xend-socket'
    7.97 -
    7.98 -    dom0_min_mem_default = '0'
    7.99 -
   7.100 -    dom0_vcpus_default = '0'
   7.101 -
   7.102 -    vncpasswd_default = None
   7.103 -
   7.104 -    """Default interface to listen for VNC connections on"""
   7.105 -    xend_vnc_listen_default = '127.0.0.1'
   7.106 -
   7.107 -    """Default session storage path."""
   7.108 -    xend_domains_path_default = '/var/lib/xend/domains'
   7.109 -
   7.110 -    """Default xend management state storage."""
   7.111 -    xend_state_path_default = '/var/lib/xend/state'
   7.112 -
   7.113 -    components = {}
   7.114 -
   7.115 -    def __init__(self):
   7.116 -        self.config_path = None
   7.117 -        self.config = None
   7.118 -        self.configure()
   7.119 -
   7.120 -
   7.121 -    def _logError(self, fmt, *args):
   7.122 -        """Logging function to log to stderr. We use this for XendRoot log
   7.123 -        messages because they may be logged before the logger has been
   7.124 -        configured.  Other components can safely use the logger.
   7.125 -        """
   7.126 -        print >>sys.stderr, "xend [ERROR]", fmt % args
   7.127 -
   7.128 -
   7.129 -    def configure(self):
   7.130 -        self.set_config()
   7.131 -        XendLogging.init(self.get_config_value("logfile",
   7.132 -                                               self.logfile_default),
   7.133 -                         self.get_config_value("loglevel",
   7.134 -                                               self.loglevel_default))
   7.135 -
   7.136 -
   7.137 -    def set_config(self):
   7.138 -        """If the config file exists, read it. If not, ignore it.
   7.139 -
   7.140 -        The config file is a sequence of sxp forms.
   7.141 -        """
   7.142 -        self.config_path = os.getenv(self.config_var, self.config_default)
   7.143 -        if os.path.exists(self.config_path):
   7.144 -            try:
   7.145 -                fin = file(self.config_path, 'rb')
   7.146 -                try:
   7.147 -                    config = sxp.parse(fin)
   7.148 -                finally:
   7.149 -                    fin.close()
   7.150 -                if config is None:
   7.151 -                    config = ['xend-config']
   7.152 -                else:
   7.153 -                    config.insert(0, 'xend-config')
   7.154 -                self.config = config
   7.155 -            except Exception, ex:
   7.156 -                self._logError('Reading config file %s: %s',
   7.157 -                               self.config_path, str(ex))
   7.158 -                raise
   7.159 -        else:
   7.160 -            self._logError('Config file does not exist: %s',
   7.161 -                           self.config_path)
   7.162 -            self.config = ['xend-config']
   7.163 -
   7.164 -    def get_config(self, name=None):
   7.165 -        """Get the configuration element with the given name, or
   7.166 -        the whole configuration if no name is given.
   7.167 -
   7.168 -        @param name: element name (optional)
   7.169 -        @return: config or none
   7.170 -        """
   7.171 -        if name is None:
   7.172 -            val = self.config
   7.173 -        else:
   7.174 -            val = sxp.child(self.config, name)
   7.175 -        return val
   7.176 -
   7.177 -    def get_config_value(self, name, val=None):
   7.178 -        """Get the value of an atomic configuration element.
   7.179 -
   7.180 -        @param name: element name
   7.181 -        @param val:  default value (optional, defaults to None)
   7.182 -        @return: value
   7.183 -        """
   7.184 -        return sxp.child_value(self.config, name, val=val)
   7.185 -
   7.186 -    def get_config_bool(self, name, val=None):
   7.187 -        v = string.lower(str(self.get_config_value(name, val)))
   7.188 -        if v in ['yes', 'y', '1', 'on',  'true',  't']:
   7.189 -            return True
   7.190 -        if v in ['no',  'n', '0', 'off', 'false', 'f']:
   7.191 -            return False
   7.192 -        raise XendError("invalid xend config %s: expected bool: %s" % (name, v))
   7.193 -
   7.194 -    def get_config_int(self, name, val=None):
   7.195 -        v = self.get_config_value(name, val)
   7.196 -        try:
   7.197 -            return int(v)
   7.198 -        except Exception:
   7.199 -            raise XendError("invalid xend config %s: expected int: %s" % (name, v))
   7.200 -
   7.201 -    def get_xen_api_server(self):
   7.202 -        """Get the Xen-API server configuration.
   7.203 -        """
   7.204 -        return self.get_config_value('xen-api-server',
   7.205 -                                     self.xen_api_server_default)
   7.206 -
   7.207 -    def get_xend_http_server(self):
   7.208 -        """Get the flag indicating whether xend should run an http server.
   7.209 -        """
   7.210 -        return self.get_config_bool("xend-http-server", self.xend_http_server_default)
   7.211 -
   7.212 -    def get_xend_tcp_xmlrpc_server(self):
   7.213 -        return self.get_config_bool("xend-tcp-xmlrpc-server",
   7.214 -                                    self.xend_tcp_xmlrpc_server_default)
   7.215 -
   7.216 -    def get_xend_unix_xmlrpc_server(self):
   7.217 -        return self.get_config_bool("xend-unix-xmlrpc-server",
   7.218 -                                    self.xend_unix_xmlrpc_server_default)
   7.219 -
   7.220 -    def get_xend_relocation_server(self):
   7.221 -        """Get the flag indicating whether xend should run a relocation server.
   7.222 -        """
   7.223 -        return self.get_config_bool("xend-relocation-server",
   7.224 -                                    self.xend_relocation_server_default)
   7.225 -
   7.226 -    def get_xend_port(self):
   7.227 -        """Get the port xend listens at for its HTTP interface.
   7.228 -        """
   7.229 -        return self.get_config_int('xend-port', self.xend_port_default)
   7.230 -
   7.231 -    def get_xend_relocation_port(self):
   7.232 -        """Get the port xend listens at for connection to its relocation server.
   7.233 -        """
   7.234 -        return self.get_config_int('xend-relocation-port',
   7.235 -                                   self.xend_relocation_port_default)
   7.236 -
   7.237 -    def get_xend_relocation_hosts_allow(self):
   7.238 -        return self.get_config_value("xend-relocation-hosts-allow",
   7.239 -                                     self.xend_relocation_hosts_allow_default)
   7.240 -
   7.241 -    def get_xend_address(self):
   7.242 -        """Get the address xend listens at for its HTTP port.
   7.243 -        This defaults to the empty string which allows all hosts to connect.
   7.244 -        If this is set to 'localhost' only the localhost will be able to connect
   7.245 -        to the HTTP port.
   7.246 -        """
   7.247 -        return self.get_config_value('xend-address', self.xend_address_default)
   7.248 -
   7.249 -    def get_xend_relocation_address(self):
   7.250 -        """Get the address xend listens at for its relocation server port.
   7.251 -        This defaults to the empty string which allows all hosts to connect.
   7.252 -        If this is set to 'localhost' only the localhost will be able to connect
   7.253 -        to the relocation port.
   7.254 -        """
   7.255 -        return self.get_config_value('xend-relocation-address', self.xend_relocation_address_default)
   7.256 -
   7.257 -    def get_xend_unix_server(self):
   7.258 -        """Get the flag indicating whether xend should run a unix-domain server.
   7.259 -        """
   7.260 -        return self.get_config_bool("xend-unix-server", self.xend_unix_server_default)
   7.261 -
   7.262 -    def get_xend_unix_path(self):
   7.263 -        """Get the path the xend unix-domain server listens at.
   7.264 -        """
   7.265 -        return self.get_config_value("xend-unix-path", self.xend_unix_path_default)
   7.266 -
   7.267 -    def get_xend_domains_path(self):
   7.268 -        """ Get the path for persistent domain configuration storage
   7.269 -        """
   7.270 -        return self.get_config_value("xend-domains-path", self.xend_domains_path_default)
   7.271 -
   7.272 -    def get_xend_state_path(self):
   7.273 -        """ Get the path for persistent domain configuration storage
   7.274 -        """
   7.275 -        return self.get_config_value("xend-state-path", self.xend_state_path_default)    
   7.276 -
   7.277 -    def get_network_script(self):
   7.278 -        """@return the script used to alter the network configuration when
   7.279 -        Xend starts and stops, or None if no such script is specified."""
   7.280 -        
   7.281 -        s = self.get_config_value('network-script')
   7.282 -
   7.283 -        if s:
   7.284 -            result = s.split(" ")
   7.285 -            result[0] = os.path.join(self.network_script_dir, result[0])
   7.286 -            return result
   7.287 -        else:
   7.288 -            return None
   7.289 -
   7.290 -    def get_external_migration_tool(self):
   7.291 -        """@return the name of the tool to handle virtual TPM migration."""
   7.292 -        return self.get_config_value('external-migration-tool', self.external_migration_tool_default)
   7.293 -
   7.294 -    def get_enable_dump(self):
   7.295 -        return self.get_config_bool('enable-dump', 'no')
   7.296 -
   7.297 -    def get_vif_script(self):
   7.298 -        return self.get_config_value('vif-script', 'vif-bridge')
   7.299 -
   7.300 -    def get_dom0_min_mem(self):
   7.301 -        return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default)
   7.302 -
   7.303 -    def get_dom0_vcpus(self):
   7.304 -        return self.get_config_int('dom0-cpus', self.dom0_vcpus_default)
   7.305 -
   7.306 -    def get_console_limit(self):
   7.307 -        return self.get_config_int('console-limit', 1024)
   7.308 -
   7.309 -    def get_vnclisten_address(self):
   7.310 -        return self.get_config_value('vnc-listen', self.xend_vnc_listen_default)
   7.311 -
   7.312 -    def get_vncpasswd_default(self):
   7.313 -        return self.get_config_value('vncpasswd',
   7.314 -                                     self.vncpasswd_default)
   7.315 -
   7.316 -def instance():
   7.317 -    """Get an instance of XendRoot.
   7.318 -    Use this instead of the constructor.
   7.319 -    """
   7.320 -    global inst
   7.321 -    try:
   7.322 -        inst
   7.323 -    except:
   7.324 -        inst = XendRoot()
   7.325 -    return inst
     8.1 --- a/tools/python/xen/xend/balloon.py	Thu Jan 18 15:04:59 2007 +0000
     8.2 +++ b/tools/python/xen/xend/balloon.py	Thu Jan 18 15:03:06 2007 +0000
     8.3 @@ -22,7 +22,7 @@ import time
     8.4  import xen.lowlevel.xc
     8.5  
     8.6  import XendDomain
     8.7 -import XendRoot
     8.8 +import XendOptions
     8.9  from XendLogging import log
    8.10  from XendError import VmError
    8.11  
    8.12 @@ -107,11 +107,11 @@ def free(need_mem):
    8.13      # usage, so we recheck the required alloc each time around the loop, but
    8.14      # track the last used value so that we don't trigger too many watches.
    8.15  
    8.16 -    xroot = XendRoot.instance()
    8.17 +    xoptions = XendOptions.instance()
    8.18      xc = xen.lowlevel.xc.xc()
    8.19  
    8.20      try:
    8.21 -        dom0_min_mem = xroot.get_dom0_min_mem() * 1024
    8.22 +        dom0_min_mem = xoptions.get_dom0_min_mem() * 1024
    8.23  
    8.24          retries = 0
    8.25          sleep_time = SLEEP_TIME_GROWTH
     9.1 --- a/tools/python/xen/xend/image.py	Thu Jan 18 15:04:59 2007 +0000
     9.2 +++ b/tools/python/xen/xend/image.py	Thu Jan 18 15:03:06 2007 +0000
     9.3 @@ -461,14 +461,14 @@ class HVMImageHandler(ImageHandler):
     9.4              vnclisten = imageConfig.get('vnclisten')
     9.5  
     9.6              if not(vnclisten):
     9.7 -                vnclisten = (xen.xend.XendRoot.instance().
     9.8 +                vnclisten = (xen.xend.XendOptions.instance().
     9.9                               get_vnclisten_address())
    9.10              if vnclisten:
    9.11                  ret += ['-vnclisten', vnclisten]
    9.12  
    9.13              vncpasswd = vncpasswd_vmconfig
    9.14              if vncpasswd is None:
    9.15 -                vncpasswd = (xen.xend.XendRoot.instance().
    9.16 +                vncpasswd = (xen.xend.XendOptions.instance().
    9.17                               get_vncpasswd_default())
    9.18                  if vncpasswd is None:
    9.19                      raise VmError('vncpasswd is not set up in ' +
    10.1 --- a/tools/python/xen/xend/server/DevController.py	Thu Jan 18 15:04:59 2007 +0000
    10.2 +++ b/tools/python/xen/xend/server/DevController.py	Thu Jan 18 15:03:06 2007 +0000
    10.3 @@ -19,7 +19,7 @@
    10.4  from threading import Event
    10.5  import types
    10.6  
    10.7 -from xen.xend import sxp, XendRoot
    10.8 +from xen.xend import sxp, XendOptions
    10.9  from xen.xend.XendError import VmError
   10.10  from xen.xend.XendLogging import log
   10.11  
   10.12 @@ -50,7 +50,7 @@ xenbusState = {
   10.13      'Closed'       : 6,
   10.14      }
   10.15  
   10.16 -xroot = XendRoot.instance()
   10.17 +xoptions = XendOptions.instance()
   10.18  
   10.19  xenbusState.update(dict(zip(xenbusState.values(), xenbusState.keys())))
   10.20  
   10.21 @@ -324,7 +324,7 @@ class DevController:
   10.22                        Make sure that the migration has finished and only
   10.23                        then return from the call.
   10.24          """
   10.25 -        tool = xroot.get_external_migration_tool()
   10.26 +        tool = xoptions.get_external_migration_tool()
   10.27          if tool:
   10.28              log.info("Calling external migration tool for step %d" % step)
   10.29              fd = os.popen("%s -type %s -step %d -host %s -domname %s" %
   10.30 @@ -341,7 +341,7 @@ class DevController:
   10.31          """ Recover from device migration. The given step was the
   10.32              last one that was successfully executed.
   10.33          """
   10.34 -        tool = xroot.get_external_migration_tool()
   10.35 +        tool = xoptions.get_external_migration_tool()
   10.36          if tool:
   10.37              log.info("Calling external migration tool")
   10.38              fd = os.popen("%s -type %s -step %d -host %s -domname %s -recover" %
    11.1 --- a/tools/python/xen/xend/server/SrvRoot.py	Thu Jan 18 15:04:59 2007 +0000
    11.2 +++ b/tools/python/xen/xend/server/SrvRoot.py	Thu Jan 18 15:03:06 2007 +0000
    11.3 @@ -25,7 +25,7 @@ class SrvRoot(SrvDir):
    11.4      """Server sub-components. Each entry is (name, class), where
    11.5      'name' is the entry name and  'class' is the name of its class.
    11.6      """
    11.7 -    #todo Get this list from the XendRoot config.
    11.8 +    #todo Get this list from the XendOptions config.
    11.9      subdirs = [
   11.10          ('node',    'SrvNode'       ),
   11.11          ('domain',  'SrvDomainDir'  ),
    12.1 --- a/tools/python/xen/xend/server/SrvServer.py	Thu Jan 18 15:04:59 2007 +0000
    12.2 +++ b/tools/python/xen/xend/server/SrvServer.py	Thu Jan 18 15:03:06 2007 +0000
    12.3 @@ -48,7 +48,7 @@ from threading import Thread
    12.4  
    12.5  from xen.web.httpserver import HttpServer, UnixHttpServer
    12.6  
    12.7 -from xen.xend import XendNode, XendRoot, XendAPI
    12.8 +from xen.xend import XendNode, XendOptions, XendAPI
    12.9  from xen.xend import Vifctl
   12.10  from xen.xend.XendLogging import log
   12.11  from xen.xend.XendClient import XEN_API_SOCKET
   12.12 @@ -57,7 +57,7 @@ from xen.web.SrvDir import SrvDir
   12.13  from SrvRoot import SrvRoot
   12.14  from XMLRPCServer import XMLRPCServer
   12.15  
   12.16 -xroot = XendRoot.instance()
   12.17 +xoptions = XendOptions.instance()
   12.18  
   12.19  
   12.20  class XendServers:
   12.21 @@ -165,7 +165,7 @@ class XendServers:
   12.22                  log.info("Restarting all XML-RPC and Xen-API servers...")
   12.23                  self.cleaningUp = False
   12.24                  self.reloadingConfig = False
   12.25 -                xroot.set_config()
   12.26 +                xoptions.set_config()
   12.27                  new_servers = [x for x in self.servers
   12.28                                 if isinstance(x, HttpServer)]
   12.29                  self.servers = new_servers
   12.30 @@ -174,16 +174,16 @@ class XendServers:
   12.31                  break
   12.32  
   12.33  def _loadConfig(servers, root, reload):
   12.34 -    if not reload and xroot.get_xend_http_server():
   12.35 +    if not reload and xoptions.get_xend_http_server():
   12.36          servers.add(HttpServer(root,
   12.37 -                               xroot.get_xend_address(),
   12.38 -                               xroot.get_xend_port()))
   12.39 -    if not reload and xroot.get_xend_unix_server():
   12.40 -        path = xroot.get_xend_unix_path()
   12.41 +                               xoptions.get_xend_address(),
   12.42 +                               xoptions.get_xend_port()))
   12.43 +    if not reload and xoptions.get_xend_unix_server():
   12.44 +        path = xoptions.get_xend_unix_path()
   12.45          log.info('unix path=' + path)
   12.46          servers.add(UnixHttpServer(root, path))
   12.47  
   12.48 -    api_cfg = xroot.get_xen_api_server()
   12.49 +    api_cfg = xoptions.get_xen_api_server()
   12.50      if api_cfg:
   12.51          try:
   12.52              addrs = [(str(x[0]).split(':'),
   12.53 @@ -218,10 +218,10 @@ def _loadConfig(servers, root, reload):
   12.54          except TypeError, exn:
   12.55              log.error('Xen-API server configuration %s is invalid.', api_cfg)
   12.56  
   12.57 -    if xroot.get_xend_tcp_xmlrpc_server():
   12.58 +    if xoptions.get_xend_tcp_xmlrpc_server():
   12.59          servers.add(XMLRPCServer(XendAPI.AUTH_PAM, False, True))
   12.60  
   12.61 -    if xroot.get_xend_unix_xmlrpc_server():
   12.62 +    if xoptions.get_xend_unix_xmlrpc_server():
   12.63          servers.add(XMLRPCServer(XendAPI.AUTH_PAM, False))
   12.64  
   12.65  
    13.1 --- a/tools/python/xen/xend/server/netif.py	Thu Jan 18 15:04:59 2007 +0000
    13.2 +++ b/tools/python/xen/xend/server/netif.py	Thu Jan 18 15:03:06 2007 +0000
    13.3 @@ -24,10 +24,10 @@ import os
    13.4  import random
    13.5  import re
    13.6  
    13.7 -from xen.xend import XendRoot
    13.8 +from xen.xend import XendOptions
    13.9  from xen.xend.server.DevController import DevController
   13.10  
   13.11 -xroot = XendRoot.instance()
   13.12 +xoptions = XendOptions.instance()
   13.13  
   13.14  def randomMAC():
   13.15      """Generate a random MAC address.
   13.16 @@ -138,8 +138,8 @@ class NetifController(DevController):
   13.17      def getDeviceDetails(self, config):
   13.18          """@see DevController.getDeviceDetails"""
   13.19  
   13.20 -        script = os.path.join(xroot.network_script_dir,
   13.21 -                              config.get('script', xroot.get_vif_script()))
   13.22 +        script = os.path.join(xoptions.network_script_dir,
   13.23 +                              config.get('script', xoptions.get_vif_script()))
   13.24          typ     = config.get('type')
   13.25          bridge  = config.get('bridge')
   13.26          mac     = config.get('mac')
   13.27 @@ -190,7 +190,7 @@ class NetifController(DevController):
   13.28          (script, ip, bridge, mac, typ, vifname, rate, uuid) = devinfo
   13.29  
   13.30          if script:
   13.31 -            network_script_dir = xroot.network_script_dir + os.sep
   13.32 +            network_script_dir = xoptions.network_script_dir + os.sep
   13.33              result['script'] = script.replace(network_script_dir, "")
   13.34          if ip:
   13.35              result['ip'] = ip
    14.1 --- a/tools/python/xen/xend/server/relocate.py	Thu Jan 18 15:04:59 2007 +0000
    14.2 +++ b/tools/python/xen/xend/server/relocate.py	Thu Jan 18 15:03:06 2007 +0000
    14.3 @@ -24,7 +24,7 @@ from xen.web import protocol, tcp, unix
    14.4  
    14.5  from xen.xend import sxp
    14.6  from xen.xend import XendDomain
    14.7 -from xen.xend import XendRoot
    14.8 +from xen.xend import XendOptions
    14.9  from xen.xend.XendError import XendError
   14.10  from xen.xend.XendLogging import log
   14.11  
   14.12 @@ -114,15 +114,15 @@ class RelocationProtocol(protocol.Protoc
   14.13  
   14.14  
   14.15  def listenRelocation():
   14.16 -    xroot = XendRoot.instance()
   14.17 -    if xroot.get_xend_unix_server():
   14.18 +    xoptions = XendOptions.instance()
   14.19 +    if xoptions.get_xend_unix_server():
   14.20          path = '/var/lib/xend/relocation-socket'
   14.21          unix.UnixListener(path, RelocationProtocol)
   14.22 -    if xroot.get_xend_relocation_server():
   14.23 -        port = xroot.get_xend_relocation_port()
   14.24 -        interface = xroot.get_xend_relocation_address()
   14.25 +    if xoptions.get_xend_relocation_server():
   14.26 +        port = xoptions.get_xend_relocation_port()
   14.27 +        interface = xoptions.get_xend_relocation_address()
   14.28  
   14.29 -        hosts_allow = xroot.get_xend_relocation_hosts_allow()
   14.30 +        hosts_allow = xoptions.get_xend_relocation_hosts_allow()
   14.31          if hosts_allow == '':
   14.32              hosts_allow = None
   14.33          else:
    15.1 --- a/tools/python/xen/xend/server/tests/test_controllers.py	Thu Jan 18 15:04:59 2007 +0000
    15.2 +++ b/tools/python/xen/xend/server/tests/test_controllers.py	Thu Jan 18 15:03:06 2007 +0000
    15.3 @@ -2,9 +2,9 @@ import os
    15.4  import re
    15.5  import unittest
    15.6  
    15.7 -import xen.xend.XendRoot
    15.8 +import xen.xend.XendOptions
    15.9  
   15.10 -xen.xend.XendRoot.XendRoot.config_default = '/dev/null'
   15.11 +xen.xend.XendOptions.XendOptions.config_default = '/dev/null'
   15.12  
   15.13  from xen.xend.server import netif
   15.14  
   15.15 @@ -13,7 +13,7 @@ FAKE_DOMID = 42
   15.16  FAKE_DEVID = 63
   15.17  
   15.18  
   15.19 -xroot = xen.xend.XendRoot.instance()
   15.20 +xoptions = xen.xend.XendOptions.instance()
   15.21  
   15.22  
   15.23  class test_controllers(unittest.TestCase):
   15.24 @@ -36,8 +36,8 @@ class test_controllers(unittest.TestCase
   15.25  
   15.26          self.assertEqual(backdets['handle'], str(FAKE_DEVID))
   15.27          self.assertEqual(backdets['script'],
   15.28 -                         os.path.join(xroot.network_script_dir,
   15.29 -                                      xroot.get_vif_script()))
   15.30 +                         os.path.join(xoptions.network_script_dir,
   15.31 +                                      xoptions.get_vif_script()))
   15.32          self.assertValidMac(backdets['mac'], expectedMac)
   15.33  
   15.34          self.assertEqual(frontdets['handle'], str(FAKE_DEVID))
    16.1 --- a/tools/python/xen/xend/server/tpmif.py	Thu Jan 18 15:04:59 2007 +0000
    16.2 +++ b/tools/python/xen/xend/server/tpmif.py	Thu Jan 18 15:03:06 2007 +0000
    16.3 @@ -20,7 +20,7 @@
    16.4  
    16.5  """Support for virtual TPM interfaces."""
    16.6  
    16.7 -from xen.xend import XendRoot
    16.8 +from xen.xend import XendOptions
    16.9  from xen.xend.XendLogging import log
   16.10  from xen.xend.XendError import XendError
   16.11  from xen.xend.XendConstants import DEV_MIGRATE_TEST, VTPM_DELETE_SCRIPT
   16.12 @@ -29,7 +29,7 @@ from xen.xend.server.DevController impor
   16.13  import os
   16.14  import re
   16.15  
   16.16 -xroot = XendRoot.instance()
   16.17 +xoptions = XendOptions.instance()
   16.18  
   16.19  def destroy_vtpmstate(name):
   16.20      if os.path.exists(VTPM_DELETE_SCRIPT):
   16.21 @@ -88,7 +88,7 @@ class TPMifController(DevController):
   16.22      def migrate(self, deviceConfig, network, dst, step, domName):
   16.23          """@see DevContoller.migrate"""
   16.24          if network:
   16.25 -            tool = xroot.get_external_migration_tool()
   16.26 +            tool = xoptions.get_external_migration_tool()
   16.27              if tool != '':
   16.28                  log.info("Request to network-migrate device to %s. step=%d.",
   16.29                           dst, step)
   16.30 @@ -116,7 +116,7 @@ class TPMifController(DevController):
   16.31      def recover_migrate(self, deviceConfig, network, dst, step, domName):
   16.32          """@see DevContoller.recover_migrate"""
   16.33          if network:
   16.34 -            tool = xroot.get_external_migration_tool()
   16.35 +            tool = xoptions.get_external_migration_tool()
   16.36              if tool != '':
   16.37                  log.info("Request to recover network-migrated device. last good step=%d.",
   16.38                           step)
    17.1 --- a/tools/python/xen/xend/server/vfbif.py	Thu Jan 18 15:04:59 2007 +0000
    17.2 +++ b/tools/python/xen/xend/server/vfbif.py	Thu Jan 18 15:03:06 2007 +0000
    17.3 @@ -52,7 +52,7 @@ class VfbifController(DevController):
    17.4              if config.has_key("vncpasswd"):
    17.5                  passwd = config["vncpasswd"]
    17.6              else:
    17.7 -                passwd = xen.xend.XendRoot.instance().get_vncpasswd_default()
    17.8 +                passwd = xen.xend.XendOptions.instance().get_vncpasswd_default()
    17.9              if passwd:
   17.10                  self.vm.storeVm("vncpasswd", passwd)
   17.11                  log.debug("Stored a VNC password for vfb access")
   17.12 @@ -66,7 +66,7 @@ class VfbifController(DevController):
   17.13              elif config.has_key("vncdisplay"):
   17.14                  args += ["--vncport", "%d" % (5900 + int(config["vncdisplay"]))]
   17.15              vnclisten = config.get("vnclisten",
   17.16 -                                   xen.xend.XendRoot.instance().get_vnclisten_address())
   17.17 +                                   xen.xend.XendOptions.instance().get_vnclisten_address())
   17.18              args += [ "--listen", vnclisten ]
   17.19              spawn_detached(args[0], args + std_args, os.environ)
   17.20          elif t == "sdl":
    18.1 --- a/tools/python/xen/xm/tests/test_create.py	Thu Jan 18 15:04:59 2007 +0000
    18.2 +++ b/tools/python/xen/xm/tests/test_create.py	Thu Jan 18 15:03:06 2007 +0000
    18.3 @@ -3,9 +3,9 @@ import os.path
    18.4  import tempfile
    18.5  import unittest
    18.6  
    18.7 -import xen.xend.XendRoot
    18.8 +import xen.xend.XendOptions
    18.9  
   18.10 -xen.xend.XendRoot.XendRoot.config_default = '/dev/null'
   18.11 +xen.xend.XendOptions.XendOptions.config_default = '/dev/null'
   18.12  
   18.13  import xen.xm.create
   18.14