use of com.emc.storageos.plugins.BaseCollectionException 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.plugins.BaseCollectionException in project coprhd-controller by CoprHD.
the class FastPolicyProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
while (it.hasNext()) {
final CIMObjectPath policyObjectPath = it.next();
String systemName = policyObjectPath.getKey(Constants.SYSTEMNAME).getValue().toString();
if (!systemName.contains((String) keyMap.get(Constants._serialID))) {
continue;
}
String[] array = systemName.split(Constants.PATH_DELIMITER_REGEX);
String policyRuleName = policyObjectPath.getKey(Constants.POLICYRULENAME).getValue().toString();
log.info("Policy Name {}", policyRuleName);
String policyKey = validateFastPolicy(array[0], policyRuleName);
if (null != policyKey) {
log.info("Adding Policy Object Path {}", policyObjectPath);
addPath(keyMap, policyKey, policyObjectPath);
}
}
} catch (Exception e) {
log.error("Fast Policy discovery failed during UnManaged Volume discovery", e);
}
}
use of com.emc.storageos.plugins.BaseCollectionException 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);
}
}
use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.
the class MetaVolumeTypeProcessor 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 metaVolumePath = getObjectPathfromCIMArgument(_args);
if (metaVolumePath == null) {
_logger.info(String.format("MetaVolumePath is null."));
} else {
_logger.info(String.format("Processing EMC_Meta for meta volume: %s", metaVolumePath));
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(metaVolumePath);
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(metaVolumePath);
_logger.debug("Meta 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("MetaVolumeTypeProcessor called for regular volume: %s", nativeGuid));
return;
}
final Iterator<?> it = (Iterator<?>) resultObj;
if (it.hasNext()) {
final CIMObjectPath symmMetaPath = (CIMObjectPath) it.next();
_logger.debug(String.format("Processing EMC_Meta: %s", symmMetaPath));
CIMInstance cimMeta = client.getInstance(symmMetaPath, false, false, STRIPE_EXTENTS_NUMBER);
CIMProperty stripeLengthProperty = cimMeta.getProperty(SmisConstants.CP_EXTENT_STRIPE_LENGTH);
Long stripeLength = Long.valueOf(stripeLengthProperty.getValue().toString());
String metaVolumeType;
if (stripeLength < 1) {
_logger.error(String.format("Stripe length for EMC_Meta is less than 1: %s", stripeLength));
return;
} else if (stripeLength == 1) {
// this is concatenated meta volume
_logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is concatenated.", stripeLength));
metaVolumeType = Volume.CompositionType.CONCATENATED.toString();
} else {
// this is striped meta volume
_logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is striped.", stripeLength));
metaVolumeType = Volume.CompositionType.STRIPED.toString();
}
_logger.info(String.format("Meta volume: %s, type: %s", metaVolumePath, metaVolumeType));
if (null == preExistingVolume) {
// storage volume update
storageVolume.setCompositionType(metaVolumeType);
// persist volume in db
dbClient.persistObject(storageVolume);
} else {
// unmanaged volume update
StringSet metaVolumeTypeSet = new StringSet();
metaVolumeTypeSet.add(metaVolumeType);
preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_VOLUME_TYPE.toString(), metaVolumeTypeSet);
// for this volume.
if (Volume.CompositionType.STRIPED.toString().equalsIgnoreCase(metaVolumeType)) {
URI storageSystemUri = preExistingVolume.getStorageSystemUri();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemUri);
if (DiscoveredDataObject.Type.vmax.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
_logger.info("Check matched vpool list for vmax striped meta volume and remove fastExpansion vpools.");
StringSet matchedVirtualPools = preExistingVolume.getSupportedVpoolUris();
if (matchedVirtualPools != null && !matchedVirtualPools.isEmpty()) {
_logger.debug("Matched Pools :" + Joiner.on("\t").join(matchedVirtualPools));
StringSet newMatchedPools = new StringSet();
boolean needToReplace = false;
for (String vPoolUriStr : matchedVirtualPools) {
URI vPoolUri = new URI(vPoolUriStr);
VirtualPool virtualPool = dbClient.queryObject(VirtualPool.class, vPoolUri);
// null check since supported vPool list in UnManagedVolume may contain inactive vPool
if (virtualPool != null && !virtualPool.getFastExpansion()) {
newMatchedPools.add(vPoolUriStr);
} else {
needToReplace = true;
}
}
if (needToReplace) {
matchedVirtualPools.replace(newMatchedPools);
_logger.info("Replaced VPools : {}", Joiner.on("\t").join(preExistingVolume.getSupportedVpoolUris()));
}
}
}
}
// persist volume in db
dbClient.updateAndReindexObject(preExistingVolume);
}
}
}
} catch (Exception e) {
_logger.error("Processing meta volume type information failed :", e);
}
}
use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.
the class PoolCapabilitiesProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
@SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
// Process the response only for vmax3 systems.
if (device.checkIfVmax3()) {
while (it.hasNext()) {
CIMInstance capabilitiesInstance = null;
try {
capabilitiesInstance = it.next();
String instanceID = capabilitiesInstance.getPropertyValue(Constants.INSTANCEID).toString();
addPath(keyMap, operation.getResult(), capabilitiesInstance.getObjectPath());
} catch (Exception e) {
_logger.warn("Pool Capabilities detailed discovery failed for {}-->{}", capabilitiesInstance.getObjectPath(), getMessage(e));
}
}
}
} catch (Exception e) {
_logger.error("Pool Capabilities detailed discovery failed", e);
}
}
Aggregations