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-unstable] [XEND] Fix many typos with VM interface t

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEND] Fix many typos with VM interface to XenAPI
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 02 Nov 2006 22:08:39 +0000
Delivery-date: Thu, 02 Nov 2006 21:41:10 -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 Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID 8e5e7399e9b54b41ba0eac221b4dd84345592fb0
# Parent  acb85833be66180659fd633253aa72e10ebddd12
[XEND] Fix many typos with VM interface to XenAPI

1. Python XMLRPC does not allow integer keys to structs.
2. Typo with on_suspend and on_preserve
3. Changed all tuples in constants to lists so .index() works.
4. Made get_vcpus_utils to return seconds of CPU time.
5. Fix flawed login in VM.get_record()
---
 tools/python/xen/xend/XendAPI.py          |   13 ++++++-------
 tools/python/xen/xend/XendAPIConstants.py |   24 ++++++++++++------------
 tools/python/xen/xend/XendDomainInfo.py   |   13 +++++++------
 3 files changed, 25 insertions(+), 25 deletions(-)

diff -r acb85833be66 -r 8e5e7399e9b5 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Thu Oct 05 18:24:18 2006 +0100
+++ b/tools/python/xen/xend/XendAPI.py  Thu Oct 05 18:48:54 2006 +0100
@@ -847,6 +847,9 @@ class XendAPI:
     def vm_get_record(self, session, vm_ref):
         xendom = XendDomain.instance()
         xeninfo = xendom.get_vm_by_uuid(vm_ref)
+        if not xeninfo:
+            return xen_api_error(XEND_ERROR_VM_INVALID)
+        
         record = {
             'uuid': xeninfo.get_uuid(),
             'power_state': xeninfo.get_power_state(),
@@ -870,7 +873,7 @@ class XendAPI:
             'vcpus_features_force_off': [],
             'actions_after_shutdown': xeninfo.get_on_shutdown(),
             'actions_after_reboot': xeninfo.get_on_reboot(),
-            'actions_after_suspend': xeninfo.get_on_preserve(),
+            'actions_after_suspend': xeninfo.get_on_suspend(),
             'actions_after_crash': xeninfo.get_on_crash(),
             'vifs': xeninfo.get_vifs(),
             'vbds': xeninfo.get_vbds(),
@@ -886,17 +889,13 @@ class XendAPI:
             'boot_method': xeninfo.get_boot_method(),
             'kernel_kernel': xeninfo.get_kernel_image(),
             'kernel_initrd': xeninfo.get_kernel_initrd(),
-            'kernel_args': xeninfo.get_boot_args(),
+            'kernel_args': xeninfo.get_kernel_args(),
             'grub_cmdline': xeninfo.get_grub_cmdline(),
             'pci_bus': xeninfo.get_pci_bus(),
             'tools_version': xeninfo.get_tools_version(),
             'otherconfig': xeninfo.get_other_config()
         }
-        
-        if not xeninfo:
-            xen_api_error(XEND_ERROR_VM_INVALID)
-        else:
-            xen_api_success(record)
+        return xen_api_success(record)
 
     def vm_clean_reboot(self, session, vm_ref):
         xendom = XendDomain.instance()
diff -r acb85833be66 -r 8e5e7399e9b5 tools/python/xen/xend/XendAPIConstants.py
--- a/tools/python/xen/xend/XendAPIConstants.py Thu Oct 05 18:24:18 2006 +0100
+++ b/tools/python/xen/xend/XendAPIConstants.py Thu Oct 05 18:48:54 2006 +0100
@@ -19,14 +19,14 @@
 # Xen API Enums
 #
 
-XEN_API_VM_POWER_STATE = (
+XEN_API_VM_POWER_STATE = [
     'Halted',
     'Paused',
     'Running',
     'Suspended',
     'ShuttingDown',
     'Unknown'
-)
+]
 
 XEN_API_VM_POWER_STATE_HALTED = 0
 XEN_API_VM_POWER_STATE_PAUSED = 1
@@ -35,7 +35,7 @@ XEN_API_VM_POWER_STATE_SHUTTINGDOWN = 4
 XEN_API_VM_POWER_STATE_SHUTTINGDOWN = 4
 XEN_API_VM_POWER_STATE_UNKNOWN = 5
 
-XEN_API_CPU_FEATURE = (
+XEN_API_CPU_FEATURE = [
     'FPU', 'VME', 'DE', 'PSE', 'TSC', 'MSR', 'PAE'
     'MCE', 'CX8', 'APIC', 'SEP', 'MTRR', 'PGE', 'MCA',
     'CMOV', 'PAT', 'PSE36', 'PN', 'CLFLSH', 'DTES',
@@ -47,29 +47,29 @@ XEN_API_CPU_FEATURE = (
     'XMM3', 'MWAIT', 'DSCPL', 'EST', 'TM2', 'CID', 'CX16',
     'XTPR', 'XSTORE', 'XSTORE_EN', 'XCRYPT', 'XCRYPT_EN',
     'LAHF_LM', 'CMP_LEGACY'
-)
+]
 
-XEN_API_ON_NORMAL_EXIT = (
+XEN_API_ON_NORMAL_EXIT = [
     'destroy',
     'restart',
-)
+]
 
-XEN_API_ON_CRASH_BEHAVIOUR = (
+XEN_API_ON_CRASH_BEHAVIOUR = [
     'destroy',
     'coredump_and_destroy',
     'restart',
     'coredump_and_restart',
     'preserve',
     'rename_restart'
-)
+]
 
-XEN_API_BOOT_TYPE = (
+XEN_API_BOOT_TYPE = [
     'bios',
     'grub',
     'kernel_external',
     'kernel_internal'
-)
+]
 
-XEN_API_VBD_MODE = ('RO', 'RW')
+XEN_API_VBD_MODE = ['RO', 'RW']
 
-XEN_API_DRIVER_TYPE = ('ioemu', 'paravirtualised')
+XEN_API_DRIVER_TYPE = ['ioemu', 'paravirtualised']
diff -r acb85833be66 -r 8e5e7399e9b5 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Oct 05 18:24:18 2006 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Oct 05 18:48:54 2006 +0100
@@ -807,7 +807,6 @@ class XendDomainInfo:
     def getVCpuCount(self):
         return self.info['vcpus']
 
-
     def setVCpuCount(self, vcpus):
         self.info['vcpu_avail'] = (1 << vcpus) - 1
         self.storeVm('vcpu_avail', self.info['vcpu_avail'])
@@ -1646,7 +1645,7 @@ class XendDomainInfo:
     def get_uuid(self):
         return self.info['uuid']
     def get_memory_static_max(self):
-        return self.info['memmax']
+        return self.info['maxmem']
     def get_memory_static_min(self):
         return self.info['memory']
     def get_vcpus_policy(self):
@@ -1761,19 +1760,21 @@ class XendDomainInfo:
 
     def get_vcpus_util(self):
         # TODO: this returns the total accum cpu time, rather than util
+        # TODO: spec says that key is int, however, python does not allow
+        #       non-string keys to dictionaries.
         vcpu_util = {}
-        if 'max_vcpu_id' in self.info:
+        if 'max_vcpu_id' in self.info and self.domid != None:
             for i in range(0, self.info['max_vcpu_id']+1):
                 info = xc.vcpu_getinfo(self.domid, i)
-                vcpu_util[i] = info['cpu_time']
+                vcpu_util[str(i)] = info['cpu_time']/1000000000.0
                 
         return vcpu_util
 
     def get_vifs(self):
-        return self.info['vif_refs']
+        return self.info.get('vif_refs', [])
 
     def get_vbds(self):
-        return self.info['vbd_refs']
+        return self.info.get('vbd_refs', [])
 
     def create_vbd(self, xenapi_vbd):
         """Create a VBD device from the passed struct in Xen API format.

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XEND] Fix many typos with VM interface to XenAPI, Xen patchbot-unstable <=