示例#1
0
 def test_get_vm_power_status(self):
     """Retrieve virtual machine power status; return power status object."""
     vm_name = 'test'
     vm = SpokeVMPowerXen(self.hv_uri, vm_name)
     result = vm.get()['data'][0]['state']
     expected_result = 'On'
     self.assertEquals(result, expected_result)
示例#2
0
文件: vm.py 项目: mattmb/spoke
def power_modify(vm_name, state):
    from spoke.lib.vm_power import SpokeVMPowerXen
    vmp = SpokeVMPowerXen(hv_uri, vm_name)
    try:
        result = vmp.modify(state)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result    
示例#3
0
文件: vm.py 项目: mattmb/spoke
def power_search(vm_name):
    from spoke.lib.vm_power import SpokeVMPowerXen
    vmp = SpokeVMPowerXen(hv_uri, vm_name)
    try:
        result = vmp.get()
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result    
示例#4
0
文件: vm.py 项目: KrisSaxton/spoke
def power_modify(vm_name, state):
    try:
        conf = _spoke_config(_salt_config('config'))
        hv_uri = conf.get('VM', 'hv_uri')
        vmp = SpokeVMPowerXen(hv_uri, vm_name)
        result = vmp.modify(state)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
示例#5
0
文件: vm.py 项目: KrisSaxton/spoke
def power_delete(vm_name, force=False):
    try:
        conf = _spoke_config(_salt_config('config'))
        hv_uri = conf.get('VM', 'hv_uri')
        vmp = SpokeVMPowerXen(hv_uri, vm_name)
        result = vmp.delete(force=force)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
示例#6
0
 def test_force_poweroff_vm(self):
     """Force power off a running virtual machine object; return True"""
     vm_name = 'test'
     vm = SpokeVMPowerXen(self.hv_uri, vm_name)
     self.assertTrue(vm.delete(force=True))
示例#7
0
 def test_poweroff_stopped_vm(self):
     """Power off a non-running virtual machine object; raise VMStopped"""
     vm_name = 'test'
     vm = SpokeVMPowerXen(self.hv_uri, vm_name)
     vm.delete()
     self.assertRaises(error.VMStopped, vm.delete)
示例#8
0
 def test_poweron_vm_twice(self):
     """Power on a running virtual machine object; raise VMRunning"""
     vm_name = 'test'
     vm = SpokeVMPowerXen(self.hv_uri, vm_name)
     self.assertRaises(error.VMRunning, vm.create)