(header['policyname'], xm_test['policyname'])) if header['date'] != xm_test['date']: FAIL("Date in header is '%s', expected is '%s'." % (header['date'], xm_test['date'])) if header.has_key("url") and header['url'] != xm_test['url']: FAIL("URL in header is '%s', expected is '%s'." % (header['url'], xm_test['url'])) # Create another domain try: # XmTestAPIDomain tries to establish a connection to XenD domain = XmTestAPIDomain(extraConfig={'security_label': vm_label_blue}) except Exception, e: SKIP("Skipping test. Error: %s" % str(e)) vm_uuid = domain.get_uuid() res = session.xenapi.VM.get_security_label(vm_uuid) if res != vm_label_blue: FAIL("VM has security label '%s', expected is '%s'" % (res, vm_label_blue)) try: domain.start(noConsole=True) except: FAIL("Could not create domain") # Attempt to relabel the running domain ssidref = session.xenapi.VM.set_security_label(vm_uuid, vm_label_red, vm_label_blue) if int(ssidref) <= 0: FAIL("Could not relabel running domain to '%s'." % vm_label_red)
print "\n\npolicystate = %s" % policystate policystate = session.xenapi.XSPolicy.get_xspolicy() # # Create two non-conflicting domains and start them # try: # XmTestAPIDomain tries to establish a connection to XenD domain1 = XmTestAPIDomain(extraConfig={ 'security_label' : vm_label_red }) except Exception, e: SKIP("Skipping test. Error: %s" % str(e)) vm1_uuid = domain1.get_uuid() try: domain1.start(noConsole=True) except: FAIL("Could not start domain1") print "Domain 1 started" try: # XmTestAPIDomain tries to establish a connection to XenD domain2 = XmTestAPIDomain(extraConfig={'security_label': vm_label_green }) except Exception, e: SKIP("Skipping test. Error: %s" % str(e)) vm2_uuid = domain2.get_uuid()
# 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]:
True) print "\n\npolicystate = %s" % policystate policystate = session.xenapi.XSPolicy.get_xspolicy() # # Create two non-conflicting domains and start them # try: # XmTestAPIDomain tries to establish a connection to XenD domain1 = XmTestAPIDomain(extraConfig={'security_label': vm_label_red}) except Exception, e: SKIP("Skipping test. Error: %s" % str(e)) vm1_uuid = domain1.get_uuid() try: domain1.start(noConsole=True) except: FAIL("Could not start domain1") print "Domain 1 started" try: # XmTestAPIDomain tries to establish a connection to XenD domain2 = XmTestAPIDomain(extraConfig={'security_label': vm_label_green}) except Exception, e: SKIP("Skipping test. Error: %s" % str(e)) vm2_uuid = domain2.get_uuid()