[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] XendDomainInfo.py, XendDomain.py:



ChangeSet 1.1662.1.2, 2005/06/03 17:17:30+01:00, cl349@xxxxxxxxxxxxxxxxxxxx

        XendDomainInfo.py, XendDomain.py:
          Make create, recreate and restore XendDomainInfo class methods.
        XendDomain.py:
          Still need XendDomainInfo.
        PrettyPrint.py:
          Fix typo.
        xc.c:
          Cleanup whitespace.
        Signed-off-by: Mike Wray <mike.wray@xxxxxx>
        Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>



 lowlevel/xc/xc.c       |    3 -
 xend/PrettyPrint.py    |    2 
 xend/XendDomain.py     |    9 +--
 xend/XendDomainInfo.py |  133 +++++++++++++++++++++++++++++--------------------
 4 files changed, 86 insertions(+), 61 deletions(-)


diff -Nru a/tools/python/xen/lowlevel/xc/xc.c 
b/tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c 2005-06-09 13:03:40 -04:00
+++ b/tools/python/xen/lowlevel/xc/xc.c 2005-06-09 13:03:40 -04:00
@@ -833,6 +833,7 @@
       0, "\n"
       "Query the xc control interface file descriptor.\n\n"
       "Returns: [int] file descriptor\n" },
+
     { "domain_create", 
       (PyCFunction)pyxc_domain_create, 
       METH_VARARGS | METH_KEYWORDS, "\n"
@@ -844,7 +845,7 @@
       (PyCFunction)pyxc_domain_dumpcore, 
       METH_VARARGS | METH_KEYWORDS, "\n"
       "Dump core of a domain.\n"
-      " dom [int]: Identifier of domain to dump core of.\n\n"
+      " dom [int]: Identifier of domain to dump core of.\n"
       " corefile [string]: Name of corefile to be created.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
diff -Nru a/tools/python/xen/xend/PrettyPrint.py 
b/tools/python/xen/xend/PrettyPrint.py
--- a/tools/python/xen/xend/PrettyPrint.py      2005-06-09 13:03:40 -04:00
+++ b/tools/python/xen/xend/PrettyPrint.py      2005-06-09 13:03:40 -04:00
@@ -285,7 +285,7 @@
         sxp.show(sxpr, out=out)
     print >> out
 
-def prettyprintstring(sxp, width=80):
+def prettyprintstring(sxpr, width=80):
     """Prettyprint an SXP form to a string.
 
     sxpr       s-expression
diff -Nru a/tools/python/xen/xend/XendDomain.py 
b/tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       2005-06-09 13:03:40 -04:00
+++ b/tools/python/xen/xend/XendDomain.py       2005-06-09 13:03:40 -04:00
@@ -133,7 +133,7 @@
         @param info:      domain info from xen
         @return: domain
         """
-        dominfo = XendDomainInfo.vm_recreate(savedinfo, info)
+        dominfo = XendDomainInfo.recreate(savedinfo, info)
         self.domains[dominfo.id] = dominfo
         return dominfo
 
@@ -282,8 +282,7 @@
         @param config: configuration
         @return: domain
         """
-        dominfo = XendDomainInfo.vm_create(config)
-        self._add_domain(dominfo)
+        dominfo = XendDomainInfo.create(config)
         return dominfo
 
     def domain_restart(self, dominfo):
@@ -316,7 +315,7 @@
         @param vmconfig: vm configuration
         """
         config = sxp.child_value(vmconfig, 'config')
-        dominfo = XendDomainInfo.vm_restore(config)
+        dominfo = XendDomainInfo.restore(config)
         self._add_domain(dominfo)
         return dominfo
     
@@ -352,7 +351,7 @@
                 info = self.xen_domain(id)
                 if info:
                     log.info("Creating entry for unknown domain: id=%s", name)
-                    dominfo = XendDomainInfo.vm_recreate(None, info)
+                    dominfo = XendDomainInfo.recreate(None, info, unknown=True)
                     self._add_domain(dominfo)
             except Exception, ex:
                 log.exception("Error creating domain info: id=%s", name)
diff -Nru a/tools/python/xen/xend/XendDomainInfo.py 
b/tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   2005-06-09 13:03:40 -04:00
+++ b/tools/python/xen/xend/XendDomainInfo.py   2005-06-09 13:03:40 -04:00
@@ -144,61 +144,7 @@
 
 def get_device_handler(name):
     return device_handlers[name]
-    
-
-def vm_create(config):
-    """Create a VM from a configuration.
-    If a vm has been partially created and there is an error it
-    is destroyed.
-
-    @param config    configuration
-    @raise: VmError for invalid configuration
-    """
-    vm = XendDomainInfo()
-    vm.construct(config)
-    return vm
 
-def vm_restore(config):
-    """Create a domain and a VM object to do a restore.
-
-    @param config:    domain configuration
-    """
-    vm = XendDomainInfo()
-    dom = xc.domain_create()
-    vm.dom_construct(dom, config)
-    return vm
-
-def vm_recreate(savedinfo, info):
-    """Create the VM object for an existing domain.
-
-    @param savedinfo: saved info from the domain DB
-    @type  savedinfo: sxpr
-    @param info:      domain info from xc
-    @type  info:      xc domain dict
-    """
-    log.debug('savedinfo=' + prettyprintstring(savedinfo))
-    log.debug('info=' + str(info))
-    vm = XendDomainInfo()
-    vm.recreate = True
-    vm.savedinfo = savedinfo
-    vm.setdom(info['dom'])
-    vm.memory = info['mem_kb']/1024
-    start_time = sxp.child_value(savedinfo, 'start_time')
-    if start_time is not None:
-        vm.start_time = float(start_time)
-    vm.restart_state = sxp.child_value(savedinfo, 'restart_state')
-    vm.restart_count = int(sxp.child_value(savedinfo, 'restart_count', 0))
-    restart_time = sxp.child_value(savedinfo, 'restart_time')
-    if restart_time is not None:
-        vm.restart_time = float(restart_time)
-    config = sxp.child_value(savedinfo, 'config')
-    if config:
-        vm.construct(config)
-    else:
-        vm.name = sxp.child_value(savedinfo, 'name', "Domain-%d" % info['dom'])
-    vm.recreate = False
-    vm.savedinfo = None
-    return vm
 
 def dom_get(dom):
     """Get info from xen for an existing domain.
@@ -218,9 +164,88 @@
     """
     MINIMUM_RESTART_TIME = 20
 
+    def _create(cls):
+        """Create a vm object.
+
+        @return vm
+        """
+        vm = cls()
+        return vm
+
+    _create = classmethod(_create)
+
+    def create(cls, config):
+        """Create a VM from a configuration.
+        If a vm has been partially created and there is an error it
+        is destroyed.
+
+        @param config    configuration
+        @raise: VmError for invalid configuration
+        """
+        vm = cls._create()
+        vm.construct(config)
+        return vm
+
+    create = classmethod(create)
+
+    def recreate(cls, savedinfo, info, unknown=False):
+        """Create the VM object for an existing domain.
+
+        @param savedinfo: saved info from the domain DB
+        @param info:      domain info from xc
+        @type  info:      xc domain dict
+        """
+        if unknown:
+            vm = cls._create()
+        else:
+            vm = cls()
+
+        log.debug('savedinfo=' + prettyprintstring(savedinfo))
+        log.debug('info=' + str(info))
+
+        vm.recreate = True
+        vm.savedinfo = savedinfo
+        vm.setdom(info['dom'])
+        vm.memory = info['mem_kb']/1024
+
+        start_time = sxp.child_value(savedinfo, 'start_time')
+        if start_time is not None:
+            vm.start_time = float(start_time)
+        vm.restart_state = sxp.child_value(savedinfo, 'restart_state')
+        vm.restart_count = int(sxp.child_value(savedinfo, 'restart_count', 0))
+        restart_time = sxp.child_value(savedinfo, 'restart_time')
+        if restart_time is not None:
+            vm.restart_time = float(restart_time)
+        config = sxp.child_value(savedinfo, 'config')
+
+        if config:
+            vm.construct(config)
+        else:
+            vm.name = sxp.child_value(savedinfo, 'name', "Domain-%d" % 
info['dom'])
+        vm.recreate = False
+        vm.savedinfo = None
+
+        return vm
+
+    recreate = classmethod(recreate)
+
+    def restore(cls, config):
+        """Create a domain and a VM object to do a restore.
+
+        @param config:    domain configuration
+        """
+        vm = cls._create()
+        dom = xc.domain_create()
+        vm.setdom(dom)
+        vm.dom_construct(dom, config)
+        return vm
+
+    restore = classmethod(restore)
+
     def __init__(self):
         self.recreate = 0
         self.restore = 0
+        
         self.config = None
         self.id = None
         self.dom = None

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.