ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
assert(hosts != null);
// For ESX host, we need to enable host firewall to allow VNC access
HostMO hostMo = new HostMO(serviceContext, hosts[0]);
HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
if(firewallMo != null) {
if(hostMo.getHostType() == VmwareHostType.ESX) {
firewallMo.enableRuleset("vncServer");
firewallMo.refreshFirewall();
}
}
// prepare at least one network on the vswitch to enable OVF importing
String vlanId = null;
if(privateTrafficLabel != null) {
String[] tokens = privateTrafficLabel.split(",");
if(tokens.length == 2)
vlanId = tokens[1];
}
if(!_nexusVSwitchActive) {
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
}
else {
s_logger.info("Preparing Network on " + privateTrafficLabel);
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
}
returnedHostList.add(hosts[0]);
return returnedHostList;
} else if(mor.getType().equals("ClusterComputeResource")) {
ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
assert(hosts != null);
if(hosts.length > _maxHostsPerCluster) {
String msg = "vCenter cluster size is too big (current configured cluster size: " + _maxHostsPerCluster + ")";
s_logger.error(msg);
throw new DiscoveredWithErrorException(msg);
}
for(ManagedObjectReference morHost: hosts) {
// For ESX host, we need to enable host firewall to allow VNC access
HostMO hostMo = new HostMO(serviceContext, morHost);
HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
if(firewallMo != null) {
if(hostMo.getHostType() == VmwareHostType.ESX) {
firewallMo.enableRuleset("vncServer");
firewallMo.refreshFirewall();
}
}
String vlanId = null;
if(privateTrafficLabel != null) {
String[] tokens = privateTrafficLabel.split(",");
if(tokens.length == 2)
vlanId = tokens[1];
}
s_logger.info("Calling prepareNetwork : " + hostMo.getContext().toString());
// prepare at least one network on the vswitch to enable OVF importing
if(!_nexusVSwitchActive) {
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
}
else {
s_logger.info("Preparing Network on " + privateTrafficLabel);
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
}
returnedHostList.add(morHost);
}
return returnedHostList;
} else if(mor.getType().equals("HostSystem")) {
// For ESX host, we need to enable host firewall to allow VNC access
HostMO hostMo = new HostMO(serviceContext, mor);
HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
if(firewallMo != null) {
if(hostMo.getHostType() == VmwareHostType.ESX) {
firewallMo.enableRuleset("vncServer");
firewallMo.refreshFirewall();
}
}
String vlanId = null;
if(privateTrafficLabel != null) {