ia64/xen-unstable

changeset 5016:7c5f7c1ed1a3

bitkeeper revision 1.1470 (428ced50yxI-yUVLt1gizxNq0Nofxg)

console.py, blkif.py, SrvDomainDir.py, XendDomain.py, XendConsole.py:
Rename XendDomain.domains() to XendDomain.list() and rename
XendDomain.domain_by_id to XendDomain.domains.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu May 19 19:47:28 2005 +0000 (2005-05-19)
parents d1e3efb12a27
children 25cc682e9734
files tools/python/xen/xend/XendConsole.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/SrvDomainDir.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/console.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConsole.py	Thu May 19 19:12:46 2005 +0000
     1.2 +++ b/tools/python/xen/xend/XendConsole.py	Thu May 19 19:47:28 2005 +0000
     1.3 @@ -17,7 +17,7 @@ class XendConsole:
     1.4      def consoles(self):
     1.5          l = []
     1.6          xd = XendRoot.get_component('xen.xend.XendDomain')
     1.7 -        for vm in xd.domains():
     1.8 +        for vm in xd.list():
     1.9              ctrl = vm.getDeviceController("console", error=False)
    1.10              if (not ctrl): continue
    1.11              console = ctrl.getDevice(0)
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Thu May 19 19:12:46 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu May 19 19:47:28 2005 +0000
     2.3 @@ -36,7 +36,7 @@ class XendDomain:
     2.4      dbpath = "domain"
     2.5  
     2.6      """Table of domain info indexed by domain id."""
     2.7 -    domain_by_id = {}
     2.8 +    domains = {}
     2.9      
    2.10      def __init__(self):
    2.11          # Hack alert. Python does not support mutual imports, but XendDomainInfo
    2.12 @@ -56,12 +56,12 @@ class XendDomain:
    2.13      def domain_lookup_by_name(self, name):
    2.14          try:
    2.15              return filter(lambda d: d.name == name,
    2.16 -                          self.domain_by_id.values())[0]
    2.17 +                          self.domains.values())[0]
    2.18          except IndexError, err:
    2.19              return None
    2.20  
    2.21      def domain_lookup_by_id(self, id):
    2.22 -        return self.domain_by_id.get(id)
    2.23 +        return self.domains.get(id)
    2.24  
    2.25      def onVirq(self, event, val):
    2.26          """Event handler for virq.
    2.27 @@ -137,7 +137,7 @@ class XendDomain:
    2.28          @return: domain
    2.29          """
    2.30          dominfo = XendDomainInfo.vm_recreate(savedinfo, info)
    2.31 -        self.domain_by_id[dominfo.id] = dominfo
    2.32 +        self.domains[dominfo.id] = dominfo
    2.33          return dominfo
    2.34  
    2.35      def _add_domain(self, info, notify=True):
    2.36 @@ -147,17 +147,17 @@ class XendDomain:
    2.37          @param notify: send a domain created event if true
    2.38          """
    2.39          # Remove entries under the wrong id.
    2.40 -        for i, d in self.domain_by_id.items():
    2.41 +        for i, d in self.domains.items():
    2.42              if i != d.id:
    2.43 -                del self.domain_by_id[i]
    2.44 +                del self.domains[i]
    2.45                  if i in self.domain_db:
    2.46                      del self.domain_db[i]
    2.47                  self.db.delete(i)
    2.48          # But also need to make sure are indexed under correct name.
    2.49          # What about entries under info.name ?
    2.50 -        if info.id in self.domain_by_id:
    2.51 +        if info.id in self.domains:
    2.52              notify = False
    2.53 -        self.domain_by_id[info.id] = info
    2.54 +        self.domains[info.id] = info
    2.55          self.domain_db[info.id] = info.sxpr()
    2.56          self.sync_domain(info.id)
    2.57          if notify:
    2.58 @@ -169,9 +169,9 @@ class XendDomain:
    2.59          @param id:     domain id
    2.60          @param notify: send a domain died event if true
    2.61          """
    2.62 -        info = self.domain_by_id.get(id)
    2.63 +        info = self.domains.get(id)
    2.64          if info:
    2.65 -            del self.domain_by_id[id]
    2.66 +            del self.domains[id]
    2.67              if notify:
    2.68                  eserver.inject('xend.domain.died', [info.name, info.id])
    2.69          if id in self.domain_db:
    2.70 @@ -195,7 +195,7 @@ class XendDomain:
    2.71          for d in casualties:
    2.72              id = str(d['dom'])
    2.73              #print 'reap>', id
    2.74 -            dominfo = self.domain_by_id.get(id)
    2.75 +            dominfo = self.domains.get(id)
    2.76              name = (dominfo and dominfo.name) or '??'
    2.77              if dominfo and dominfo.is_terminated():
    2.78                  #print 'reap> already terminated:', id
    2.79 @@ -228,12 +228,12 @@ class XendDomain:
    2.80          doms = self.xen_domains()
    2.81          # Add entries for any domains we don't know about.
    2.82          for (id, d) in doms.items():
    2.83 -            if id not in self.domain_by_id:
    2.84 +            if id not in self.domains:
    2.85                  self.domain_lookup(id)
    2.86          # Remove entries for domains that no longer exist.
    2.87          # Update entries for existing domains.
    2.88          do_domain_restarts = False
    2.89 -        for d in self.domain_by_id.values():
    2.90 +        for d in self.domains.values():
    2.91              info = doms.get(d.id)
    2.92              if info:
    2.93                  d.update(info)
    2.94 @@ -249,7 +249,7 @@ class XendDomain:
    2.95  
    2.96          @param id: domain id
    2.97          """
    2.98 -        dominfo = self.domain_by_id.get(id)
    2.99 +        dominfo = self.domains.get(id)
   2.100          if dominfo:
   2.101              self.domain_db[id] = dominfo.sxpr()
   2.102              self.sync_domain(id)
   2.103 @@ -261,7 +261,7 @@ class XendDomain:
   2.104          """
   2.105          dominfo = self.xen_domain(id)
   2.106          if dominfo:
   2.107 -            d = self.domain_by_id.get(id)
   2.108 +            d = self.domains.get(id)
   2.109              if d:
   2.110                  d.update(dominfo)
   2.111          else:
   2.112 @@ -273,7 +273,7 @@ class XendDomain:
   2.113          @return: domain names
   2.114          """
   2.115          self.refresh()
   2.116 -        doms = self.domain_by_id.values()
   2.117 +        doms = self.domains.values()
   2.118          doms.sort(lambda x, y: cmp(x.name, y.name))
   2.119          return map(lambda x: x.name, doms)
   2.120  
   2.121 @@ -283,15 +283,15 @@ class XendDomain:
   2.122          @return: domain names
   2.123          """
   2.124          self.refresh()
   2.125 -        return self.domain_by_id.keys()
   2.126 +        return self.domains.keys()
   2.127  
   2.128 -    def domains(self):
   2.129 +    def list(self):
   2.130          """Get list of domain objects.
   2.131  
   2.132          @return: domain objects
   2.133          """
   2.134          self.refresh()
   2.135 -        return self.domain_by_id.values()
   2.136 +        return self.domains.values()
   2.137      
   2.138      def domain_create(self, config):
   2.139          """Create a domain from a configuration.
   2.140 @@ -358,7 +358,7 @@ class XendDomain:
   2.141          """
   2.142          id = str(id)
   2.143          self.refresh_domain(id)
   2.144 -        return self.domain_by_id.get(id)
   2.145 +        return self.domains.get(id)
   2.146  
   2.147      def domain_lookup(self, name):
   2.148          name = str(name)
   2.149 @@ -429,7 +429,7 @@ class XendDomain:
   2.150          Destroys domains whose shutdowns have timed out.
   2.151          """
   2.152          timeout = SHUTDOWN_TIMEOUT + 1
   2.153 -        for dominfo in self.domain_by_id.values():
   2.154 +        for dominfo in self.domains.values():
   2.155              if not dominfo.shutdown_pending:
   2.156                  # domain doesn't need shutdown
   2.157                  continue
   2.158 @@ -480,7 +480,7 @@ class XendDomain:
   2.159          """Execute any scheduled domain restarts for domains that have gone.
   2.160          """
   2.161          doms = self.xen_domains()
   2.162 -        for dominfo in self.domain_by_id.values():
   2.163 +        for dominfo in self.domains.values():
   2.164              if not dominfo.restart_pending():
   2.165                  continue
   2.166              print 'domain_restarts>', dominfo.name, dominfo.id
     3.1 --- a/tools/python/xen/xend/server/SrvDomainDir.py	Thu May 19 19:12:46 2005 +0000
     3.2 +++ b/tools/python/xen/xend/server/SrvDomainDir.py	Thu May 19 19:47:28 2005 +0000
     3.3 @@ -134,7 +134,7 @@ class SrvDomainDir(SrvDir):
     3.4              domains = self.xd.domain_ls()
     3.5              sxp.show(domains, out=req)
     3.6          else:
     3.7 -            domains = self.xd.domains()
     3.8 +            domains = self.xd.list()
     3.9              domains.sort(lambda x, y: cmp(x.name, y.name))
    3.10              req.write('<ul>')
    3.11              for d in domains:
     4.1 --- a/tools/python/xen/xend/server/blkif.py	Thu May 19 19:12:46 2005 +0000
     4.2 +++ b/tools/python/xen/xend/server/blkif.py	Thu May 19 19:47:28 2005 +0000
     4.3 @@ -262,7 +262,7 @@ class BlkDev(Dev):
     4.4      def check_mounted(self, name):
     4.5          mode = blkif.mount_mode(name)
     4.6          xd = XendRoot.get_component('xen.xend.XendDomain')
     4.7 -        for vm in xd.domains():
     4.8 +        for vm in xd.list():
     4.9              ctrl = vm.getDeviceController(self.getType(), error=False)
    4.10              if (not ctrl): continue
    4.11              for dev in ctrl.getDevices():
     5.1 --- a/tools/python/xen/xend/server/console.py	Thu May 19 19:12:46 2005 +0000
     5.2 +++ b/tools/python/xen/xend/server/console.py	Thu May 19 19:47:28 2005 +0000
     5.3 @@ -114,7 +114,7 @@ class ConsoleDev(Dev, protocol.ServerFac
     5.4          """Check that a console port is not in use by another console.
     5.5          """
     5.6          xd = XendRoot.get_component('xen.xend.XendDomain')
     5.7 -        for vm in xd.domains():
     5.8 +        for vm in xd.list():
     5.9              ctrl = vm.getDeviceController(self.getType(), error=False)
    5.10              if (not ctrl): continue
    5.11              ctrl.checkConsolePort(console_port)