Skip to content
Closed
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 @@ -38,6 +38,7 @@

import com.cloud.storage.Storage;
import com.cloud.utils.exception.CloudRuntimeException;
import com.vmware.vim25.HostDnsConfig;
import com.vmware.vim25.InvalidStateFaultMsg;
import com.vmware.vim25.RuntimeFaultFaultMsg;
import com.vmware.vim25.TaskInfo;
Expand Down Expand Up @@ -1177,24 +1178,34 @@ public boolean configureVm(Ternary<VirtualDevice, VirtualDeviceConfigSpecOperati
return false;
}

private String getHostFqdn(HostMO hostMO, String hostName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nvazquez I think, it is better to keep this method in HostMO.

public String getHostFqdn() {
        try {
             HostDnsConfig hostDnsConfig = getHostNetworkInfo().getDnsConfig();
             return String.format("%s.%s", hostDnsConfig.getHostName(), hostDnsConfig.getDomainName());
         } catch (Exception e) {
             s_logger.error("Could not get host FQDN for host: " + getHostName());
         }
         return null;
}

try {
HostDnsConfig hostDnsConfig = hostMO.getHostNetworkInfo().getDnsConfig();
return String.format("%s.%s", hostDnsConfig.getHostName(), hostDnsConfig.getDomainName());
} catch (Exception e) {
s_logger.error("Could not get host FQDN for host: " + hostName);
}
return null;
}

public Pair<String, Integer> getVncPort(String hostNetworkName) throws Exception {
HostMO hostMo = getRunningHost();
VmwareHypervisorHostNetworkSummary summary = hostMo.getHyperHostNetworkSummary(hostNetworkName);

VirtualMachineConfigInfo configInfo = getConfigInfo();
List<OptionValue> values = configInfo.getExtraConfig();

String hostKey = StringUtils.isNotBlank(summary.getHostIp()) ? summary.getHostIp() : getHostFqdn(hostMo, hostMo.getHostName());
if (values != null) {
for (OptionValue option : values) {
if (option.getKey().equals("RemoteDisplay.vnc.port")) {
String value = (String)option.getValue();
if (value != null) {
return new Pair<String, Integer>(summary.getHostIp(), Integer.parseInt(value));
return new Pair<String, Integer>(hostKey, Integer.parseInt(value));
}
}
}
}
return new Pair<String, Integer>(summary.getHostIp(), 0);
return new Pair<String, Integer>(hostKey, 0);
}

// vmdkDatastorePath: [datastore name] vmdkFilePath
Expand Down