use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume 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 com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume 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 com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume 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 com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume 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 com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VolumeDiscoveryPostProcessor method setSupportedVPoolsForReplicas.
private void setSupportedVPoolsForReplicas(Map<String, LocalReplicaObject> volumeToReplicaMap, DbClient dbClient) {
_logger.info("Post processing UnManagedVolumes setSupportedVPoolsForReplicas");
List<UnManagedVolume> modifiedUnManagedVolumes = new ArrayList<UnManagedVolume>();
// for each source, set SUPPORTED_VPOOL_LIST for its targets
for (Entry<String, LocalReplicaObject> entry : volumeToReplicaMap.entrySet()) {
String srcNativeGuid = entry.getKey();
LocalReplicaObject srcObj = entry.getValue();
if (srcObj.hasReplica() && !srcObj.isReplica()) {
// process its dependents
try {
StringSet vPools = null;
// check if unmanaged volume is created
UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(srcNativeGuid, dbClient);
if (unManagedVolume != null) {
vPools = unManagedVolume.getSupportedVpoolUris();
} else {
// check if it has already been ingested
String volumeNativeGuid = srcNativeGuid.replace(NativeGUIDGenerator.UN_MANAGED_VOLUME, NativeGUIDGenerator.VOLUME);
Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, dbClient);
if (volume != null) {
_logger.debug("Volume {} is already being managed by ViPR", volumeNativeGuid);
vPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(dbClient, volume.getPool(), volume.getThinlyProvisioned().toString(), unManagedVolume);
}
}
if (vPools != null && !vPools.isEmpty()) {
setVPoolsForDependents(vPools, srcObj, volumeToReplicaMap, modifiedUnManagedVolumes, dbClient);
} else {
_logger.info("Cannot find supported VPools for {}", srcNativeGuid);
}
} catch (Exception e) {
_logger.warn("Exception on setVPoolsForReplicas {}", e.getMessage());
}
}
// if modifiedUnManagedVolumes size reaches BATCH_SIZE, persist to db
if (modifiedUnManagedVolumes.size() >= BATCH_SIZE) {
_partitionManager.updateAndReIndexInBatches(modifiedUnManagedVolumes, BATCH_SIZE, dbClient, "UnManagedVolumes");
modifiedUnManagedVolumes.clear();
}
}
if (!modifiedUnManagedVolumes.isEmpty()) {
_partitionManager.updateAndReIndexInBatches(modifiedUnManagedVolumes, BATCH_SIZE, dbClient, "UnManagedVolumes");
}
}
Aggregations