def test_09_expunge_vm(self): """Test destroy(expunge) Virtual Machine """ # Validate the following # 1. listVM command should NOT return this VM any more. self.debug("Expunge VM-ID: %s" % self.small_virtual_machine.id) cmd = destroyVirtualMachine.destroyVirtualMachineCmd() cmd.id = self.small_virtual_machine.id self.apiclient.destroyVirtualMachine(cmd) config = list_configurations( self.apiclient, name='expunge.delay' ) expunge_delay = int(config[0].value) time.sleep(expunge_delay * 2) #VM should be destroyed unless expunge thread hasn't run #Wait for two cycles of the expunge thread config = list_configurations( self.apiclient, name='expunge.interval' ) expunge_cycle = int(config[0].value) wait_time = expunge_cycle * 2 while wait_time >= 0: list_vm_response = list_virtual_machines( self.apiclient, id=self.small_virtual_machine.id ) if list_vm_response: time.sleep(expunge_cycle) wait_time = wait_time - expunge_cycle else: break self.debug("listVirtualMachines response: %s" % list_vm_response) self.assertEqual( list_vm_response, None, "Check Expunged virtual machine is in listVirtualMachines response" ) return
def test_09_expunge_vm(self): """Test destroy(expunge) Virtual Machine """ # Validate the following # 1. listVM command should NOT return this VM any more. self.debug("Expunge VM-ID: %s" % self.small_virtual_machine.id) cmd = destroyVirtualMachine.destroyVirtualMachineCmd() cmd.id = self.small_virtual_machine.id self.apiclient.destroyVirtualMachine(cmd) config = list_configurations(self.apiclient, name='expunge.delay') expunge_delay = int(config[0].value) time.sleep(expunge_delay * 2) #VM should be destroyed unless expunge thread hasn't run #Wait for two cycles of the expunge thread config = list_configurations(self.apiclient, name='expunge.interval') expunge_cycle = int(config[0].value) wait_time = expunge_cycle * 2 while wait_time >= 0: list_vm_response = list_virtual_machines( self.apiclient, id=self.small_virtual_machine.id) if list_vm_response: time.sleep(expunge_cycle) wait_time = wait_time - expunge_cycle else: break self.debug("listVirtualMachines response: %s" % list_vm_response) self.assertEqual( list_vm_response, None, "Check Expunged virtual machine is in listVirtualMachines response" ) return