use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class AixVioDiscoveryAdapter method discoverInitiators.
@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
AixVioCLI cli = getCli(host);
List<Initiator> addedInitiators = Lists.newArrayList();
try {
for (HBAInfo hba : cli.listInitiators()) {
Initiator initiator;
String wwpn = SanUtils.normalizeWWN(hba.getWwpn());
if (findInitiatorByPort(oldInitiators, wwpn) == null) {
initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
addedInitiators.add(initiator);
} else {
initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
}
discoverFCInitiator(host, initiator, hba);
}
} catch (DeviceControllerException e) {
throw e;
} catch (Exception e) {
LOG.error("Failed to list FC Ports, skipping");
}
try {
for (String iqn : cli.listIQNs()) {
Initiator initiator;
if (findInitiatorByPort(oldInitiators, iqn) == null) {
initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
addedInitiators.add(initiator);
} else {
initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
}
discoverISCSIInitiator(host, initiator, iqn);
}
} catch (DeviceControllerException e) {
throw e;
} catch (Exception e) {
LOG.error("Failed to list iSCSI Ports, skipping");
}
// update export groups with new initiators if host is in use.
if (!addedInitiators.isEmpty()) {
Collection<URI> addedInitiatorIds = Lists.newArrayList(Collections2.transform(addedInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
changes.setNewInitiators(addedInitiatorIds);
}
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class EsxHostDiscoveryAdapter method discoverHost.
/**
* Discover Exs host and its IpIterfaces and Initiators.
*
* @param hostSystem
* - {@link HostSystem} VI SDK managedObject instance
* @param targetHost
* - {@link Host} being discovered.
* @param changes
* {@link HostStateChange} instance containing host changes
* during discovery.
*/
private void discoverHost(HostSystem hostSystem, Host targetHost, HostStateChange changes) {
// Only attempt to update ip interfaces or initiators for connected
// hosts
HostSystemConnectionState connectionState = getConnectionState(hostSystem);
if (connectionState == HostSystemConnectionState.connected) {
// discover initiators
List<Initiator> oldInitiators = new ArrayList<Initiator>();
List<Initiator> addedInitiators = new ArrayList<Initiator>();
discoverConnectedHostInitiators(hostSystem, targetHost, oldInitiators, addedInitiators);
if (!oldInitiators.isEmpty() || !addedInitiators.isEmpty()) {
Collection<URI> oldInitiatorIds = Lists.newArrayList(Collections2.transform(oldInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
changes.setOldInitiators(oldInitiatorIds);
Collection<URI> addedInitiatorIds = Lists.newArrayList(Collections2.transform(addedInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
changes.setNewInitiators(addedInitiatorIds);
}
} else {
if (connectionState == HostSystemConnectionState.disconnected) {
throw new IllegalStateException("Host is disconnected");
} else if (connectionState == HostSystemConnectionState.notResponding) {
throw new IllegalStateException("Host is not responding");
} else {
throw new IllegalStateException("Could not determine host connection state");
}
}
}
use of com.emc.storageos.db.client.model.Initiator 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.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class UcsComputeDevice method getHBAToStoragePorts.
private Map<String, Map<String, Integer>> getHBAToStoragePorts(URI volumeId, URI hostId) {
Host host = _dbClient.queryObject(Host.class, hostId);
Map<String, String> initiatorToHBAMapping = getInitiatorToHBAMapping(host.getComputeElement());
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
List<Initiator> initiators = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, hostId, Initiator.class, "host");
Map<ExportMask, ExportGroup> exportMasks = ExportUtils.getExportMasks(volume, _dbClient);
Map<String, Map<String, Integer>> hbaToStoragePortMapForBoot = new HashMap<String, Map<String, Integer>>();
for (Initiator initiator : initiators) {
for (ExportMask exportMask : exportMasks.keySet()) {
List<URI> storagePorts = ExportUtils.getInitiatorPortsInMask(exportMask, initiator, _dbClient);
if (storagePorts != null && !storagePorts.isEmpty()) {
Integer volumeHLU = Integer.valueOf(exportMask.getVolumes().get(volumeId.toString()));
for (URI storagePortUri : storagePorts) {
StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortUri);
String hbaName = initiatorToHBAMapping.get(initiator.getInitiatorPort());
if (hbaName != null) {
if (hbaToStoragePortMapForBoot.get(hbaName) == null) {
hbaToStoragePortMapForBoot.put(hbaName, new HashMap<String, Integer>());
}
hbaToStoragePortMapForBoot.get(hbaName).put(port.getPortNetworkId(), volumeHLU);
}
}
}
}
}
return hbaToStoragePortMapForBoot;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VplexExportGroupServiceApiImpl method getNetworkTaggedPortsForHost.
/**
* This method returns all StoragePorts from networks containing initiators
* of a host.
*
* @param hostUri
* @param networkToPortsMap map of network to storageport set
*/
private Map<URI, StoragePort> getNetworkTaggedPortsForHost(URI hostUri, Map<Network, Set<StoragePort>> networkToPortsMap) {
URIQueryResultList initiatorURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(hostUri, Initiator.class, "host"), initiatorURIs);
Map<URI, StoragePort> networkStoragePorts = new HashMap<URI, StoragePort>();
Set<StoragePort> storagePorts = new HashSet<StoragePort>();
Iterator<URI> initiatorURIsIter = initiatorURIs.iterator();
while (initiatorURIsIter.hasNext()) {
URI initiatorURI = initiatorURIs.iterator().next();
Initiator initiator = _dbClient.queryObject(Initiator.class, initiatorURI);
if (!initiator.getInactive() && initiator.getRegistrationStatus().equals(DiscoveredDataObject.RegistrationStatus.REGISTERED.name())) {
for (Map.Entry<Network, Set<StoragePort>> entry : networkToPortsMap.entrySet()) {
if (entry.getKey().retrieveEndpoints().contains(initiator.getInitiatorPort())) {
storagePorts.addAll(entry.getValue());
}
}
}
}
for (StoragePort storagePort : storagePorts) {
networkStoragePorts.put(storagePort.getId(), storagePort);
}
return networkStoragePorts;
}
Aggregations