Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5253,7 +5253,7 @@ public static String createDatastoreNameFromIqn(String iqn) {
protected AttachIsoAnswer execute(AttachIsoCommand cmd) {
try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
VirtualMachineMO vmMo = HypervisorHostHelper.findVmOnHypervisorHostOrPeer(hyperHost, cmd.getVmName());
if (vmMo == null) {
String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + cmd.getVmName();
s_logger.error(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ private Answer attachIso(DiskTO disk, boolean isAttach, String vmName, boolean f
try {
VmwareContext context = hostService.getServiceContext(null);
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
VirtualMachineMO vmMo = HypervisorHostHelper.findVmOnHypervisorHostOrPeer(hyperHost, vmName);
if (vmMo == null) {
String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + vmName;
s_logger.error(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2340,4 +2340,15 @@ public static String getMinimumHostHardwareVersion(VmwareHypervisorHost host1, V
}
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;
}
}