use of javax.cim.CIMInstance 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);
}
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class StorageGroupProcessor method findVolumesSLOFromSGInstance.
/**
* Find the volumes associated with the SG and extract the SLOName and set
* it in keyMap.
*
* @param client
* - WBEMClient
* @param path
* - SG CoP.
* @param volumesWithSLO
* - Volumes with SLO Names.
*/
private void findVolumesSLOFromSGInstance(WBEMClient client, CIMObjectPath path, Map<String, String> volumesWithSLO) {
try {
CIMInstance instance = client.getInstance(path, false, true, SmisConstants.PS_HOST_IO);
String fastSetting = SmisUtils.getSLOPolicyName(instance);
CloseableIterator<CIMObjectPath> volPaths = client.associatorNames(path, null, Constants.STORAGE_VOLUME, null, null);
while (volPaths.hasNext()) {
CIMObjectPath volPath = volPaths.next();
String volumeNativeGuid = getVolumeNativeGuid(volPath);
// Allow overwriting a previous entry if fast setting is non-null.
if (!volumesWithSLO.containsKey(volumeNativeGuid) || fastSetting != null) {
logger.debug("Volume key: {} fastSetting: {}", volumeNativeGuid, fastSetting);
volumesWithSLO.put(volumeNativeGuid, fastSetting);
}
}
} catch (Exception e) {
logger.warn("Finding unexported volume SLOName failed during unmanaged volume discovery", e);
}
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class StorageSynchronizedProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
final Iterator<?> it = (Iterator<?>) resultObj;
@SuppressWarnings("unchecked") Map<String, RemoteMirrorObject> volumeToRAGroupMap = (Map<String, RemoteMirrorObject>) keyMap.get(Constants.UN_VOLUME_RAGROUP_MAP);
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
while (it.hasNext()) {
try {
final CIMInstance instance = (CIMInstance) it.next();
CIMObjectPath volumePath = instance.getObjectPath();
CIMObjectPath sourcePath = (CIMObjectPath) volumePath.getKey(Constants._SystemElement).getValue();
CIMObjectPath destPath = (CIMObjectPath) volumePath.getKey(Constants._SyncedElement).getValue();
String mode = instance.getPropertyValue(SmisConstants.CP_MODE).toString();
String copyMode = null;
if (mode != null) {
copyMode = SupportedCopyModes.getCopyMode(mode);
}
String sourceNativeGuid = createKeyfromPath(sourcePath);
sourceNativeGuid = sourceNativeGuid.replace("VOLUME", "UNMANAGEDVOLUME");
_log.debug("Source Native Guid {}", sourceNativeGuid);
String targetNativeGuid = createKeyfromPath(destPath);
targetNativeGuid = targetNativeGuid.replace("VOLUME", "UNMANAGEDVOLUME");
_log.debug("Target Native Guid {}", targetNativeGuid);
// if child
if (volumeToRAGroupMap.containsKey(targetNativeGuid)) {
// set Parent
// copyMode and raGroup Uri are already part of RemoteMirrorObject
_log.debug("Found Target Native Guid {}", targetNativeGuid);
RemoteMirrorObject rmObj = volumeToRAGroupMap.get(targetNativeGuid);
_log.debug("Found Target Remote Object {}", rmObj);
rmObj.setSourceVolumeNativeGuid(sourceNativeGuid);
rmObj.setType(RemoteMirrorObject.Types.TARGET.toString());
if (copyMode != null && !SupportedCopyModes.UNKNOWN.name().equals(copyMode) && !copyMode.equalsIgnoreCase(rmObj.getCopyMode()) && updateSupportedCopyMode(rmObj.getCopyMode())) {
rmObj.setCopyMode(copyMode);
updateCopyModeInRAGroupObjectIfRequired(copyMode, rmObj);
}
}
if (volumeToRAGroupMap.containsKey(sourceNativeGuid)) {
_log.debug("Found Source Native Guid {}", sourceNativeGuid);
RemoteMirrorObject rmObj = volumeToRAGroupMap.get(sourceNativeGuid);
_log.debug("Found Source Remote Object {}", rmObj);
if (null == rmObj.getTargetVolumenativeGuids()) {
rmObj.setTargetVolumenativeGuids(new StringSet());
}
if (!findVolumesArefromSameArray(sourceNativeGuid, targetNativeGuid)) {
rmObj.getTargetVolumenativeGuids().add(targetNativeGuid);
// Set this only for the volumes have remote replication
rmObj.setType(RemoteMirrorObject.Types.SOURCE.toString());
_log.debug("Updated Target Volumes", rmObj);
}
}
} catch (Exception e) {
_log.error("Finding out Parent of a target Volume failed", e);
}
}
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class StorageVolumeBoundPoolProcessor method processVolumes.
private void processVolumes(CloseableIterator<CIMInstance> allocatedFromStoragePoolInstances, Set<String> volumesList) {
while (allocatedFromStoragePoolInstances.hasNext()) {
CIMInstance allocatedFromStoragePoolInstance = allocatedFromStoragePoolInstances.next();
String boundToThinStoragePool = allocatedFromStoragePoolInstance.getPropertyValue(SmisConstants.EMC_BOUND_TO_THIN_STORAGE_POOL).toString();
if (Boolean.valueOf(boundToThinStoragePool)) {
String volume = allocatedFromStoragePoolInstance.getPropertyValue(SmisConstants.CP_DEPENDENT).toString();
CIMObjectPath volumePath = new CIMObjectPath(volume);
String deviceId = volumePath.getKey(DEVICE_ID).getValue().toString();
volumesList.add(deviceId);
}
}
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class StorageVolumeBoundPoolProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
CloseableIterator<CIMInstance> allocatedFromStoragePoolInstances = null;
EnumerateResponse<CIMInstance> allocatedFromStoragePoolInstanceChunks = null;
@SuppressWarnings("unchecked") Map<String, Set<String>> vmax2ThinPoolToBoundVolumesMap = (Map<String, Set<String>>) keyMap.get(Constants.VMAX2_THIN_POOL_TO_BOUND_VOLUMES);
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
CIMObjectPath storagePoolPath = null;
try {
storagePoolPath = getObjectPathfromCIMArgument(_args);
_logger.debug("VMAX2 Thin Pool: {}", storagePoolPath.toString());
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
if (pool == null) {
_logger.error("Skipping unmanaged volume discovery as the storage pool with path {} doesn't exist in ViPR", storagePoolPath.toString());
return;
}
Set<String> boundVolumes = new HashSet<String>();
allocatedFromStoragePoolInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
allocatedFromStoragePoolInstances = allocatedFromStoragePoolInstanceChunks.getResponses();
processVolumes(allocatedFromStoragePoolInstances, boundVolumes);
while (!allocatedFromStoragePoolInstanceChunks.isEnd()) {
_logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
allocatedFromStoragePoolInstanceChunks = client.getInstancesWithPath(storagePoolPath, allocatedFromStoragePoolInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumes(allocatedFromStoragePoolInstanceChunks.getResponses(), boundVolumes);
}
vmax2ThinPoolToBoundVolumesMap.put(storagePoolPath.toString(), boundVolumes);
_logger.debug("Bound volumes list {}", Joiner.on("\t").join(boundVolumes));
} catch (Exception e) {
_logger.error("Processing Bound Storage Volume Information failed :", e);
} finally {
if (null != allocatedFromStoragePoolInstances) {
allocatedFromStoragePoolInstances.close();
}
if (null != allocatedFromStoragePoolInstanceChunks) {
try {
client.closeEnumeration(storagePoolPath, allocatedFromStoragePoolInstanceChunks.getContext());
} catch (Exception e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
}
Aggregations