Github user rafaelweingartner commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1560#discussion_r64607461 --- Diff: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java --- @@ -5510,6 +5501,27 @@ public Answer execute(DestroyCommand cmd) { } } + /** + * Use data center to look for vm, instead of randomly picking up a cluster<br/> + * (in multiple cluster environments vm could not be found if wrong cluster was chosen) + * @param context vmware context + * @param hyperHost vmware hv host + * @param vol volume + * @return a virtualmachinemo if could be found on datacenter + * @throws Exception if there is an error while finding vm + * @throws CloudRuntimeException if datacenter cannot be found + */ + protected VirtualMachineMO findVmOnDatacenter(VmwareContext context, VmwareHypervisorHost hyperHost, VolumeTO vol) throws Exception { + DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter()); + if (dcMo.getMor() == null) { + String msg = "Unable to find VMware DC"; + s_logger.error(msg); + throw new CloudRuntimeException(msg); + } + VirtualMachineMO vmMo = dcMo.findVm(vol.getPath()); --- End diff -- What about using here: `return dcMo.findVm(vol.getPath());` then, we could save 1 line of code ;)
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---