Merge remote-tracking branch 'apache/4.18'

This commit is contained in:
Abhishek Kumar 2023-12-21 20:55:38 +05:30
commit 26214ea139
2 changed files with 35 additions and 6 deletions

View File

@ -602,7 +602,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
protected void advanceExpunge(VMInstanceVO vm) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
if (vm == null || vm.getRemoved() != null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find vm or vm is destroyed: " + vm);
s_logger.debug("Unable to find vm or vm is expunged: " + vm);
}
return;
}
@ -612,17 +612,17 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
try {
if (!stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, vm.getHostId())) {
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm);
throw new CloudRuntimeException("Unable to destroy " + vm);
s_logger.debug("Unable to expunge the vm because it is not in the correct state: " + vm);
throw new CloudRuntimeException("Unable to expunge " + vm);
}
} catch (final NoTransitionException e) {
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm);
throw new CloudRuntimeException("Unable to destroy " + vm, e);
s_logger.debug("Unable to expunge the vm because it is not in the correct state: " + vm);
throw new CloudRuntimeException("Unable to expunge " + vm, e);
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Destroying vm " + vm);
s_logger.debug("Expunging vm " + vm);
}
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);

View File

@ -1011,8 +1011,37 @@ class TestSecuredVmMigration(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
if cls.hypervisor.lower() in ["kvm"]:
cls.ensure_all_hosts_are_up()
super(TestSecuredVmMigration, cls).tearDownClass()
@classmethod
def ensure_all_hosts_are_up(cls):
hosts = Host.list(
cls.apiclient,
zoneid=cls.zone.id,
type='Routing',
hypervisor='KVM'
)
for host in hosts:
if host.state != "Up":
SshClient(host.ipaddress, port=22, user=cls.hostConfig["username"], passwd=cls.hostConfig["password"]) \
.execute("service cloudstack-agent stop ; \
sleep 10 ; \
service cloudstack-agent start")
interval = 5
retries = 10
while retries > -1:
time.sleep(interval)
restarted_host = Host.list(
cls.apiclient,
hostid=host.id,
type='Routing'
)[0]
if restarted_host.state == "Up":
break
retries = retries - 1
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()