use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class MetaVolumeMembersProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
CIMObjectPath[] metaMembersPaths = (CIMObjectPath[]) getFromOutputArgs((CIMArgument[]) resultObj, "OutElements");
if (metaMembersPaths == null || (metaMembersPaths.length == 0)) {
_logger.info(String.format("There are no meta members to process"));
} else {
_logger.debug(String.format("Processing meta members: %s", Arrays.toString(metaMembersPaths)));
// Get volume from db
_logger.debug(String.format("Args size: %s", _args.size()));
Object[] arguments = (Object[]) _args.get(0);
CIMArgument theElement = ((CIMArgument[]) arguments[2])[1];
_logger.info(String.format("TheElement: %s, type %s", theElement.getValue().toString(), theElement.getValue().getClass().toString()));
CIMObjectPath theElementPath = (CIMObjectPath) theElement.getValue();
UnManagedVolume preExistingVolume = null;
String isMetaVolume = "true";
String nativeGuid;
// Check if storage volume exists in db (the method is called from re-discovery context).
nativeGuid = getVolumeNativeGuid(theElementPath);
Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
if (null == storageVolume || storageVolume.getInactive()) {
// Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(theElementPath);
_logger.debug("Volume nativeguid :" + nativeGuid);
preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
if (null == preExistingVolume) {
_logger.debug("Volume Info Object not found :" + nativeGuid);
return;
}
isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
} else {
_logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
isMetaVolume = storageVolume.getIsComposite().toString();
}
if (isMetaVolume.equalsIgnoreCase("false")) {
_logger.error(String.format("MetaVolumeMembersProcessor called for regular volume: %s", nativeGuid));
return;
}
Integer membersCount = metaMembersPaths.length;
// get meta member size. use second member --- the first member will show size of meta volume itself.
CIMObjectPath metaMemberPath = metaMembersPaths[1];
CIMInstance cimVolume = client.getInstance(metaMemberPath, false, false, META_MEMBER_SIZE_INFO);
CIMProperty consumableBlocks = cimVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
CIMProperty blockSize = cimVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
// calculate size = consumableBlocks * block size
Long size = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
// set meta member count and meta members size for meta volume (required for volume expansion)
if (null != preExistingVolume) {
StringSet metaMembersCount = new StringSet();
metaMembersCount.add(membersCount.toString());
preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_COUNT.toString(), metaMembersCount);
StringSet metaMemberSize = new StringSet();
metaMemberSize.add(size.toString());
preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_SIZE.toString(), metaMemberSize);
// persist unmanaged volume in db
dbClient.persistObject(preExistingVolume);
} else {
storageVolume.setMetaMemberCount(membersCount);
storageVolume.setMetaMemberSize(size);
storageVolume.setTotalMetaMemberCapacity(membersCount * size);
// persist volume in db
dbClient.persistObject(storageVolume);
}
_logger.info(String.format("Meta member info: meta member count --- %s, blocks --- %s, block size --- %s, size --- %s .", membersCount, consumableBlocks.getValue().toString(), blockSize.getValue().toString(), size));
}
} catch (Exception e) {
_logger.error("Processing meta volume information failed :", e);
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method activateSingleClone.
@Override
@SuppressWarnings("rawtypes")
public void activateSingleClone(StorageSystem storageSystem, URI fullCopy, TaskCompleter completer) {
_log.info("START activateSingleClone for {}", fullCopy);
try {
Volume volume = _dbClient.queryObject(Volume.class, fullCopy);
CIMArgument[] inArgs = _helper.getActivateFullCopyArguments(storageSystem, volume);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifyReplica(storageSystem, inArgs, outArgs);
// Update sync active property
volume.setSyncActive(true);
volume.setRefreshRequired(true);
volume.setReplicaState(ReplicationState.SYNCHRONIZED.name());
_dbClient.persistObject(volume);
completer.ready(_dbClient);
_log.info("FINISH activateSingleClone for {}", fullCopy);
} catch (Exception e) {
String errorMsg = String.format(ACTIVATE_ERROR_MSG_FORMAT, fullCopy);
_log.error(errorMsg, e);
completer.error(_dbClient, DeviceControllerException.exceptions.activateVolumeFullCopyFailed(e));
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method resyncSingleClone.
@Override
@SuppressWarnings("rawtypes")
public void resyncSingleClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
_log.info("START resyncSingleClone operation");
Volume clone = null;
try {
callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
clone = _dbClient.queryObject(Volume.class, cloneVolume);
URI sourceUri = clone.getAssociatedSourceVolume();
Volume sourceObj = _dbClient.queryObject(Volume.class, sourceUri);
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
if (instance != null) {
CIMArgument[] inArgs = _helper.getResyncReplicaInputArguments(syncObject);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifyReplica(storageSystem, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneResyncJob(job, storageSystem.getId(), taskCompleter)));
}
} else {
String errorMsg = "The clone is already detached. resync will not be performed.";
_log.info(errorMsg);
ServiceError error = DeviceControllerErrors.smis.methodFailed("resyncSingleClone", errorMsg);
taskCompleter.error(_dbClient, error);
}
} catch (Exception e) {
String errorMsg = String.format(RESYNC_ERROR_MSG_FORMAT, cloneVolume);
_log.error(errorMsg, e);
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.resynchronizeFullCopyFailed(e));
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method getReplicationSettingDataInstanceForThinProvisioningPolicy.
@SuppressWarnings("rawtypes")
private CIMInstance getReplicationSettingDataInstanceForThinProvisioningPolicy(final StorageSystem storageSystem, int desiredValue) {
CIMInstance modifiedInstance = null;
try {
CIMObjectPath replicationSettingCapabilities = _cimPath.getReplicationServiceCapabilitiesPath(storageSystem);
CIMArgument[] inArgs = _helper.getReplicationSettingDataInstance();
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storageSystem, replicationSettingCapabilities, GET_DEFAULT_REPLICATION_SETTING_DATA, inArgs, outArgs);
for (CIMArgument<?> outArg : outArgs) {
if (null == outArg) {
continue;
}
if (outArg.getName().equalsIgnoreCase(SmisConstants.DEFAULT_INSTANCE)) {
CIMInstance repInstance = (CIMInstance) outArg.getValue();
if (null != repInstance) {
CIMProperty<?> thinProvisioningPolicy = new CIMProperty<Object>(SmisConstants.THIN_PROVISIONING_POLICY, UINT16_T, new UnsignedInteger16(desiredValue));
CIMProperty<?> targetElementSupplier = new CIMProperty<Object>(TARGET_ELEMENT_SUPPLIER, UINT16_T, new UnsignedInteger16(CREATE_NEW_TARGET_VALUE));
CIMProperty<?>[] propArray = new CIMProperty<?>[] { thinProvisioningPolicy, targetElementSupplier };
modifiedInstance = repInstance.deriveInstance(propArray);
break;
}
}
}
} catch (Exception e) {
_log.error("Error retrieving Replication Setting Data Instance ", e);
}
return modifiedInstance;
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method detachSingleClone.
@Override
@SuppressWarnings("rawtypes")
public void detachSingleClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
_log.info("START detachSingleClone operation");
Volume clone = null;
try {
callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
clone = _dbClient.queryObject(Volume.class, cloneVolume);
URI sourceUri = clone.getAssociatedSourceVolume();
if (!NullColumnValueGetter.isNullURI(sourceUri)) {
BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceUri);
if (sourceObj != null) {
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
if (instance != null) {
CIMArgument[] inArgs = _helper.getDetachSynchronizationInputArguments(syncObject);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifyReplica(storageSystem, inArgs, outArgs);
} else {
_log.info("The clone is already detached. Detach will not be performed.");
}
} else {
_log.info("The clone's source volume cannot be found in the database. Detach will not be performed.");
}
} else {
_log.info("The clone does not have a source volume. Detach will not be performed.");
}
// Update sync active property
/**
* cq:609984 - No need to reset sync active flag as its caused problem
* when check for activated target volume.
*
* @see <code>BlockService#activateFullCopy
* volume.setSyncActive(false);
*/
ReplicationUtils.removeDetachedFullCopyFromSourceFullCopiesList(clone, _dbClient);
clone.setAssociatedSourceVolume(NullColumnValueGetter.getNullURI());
clone.setReplicaState(ReplicationState.DETACHED.name());
_dbClient.persistObject(clone);
if (taskCompleter != null) {
taskCompleter.ready(_dbClient);
}
} catch (Exception e) {
String errorMsg = String.format(DETACH_ERROR_MSG_FORMAT, cloneVolume, clone.getAssociatedSourceVolume());
_log.error(errorMsg, e);
if (taskCompleter != null) {
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.detachVolumeFullCopyFailed(e));
}
}
}
Aggregations