use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class ConnectivityCollectionRelationshipsProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
@SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
boolean volumeAdded = false;
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
CIMObjectPath raGroupPath = getObjectPathfromCIMArgument(args);
String ragGroupId = NativeGUIDGenerator.generateRAGroupNativeGuid(raGroupPath);
_log.debug("RA Group Id : {}", ragGroupId);
RemoteDirectorGroup rg = getRAGroupUriFromDB(dbClient, ragGroupId);
if (null == rg) {
_log.info("RA Group Not found : {}", ragGroupId);
return;
}
URI raGroupUri = rg.getId();
@SuppressWarnings("unchecked") Map<String, URI> rAGroupMap = (Map<String, URI>) keyMap.get(Constants.RAGROUP);
Set<String> volumeNativeGuids = new StringSet();
while (it.hasNext()) {
CIMObjectPath connCollectionRelationPaths = it.next();
String cimClass = connCollectionRelationPaths.getObjectName();
if (PROTOCOL_END_POINT.equals(cimClass)) {
String endPointId = connCollectionRelationPaths.getKey(Constants.NAME).getValue().toString();
_log.info("End Point Added {}", connCollectionRelationPaths);
addPath(keyMap, Constants.ENDPOINTS_RAGROUP, connCollectionRelationPaths);
rAGroupMap.put(endPointId, raGroupUri);
} else if (VOLUME.equals(cimClass)) {
String volumeNativeGuid = getVolumeNativeGuid(connCollectionRelationPaths);
if (!volumeAdded && !rAGroupMap.containsKey(volumeNativeGuid)) {
volumeAdded = true;
_log.info("Volume Added {}", connCollectionRelationPaths);
addPath(keyMap, Constants.VOLUME_RAGROUP, connCollectionRelationPaths);
rAGroupMap.put(volumeNativeGuid, raGroupUri);
} else {
_log.info("Volume {} is part of multiple RA Groups", volumeNativeGuid);
}
volumeNativeGuids.add(volumeNativeGuid);
}
}
RemoteDirectorGroup remoteGroup = dbClient.queryObject(RemoteDirectorGroup.class, raGroupUri);
// async
if (!volumeAdded) {
remoteGroup.setSupportedCopyMode(SupportedCopyModes.ALL.toString());
}
if (null == remoteGroup.getVolumes() || remoteGroup.getVolumes().isEmpty()) {
remoteGroup.setVolumes(new StringSet(volumeNativeGuids));
} else {
_log.debug("Existing Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
_log.debug("New Volumes {}", Joiner.on("\t").join(volumeNativeGuids));
remoteGroup.getVolumes().replace(volumeNativeGuids);
_log.debug("Updated Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
}
dbClient.persistObject(remoteGroup);
} catch (Exception e) {
_log.error("Exception occurred while processing remote connectivity information.", e);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class SRDFStorageSyncProcessor method processStorageSynchronizedPaths.
private void processStorageSynchronizedPaths(Operation operation, Iterator<CIMObjectPath> it, Object resultObj, Map<String, Object> keyMap) {
while (it.hasNext()) {
try {
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
CIMObjectPath volumePath = it.next();
CIMObjectPath sourcePath = (CIMObjectPath) volumePath.getKey(Constants._SystemElement).getValue();
CIMObjectPath destPath = (CIMObjectPath) volumePath.getKey(Constants._SyncedElement).getValue();
CIMProperty<?> prop = sourcePath.getKey(Constants._SystemName);
String[] serialNumber_split = prop.getValue().toString().split(Constants.PATH_DELIMITER_REGEX);
if (serialNumber_split[1].equalsIgnoreCase((String) keyMap.get(Constants._serialID))) {
// If mirror
String sourceVolumeNativeGuid = getVolumeNativeGuid(sourcePath);
Volume sourceVolume = checkStorageVolumeExistsInDB(sourceVolumeNativeGuid, dbClient);
if (null == sourceVolume || !isSRDFProtectedVolume(sourceVolume)) {
continue;
}
String targetVolumeNativeGuid = getVolumeNativeGuid(destPath);
Volume targetVolume = checkStorageVolumeExistsInDB(targetVolumeNativeGuid, dbClient);
if (null == targetVolume || !isSRDFProtectedVolume(targetVolume)) {
continue;
}
if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(sourceVolume.getPersonality())) {
if (null == sourceVolume.getSrdfTargets() || !sourceVolume.getSrdfTargets().contains(targetVolume.getId().toString())) {
_log.info("target volume {} is not part of ViPR managed targtes for given source {}", targetVolumeNativeGuid, sourceVolumeNativeGuid);
continue;
}
} else if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(targetVolume.getPersonality())) {
if (null == targetVolume.getSrdfTargets() || !targetVolume.getSrdfTargets().contains(sourceVolume.getId().toString())) {
_log.info("target volume {} is not part of ViPR managed targtes for given source {}", sourceVolumeNativeGuid, targetVolumeNativeGuid);
continue;
}
}
addPath(keyMap, operation.getResult(), volumePath);
}
} catch (Exception e) {
_log.error("Prerequiste Step for getting srdf storage synchronized relations failed :", e);
}
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class VmaxSLOBookkeepingProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
Set<String> policyNames = (Set<String>) keyMap.get(Constants.SLO_NAMES);
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, profile.getSystemId());
boolean isVmax3 = storageSystem.checkIfVmax3();
if (isVmax3 && policyNames != null && !policyNames.isEmpty()) {
try {
performPolicyBookKeeping(dbClient, policyNames, storageSystem);
} catch (IOException e) {
log.error("Exception caught while trying to run bookkeeping on VMAX3 SLO AutoTieringPolicies", e);
}
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class VolumeSizeProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
DbClient _dbClient;
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
try {
String minVolSize = null;
String maxVolSize = null;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
if (resultObj instanceof CIMArgument<?>[]) {
CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
for (CIMArgument<?> outArg : outputArguments) {
if (null == outArg) {
continue;
}
if (outArg.getName().equalsIgnoreCase(MINIMUM_VOLUME_SIZE)) {
minVolSize = outArg.getValue().toString();
} else if (outArg.getName().equalsIgnoreCase(MAXIMUM_VOLUME_SIZE)) {
maxVolSize = outArg.getValue().toString();
}
}
// we are setting at compile time, hence value will be there always.
CIMObjectPath poolObjectPath = getObjectPathfromCIMArgument();
String instanceID = poolObjectPath.getKey(Constants.INSTANCEID).getValue().toString();
StoragePool pool = checkStoragePoolExistsInDB(getNativeIDFromInstance(instanceID), _dbClient, device);
if (null != pool) {
Long maxVolumeSize = ControllerUtils.convertBytesToKBytes(maxVolSize);
Long minVolumeSize = ControllerUtils.convertBytesToKBytes(minVolSize);
if (Type.ibmxiv.name().equals((device.getSystemType()))) {
String supportedResourceType = pool.getSupportedResourceTypes();
if (SupportedResourceTypes.THIN_ONLY.name().equals(supportedResourceType)) {
pool.setMaximumThinVolumeSize(maxVolumeSize);
pool.setMinimumThinVolumeSize(minVolumeSize);
} else if (SupportedResourceTypes.THICK_ONLY.name().equals(supportedResourceType)) {
pool.setMaximumThickVolumeSize(maxVolumeSize);
pool.setMinimumThickVolumeSize(minVolumeSize);
}
} else {
// TODO - could this be changed to use the same logic as for IBM pool?
// if the result is obtained from calling on Thick, use thick volume size else thin
String elementType = determineCallType();
if (elementType.equalsIgnoreCase(FIVE)) {
pool.setMaximumThinVolumeSize(maxVolumeSize);
pool.setMinimumThinVolumeSize(minVolumeSize);
} else if (elementType.equalsIgnoreCase(THREE)) {
pool.setMaximumThickVolumeSize(maxVolumeSize);
pool.setMinimumThickVolumeSize(minVolumeSize);
}
}
_logger.info(String.format("Maximum limits for volume capacity in storage pool: %s %n max thin volume capacity: %s, max thick volume capacity: %s ", pool.getId(), pool.getMaximumThinVolumeSize(), pool.getMaximumThickVolumeSize()));
_dbClient.persistObject(pool);
}
}
} catch (Exception e) {
_logger.error("Failed while processing Result : ", e);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class MetaVolumeMembersProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
CIMObjectPath[] metaMembersPaths = (CIMObjectPath[]) getFromOutputArgs((CIMArgument[]) resultObj, "OutElements");
if (metaMembersPaths == null || (metaMembersPaths.length == 0)) {
_logger.info(String.format("There are no meta members to process"));
} else {
_logger.debug(String.format("Processing meta members: %s", Arrays.toString(metaMembersPaths)));
// Get volume from db
_logger.debug(String.format("Args size: %s", _args.size()));
Object[] arguments = (Object[]) _args.get(0);
CIMArgument theElement = ((CIMArgument[]) arguments[2])[1];
_logger.info(String.format("TheElement: %s, type %s", theElement.getValue().toString(), theElement.getValue().getClass().toString()));
CIMObjectPath theElementPath = (CIMObjectPath) theElement.getValue();
UnManagedVolume preExistingVolume = null;
String isMetaVolume = "true";
String nativeGuid;
// Check if storage volume exists in db (the method is called from re-discovery context).
nativeGuid = getVolumeNativeGuid(theElementPath);
Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
if (null == storageVolume || storageVolume.getInactive()) {
// Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(theElementPath);
_logger.debug("Volume nativeguid :" + nativeGuid);
preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
if (null == preExistingVolume) {
_logger.debug("Volume Info Object not found :" + nativeGuid);
return;
}
isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
} else {
_logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
isMetaVolume = storageVolume.getIsComposite().toString();
}
if (isMetaVolume.equalsIgnoreCase("false")) {
_logger.error(String.format("MetaVolumeMembersProcessor called for regular volume: %s", nativeGuid));
return;
}
Integer membersCount = metaMembersPaths.length;
// get meta member size. use second member --- the first member will show size of meta volume itself.
CIMObjectPath metaMemberPath = metaMembersPaths[1];
CIMInstance cimVolume = client.getInstance(metaMemberPath, false, false, META_MEMBER_SIZE_INFO);
CIMProperty consumableBlocks = cimVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
CIMProperty blockSize = cimVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
// calculate size = consumableBlocks * block size
Long size = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
// set meta member count and meta members size for meta volume (required for volume expansion)
if (null != preExistingVolume) {
StringSet metaMembersCount = new StringSet();
metaMembersCount.add(membersCount.toString());
preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_COUNT.toString(), metaMembersCount);
StringSet metaMemberSize = new StringSet();
metaMemberSize.add(size.toString());
preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_SIZE.toString(), metaMemberSize);
// persist unmanaged volume in db
dbClient.persistObject(preExistingVolume);
} else {
storageVolume.setMetaMemberCount(membersCount);
storageVolume.setMetaMemberSize(size);
storageVolume.setTotalMetaMemberCapacity(membersCount * size);
// persist volume in db
dbClient.persistObject(storageVolume);
}
_logger.info(String.format("Meta member info: meta member count --- %s, blocks --- %s, block size --- %s, size --- %s .", membersCount, consumableBlocks.getValue().toString(), blockSize.getValue().toString(), size));
}
} catch (Exception e) {
_logger.error("Processing meta volume information failed :", e);
}
}
Aggregations