use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary in project cloudstack by apache.
the class VmwareResource method fillHostNetworkInfo.
private void fillHostNetworkInfo(VmwareContext serviceContext, StartupRoutingCommand cmd) throws RuntimeFaultFaultMsg, RemoteException {
try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
assert (hyperHost instanceof HostMO);
VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
VmwareHypervisorHostNetworkSummary summary = hyperHost.getHyperHostNetworkSummary(mgr.getManagementPortGroupByHost((HostMO) hyperHost));
if (summary == null) {
throw new Exception("No ESX(i) host found");
}
if (s_logger.isInfoEnabled()) {
s_logger.info("Startup report on host network info. " + _gson.toJson(summary));
}
cmd.setPrivateIpAddress(summary.getHostIp());
cmd.setPrivateNetmask(summary.getHostNetmask());
cmd.setPrivateMacAddress(summary.getHostMacAddress());
cmd.setStorageIpAddress(summary.getHostIp());
cmd.setStorageNetmask(summary.getHostNetmask());
cmd.setStorageMacAddress(summary.getHostMacAddress());
} catch (Throwable e) {
String msg = "querying host network info failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(msg, e);
throw new CloudRuntimeException(msg);
}
}
use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary in project cloudstack by apache.
the class VmwareResource method getTargetHyperHost.
private VmwareHypervisorHost getTargetHyperHost(DatacenterMO dcMo, String destIp) throws Exception {
VmwareManager mgr = dcMo.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
List<ObjectContent> ocs = dcMo.getHostPropertiesOnDatacenterHostFolder(new String[] { "name", "parent" });
if (ocs != null && ocs.size() > 0) {
for (ObjectContent oc : ocs) {
HostMO hostMo = new HostMO(dcMo.getContext(), oc.getObj());
VmwareHypervisorHostNetworkSummary netSummary = hostMo.getHyperHostNetworkSummary(mgr.getManagementPortGroupByHost(hostMo));
if (destIp.equalsIgnoreCase(netSummary.getHostIp())) {
return new HostMO(dcMo.getContext(), oc.getObj());
}
}
}
throw new Exception("Unable to locate dest host by " + destIp);
}
use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary in project cloudstack by apache.
the class VmwareSecondaryStorageResourceHandler method getHyperHost.
@Override
public VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd) {
String guid = cmd.getContextParam("guid");
assert (guid != null);
String[] tokens = guid.split("@");
assert (tokens != null && tokens.length == 2);
ManagedObjectReference morHyperHost = new ManagedObjectReference();
String[] hostTokens = tokens[0].split(":");
if (hostTokens == null || hostTokens.length != 2) {
s_logger.error("Invalid content in command context parameter guid");
return null;
}
morHyperHost.setType(hostTokens[0]);
morHyperHost.setValue(hostTokens[1]);
if (morHyperHost.getType().equalsIgnoreCase("HostSystem")) {
HostMO hostMo = new HostMO(context, morHyperHost);
try {
ManagedObjectReference mor = hostMo.getHyperHostCluster();
ClusterMO clusterMo = new ClusterMO(hostMo.getContext(), mor);
List<Pair<ManagedObjectReference, String>> hostsInCluster = clusterMo.getClusterHosts();
for (Pair<ManagedObjectReference, String> hostPair : hostsInCluster) {
HostMO hostIteratorMo = new HostMO(hostMo.getContext(), hostPair.first());
VmwareHypervisorHostNetworkSummary netSummary = hostIteratorMo.getHyperHostNetworkSummary(hostIteratorMo.getHostType() == VmwareHostType.ESXi ? cmd.getContextParam("manageportgroup") : cmd.getContextParam("serviceconsole"));
_resource.ensureOutgoingRuleForAddress(netSummary.getHostIp());
s_logger.info("Setup firewall rule for host: " + netSummary.getHostIp());
}
} catch (Throwable e) {
s_logger.warn("Unable to retrive host network information due to exception " + e.toString() + ", host: " + hostTokens[0] + "-" + hostTokens[1]);
}
return hostMo;
}
assert (false);
return new ClusterMO(context, morHyperHost);
}
Aggregations