use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class StorageVolumeProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
_keyMap = keyMap;
_updateVolumes = new ArrayList<Volume>();
_updateSnapShots = new ArrayList<BlockSnapshot>();
_updateMirrors = new ArrayList<BlockMirror>();
CloseableIterator<CIMInstance> volumeInstances = null;
try {
// create empty place holder list for meta volume paths (cannot define this in xml)
_metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
if (_metaVolumePaths == null) {
keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
}
_volumeToSpaceConsumedMap = (Map<String, String>) keyMap.get(Constants.VOLUME_SPACE_CONSUMED_MAP);
CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
_isVMAX3 = storagePoolPath.getObjectName().equals(StoragePool.PoolClassNames.Symm_SRPStoragePool.name());
processResultbyChunk(resultObj, keyMap);
_partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
_partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
_partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
} catch (Exception e) {
_logger.error("Processing Volumes and Snapshots failed", e);
} finally {
_updateVolumes = null;
_updateSnapShots = null;
_updateMirrors = null;
if (null != volumeInstances) {
volumeInstances.close();
}
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class StorageVolumeViewProcessor method processVolumes.
private void processVolumes(CloseableIterator<CIMInstance> volumeInstances, Map<String, Object> keyMap) throws IOException {
List<CIMObjectPath> metaVolumes = new ArrayList<>();
while (volumeInstances.hasNext()) {
CIMInstance volumeViewInstance = volumeInstances.next();
String nativeGuid = getVolumeViewNativeGuid(volumeViewInstance.getObjectPath(), keyMap);
if (isSnapShot(volumeViewInstance)) {
BlockSnapshot snapShot = checkSnapShotExistsInDB(nativeGuid, _dbClient);
if (null == snapShot || snapShot.getInactive()) {
_logger.debug("Skipping Snapshot, as its not being managed in Bourne");
continue;
}
updateBlockSnapShot(volumeViewInstance, snapShot, keyMap);
if (_updateSnapShots.size() > BATCH_SIZE) {
_partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
_updateSnapShots.clear();
}
} else if (isMirror(volumeViewInstance)) {
BlockMirror mirror = checkBlockMirrorExistsInDB(nativeGuid, _dbClient);
if (null == mirror || mirror.getInactive()) {
_logger.debug("Skipping Mirror, as its not being managed in Bourne");
continue;
}
updateBlockMirror(volumeViewInstance, mirror, keyMap);
if (_updateMirrors.size() > BATCH_SIZE) {
_partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
_updateMirrors.clear();
}
} else {
Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, _dbClient);
if (null == storageVolume || storageVolume.getInactive()) {
continue;
}
_logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
updateStorageVolume(volumeViewInstance, storageVolume, keyMap);
// This is applicable for meta volumes discovered as unmanaged volumes and ingested prior to vipr controller 2.2 .
if (storageVolume.getIsComposite() && (storageVolume.getCompositionType() == null || storageVolume.getCompositionType().isEmpty())) {
// meta volume is missing meta related data. Need to discover this data and set in the volume.
metaVolumes.add(volumeViewInstance.getObjectPath());
_logger.info("Found meta volume in vipr with missing data: {}, name: {}", volumeViewInstance.getObjectPath(), storageVolume.getLabel());
}
}
if (_updateVolumes.size() > BATCH_SIZE) {
_partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
_updateVolumes.clear();
}
}
// Add meta volumes to the keyMap
try {
if (metaVolumes != null && !metaVolumes.isEmpty()) {
_metaVolumeViewPaths.addAll(metaVolumes);
_logger.info("Added {} meta volumes.", metaVolumes.size());
}
} catch (Exception ex) {
_logger.error("Processing meta volumes.", ex);
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class StorageVolumeViewProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
_updateVolumes = new ArrayList<Volume>();
_updateSnapShots = new ArrayList<BlockSnapshot>();
_updateMirrors = new ArrayList<BlockMirror>();
CloseableIterator<CIMInstance> volumeInstances = null;
try {
_metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
if (_metaVolumeViewPaths == null) {
_metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
}
// create empty place holder list for meta volume paths (cannot define this in xml)
List<CIMObjectPath> metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
if (metaVolumePaths == null) {
keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
}
CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
volumeInstances = volumeInstanceChunks.getResponses();
processVolumes(volumeInstances, keyMap);
while (!volumeInstanceChunks.isEnd()) {
_logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumes(volumeInstanceChunks.getResponses(), keyMap);
}
// if list empty, this method returns back immediately.
// partition size might not be used in this context, as batch size < partition size.
// TODO metering might need some extra work to push volumes in batches, hence not changing this method
// signature
_partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
_partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
_partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
} catch (Exception e) {
_logger.error("Processing Volumes and Snapshots failed", e);
} finally {
_updateVolumes = null;
_updateSnapShots = null;
_updateMirrors = null;
if (null != volumeInstances) {
volumeInstances.close();
}
}
}
use of javax.cim.CIMObjectPath 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 javax.cim.CIMObjectPath 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);
}
}
Aggregations