use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class ExportUtils method cleanStaleHostReferences.
/**
* Cleans stale host references from export group instance
*
* @param exportGroup {@link ExportGroup}
* @param dbClient {@link DbClient}
*/
private static void cleanStaleHostReferences(ExportGroup exportGroup, DbClient dbClient) {
if (null == exportGroup || exportGroup.getInactive()) {
return;
}
StringSet exportGroupInitiators = exportGroup.getInitiators();
// not be empty
if (!CollectionUtils.isEmpty(exportGroup.getHosts()) && !CollectionUtils.isEmpty(exportGroupInitiators)) {
Set<String> egHosts = new HashSet<>();
Collection<Initiator> initiators = Collections2.transform(exportGroupInitiators, CommonTransformerFunctions.fctnStringToInitiator(dbClient));
for (Initiator initiator : initiators) {
// upgrade.
if (null != initiator && initiator.getHost() != null) {
egHosts.add(initiator.getHost().toString());
}
}
Set<String> staleHosts = new HashSet<>(Sets.difference(exportGroup.getHosts(), egHosts));
if (!CollectionUtils.isEmpty(staleHosts)) {
Collection<URI> staleHostURIs = Collections2.transform(staleHosts, CommonTransformerFunctions.FCTN_STRING_TO_URI);
_log.info(String.format("Stale host references [%s] will be removed from Export Group %s", Joiner.on(',').join(staleHostURIs), exportGroup.getId()));
exportGroup.removeHosts(new ArrayList<>(staleHostURIs));
}
}
if (!ExportGroupType.Initiator.toString().equalsIgnoreCase(exportGroup.getType()) && CollectionUtils.isEmpty(exportGroup.getHosts()) && !exportGroup.checkInternalFlags(DataObject.Flag.INTERNAL_OBJECT)) {
// COP-27689 - Even if all the export masks got cleared, the export Group still remains with initiators and volumes.
// Clean up all the initiators, volumes and ports as there are no available export masks.
_log.info("There are no hosts in the export Group {}-->{} after cleaning up stale hosts.", exportGroup.getId(), exportGroup.getLabel());
resetExportGroup(exportGroup, dbClient);
}
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class NetworkUtil method getNetworkToInitiators.
/**
* Returns a Map of networkURI => [set of endpoints connected].
*
* @param dbClient
* @param initiators
* @return
*/
public static Map<URI, Set<String>> getNetworkToInitiators(DbClient dbClient, List<Initiator> initiators) {
Map<URI, Set<String>> networkToEndPoints = new HashMap<URI, Set<String>>();
for (Initiator initiator : initiators) {
Set<NetworkLite> networkLites = getEndpointAllNetworksLite(initiator.getInitiatorPort(), dbClient);
if (null == networkLites || networkLites.isEmpty()) {
_log.info(String.format("getNetworkToInitiators(%s) -- Initiator is not associated with any network", initiator.getInitiatorPort()));
} else {
for (NetworkLite networkLite : networkLites) {
URI networkUri = networkLite.getId();
_log.info(String.format("Adding initiator, network (%s, %s) to map", initiator.getInitiatorPort(), networkLite.getLabel()));
Set<String> endPoints = networkToEndPoints.get(networkUri);
if (null == endPoints) {
endPoints = new HashSet<String>();
}
endPoints.add(initiator.getInitiatorPort());
networkToEndPoints.put(networkUri, endPoints);
}
}
}
return networkToEndPoints;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VPlexUtil method getBackendPortInitiators.
/**
* Returns a set of all VPLEX backend ports as their related
* Initiator URIs for a given VPLEX storage system.
*
* @param vplexUri - URI of the VPLEX system to find initiators for
* @param dbClient - database client instance
* @return a Set of Initiator URIs
*/
public static Set<URI> getBackendPortInitiators(URI vplexUri, DbClient dbClient) {
_log.info("finding backend port initiators for VPLEX: " + vplexUri);
Set<URI> initiators = new HashSet<>();
List<StoragePort> ports = ConnectivityUtil.getStoragePortsForSystem(dbClient, vplexUri);
for (StoragePort port : ports) {
if (StoragePort.PortType.backend.name().equals(port.getPortType())) {
Initiator init = ExportUtils.getInitiator(port.getPortNetworkId(), dbClient);
if (init != null) {
_log.info("found initiator {} for wwpn {}", init.getId(), port.getPortNetworkId());
initiators.add(init.getId());
}
}
}
return initiators;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VPlexUtil method filterInitiatorsForVplex.
/**
* Filter a list of initiators to contain only those with protocols
* supported by the VPLEX.
*
* @param dbClient a database client instance
* @param initiators list of initiators
*
* @return a filtered list of initiators containing
* only those with protocols supported by VPLEX
*/
public static List<URI> filterInitiatorsForVplex(DbClient dbClient, List<URI> initiators) {
// filter initiators for FC protocol type only (CTRL-6326)
List<URI> initsToRemove = new ArrayList<>();
for (URI init : initiators) {
Initiator initiator = dbClient.queryObject(Initiator.class, init);
if ((null != initiator) && !HostInterface.Protocol.FC.toString().equals(initiator.getProtocol())) {
initsToRemove.add(init);
}
}
initiators.removeAll(initsToRemove);
return initiators;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VPlexUtil method makeHostInitiatorsMap.
/**
* Given a list of initiator URIs, make a map of Host URI to a list of Initiators.
*
* @param initiators -- list of Initiator URIs
* @return -- Map of Host URI to List<Initiator> (objects)
*/
public static Map<URI, List<Initiator>> makeHostInitiatorsMap(List<URI> initiators, DbClient dbClient) {
// sort initiators in a host to initiator map
Map<URI, List<Initiator>> hostInitiatorMap = new HashMap<>();
if (!initiators.isEmpty()) {
for (URI initiatorUri : initiators) {
Initiator initiator = dbClient.queryObject(Initiator.class, initiatorUri);
URI initiatorHostURI = VPlexUtil.getInitiatorHost(initiator);
List<Initiator> initiatorSet = hostInitiatorMap.get(initiatorHostURI);
if (initiatorSet == null) {
hostInitiatorMap.put(initiatorHostURI, new ArrayList<Initiator>());
initiatorSet = hostInitiatorMap.get(initiatorHostURI);
}
initiatorSet.add(initiator);
}
}
_log.info("assembled map of hosts to initiators: " + hostInitiatorMap);
return hostInitiatorMap;
}
Aggregations