mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
vmware,cks: fix attachiso failure with vmware drs (#6625)
Fixes #4314 Failure in attaching k8s ISO is seen when VMware DRS is enabled. Log reported VM is not found. This fix tries to find VM on peer hosts when the VM is not found on the given host. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
a5716d964a
commit
770df60bbe
@ -5253,7 +5253,7 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
|
|||||||
protected AttachIsoAnswer execute(AttachIsoCommand cmd) {
|
protected AttachIsoAnswer execute(AttachIsoCommand cmd) {
|
||||||
try {
|
try {
|
||||||
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
|
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
|
||||||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
|
VirtualMachineMO vmMo = HypervisorHostHelper.findVmOnHypervisorHostOrPeer(hyperHost, cmd.getVmName());
|
||||||
if (vmMo == null) {
|
if (vmMo == null) {
|
||||||
String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + cmd.getVmName();
|
String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + cmd.getVmName();
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
|
|||||||
@ -2341,7 +2341,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
|||||||
try {
|
try {
|
||||||
VmwareContext context = hostService.getServiceContext(null);
|
VmwareContext context = hostService.getServiceContext(null);
|
||||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
|
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
|
||||||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
|
VirtualMachineMO vmMo = HypervisorHostHelper.findVmOnHypervisorHostOrPeer(hyperHost, vmName);
|
||||||
if (vmMo == null) {
|
if (vmMo == null) {
|
||||||
String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + vmName;
|
String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + vmName;
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
|
|||||||
@ -2340,4 +2340,15 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
return hardwareVersion;
|
return hardwareVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static VirtualMachineMO findVmOnHypervisorHostOrPeer(VmwareHypervisorHost hypervisorHost, String vmName) throws Exception {
|
||||||
|
VirtualMachineMO vmMo = hypervisorHost.findVmOnHyperHost(vmName);
|
||||||
|
if (vmMo == null) {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("Unable to find the VM on host %s, try within datacenter", hypervisorHost.getHyperHostName()));
|
||||||
|
}
|
||||||
|
vmMo = hypervisorHost.findVmOnPeerHyperHost(vmName);
|
||||||
|
}
|
||||||
|
return vmMo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user