Skip to content

Commit 687e87f

Browse files
committed
CLOUDSTACK-4529: use property collector to collect all information in one round
1 parent 8e350cb commit 687e87f

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • vmware-base/src/com/cloud/hypervisor/vmware/mo

‎vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.vmware.vim25.AlreadyExistsFaultMsg;
3636
import com.vmware.vim25.ClusterDasConfigInfo;
3737
import com.vmware.vim25.ComputeResourceSummary;
38+
import com.vmware.vim25.CustomFieldStringValue;
3839
import com.vmware.vim25.DatastoreSummary;
3940
import com.vmware.vim25.DynamicProperty;
4041
import com.vmware.vim25.HostConfigManager;
@@ -577,8 +578,14 @@ public boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception {
577578
}
578579

579580
public HashMap<String, Integer> getVmVncPortsOnHost() throws Exception {
581+
582+
int key = getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
583+
if(key == 0) {
584+
s_logger.warn("Custom field " + CustomFieldConstants.CLOUD_VM_INTERNAL_NAME + " is not registered ?!");
585+
}
586+
580587
ObjectContent[] ocs = getVmPropertiesOnHyperHost(
581-
new String[] { "name", "config.extraConfig[\"RemoteDisplay.vnc.port\"]" }
588+
new String[] { "name", "config.extraConfig[\"RemoteDisplay.vnc.port\"]", "value[" + key + "]" }
582589
);
583590

584591
HashMap<String, Integer> portInfo = new HashMap<String, Integer>();
@@ -592,14 +599,15 @@ public HashMap<String, Integer> getVmVncPortsOnHost() throws Exception {
592599
for(DynamicProperty objProp : objProps) {
593600
if(objProp.getName().equals("name")) {
594601
vmName = (String)objProp.getVal();
602+
} else if(objProp.getName().startsWith("value[")) {
603+
if(objProp.getVal() != null)
604+
vmInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue();
595605
} else {
596606
OptionValue optValue = (OptionValue)objProp.getVal();
597607
value = (String)optValue.getValue();
598608
}
599609
}
600-
VirtualMachineMO vmMo = new VirtualMachineMO(_context, oc.getObj());
601-
// Check if vmMo has the custom property CLOUD_VM_INTERNAL_NAME set.
602-
vmInternalCSName = vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
610+
603611
if (vmInternalCSName != null && isUserVMInternalCSName(vmInternalCSName))
604612
vmName = vmInternalCSName;
605613

0 commit comments

Comments
 (0)