use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class TierPolicyProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
CIMObjectPath storageGroupPath = getObjectPathfromCIMArgument(_args);
@SuppressWarnings("unchecked") Map<String, CIMObjectPath> volumeToStorageGroupMapping = (Map<String, CIMObjectPath>) keyMap.get(Constants.VOLUME_STORAGE_GROUP_MAPPING);
CIMObjectPath volumePath = volumeToStorageGroupMapping.get(storageGroupPath.getKey(Constants.INSTANCEID).getValue().toString());
String nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
UnManagedVolume preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, _dbClient);
if (null == preExistingVolume) {
return;
}
// get VolumeInfo Object and inject Fast Policy Name.
@SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
while (it.hasNext()) {
CIMObjectPath policyPath = it.next();
injectIntoVolumeInformationContainer(preExistingVolume, Constants.POLICYRULENAME, policyPath);
preExistingVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(), "true");
}
_dbClient.persistObject(preExistingVolume);
} catch (Exception e) {
_logger.error("Processing Tier Policy in Pre Existing Volume failed", e);
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VNXFastVolumesProcessor method processVolumes.
private void processVolumes(Iterator<CIMObjectPath> it, CIMObjectPath tierPolicyPath, Map<String, Object> keyMap, Operation operation) {
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
while (it.hasNext()) {
CIMObjectPath volumePath = null;
try {
volumePath = it.next();
if (tierPolicyPath.toString().contains(AutoTieringPolicy.VnxFastPolicy.DEFAULT_AUTOTIER.toString())) {
_logger.debug("Adding Auto Tier Policy Rule ");
addPath(keyMap, operation.getResult(), volumePath);
continue;
}
String volumeNativeGuid = getVolumeNativeGuid(volumePath);
Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
if (null != volume) {
_logger.debug("Skipping discovery, as this Volume {} is already being managed by ViPR.", volumeNativeGuid);
continue;
}
String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
if (null != unManagedVolume) {
String policyName = getCIMPropertyValue(tierPolicyPath, Constants.POLICYRULENAME);
_logger.info("Adding {} Policy Rule to UnManaged Volume {}", policyName, unManagedVolumeNativeGuid);
injectIntoVolumeInformationContainer(unManagedVolume, Constants.POLICYRULENAME, tierPolicyPath);
unManagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(), "true");
// StorageVolumeInfoProcessor updated supported_vpool_list based on its pool's presence in vPool
// Now, filter those vPools based on policy associated
DiscoveryUtils.filterSupportedVpoolsBasedOnTieringPolicy(unManagedVolume, policyName, system, _dbClient);
_unManagedVolumesUpdate.add(unManagedVolume);
}
if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
_partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
_unManagedVolumesUpdate.clear();
}
} catch (Exception ex) {
_logger.error("Processing UnManaged Storage Volume {} ", volumePath, ex);
}
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VNXFastVolumesProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
CloseableIterator<CIMObjectPath> volumeInstances = null;
try {
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
_unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
@SuppressWarnings("unchecked") EnumerateResponse<CIMObjectPath> volumeInstanceChunks = (EnumerateResponse<CIMObjectPath>) resultObj;
volumeInstances = volumeInstanceChunks.getResponses();
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
CIMObjectPath tierPolicypath = getObjectPathfromCIMArgument(_args);
processVolumes(volumeInstances, tierPolicypath, keyMap, operation);
while (!volumeInstanceChunks.isEnd()) {
_logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
volumeInstanceChunks = client.getInstancePaths(tierPolicypath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumes(volumeInstanceChunks.getResponses(), tierPolicypath, keyMap, operation);
}
if (!_unManagedVolumesUpdate.isEmpty()) {
_partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
_unManagedVolumesUpdate.clear();
}
} catch (Exception e) {
_logger.error("Discovering Tier Policies for vnx volumes failed", e);
} finally {
volumeInstances.close();
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VolumeAccessStateProcessor method processVolumes.
private void processVolumes(Iterator<CIMInstance> it, Map<String, Object> keyMap, Operation operation) {
while (it.hasNext()) {
try {
CIMInstance volumeInstance = it.next();
CIMObjectPath volumePath = volumeInstance.getObjectPath();
// TODO add logic to get Access
String access = null;
Object value = volumeInstance.getPropertyValue(SupportedVolumeInformation.ACCESS.toString());
if (value != null) {
access = value.toString();
}
StringSet statusDesc = new StringSet();
String[] descriptions = null;
value = volumeInstance.getPropertyValue(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString());
if (value != null) {
descriptions = (String[]) value;
for (String desc : descriptions) {
statusDesc.add(desc);
}
}
String volumeNativeGuid = getVolumeNativeGuid(volumePath);
Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
if (null != volume) {
_logger.debug("Skipping discovery, as this Volume is already being managed by ViPR :" + volumeNativeGuid);
continue;
}
String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
if (null != unManagedVolume) {
_logger.debug("Adding Access {}", unManagedVolumeNativeGuid);
StringSet accessSet = new StringSet();
if (access != null) {
accessSet.add(access);
}
if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString())) {
unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.ACCESS.toString(), accessSet);
} else {
unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString()).replace(accessSet);
}
if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString())) {
unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString(), statusDesc);
} else {
unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString()).replace(statusDesc);
}
_unManagedVolumesUpdate.add(unManagedVolume);
}
if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
_partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "UnManagedVolume");
_unManagedVolumesUpdate.clear();
}
} catch (Exception ex) {
_logger.error("Processing UnManaged Storage Volume", ex);
}
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class ArrayAffinityProcessor method getPreferredPoolMap.
/**
* Get preferred pool to export type map for a host
*
* @param hostId Id of Host instance
* @param profile AccessProfile
* @param cimClient WBEMClient
* @param dbClient DbClient
* @return preferred pool to export type map
*/
private Map<String, String> getPreferredPoolMap(URI hostId, AccessProfile profile, WBEMClient cimClient, DbClient dbClient) {
Map<String, String> preferredPoolMap = new HashMap<String, String>();
List<Initiator> allInitiators = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Initiator.class, ContainmentConstraint.Factory.getContainedObjectsConstraint(hostId, Initiator.class, Constants.HOST));
Set<CIMObjectPath> hardwareIdPaths = new HashSet<CIMObjectPath>();
for (Initiator initiator : allInitiators) {
_logger.info("Processing initiator {}", initiator.getLabel());
String normalizedPortName = Initiator.normalizePort(initiator.getInitiatorPort());
String query = String.format("SELECT %s.%s FROM %s where %s.%s ='%s'", SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CP_INSTANCE_ID, SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CP_ELEMENT_NAME, normalizedPortName);
CIMObjectPath hardwareIdPath = CimObjectPathCreator.createInstance(SmisConstants.CIM_STORAGE_HARDWARE_ID, Constants.EMC_NAMESPACE, null);
List<CIMInstance> hardwareIds = DiscoveryUtils.executeQuery(cimClient, hardwareIdPath, query, CQL);
if (!hardwareIds.isEmpty()) {
hardwareIdPaths.add(hardwareIds.get(0).getObjectPath());
}
}
Set<CIMObjectPath> maskPaths = new HashSet<CIMObjectPath>();
for (CIMObjectPath hardwareIdPath : hardwareIdPaths) {
maskPaths.addAll(DiscoveryUtils.getAssociatorNames(cimClient, hardwareIdPath, null, SmisConstants.CIM_PROTOCOL_CONTROLLER, null, null));
}
Set<CIMObjectPath> volumePathsInMasks = new HashSet<CIMObjectPath>();
Map<CIMObjectPath, String> volumeToPool = new HashMap<CIMObjectPath, String>();
for (CIMObjectPath path : maskPaths) {
_logger.info("Processing masking view {}", path.toString());
List<CIMObjectPath> hardwareIdsInMask = DiscoveryUtils.getAssociatorNames(cimClient, path, null, SmisConstants.CIM_STORAGE_HARDWARE_ID, null, null);
// check if the mask is shared or exclusive
String maskType = hardwareIdPaths.containsAll(hardwareIdsInMask) ? ExportGroup.ExportGroupType.Host.name() : ExportGroup.ExportGroupType.Cluster.name();
List<CIMObjectPath> volumePaths = DiscoveryUtils.getAssociatorNames(cimClient, path, null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
for (CIMObjectPath volumePath : volumePaths) {
if (ArrayAffinityDiscoveryUtils.isUnmanagedVolume(volumePath, dbClient)) {
URI poolURI = ArrayAffinityDiscoveryUtils.getStoragePool(volumePath, cimClient, dbClient);
if (!NullColumnValueGetter.isNullURI(poolURI)) {
if (ExportGroup.ExportGroupType.Host.name().equals(maskType)) {
volumePathsInMasks.add(volumePath);
volumeToPool.put(volumePath, poolURI.toString());
}
ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, poolURI.toString(), maskType);
}
}
}
}
for (CIMObjectPath volumePath : volumePathsInMasks) {
// get masks from the volume path
List<CIMObjectPath> masks = DiscoveryUtils.getAssociatorNames(cimClient, volumePath, null, SmisConstants.CIM_PROTOCOL_CONTROLLER, null, null);
if (!maskPaths.containsAll(masks)) {
// shared volumes
_logger.info("Volume {} is shared by multiple hosts", volumePath);
ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, volumeToPool.get(volumePath), ExportGroup.ExportGroupType.Cluster.name());
}
}
return preferredPoolMap;
}
Aggregations