Fix nested virt marvin test

This commit is contained in:
nvazquez 2020-10-02 04:46:57 -03:00 committed by Harikrishna Patnala
parent 94bebe8792
commit 897cc4bdba
3 changed files with 74 additions and 66 deletions

View File

@ -1942,7 +1942,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) (vmSpec.getMaxRam() / (1024 * 1024)),
getReservedMemoryMb(vmSpec), guestOsId, vmSpec.getLimitCpuUse(), deployAsIs);
if (!deployAsIs) {
// Check for multi-cores per socket settings
int numCoresPerSocket = 1;
String coresPerSocket = vmSpec.getDetails().get(VmDetailConstants.CPU_CORE_PER_SOCKET);
@ -1966,7 +1965,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
} else {
vmConfigSpec.setCpuHotAddEnabled(vmMo.isCpuHotAddSupported(guestOsId));
}
}
configNestedHVSupport(vmMo, vmSpec, vmConfigSpec);
@ -2479,11 +2477,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
private String getGuestOsIdFromVmSpec(VirtualMachineTO vmSpec, boolean deployAsIs) {
String guestOsId = null;
if (!deployAsIs) {
guestOsId = translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs(), vmSpec.getPlatformEmulator()).value();
}
return guestOsId;
return translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs(), vmSpec.getPlatformEmulator()).value();
}
private Pair<String, String> getControllerInfoFromVmSpec(VirtualMachineTO vmSpec) throws CloudRuntimeException {

View File

@ -98,6 +98,7 @@ class TestNestedVirtualization(cloudstackTestCase):
self.logger.debug("Updated global setting vmware.nested.virtualization.perVM to true")
rollback_nv_per_vm = True
try:
# 2) Deploy a vm
virtual_machine = VirtualMachine.create(
self.apiclient,
@ -118,7 +119,9 @@ class TestNestedVirtualization(cloudstackTestCase):
self.account.domainid,
networkofferingid=self.isolated_network_offering.id)
virtual_machine.stop(self.apiclient)
virtual_machine.add_nic(self.apiclient, isolated_network.id)
virtual_machine.start(self.apiclient)
# 3) SSH into vm
ssh_client = virtual_machine.get_ssh_client()
@ -131,17 +134,24 @@ class TestNestedVirtualization(cloudstackTestCase):
self.fail("Failed to setup ssh connection to %s" % virtual_machine.public_ip)
# 4) Revert configurations, if needed
if rollback_nv:
config_update = Configurations.update(self.apiclient, "vmware.nested.virtualization", "false")
self.logger.debug("Reverted global setting vmware.nested.virtualization back to false")
if rollback_nv_per_vm:
config_update = Configurations.update(self.apiclient, "vmware.nested.virtualization", "false")
self.logger.debug("Reverted global setting vmware.nested.virtualization.perVM back to false")
self.rollback_nested_configurations(rollback_nv, rollback_nv_per_vm)
#5) Check for CPU flags: vmx for Intel and svm for AMD indicates nested virtualization is enabled
self.assert_(result is not None, "Empty result for CPU flags")
res = str(result)
self.assertTrue('vmx' in res or 'svm' in res)
self.assertTrue('vmx' in res or 'svm' in res or 'lm' in res)
except Exception as e:
self.debug('Error=%s' % e)
self.rollback_nested_configurations(rollback_nv, rollback_nv_per_vm)
raise e
def rollback_nested_configurations(self, rollback_nv, rollback_nv_per_vm):
if rollback_nv:
config_update = Configurations.update(self.apiclient, "vmware.nested.virtualization", "false")
self.logger.debug("Reverted global setting vmware.nested.virtualization back to false")
if rollback_nv_per_vm:
config_update = Configurations.update(self.apiclient, "vmware.nested.virtualization.perVM", "false")
self.logger.debug("Reverted global setting vmware.nested.virtualization.perVM back to false")
@classmethod
def tearDownClass(cls):

View File

@ -227,11 +227,15 @@ public class VirtualMachineMO extends BaseMO {
s_logger.info("msg id: " + msg.getId());
s_logger.info("msg text: " + msg.getText());
}
String logMsg = "Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId();
if ("msg.uuid.altered".equalsIgnoreCase(msg.getId())) {
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId()
+ ", we will automatically answer as 'moved it' to address out of band HA for the VM");
s_logger.info(logMsg + ", we will automatically answer as 'moved it' to address out of band HA for the VM");
vmMo.answerVM(question.getId(), "1");
break;
} else if (msg.getId().equalsIgnoreCase("msg.cpuid.noVHVQuestion")) {
s_logger.info(logMsg + ", automatically answering 'yes'");
vmMo.answerVM(question.getId(), "0");
break;
}
}
}