ia64/xen-unstable

changeset 7561:9f44b2aa98f3

Change the interface between XendRoot.get_network_script and Vifctl so that a
list is passed rather than a single string. This expands the config-file
interface so that parameters may be passed to the network scripts from the
config file.

Fix XendRoot._logError (missing asterisk before args parameter).

In XendRoot, allow an empty configuration file. This makes it easier to unit
test code reliant on XendRoot.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sun Oct 30 13:48:34 2005 +0100 (2005-10-30)
parents 03612b7f69d5
children dc36edf1102f
files tools/python/xen/xend/Vifctl.py tools/python/xen/xend/XendRoot.py
line diff
     1.1 --- a/tools/python/xen/xend/Vifctl.py	Sun Oct 30 13:45:06 2005 +0100
     1.2 +++ b/tools/python/xen/xend/Vifctl.py	Sun Oct 30 13:48:34 2005 +0100
     1.3 @@ -32,4 +32,5 @@ def network(op):
     1.4          raise ValueError('Invalid operation: ' + op)
     1.5      script = XendRoot.instance().get_network_script()
     1.6      if script:
     1.7 -        os.spawnl(os.P_WAIT, script, script, op)
     1.8 +        script.insert(1, op)
     1.9 +        os.spawnv(os.P_WAIT, script[0], script)
     2.1 --- a/tools/python/xen/xend/XendRoot.py	Sun Oct 30 13:45:06 2005 +0100
     2.2 +++ b/tools/python/xen/xend/XendRoot.py	Sun Oct 30 13:48:34 2005 +0100
     2.3 @@ -114,7 +114,7 @@ class XendRoot:
     2.4          """
     2.5          return self.components.get(name)
     2.6  
     2.7 -    def _logError(self, fmt, args):
     2.8 +    def _logError(self, fmt, *args):
     2.9          """Logging function to log to stderr. We use this for XendRoot log
    2.10          messages because they may be logged before the logger has been
    2.11          configured.  Other components can safely use the logger.
    2.12 @@ -144,7 +144,10 @@ class XendRoot:
    2.13                      config = sxp.parse(fin)
    2.14                  finally:
    2.15                      fin.close()
    2.16 -                config.insert(0, 'xend-config')
    2.17 +                if config is None:
    2.18 +                    config = ['xend-config']
    2.19 +                else:
    2.20 +                    config.insert(0, 'xend-config')
    2.21                  self.config = config
    2.22              except Exception, ex:
    2.23                  self._logError('Reading config file %s: %s',
    2.24 @@ -250,7 +253,9 @@ class XendRoot:
    2.25          s = self.get_config_value('network-script')
    2.26  
    2.27          if s:
    2.28 -            return os.path.join(self.network_script_dir, s)
    2.29 +            result = s.split(" ")
    2.30 +            result[0] = os.path.join(self.network_script_dir, result[0])
    2.31 +            return result
    2.32          else:
    2.33              return None
    2.34  
    2.35 @@ -258,9 +263,6 @@ class XendRoot:
    2.36      def get_enable_dump(self):
    2.37          return self.get_config_bool('enable-dump', 'no')
    2.38  
    2.39 -    def get_vif_bridge(self):
    2.40 -        return self.get_config_value('vif-bridge', 'xenbr0')
    2.41 -
    2.42      def get_vif_script(self):
    2.43          return self.get_config_value('vif-script', 'vif-bridge')
    2.44