def clear(self):
        """Remove all the VMs, disks and images """
        request = GetResourcesRequest()
        response = rpc_call(self.host_client.get_resources, request)
        assert_that(response.result, is_(GetResourcesResultCode.OK))
        for resource in response.resources:
            delete_request = Host.DeleteVmRequest(vm_id=resource.vm.id,
                                                  force=True)
            response = rpc_call(self.host_client.delete_vm, delete_request)

            if response.result == DeleteVmResultCode.VM_NOT_POWERED_OFF:
                poweroff_request = Host.PowerVmOpRequest(vm_id=resource.vm.id,
                                                         op=Host.PowerVmOp.OFF)
                response = rpc_call(self.host_client.power_vm_op,
                                    poweroff_request)
                assert_that(response.result, is_(PowerVmOpResultCode.OK))
                response = rpc_call(self.host_client.delete_vm, delete_request)

            if response.result != DeleteVmResultCode.OK:
                logger.info("Cannot delete vm %s trying vim_client" %
                            resource.vm.id)
                self.vim_delete_vm(resource.vm.id)
        self.clean_images()
 def power_request(self, op):
     return Host.PowerVmOpRequest(vm_id=self.id, op=op)