ia64/xen-unstable
changeset 13074:63e72c3254da
Persist all the Xen-API data values for VMs.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | Ewan Mellor <ewan@xensource.com> |
---|---|
date | Sat Dec 16 12:49:23 2006 +0000 (2006-12-16) |
parents | 7cf33c0856d4 |
children | c38370be1e0e |
files | tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py |
line diff
1.1 --- a/tools/python/xen/xend/XendAPI.py Fri Dec 15 17:19:00 2006 +0000 1.2 +++ b/tools/python/xen/xend/XendAPI.py Sat Dec 16 12:49:23 2006 +0000 1.3 @@ -663,7 +663,10 @@ class XendAPI: 1.4 XendDomain.instance().get_vm_by_uuid(vm_ref).info[name]) 1.5 1.6 def VM_set(self, name, session, vm_ref, value): 1.7 - XendDomain.instance().get_vm_by_uuid(vm_ref).info[name] = value 1.8 + xd = XendDomain.instance() 1.9 + dominfo = xd.get_vm_by_uuid(vm_ref) 1.10 + dominfo.info[name] = value 1.11 + xd.managed_config_save(dominfo) 1.12 return xen_api_success_void() 1.13 1.14 # attributes (ro)
2.1 --- a/tools/python/xen/xend/XendConfig.py Fri Dec 15 17:19:00 2006 +0000 2.2 +++ b/tools/python/xen/xend/XendConfig.py Sat Dec 16 12:49:23 2006 +0000 2.3 @@ -430,8 +430,12 @@ class XendConfig(dict): 2.4 """ 2.5 cfg = {} 2.6 2.7 - # First step is to convert deprecated options to 2.8 - # current equivalents. 2.9 + for key, typ in XENAPI_CFG_TYPES.items(): 2.10 + val = sxp.child_value(sxp_cfg, key) 2.11 + if val is not None: 2.12 + cfg[key] = typ(val) 2.13 + 2.14 + # Convert deprecated options to current equivalents. 2.15 2.16 restart = sxp.child_value(sxp_cfg, 'restart') 2.17 if restart: 2.18 @@ -576,6 +580,11 @@ class XendConfig(dict): 2.19 """ 2.20 cfg = self._parse_sxp(sxp_cfg) 2.21 2.22 + for key, typ in XENAPI_CFG_TYPES.items(): 2.23 + val = cfg.get(key) 2.24 + if val is not None: 2.25 + self[key] = typ(val) 2.26 + 2.27 # Convert parameters that can be directly mapped from 2.28 # the Legacy Config to Xen API Config 2.29 2.30 @@ -590,9 +599,13 @@ class XendConfig(dict): 2.31 except KeyError: 2.32 pass 2.33 2.34 - self['PV_bootloader'] = cfg.get('bootloader', '') 2.35 - self['PV_bootloader_args'] = cfg.get('bootloader_args', '') 2.36 - 2.37 + def update_with(n, o): 2.38 + if not self.get(n): 2.39 + self[n] = cfg.get(o, '') 2.40 + 2.41 + update_with('PV_bootloader', 'bootloader') 2.42 + update_with('PV_bootloader_args', 'bootloader_args') 2.43 + 2.44 image_sxp = sxp.child_value(sxp_cfg, 'image', []) 2.45 if image_sxp: 2.46 self.update_with_image_sxp(image_sxp) 2.47 @@ -760,11 +773,8 @@ class XendConfig(dict): 2.48 2.49 self.validate() 2.50 2.51 - def to_xml(self): 2.52 - """Return an XML string representing the configuration.""" 2.53 - pass 2.54 - 2.55 - def to_sxp(self, domain = None, ignore_devices = False, ignore = []): 2.56 + def to_sxp(self, domain = None, ignore_devices = False, ignore = [], 2.57 + legacy_only = True): 2.58 """ Get SXP representation of this config object. 2.59 2.60 Incompat: removed store_mfn, console_mfn 2.61 @@ -785,6 +795,11 @@ class XendConfig(dict): 2.62 if domain.getDomid() is not None: 2.63 sxpr.append(['domid', domain.getDomid()]) 2.64 2.65 + if not legacy_only: 2.66 + for name in XENAPI_CFG_TYPES.keys(): 2.67 + if name in self and self[name] not in (None, []): 2.68 + sxpr.append([name, str(self[name])]) 2.69 + 2.70 for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items(): 2.71 if self.has_key(xenapi) and self[xenapi] not in (None, []): 2.72 if type(self[xenapi]) == bool:
3.1 --- a/tools/python/xen/xend/XendDomain.py Fri Dec 15 17:19:00 2006 +0000 3.2 +++ b/tools/python/xen/xend/XendDomain.py Sat Dec 16 12:49:23 2006 +0000 3.3 @@ -284,7 +284,8 @@ class XendDomain: 3.4 fd, fn = tempfile.mkstemp() 3.5 f = os.fdopen(fd, 'w+b') 3.6 try: 3.7 - prettyprint(dominfo.sxpr(), f, width = 78) 3.8 + prettyprint(dominfo.sxpr(legacy_only = False), f, 3.9 + width = 78) 3.10 finally: 3.11 f.close() 3.12 try:
4.1 --- a/tools/python/xen/xend/XendDomainInfo.py Fri Dec 15 17:19:00 2006 +0000 4.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Sat Dec 16 12:49:23 2006 +0000 4.3 @@ -1800,9 +1800,10 @@ class XendDomainInfo: 4.4 log.trace("XendDomainInfo.update done on domain %s: %s", 4.5 str(self.domid), self.info) 4.6 4.7 - def sxpr(self, ignore_store = False): 4.8 + def sxpr(self, ignore_store = False, legacy_only = True): 4.9 result = self.info.to_sxp(domain = self, 4.10 - ignore_devices = ignore_store) 4.11 + ignore_devices = ignore_store, 4.12 + legacy_only = legacy_only) 4.13 4.14 if not ignore_store and self.dompath: 4.15 vnc_port = self.readDom('console/vnc-port')