Files
xen/tools/xm-test/tests/xapi/01_xapi-vm_basic.py
T
Ewan Mellor baacea8058 This patch does the following:
- renames the XenManagedDomain.py file to XenAPIDomain.py, since this
name better reflects its functionality/purpose
- adds domain tracking to the XenAPIDomain class so that xend-managed
domains can be deleted in an 'atexit' handler upon test case termination
- adds one basic xapi-related test which is part of the grouptests
'xapi'
- refactors the vtpm-related test using xen-api and adds it to the
grouptest 'xapi'
- adds documentation to the README for how to configure xm and xend to
use XML-RPC or Xen-API for communication

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2007-01-11 19:00:35 +00:00

62 lines
1.7 KiB
Python

#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: Stefan Berger <stefanb@us.ibm.com>
# Basic VM creation test
from XmTestLib import xapi
from XmTestLib.XenAPIDomain import XmTestAPIDomain
from XmTestLib import *
from xen.xend import XendAPIConstants
import commands
import os
try:
# XmTestAPIDomain tries to establish a connection to XenD
domain = XmTestAPIDomain()
except Exception, e:
SKIP("Skipping test. Error: %s" % str(e))
vm_uuid = domain.get_uuid()
session = xapi.connect()
domain.start(startpaused=True)
res = session.xenapi.VM.get_power_state(vm_uuid)
if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_PAUSED]:
FAIL("VM was not started in 'paused' state")
res = session.xenapi.VM.unpause(vm_uuid)
res = session.xenapi.VM.get_power_state(vm_uuid)
if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_RUNNING]:
FAIL("VM could not be put into 'running' state")
console = domain.getConsole()
try:
run = console.runCmd("cat /proc/interrupts")
except ConsoleError, e:
saveLog(console.getHistory())
FAIL("Could not access proc-filesystem")
res = session.xenapi.VM.pause(vm_uuid)
res = session.xenapi.VM.get_power_state(vm_uuid)
if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_PAUSED]:
FAIL("VM could not be put into 'paused' state")
res = session.xenapi.VM.unpause(vm_uuid)
res = session.xenapi.VM.get_power_state(vm_uuid)
if res != XendAPIConstants.XEN_API_VM_POWER_STATE[XendAPIConstants.XEN_API_VM_POWER_STATE_RUNNING]:
FAIL("VM could not be 'unpaused'")
domain.stop()
domain.destroy()