use of com.vmware.vim25.HostVirtualNic in project coprhd-controller by CoprHD.
the class EsxHostDiscoveryAdapter method discoverConnectedHostInitiators.
/**
* Discovers connected Host's Initiators and Ipinterfaces
*
* @param hostSystem
* - {@link HostSystem} VI SDK managedObject instance
* @param targetHost
* - {@link Host} being discovered.
* @param oldInitiators
* - old initiator list
* @param addedInitiators
* - new/added initiator list
*/
protected void discoverConnectedHostInitiators(HostSystem hostSystem, Host targetHost, List<Initiator> oldInitiators, List<Initiator> addedInitiators) {
// discover ipInterfaces
info(String.format("Discovering IP interfaces for %s", targetHost.forDisplay()));
List<IpInterface> oldIpInterfaces = new ArrayList<IpInterface>();
Iterables.addAll(oldIpInterfaces, getIpInterfaces(targetHost));
for (HostVirtualNic nic : getNics(hostSystem)) {
if (isIp6Interface(nic)) {
IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, nic.spec.getIp().ipAddress);
discoverIp6Interface(targetHost, ipInterface, nic);
}
if (isIp4Interface(nic)) {
IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, nic.spec.getIp().ipAddress);
discoverIp4Interface(targetHost, ipInterface, nic);
}
}
removeDiscoveredInterfaces(oldIpInterfaces);
info(String.format("Discovering initiators for %s", targetHost.forDisplay()));
Iterables.addAll(oldInitiators, getInitiators(targetHost));
for (HostHostBusAdapter hba : getHostBusAdapters(hostSystem)) {
if (hba instanceof HostFibreChannelHba) {
String port = SanUtils.normalizeWWN(((HostFibreChannelHba) hba).getPortWorldWideName());
Initiator initiator;
if (findInitiatorByPort(oldInitiators, port) == null) {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, port);
addedInitiators.add(initiator);
} else {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, port);
}
discoverInitiator(targetHost, initiator, (HostFibreChannelHba) hba);
} else if (hba instanceof HostInternetScsiHba) {
String iqn = ((HostInternetScsiHba) hba).getIScsiName();
Initiator initiator;
if (findInitiatorByPort(oldInitiators, iqn) == null) {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, iqn);
addedInitiators.add(initiator);
} else {
initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, iqn);
}
discoverInitiator(targetHost, initiator, (HostInternetScsiHba) hba);
}
}
if (!oldInitiators.isEmpty()) {
clearScaleIOInitiators(oldInitiators);
}
}
use of com.vmware.vim25.HostVirtualNic in project CloudStack-archive by CloudStack-extras.
the class HostMO method getHyperHostNetworkSummary.
@Override
public VmwareHypervisorHostNetworkSummary getHyperHostNetworkSummary(String managementPortGroup) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.get_value() + ", mgmtPortgroup: " + managementPortGroup);
VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
if (this.getHostType() == VmwareHostType.ESXi) {
VirtualNicManagerNetConfig[] netConfigs = (VirtualNicManagerNetConfig[]) _context.getServiceUtil().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
assert (netConfigs != null);
for (int i = 0; i < netConfigs.length; i++) {
if (netConfigs[i].getNicType().equals("management")) {
for (HostVirtualNic nic : netConfigs[i].getCandidateVnic()) {
if (nic.getPortgroup().equals(managementPortGroup)) {
summary.setHostIp(nic.getSpec().getIp().getIpAddress());
summary.setHostNetmask(nic.getSpec().getIp().getSubnetMask());
summary.setHostMacAddress(nic.getSpec().getMac());
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary() done(successfully)");
return summary;
}
}
}
}
} else {
// try with ESX path
HostVirtualNic[] hostVNics = (HostVirtualNic[]) _context.getServiceUtil().getDynamicProperty(_mor, "config.network.consoleVnic");
if (hostVNics != null) {
for (HostVirtualNic vnic : hostVNics) {
if (vnic.getPortgroup().equals(managementPortGroup)) {
summary.setHostIp(vnic.getSpec().getIp().getIpAddress());
summary.setHostNetmask(vnic.getSpec().getIp().getSubnetMask());
summary.setHostMacAddress(vnic.getSpec().getMac());
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary() done(successfully)");
return summary;
}
}
}
}
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary() done(failed)");
throw new Exception("Uanble to find management port group " + managementPortGroup);
}
use of com.vmware.vim25.HostVirtualNic in project CloudStack-archive by CloudStack-extras.
the class HostMO method getPortGroupNameByNicType.
public String getPortGroupNameByNicType(HostVirtualNicType nicType) throws Exception {
assert (nicType != null);
VirtualNicManagerNetConfig[] netConfigs = (VirtualNicManagerNetConfig[]) _context.getServiceUtil().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
if (netConfigs != null) {
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
if (netConfig.getNicType().equals(nicType.toString())) {
HostVirtualNic[] nics = netConfig.getCandidateVnic();
if (nics != null) {
for (HostVirtualNic nic : nics) {
return nic.getPortgroup();
}
}
}
}
}
if (nicType == HostVirtualNicType.management) {
// ESX management network is configured in service console
HostNetworkInfo netInfo = getHostNetworkInfo();
assert (netInfo != null);
HostVirtualNic[] nics = netInfo.getConsoleVnic();
if (nics != null) {
for (HostVirtualNic nic : nics) {
return nic.getPortgroup();
}
}
}
return null;
}
use of com.vmware.vim25.HostVirtualNic in project opennms by OpenNMS.
the class VmwareViJavaAccess method getHostSystemIpAddresses.
/**
* Searches for all ip addresses of a host system
*
* @param hostSystem the host system to query
* @return the ip addresses of the host system, the first one is the primary
*/
public TreeSet<String> getHostSystemIpAddresses(HostSystem hostSystem) {
TreeSet<String> ipAddresses = new TreeSet<String>();
HostNetworkSystem hostNetworkSystem = null;
try {
hostNetworkSystem = hostSystem.getHostNetworkSystem();
} catch (RemoteException e) {
logger.warn("Error fetching network information for Host System '{}' (ID: {})", hostSystem.getName(), hostSystem.getMOR().getVal());
logger.warn("Exception thrown while fetching network information: {}", e);
return ipAddresses;
}
if (hostNetworkSystem != null) {
HostNetworkInfo hostNetworkInfo = hostNetworkSystem.getNetworkInfo();
if (hostNetworkInfo != null) {
HostVirtualNic[] hostVirtualNics = hostNetworkInfo.getConsoleVnic();
if (hostVirtualNics != null) {
for (HostVirtualNic hostVirtualNic : hostVirtualNics) {
ipAddresses.add(hostVirtualNic.getSpec().getIp().getIpAddress());
}
}
hostVirtualNics = hostNetworkInfo.getVnic();
if (hostVirtualNics != null) {
for (HostVirtualNic hostVirtualNic : hostVirtualNics) {
ipAddresses.add(hostVirtualNic.getSpec().getIp().getIpAddress());
}
}
}
}
return ipAddresses;
}
use of com.vmware.vim25.HostVirtualNic in project cloudstack by apache.
the class HostMO method getPortGroupNameByNicType.
public String getPortGroupNameByNicType(HostVirtualNicType nicType) throws Exception {
assert (nicType != null);
List<VirtualNicManagerNetConfig> netConfigs = _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
if (netConfigs != null) {
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
if (netConfig.getNicType().equals(nicType.toString())) {
List<HostVirtualNic> nics = netConfig.getCandidateVnic();
if (nics != null) {
for (HostVirtualNic nic : nics) {
return nic.getPortgroup();
}
}
}
}
}
if (nicType == HostVirtualNicType.management) {
// ESX management network is configured in service console
HostNetworkInfo netInfo = getHostNetworkInfo();
assert (netInfo != null);
List<HostVirtualNic> nics = netInfo.getConsoleVnic();
if (nics != null) {
for (HostVirtualNic nic : nics) {
return nic.getPortgroup();
}
}
}
return null;
}
Aggregations