WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-3.0.4-testing] Persist all the Xen-API data values

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.0.4-testing] Persist all the Xen-API data values for VMs.
From: "Xen patchbot-3.0.4-testing" <patchbot-3.0.4-testing@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 18 Dec 2006 10:45:21 -0800
Delivery-date: Tue, 19 Dec 2006 03:15:55 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1166273363 0
# Node ID 63e72c3254da9023ad496276ff8547c2dd74db19
# Parent  7cf33c0856d40596e880391701ddc304ced8b351
Persist all the Xen-API data values for VMs.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendAPI.py        |    5 +++-
 tools/python/xen/xend/XendConfig.py     |   35 ++++++++++++++++++++++----------
 tools/python/xen/xend/XendDomain.py     |    3 +-
 tools/python/xen/xend/XendDomainInfo.py |    5 ++--
 4 files changed, 34 insertions(+), 14 deletions(-)

diff -r 7cf33c0856d4 -r 63e72c3254da tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Fri Dec 15 17:19:00 2006 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Sat Dec 16 12:49:23 2006 +0000
@@ -663,7 +663,10 @@ class XendAPI:
             XendDomain.instance().get_vm_by_uuid(vm_ref).info[name])
 
     def VM_set(self, name, session, vm_ref, value):
-        XendDomain.instance().get_vm_by_uuid(vm_ref).info[name] = value
+        xd = XendDomain.instance()
+        dominfo = xd.get_vm_by_uuid(vm_ref)
+        dominfo.info[name] = value
+        xd.managed_config_save(dominfo)
         return xen_api_success_void()
 
     # attributes (ro)
diff -r 7cf33c0856d4 -r 63e72c3254da tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Fri Dec 15 17:19:00 2006 +0000
+++ b/tools/python/xen/xend/XendConfig.py       Sat Dec 16 12:49:23 2006 +0000
@@ -430,8 +430,12 @@ class XendConfig(dict):
         """
         cfg = {}
 
-        # First step is to convert deprecated options to
-        # current equivalents.
+        for key, typ in XENAPI_CFG_TYPES.items():
+            val = sxp.child_value(sxp_cfg, key)
+            if val is not None:
+                cfg[key] = typ(val)
+
+        # Convert deprecated options to current equivalents.
         
         restart = sxp.child_value(sxp_cfg, 'restart')
         if restart:
@@ -576,6 +580,11 @@ class XendConfig(dict):
         """
         cfg = self._parse_sxp(sxp_cfg)
 
+        for key, typ in XENAPI_CFG_TYPES.items():
+            val = cfg.get(key)
+            if val is not None:
+                self[key] = typ(val)
+
         # Convert parameters that can be directly mapped from
         # the Legacy Config to Xen API Config
         
@@ -590,9 +599,13 @@ class XendConfig(dict):
             except KeyError:
                 pass
 
-        self['PV_bootloader']      = cfg.get('bootloader',      '')
-        self['PV_bootloader_args'] = cfg.get('bootloader_args', '')
-        
+        def update_with(n, o):
+            if not self.get(n):
+                self[n] = cfg.get(o, '')
+
+        update_with('PV_bootloader',      'bootloader')
+        update_with('PV_bootloader_args', 'bootloader_args')
+
         image_sxp = sxp.child_value(sxp_cfg, 'image', [])
         if image_sxp:
             self.update_with_image_sxp(image_sxp)
@@ -760,11 +773,8 @@ class XendConfig(dict):
 
         self.validate()
 
-    def to_xml(self):
-        """Return an XML string representing the configuration."""
-        pass
-
-    def to_sxp(self, domain = None, ignore_devices = False, ignore = []):
+    def to_sxp(self, domain = None, ignore_devices = False, ignore = [],
+               legacy_only = True):
         """ Get SXP representation of this config object.
 
         Incompat: removed store_mfn, console_mfn
@@ -784,6 +794,11 @@ class XendConfig(dict):
 
         if domain.getDomid() is not None:
             sxpr.append(['domid', domain.getDomid()])
+
+        if not legacy_only:
+            for name in XENAPI_CFG_TYPES.keys():
+                if name in self and self[name] not in (None, []):
+                    sxpr.append([name, str(self[name])])
 
         for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items():
             if self.has_key(xenapi) and self[xenapi] not in (None, []):
diff -r 7cf33c0856d4 -r 63e72c3254da tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Fri Dec 15 17:19:00 2006 +0000
+++ b/tools/python/xen/xend/XendDomain.py       Sat Dec 16 12:49:23 2006 +0000
@@ -284,7 +284,8 @@ class XendDomain:
                 fd, fn = tempfile.mkstemp()
                 f = os.fdopen(fd, 'w+b')
                 try:
-                    prettyprint(dominfo.sxpr(), f, width = 78)
+                    prettyprint(dominfo.sxpr(legacy_only = False), f,
+                                width = 78)
                 finally:
                     f.close()
                 try:
diff -r 7cf33c0856d4 -r 63e72c3254da tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Fri Dec 15 17:19:00 2006 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Sat Dec 16 12:49:23 2006 +0000
@@ -1800,9 +1800,10 @@ class XendDomainInfo:
         log.trace("XendDomainInfo.update done on domain %s: %s",
                   str(self.domid), self.info)
 
-    def sxpr(self, ignore_store = False):
+    def sxpr(self, ignore_store = False, legacy_only = True):
         result = self.info.to_sxp(domain = self,
-                                   ignore_devices = ignore_store)
+                                  ignore_devices = ignore_store,
+                                  legacy_only = legacy_only)
 
         if not ignore_store and self.dompath:
             vnc_port = self.readDom('console/vnc-port')

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.0.4-testing] Persist all the Xen-API data values for VMs., Xen patchbot-3.0.4-testing <=