use of com.emc.storageos.db.client.impl.DbModelClientImpl in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method verifyNumPath.
/**
* Given a ZoneInfoMap, check that the hosts in a cluster have a number of
* paths that is compliant with the vpool specifications.
*
* @param initiatorUris
* a list of initiators sets, each set belongs to one host in the
* cluster
* @param umask
* the UnManagedExportMask being checked
* @param block
* the volume or snapshot for which the zoning are verified
* @param vPoolURI
* - URI of the VPool to ingest blockObject.
* @param varrayURI
* - URI of the Varray to ingest blockObject.
* @param dbClient
* an instance of dbclient
* @return true if the number of paths is valid.
*/
private static boolean verifyNumPath(List<Set<String>> initiatorUris, UnManagedExportMask umask, BlockObject block, URI vPoolURI, URI varrayUri, DbClient dbClient) {
DbModelClientImpl dbModelClient = new DbModelClientImpl(dbClient);
ExportPathParams pathParams = BlockStorageScheduler.getExportPathParam(block, vPoolURI, dbClient);
for (Set<String> hostInitiatorUris : initiatorUris) {
List<Initiator> initiators = CustomQueryUtility.iteratorToList(dbModelClient.find(Initiator.class, StringSetUtil.stringSetToUriList(hostInitiatorUris)));
// If this an RP initiator, do not validate num path against the vpool; it's a back-end mask with different
// pathing rules.
boolean avoidNumPathCheck = false;
for (Initiator initiator : initiators) {
if (initiator.checkInternalFlags(Flag.RECOVERPOINT)) {
avoidNumPathCheck = true;
}
}
// if vplex distributed, only verify initiators connected to same vplex cluster as unmanaged export mask
if (isVplexVolume(block, dbClient)) {
VirtualPool vpool = dbClient.queryObject(VirtualPool.class, vPoolURI);
if (VirtualPool.vPoolSpecifiesHighAvailabilityDistributed(vpool)) {
_logger.info("initiators before filtering for vplex distributed: " + initiators);
// determine the source and ha vplex cluster names for comparing to the unmanaged export mask
StorageSystem vplex = dbClient.queryObject(StorageSystem.class, umask.getStorageSystemUri());
String sourceVarrayVplexClusterName = VPlexControllerUtils.getVPlexClusterName(dbClient, varrayUri, vplex.getId());
List<URI> varrayUris = new ArrayList<URI>();
varrayUris.add(varrayUri);
URI haVarrayUri = VPlexUtil.getHAVarray(vpool);
String haVarrayVplexClusterName = null;
if (null != haVarrayUri) {
varrayUris.add(haVarrayUri);
haVarrayVplexClusterName = VPlexControllerUtils.getVPlexClusterName(dbClient, haVarrayUri, vplex.getId());
}
// determine the vplex cluster name that the unmanaged export mask resides upon
String umaskVplexClusterId = ConnectivityUtil.getVplexClusterForStoragePortUris(URIUtil.toURIList(umask.getKnownStoragePortUris()), umask.getStorageSystemUri(), dbClient);
String umaskVplexClusterName = VPlexControllerUtils.getClusterNameForId(umaskVplexClusterId, vplex.getId(), dbClient);
// partition the host's initiators by virtual array (source or high availability)
Map<URI, List<URI>> varraysToInitiators = VPlexUtil.partitionInitiatorsByVarray(dbClient, URIUtil.toURIList(hostInitiatorUris), varrayUris, vplex);
// determine the varray to check by matching the vplex cluster names
URI varrayToCheck = null;
URI otherVarray = null;
if (null != umaskVplexClusterName) {
if (umaskVplexClusterName.equalsIgnoreCase(sourceVarrayVplexClusterName)) {
varrayToCheck = varrayUri;
otherVarray = haVarrayUri;
} else if (umaskVplexClusterName.equalsIgnoreCase(haVarrayVplexClusterName)) {
varrayToCheck = haVarrayUri;
otherVarray = varrayUri;
}
} else {
_logger.error("Could not determine UnManagedExportMask VPLEX cluster name for mask " + umask.getMaskName());
return false;
}
// if no initiators match, then skip the num path check, it doesn't apply to this host.
if (null != varrayToCheck) {
List<URI> initsToCheck = varraysToInitiators.get(varrayToCheck);
if (initsToCheck != null && !initsToCheck.isEmpty()) {
initiators = CustomQueryUtility.iteratorToList(dbModelClient.find(Initiator.class, initsToCheck));
} else {
List<URI> otherVarrayInits = varraysToInitiators.get(otherVarray);
if (null != otherVarrayInits && !otherVarrayInits.isEmpty()) {
avoidNumPathCheck = true;
}
}
} else {
_logger.error("inits not filtered for vplex distributed because a varray couldn't be determined for mask " + umask.getMaskName());
return false;
}
_logger.info("initiators after filtering for vplex distributed: " + initiators);
}
}
if (hasFCInitiators(initiators) && !avoidNumPathCheck) {
return verifyHostNumPath(pathParams, initiators, umask.getZoningMap(), dbClient);
}
}
return true;
}
use of com.emc.storageos.db.client.impl.DbModelClientImpl in project coprhd-controller by CoprHD.
the class LazyLoadTests method setupTest.
@Before
public void setupTest() {
DbClientImplUnitTester dbClient = new DbClientImplUnitTester();
dbClient.setCoordinatorClient(_coordinator);
dbClient.setDbVersionInfo(sourceVersion);
dbClient.setBypassMigrationLock(true);
_encryptionProvider.setCoordinator(_coordinator);
dbClient.setEncryptionProvider(_encryptionProvider);
DbClientContext localCtx = new DbClientContext();
localCtx.setClusterName("Test");
localCtx.setKeyspaceName("Test");
dbClient.setLocalContext(localCtx);
VdcUtil.setDbClient(dbClient);
dbClient.setBypassMigrationLock(false);
dbClient.setDrUtil(new DrUtil(_coordinator));
dbClient.start();
_dbClient = dbClient;
modelClient = new DbModelClientImpl(_dbClient);
}
Aggregations