def test_0060_vm_power_operations(self): """Test the method related to power operations in vm.py. This test passes if all the power operations are successful. """ logger = Environment.get_default_logger() vm_name = TestVM._test_vapp_first_vm_name vm = VM(client=TestVM._client, href=TestVM._test_vapp_first_vm_href) # make sure the vm is powered on before running tests logger.debug('Making sure vm ' + vm_name + ' is powered on.') if vm.is_suspended(): task = vm.deploy() TestVM._client.get_task_monitor().wait_for_success(task=task) vm.reload() if not vm.is_powered_on(): task = vm.power_on() TestVM._client.get_task_monitor().wait_for_success(task=task) vm.reload() logger.debug('Un-deploying vm ' + vm_name) task = vm.undeploy() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Deploying vm ' + vm_name) vm.reload() task = vm.deploy(power_on=False) result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering on vm ' + vm_name) vm.reload() task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Reseting (power) vm ' + vm_name) vm.reload() task = vm.power_reset() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering off vm ' + vm_name) vm.reload() task = vm.power_off() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering back on vm ' + vm_name) vm.reload() task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
def test_0060_vm_power_operations(self): """Test the method related to power operations in vm.py. This test passes if all the power operations are successful. """ logger = Environment.get_default_logger() vm_name = TestVM._test_vapp_first_vm_name vm = VM(client=TestVM._client, href=TestVM._test_vapp_first_vm_href) # make sure the vm is powered on before running tests logger.debug('Making sure vm ' + vm_name + ' is powered on.') if vm.is_suspended(): task = vm.deploy() TestVM._client.get_task_monitor().wait_for_success(task=task) vm.reload() if not vm.is_powered_on(): task = vm.power_on() TestVM._client.get_task_monitor().wait_for_success(task=task) vm.reload() logger.debug('Un-deploying vm ' + vm_name) task = vm.undeploy() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Deploying vm ' + vm_name) vm.reload() task = vm.deploy(power_on=False) result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering on vm ' + vm_name) vm.reload() task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Reseting (power) vm ' + vm_name) vm.reload() task = vm.power_reset() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering off vm ' + vm_name) vm.reload() task = vm.power_off() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering back on vm ' + vm_name) vm.reload() task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Suspend a vm ' + vm_name) vm.reload() task = vm.suspend() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Discard suspended state of a vm ' + vm_name) vm.reload() if vm.is_suspended(): task = vm.discard_suspended_state() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering back on vm ' + vm_name) vm.reload() if not vm.is_powered_on(): task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
def test_0060_vm_power_operations(self): """Test the method related to power operations in vm.py. This test passes if all the power operations are successful. """ logger = Environment.get_default_logger() vm_name = TestVM._test_vapp_first_vm_name vm = VM(client=TestVM._client, href=TestVM._test_vapp_first_vm_href) # make sure the vm is powered on before running tests logger.debug('Making sure vm ' + vm_name + ' is powered on.') if vm.is_suspended(): task = vm.deploy() TestVM._client.get_task_monitor().wait_for_success(task=task) vm.reload() if not vm.is_powered_on(): task = vm.power_on() TestVM._client.get_task_monitor().wait_for_success(task=task) vm.reload() logger.debug('Un-deploying vm ' + vm_name) task = vm.undeploy() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Deploying vm ' + vm_name) vm.reload() task = vm.deploy(power_on=False) result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering on vm ' + vm_name) vm.reload() task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Reseting (power) vm ' + vm_name) vm.reload() task = vm.power_reset() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering off vm ' + vm_name) vm.reload() task = vm.power_off() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) logger.debug('Powering back on vm ' + vm_name) vm.reload() task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) # discard suspend state sometime show inconsistent behavior and puts # VM in partially suspended state. Commenting theis scenerio to avoid # this failure. # logger.debug('Suspend a vm ' + vm_name) # vm.reload() # task = vm.suspend() # result = TestVM._client.get_task_monitor().wait_for_success(task) # self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) # logger.debug('Discard suspended state of a vm ' + vm_name) # vm.reload() # if vm.is_suspended(): # task = vm.discard_suspended_state() # result = TestVM._client.get_task_monitor().wait_for_success(task) # self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) # logger.debug('Powering back on vm ' + vm_name) vm.reload() if not vm.is_powered_on(): task = vm.power_on() result = TestVM._client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)