mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
[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()
This commit is contained in:
1 parent
7e63b4bf7e
commit
b2b451d4cd
3 files changed
+25
-25
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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_SUSPENDED = 3
|
||||
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']
|
||||
@@ -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.
|
||||
|
||||