use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method updateExportGroup.
/**
* Update an ExportGroup.
*
* @param exportGroup the ExportGroup to update
* @param volume a BlockObject for the ExportGroup
* @param wwnToHluMap the wwn to hlu map
* @param dbClient a reference to the database client
* @param allInitiators a List of all initiators for the ExportGroup
* @param hosts a List of Hosts for the ExportGroup
* @param cluster a Cluster for the ExportGroup
*/
public static <T extends BlockObject> void updateExportGroup(ExportGroup exportGroup, T volume, Map<String, Integer> wwnToHluMap, DbClient dbClient, List<Initiator> allInitiators, List<Host> hosts, Cluster cluster) {
for (Host host : hosts) {
if (null == exportGroup.getHosts() || !exportGroup.getHosts().contains(host.getId().toString())) {
exportGroup.addHost(host);
}
}
if (null != cluster && (null == exportGroup.getClusters() || !exportGroup.getClusters().contains(cluster.getId().toString()))) {
exportGroup.addCluster(cluster);
}
for (Initiator ini : allInitiators) {
if (exportGroup.getInitiators() == null || !exportGroup.getInitiators().contains(ini.getId().toString())) {
exportGroup.addInitiator(ini);
}
}
// Do not add the block object to the export group if it is partially ingested
if (!volume.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
_logger.info("adding volume {} to export group {}", volume.forDisplay(), exportGroup.forDisplay());
Integer hlu = ExportGroup.LUN_UNASSIGNED;
if (wwnToHluMap.containsKey(volume.getWWN())) {
hlu = wwnToHluMap.get(volume.getWWN());
}
exportGroup.addVolume(volume.getId(), hlu);
} else {
_logger.info("volume {} is partially ingested, so not adding to export group {}", volume.forDisplay(), exportGroup.forDisplay());
}
if (volume instanceof Volume) {
Volume vol = (Volume) volume;
URI haVarray = checkVplexHighAvailabilityArray(vol, dbClient);
if (null != haVarray) {
exportGroup.putAltVirtualArray(volume.getStorageController().toString(), haVarray.toString());
}
}
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method createExportMask.
/**
* Creates an ExportMask for the given arguments and returns the BlockObject.
*
* @param eligibleMask an UnManagedExportMask to base the ExportMask on
* @param unManagedVolume the UnManagedVolume being ingested
* @param exportGroup the ExportGroup for the ExportMask
* @param volume the Volume object for the ExportMask
* @param dbClient a reference to the database client
* @param hosts a List of Hosts for the ExportMask
* @param cluster a Cluster for the ExportMask
* @param exportMaskLabel the name of the ExportMask
* @throws Exception
*/
public static <T extends BlockObject> ExportMask createExportMask(UnManagedExportMask eligibleMask, UnManagedVolume unManagedVolume, ExportGroup exportGroup, T volume, DbClient dbClient, List<Host> hosts, Cluster cluster, String exportMaskLabel) throws Exception {
_logger.info("Creating ExportMask for unManaged Mask {}", eligibleMask.getMaskName());
List<URI> initiatorUris = new ArrayList<URI>(Collections2.transform(eligibleMask.getKnownInitiatorUris(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
List<Initiator> allInitiators = dbClient.queryObject(Initiator.class, initiatorUris);
List<Initiator> userAddedInis = VolumeIngestionUtil.findUserAddedInisFromExistingIniListInMask(allInitiators, eligibleMask.getId(), dbClient);
List<URI> storagePortUris = new ArrayList<URI>(Collections2.transform(eligibleMask.getKnownStoragePortUris(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
Map<String, Integer> wwnToHluMap = extractWwnToHluMap(eligibleMask, dbClient);
ExportMask exportMask = ExportMaskUtils.initializeExportMaskWithVolumes(eligibleMask.getStorageSystemUri(), exportGroup, eligibleMask.getMaskName(), exportMaskLabel, allInitiators, null, storagePortUris, eligibleMask.getZoningMap(), volume, eligibleMask.getUnmanagedInitiatorNetworkIds(), eligibleMask.getNativeId(), userAddedInis, dbClient, wwnToHluMap);
// remove unmanaged mask if created if the block object is not marked as internal
if (!volume.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
_logger.info("breaking relationship between UnManagedExportMask {} and UnManagedVolume {}", eligibleMask.getMaskName(), unManagedVolume.getLabel());
unManagedVolume.getUnmanagedExportMasks().remove(eligibleMask.getId().toString());
eligibleMask.getUnmanagedVolumeUris().remove(unManagedVolume.getId().toString());
}
updateExportGroup(exportGroup, volume, wwnToHluMap, dbClient, allInitiators, hosts, cluster);
return exportMask;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method groupInitiatorsByHost.
/**
* Group Initiators by Host containing them and return a
* Map of Host to Initiators the Host contains.
*
* @param iniStrList a set of Initiator URI Strings
* @param dbClient a reference to the database client
* @return a Map of Host to Initiators the Host contains
*/
private static Map<String, Set<String>> groupInitiatorsByHost(Set<String> iniStrList, DbClient dbClient) {
Map<String, Set<String>> iniByHost = new HashMap<String, Set<String>>();
List<URI> iniList = new ArrayList<URI>(Collections2.transform(iniStrList, CommonTransformerFunctions.FCTN_STRING_TO_URI));
List<Initiator> initiators = dbClient.queryObject(Initiator.class, iniList);
for (Initiator ini : initiators) {
if (null == ini.getHost()) {
_logger.warn("Initiator {} with Host set to Null", ini.getId());
continue;
}
if (!iniByHost.containsKey(ini.getHost())) {
iniByHost.put(ini.getHost().toString(), new HashSet<String>());
}
iniByHost.get(ini.getHost().toString()).add(ini.getId().toString());
}
return iniByHost;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method findUnManagedExportMasksForHost.
/**
* Returns a List of the UnManagedExportMasks associated with a given Host URI.
*
* @param hostUri the Host URI to check
* @param dbClient a reference to the database client
* @return a List of the UnManagedExportMasks associated with a given Host URI
*/
public static List<UnManagedExportMask> findUnManagedExportMasksForHost(URI hostUri, DbClient dbClient) {
_logger.info("finding unmanaged export masks for host " + hostUri);
List<UnManagedExportMask> uems = new ArrayList<UnManagedExportMask>();
List<Initiator> initiators = ComputeSystemHelper.queryInitiators(dbClient, hostUri);
Set<URI> uemUris = new HashSet<URI>();
URIQueryResultList results = new URIQueryResultList();
for (Initiator initiator : initiators) {
_logger.info(" looking at initiator " + initiator.getInitiatorPort());
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedExportMaskKnownInitiatorConstraint(initiator.getInitiatorPort()), results);
if (results.iterator() != null) {
for (URI uri : results) {
_logger.info(" found UnManagedExportMask " + uri);
uemUris.add(uri);
}
}
}
for (URI uemUri : uemUris) {
UnManagedExportMask uem = dbClient.queryObject(UnManagedExportMask.class, uemUri);
if (uem == null || uem.getInactive() == true) {
continue;
}
uems.add(uem);
_logger.info(" maskName: " + uem.getMaskName() + " nativeGuid: " + uem.getNativeGuid());
}
if (uems.isEmpty()) {
_logger.info(" did not find any unmanaged export masks for this host");
}
return uems;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method verifyHostNumPath.
/**
* Given the zoneInfoMap, check the existing paths to make sure they
* comply with the ingestion vpool requirements.
*
* @param pathParams the ingestion parameter
* @param initiators the host initiators to be checked
* @param zoneInfoMap the zoneInfoMap that is stored in the UnManagedExportMask
* @param dbClient a reference to the database client
* @return true if the host paths are compliant. False otherwise.
*/
private static boolean verifyHostNumPath(ExportPathParams pathParams, List<Initiator> initiators, ZoneInfoMap zoneInfoMap, DbClient dbClient) {
_logger.info("verifyHostNumPath for initiators {} with zoningMap {}", initiators, zoneInfoMap);
if (initiators == null || initiators.isEmpty()) {
_logger.error("Host has no initiators configured.");
throw IngestionException.exceptions.hostHasNoInitiators();
}
int unassignedInitiators = 0;
int totalPaths = 0;
StringSetMap zoningMap = ExportMaskUtils.getZoneMapFromZoneInfoMap(zoneInfoMap, initiators);
if (null == zoningMap || zoningMap.isEmpty()) {
_logger.error("No zoning information found for the initiators");
List<String> messageArray = new ArrayList<String>();
for (Initiator init : initiators) {
messageArray.add(init.getHostName() + ":" + init.getInitiatorPort());
}
throw IngestionException.exceptions.hostHasNoZoning(Joiner.on(", ").join(messageArray));
}
if (VPlexControllerUtils.isVplexInitiator(initiators.get(0), dbClient)) {
_logger.info("these are VPLEX backend initiators, " + "so no need to validate against virtual pool path params");
return true;
}
String hostName = initiators.get(0).getHostName();
URI hostURI = initiators.get(0).getHost() == null ? URIUtil.NULL_URI : initiators.get(0).getHost();
_logger.info("Checking numpath for host {}", hostName);
for (Initiator initiator : initiators) {
if (initiator.getHostName() != null) {
hostName = initiator.getHostName();
}
StringSet ports = zoningMap.get(initiator.getId().toString());
if (ports == null || ports.isEmpty()) {
unassignedInitiators++;
_logger.info("Initiator {} of host {} is not assigned to any ports.", new Object[] { initiator.getInitiatorPort(), hostName });
} else if (ports.size() < pathParams.getPathsPerInitiator()) {
_logger.error("Initiator {} of host {} has fewer SAN paths than what is required according to the virtual pool " + "({} are zoned, but {} are required)", new Object[] { initiator.getInitiatorPort(), hostName, ports.size(), pathParams.getPathsPerInitiator() });
throw IngestionException.exceptions.hostZoningHasDifferentPortCount(initiator.getInitiatorPort(), hostName, String.valueOf(ports.size()), String.valueOf(pathParams.getPathsPerInitiator()));
} else {
totalPaths += ports.size();
_logger.info("Initiator {} of host {} has {} paths", new Object[] { initiator.getInitiatorPort(), hostName, ports.size(), ports.size() });
}
}
if (totalPaths < pathParams.getMinPaths()) {
_logger.error(String.format("Host %s (%s) has fewer paths assigned %d than min_paths %d", hostName, hostURI.toString(), totalPaths, pathParams.getMinPaths()));
throw IngestionException.exceptions.hostZoningHasFewerPorts(hostName, String.valueOf(totalPaths), String.valueOf(pathParams.getMinPaths()));
}
if (totalPaths > pathParams.getMaxPaths()) {
_logger.warn(String.format("Host %s (%s) has more paths assigned %d than max_paths %d", hostName, hostURI.toString(), totalPaths, pathParams.getMaxPaths()));
}
if (unassignedInitiators > 0) {
_logger.info(String.format("Host %s (%s) has %d unassigned initiators", hostName, hostURI.toString(), unassignedInitiators));
}
return true;
}
Aggregations