use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class SoftwareIdentityProcessor method processResult.
/**
* {@inheritDoc}
*/
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
AccessProfile profile = null;
try {
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
@SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
if (it.hasNext()) {
CIMInstance softwareInstance = it.next();
String providerId = profile.getIpAddress() + "-" + profile.getProviderPort();
List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerId);
if (!providers.isEmpty()) {
checkProviderVersion(softwareInstance, providers.get(0));
}
} else {
String errMsg = String.format("No information obtained from Provider %s for Provider version", profile.getIpAddress());
throw new SMIPluginException(errMsg, SMIPluginException.ERRORCODE_OPERATIONFAILED);
}
} catch (SMIPluginException e) {
throw e;
} catch (Exception e) {
String errMsg = String.format("An error occurred while verifying Provider version: %s", e.getMessage());
throw new SMIPluginException(SMIPluginException.ERRORCODE_OPERATIONFAILED, e, errMsg);
}
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class StorageConfigurationCapabilitiesProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
@SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
_profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
try {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
Boolean usingSMIS80 = (Boolean) keyMap.get(Constants.USING_SMIS80_DELIMITERS);
boolean isSMIS80 = (usingSMIS80 != null && usingSMIS80);
while (it.hasNext()) {
CIMInstance storageConfigurationInstance = it.next();
if (Type.vnxblock.toString().equalsIgnoreCase(system.getSystemType())) {
updateStorageSystemCapabilityOnVolumeForVNX(storageConfigurationInstance, system);
} else {
updateStorageSystemCapabilityOnVolume(storageConfigurationInstance, system);
}
system.setUsingSmis80(isSMIS80);
}
_dbClient.persistObject(system);
} catch (Exception e) {
_logger.error("Finding out Storage System Capability on Volume Creation failed :", e);
}
}
use of javax.cim.CIMInstance 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.CIMInstance 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.CIMInstance 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();
}
}
}
Aggregations