ia64/xen-unstable

changeset 1996:7987ae627d4e

bitkeeper revision 1.1108.35.7 (410a0b93obztTzgYAKS6IcEBh3xJcQ)

Use environment variables XEND and XEND_ROOT to set the location
of the xend server and its root path.
author mjw@wray-m-3.hpl.hp.com
date Fri Jul 30 08:49:23 2004 +0000 (2004-07-30)
parents d004111c84fe
children 3eab8d7061ba 0fe3e389d7e0
files tools/python/xen/xend/XendClient.py
line diff
     1.1 --- a/tools/python/xen/xend/XendClient.py	Thu Jul 29 15:54:01 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendClient.py	Fri Jul 30 08:49:23 2004 +0000
     1.3 @@ -9,6 +9,7 @@ The 'data-plane' is done separately. For
     1.4  are accessed via sockets on xend, but the list of consoles
     1.5  is accessible via this API.
     1.6  """
     1.7 +import os
     1.8  import sys
     1.9  import httplib
    1.10  import types
    1.11 @@ -331,9 +332,15 @@ class Xend:
    1.12      """Default location of the xend server."""
    1.13      SRV_DEFAULT = "localhost:8000"
    1.14  
    1.15 +    """Environment variable to set the location of xend."""
    1.16 +    SRV_VAR = "XEND"
    1.17 +
    1.18      """Default path to the xend root on the server."""
    1.19      ROOT_DEFAULT = "/xend/"
    1.20  
    1.21 +    """Environment variable to set the xend root path."""
    1.22 +    ROOT_VAR = "XEND_ROOT"
    1.23 +
    1.24      def __init__(self, client=None, srv=None, root=None):
    1.25          """Create a xend client interface.
    1.26          If the client protocol is not specified, the default
    1.27 @@ -348,14 +355,24 @@ class Xend:
    1.28          self.client = client
    1.29          self.bind(srv, root)
    1.30  
    1.31 +    def default_server(self):
    1.32 +        """Get the default location of the xend server.
    1.33 +        """
    1.34 +        return os.getenv(self.SRV_VAR, self.SRV_DEFAULT)
    1.35 +
    1.36 +    def default_root(self):
    1.37 +        """Get the default root path on the xend server.
    1.38 +        """
    1.39 +        return os.getenv(self.ROOT_VAR, self.ROOT_DEFAULT)
    1.40 +
    1.41      def bind(self, srv=None, root=None):
    1.42          """Bind to a given server.
    1.43  
    1.44          @param srv:  server location (host:port)
    1.45          @param root: xend root path on the server
    1.46          """
    1.47 -        if srv is None: srv = self.SRV_DEFAULT
    1.48 -        if root is None: root = self.ROOT_DEFAULT
    1.49 +        if srv is None: srv = self.default_server()
    1.50 +        if root is None: root = self.default_root()
    1.51          if not root.endswith('/'): root += '/'
    1.52          (host, port) = srv.split(':', 1)
    1.53          self.url = URL(host=host, port=port, path=root)