use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ImplicitUnManagedObjectsMatcher method matchVirtualPoolsWithUnManagedFileSystems.
public static void matchVirtualPoolsWithUnManagedFileSystems(VirtualPool virtualPool, DbClient dbClient) {
List<UnManagedFileSystem> modifiedUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
Map<String, StringSet> poolMapping = new HashMap<String, StringSet>();
StringSet invalidPools = null;
// Otherwise use matched pools
if (virtualPool.getUseMatchedPools() && null != virtualPool.getMatchedStoragePools()) {
poolMapping.put(MATCHED, virtualPool.getMatchedStoragePools());
} else if (null != virtualPool.getAssignedStoragePools()) {
poolMapping.put(MATCHED, virtualPool.getAssignedStoragePools());
// Find out the storage pools which are in matched pools but not in assigned pools.
// These pools should not be in the supported vpool list
invalidPools = (StringSet) virtualPool.getMatchedStoragePools().clone();
invalidPools.removeAll(virtualPool.getAssignedStoragePools());
}
if (null != virtualPool.getInvalidMatchedPools()) {
if (invalidPools == null) {
invalidPools = virtualPool.getInvalidMatchedPools();
} else {
invalidPools.addAll(virtualPool.getInvalidMatchedPools());
}
}
if (invalidPools != null) {
poolMapping.put(INVALID, invalidPools);
}
for (Entry<String, StringSet> entry : poolMapping.entrySet()) {
String key = entry.getKey();
for (String pool : entry.getValue()) {
List<URI> unManagedFileSystemUris = dbClient.queryByConstraint(ContainmentConstraint.Factory.getPoolUnManagedFileSystemConstraint(URI.create(pool)));
Iterator<UnManagedFileSystem> unManagedFileSystems = dbClient.queryIterativeObjects(UnManagedFileSystem.class, unManagedFileSystemUris);
while (unManagedFileSystems.hasNext()) {
UnManagedFileSystem unManagedFileSystem = unManagedFileSystems.next();
StringSetMap unManagedFileSystemInfo = unManagedFileSystem.getFileSystemInformation();
if (null == unManagedFileSystemInfo) {
continue;
}
String unManagedFileSystemProvisioningType = UnManagedFileSystem.SupportedProvisioningType.getProvisioningType(unManagedFileSystem.getFileSystemCharacterstics().get(SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString()));
boolean isNetApp = unManagedFileSystemInfo.get(SupportedFileSystemInformation.SYSTEM_TYPE.toString()).contains(DiscoveredDataObject.Type.netapp.name());
// Ignoring the provisioning type check for NetApp.
if (INVALID.equalsIgnoreCase(key) || ((!isNetApp) && !unManagedFileSystemProvisioningType.equalsIgnoreCase(virtualPool.getSupportedProvisioningType()))) {
if (removeVPoolFromUnManagedVolumeObjectVPools(virtualPool, unManagedFileSystem)) {
modifiedUnManagedFileSystems.add(unManagedFileSystem);
}
} else if (addVPoolToUnManagedObjectSupportedVPools(virtualPool, unManagedFileSystemInfo, unManagedFileSystem, null, null, null)) {
modifiedUnManagedFileSystems.add(unManagedFileSystem);
}
if (modifiedUnManagedFileSystems.size() > FILESHARE_BATCH_SIZE) {
insertInBatches(modifiedUnManagedFileSystems, dbClient, "UnManagedFileSystems");
modifiedUnManagedFileSystems.clear();
}
}
}
}
insertInBatches(modifiedUnManagedFileSystems, dbClient, "UnManagedFileSystems");
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionUnlinkTargetJob method getBlockConsistencyGroupForPromotedSnapshot.
/**
* Given a CG snapshot that is to be promoted, create a new BlockConsistencyGroup based on its
* ReplicationGroup. A group cache parameter is accepted and serves to cache BlockConsistencyGroup
* instances that have already been created.
*
* @param snapshot BlockSnapshot being promoted.
* @param groupCache Cache mapping of ReplicationGroup name to BlockConsistencyGroup instances.
* @param dbClient Database client.
* @return BlockConsistencyGroup URI or null.
*/
private URI getBlockConsistencyGroupForPromotedSnapshot(BlockSnapshot snapshot, Map<String, BlockConsistencyGroup> groupCache, DbClient dbClient) {
if (!snapshot.hasConsistencyGroup()) {
return null;
}
// Create new BlockConsistencyGroup instances to track the existing target groups.
String groupInstance = snapshot.getReplicationGroupInstance();
BlockConsistencyGroup cg = null;
if (groupCache.containsKey(groupInstance)) {
cg = groupCache.get(groupInstance);
} else {
cg = new BlockConsistencyGroup();
cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
Project project = dbClient.queryObject(Project.class, snapshot.getProject().getURI());
cg.setProject(new NamedURI(project.getId(), project.getLabel()));
cg.setTenant(new NamedURI(project.getTenantOrg().getURI(), project.getTenantOrg().getName()));
String repGrpName = groupInstance.substring(groupInstance.indexOf("+") + 1, groupInstance.length());
cg.setLabel(repGrpName);
StringSetMap map = new StringSetMap();
map.put(snapshot.getStorageController().toString(), new StringSet(Arrays.asList(repGrpName)));
cg.setSystemConsistencyGroups(map);
StringSet types = new StringSet();
types.add(BlockConsistencyGroup.Types.LOCAL.name());
cg.setTypes(types);
cg.setRequestedTypes(types);
cg.setStorageController(snapshot.getStorageController());
s_logger.info("Creating new BlockConsistencyGroup for ReplicationGroup {} with ID: {}", groupInstance, cg.getId());
dbClient.createObject(cg);
groupCache.put(groupInstance, cg);
}
return cg.getId();
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupUtils method getLocalSystems.
/**
* Gets the storage system(s) containing the native CGs corresponding to the
* passed VPLEX CG.
*
* @param cg A reference to a VPLEX CG
* @param dbClient A reference to a database client
*
* @return A list of the the storage system(s) containing the native CGs
* corresponding to the passed VPLEX CG.
*/
public static List<URI> getLocalSystems(BlockConsistencyGroup cg, DbClient dbClient) {
List<URI> localSystemUris = new ArrayList<URI>();
StringSetMap systemCgMap = cg.getSystemConsistencyGroups();
if (systemCgMap != null) {
Iterator<String> cgSystemIdsIter = cg.getSystemConsistencyGroups().keySet().iterator();
while (cgSystemIdsIter.hasNext()) {
URI cgSystemUri = URI.create(cgSystemIdsIter.next());
if (URIUtil.isType(cgSystemUri, StorageSystem.class)) {
StorageSystem cgSystem = dbClient.queryObject(StorageSystem.class, cgSystemUri);
// to add another type check here.
if (!DiscoveredDataObject.Type.vplex.name().equals(cgSystem.getSystemType())) {
localSystemUris.add(cgSystemUri);
}
}
}
}
return localSystemUris;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VDCRoleMigrationCallback method removeRoleFromRootTenant.
/**
* remove VDC roles from rootTenantOrg
*
* @param vdc
* @param rootTenant
*/
private void removeRoleFromRootTenant(VirtualDataCenter vdc, TenantOrg rootTenant) {
StringSetMap vdcRoles = vdc.getRoleAssignments();
for (Map.Entry<String, AbstractChangeTrackingSet<String>> roleAssignment : vdcRoles.entrySet()) {
String uid = roleAssignment.getKey();
Iterator<String> itr = roleAssignment.getValue().iterator();
while (itr.hasNext()) {
String role = itr.next();
rootTenant.removeRole(uid, role);
}
}
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VirtualPoolDefaultValuesForSystemTypeDriveTypeMigration method process.
@Override
public void process() throws MigrationCallbackException {
logger.info("Migration started");
DbClient dbClient = getDbClient();
boolean changed = false;
try {
List<URI> virtualPoolUris = dbClient.queryByType(VirtualPool.class, true);
Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolUris, true);
logger.info("Processing virtual pool to set default values for drive type and system type as NONE");
while (virtualPools.hasNext()) {
VirtualPool virtualPool = virtualPools.next();
changed = false;
if (virtualPool.getDriveType() == null) {
logger.info("Setting drive type to NONE for Virtual Pool {}", virtualPool.getId());
virtualPool.setDriveType(SupportedDriveTypes.NONE.name());
changed = true;
}
StringSetMap arrayInfo = virtualPool.getArrayInfo();
if (arrayInfo != null) {
if (arrayInfo.get(SYSTEM_TYPE_KEY) == null) {
logger.info("Setting array system type to NONE for Virtual Pool {}", virtualPool.getId());
arrayInfo.put(SYSTEM_TYPE_KEY, VirtualPool.SystemType.NONE.name());
changed = true;
}
} else {
logger.info("No existing array info. Creating new array info and setting system type to NONE for Virtual Pool {}", virtualPool.getId());
arrayInfo = new StringSetMap();
arrayInfo.put(SYSTEM_TYPE_KEY, VirtualPool.SystemType.NONE.name());
virtualPool.setArrayInfo(arrayInfo);
changed = true;
}
if (changed) {
logger.info("Persisting changes into DB for Virtual Pool {}", virtualPool.getId());
dbClient.persistObject(virtualPool);
}
}
} catch (Exception ex) {
logger.error("Exception occured while setting default values to system type and drive type in virtual pool");
logger.error(ex.getMessage(), ex);
}
logger.info("Migration completed successfully");
}
Aggregations