use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SRDFOperations method createSRDFCgPairs.
public void createSRDFCgPairs(final StorageSystem sourceSystem, List<URI> sourceURIs, List<URI> targetURIs, SRDFMirrorCreateCompleter completer) {
List<Volume> sourceVolumes = dbClient.queryObject(Volume.class, sourceURIs);
List<Volume> targetVolumes = dbClient.queryObject(Volume.class, targetURIs);
Volume firstSource = sourceVolumes.get(0);
Volume firstTarget = targetVolumes.get(0);
int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
RemoteDirectorGroup raGroup = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, raGroup.getRemoteStorageSystemUri());
CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(sourceSystem);
CIMObjectPath srcCGPath = null;
CIMObjectPath tgtCGPath = null;
try {
log.info("Creating sources group with: {}", firstSource.getNativeId());
srcCGPath = createDeviceGroup(sourceSystem, sourceSystem, sourceVolumes, dbClient);
String sourceGroupName = (String) srcCGPath.getKey(CP_INSTANCE_ID).getValue();
log.info("Source volumes placed into replication group: {}", srcCGPath);
log.info("Creating targets group with: {}", targetVolumes.get(0).getNativeId());
tgtCGPath = createDeviceGroup(targetSystem, sourceSystem, targetVolumes, dbClient);
String targetGroupName = (String) tgtCGPath.getKey(CP_INSTANCE_ID).getValue();
log.info("Target volumes placed into replication group: {}", tgtCGPath);
if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
log.info("SRDF Link already established.");
return;
}
CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(sourceSystem, raGroup);
// look for existing volumes, if found then use AddSyncPair
boolean formatVolumeFlagNeeded = ((SRDFMirrorCreateCompleter) completer).getVirtualPoolChangeURI() == null;
CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(sourceSystem, modeValue, true, formatVolumeFlagNeeded);
String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(firstSource, dbClient);
CIMArgument[] inArgs = helper.getCreateGroupReplicaForSRDFInputArguments(sourceSystem, groupName, srcCGPath, tgtCGPath, repCollectionPath, modeValue, replicationSettingDataInstance);
CIMArgument[] outArgs = new CIMArgument[5];
completer.setCGName(sourceGroupName, targetGroupName, firstSource.getConsistencyGroup());
helper.invokeMethodSynchronously(sourceSystem, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, sourceSystem.getId(), completer));
completer.ready(dbClient);
} catch (WBEMException wbeme) {
String msg = format("SMI-S error creating mirror for Sources:%s Targets:%s", sourceURIs, targetURIs);
log.error(msg, wbeme);
// check whether synchronization really succeeds in Array
if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
completer.ready(dbClient);
} else {
ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
completer.error(dbClient, error);
}
} catch (Exception e) {
String msg = format("Error creating mirror for Sources:%s Targets:%s", sourceURIs, targetURIs);
log.error(msg, e);
if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
completer.ready(dbClient);
} else {
if (e.getMessage().contains("Replication Control Succeeded")) {
String dbMsg = format("Replication Succeeded but save to DB failed exception leaves the SRDF relationship to get established properly after some time. Hence for now succeeding this operation. for Sources:%s Targets:%s", sourceURIs, targetURIs);
log.info(dbMsg, e);
completer.ready(dbClient);
return;
}
ServiceError error = SmisException.errors.jobFailed(e.getMessage());
WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
completer.error(dbClient, error);
}
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SRDFOperations method removeFromDeviceGroups.
@SuppressWarnings("rawtypes")
private boolean removeFromDeviceGroups(final StorageSystem system, final StorageSystem forProvider, final Volume volume, final BlockConsistencyGroup cg) {
log.info("removeFromDeviceGroups:");
log.info("Volume: {} / {}", volume.getDeviceLabel(), volume.getNativeId());
log.info("Array: {}", system.getSerialNumber());
log.info("Provider: {}", forProvider.getSmisProviderIP());
boolean removedFromAllGroups = true;
try {
String cgLabel = (cg.getAlternateLabel() != null) ? cg.getAlternateLabel() : cg.getLabel();
log.info("Volume nativeId: {}, CG name: {}", volume.getNativeId(), cgLabel);
CIMObjectPath deviceGroupPath = getDeviceGroup(system, forProvider, volume, cgLabel);
CIMObjectPath volumePath = cimPath.getBlockObjectPath(system, volume);
CIMObjectPath repSvcPath = cimPath.getControllerReplicationSvcPath(system);
if (deviceGroupPath != null) {
log.info(format("Found Volume %s to be a member of group %s", volume.getNativeId(), deviceGroupPath));
CIMArgument[] inArgs = helper.getRemoveMembersInputArguments(deviceGroupPath, new CIMObjectPath[] { volumePath });
CIMArgument[] outArgs = new CIMArgument[5];
helper.invokeMethod(forProvider, repSvcPath, REMOVE_MEMBERS, inArgs, outArgs);
if (!getVolumesPartOfReplicationGroup(deviceGroupPath, forProvider, system).isEmpty()) {
log.warn(format("Group %s still has Volumes part of it.", deviceGroupPath));
removedFromAllGroups = false;
}
// From 8.0 providers, DeleteOnEmptyElement property is not supported on Group creations.
// hence, we need to check and delete the RG when it becomes empty.
CIMInstance deviceGroupInstance = helper.checkExists(forProvider, deviceGroupPath, false, false);
if (deviceGroupInstance != null) {
if (getVolumesPartOfRG(deviceGroupPath, forProvider, system).isEmpty()) {
// delete RG
log.info("No more volumes left on Group {}, Deleting it.", deviceGroupPath.toString());
inArgs = helper.getDeleteReplicationGroupInputArguments(system, deviceGroupInstance.getPropertyValue(CP_ELEMENT_NAME).toString());
helper.invokeMethod(forProvider, repSvcPath, SmisConstants.DELETE_GROUP, inArgs, outArgs);
}
}
} else {
// volume is not found to be part of SRDF RG. return false indicating this method didn't process anything.
removedFromAllGroups = false;
}
} catch (WBEMException e) {
log.debug("Failed to remove volume {} from its replication group, probably already removed", volume.getId(), e);
} catch (Exception e) {
log.debug("Failed to remove volume {} from its replication group, probabaly already removed", volume.getId(), e);
}
return removedFromAllGroups;
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SRDFOperations method getReplicationSettingDataInstance.
/**
* Gets the replication setting data instance.
*
* @param sourceSystem the source system
* @param modeValue the mode value
* @param nonEmptyRDFGroup indicates whether to pass CONSISTENCY_EXEMPT flag or not
* CONSISTENCY_EXEMPT does not need to be set if the RDF group is empty
* CONSISTENCY_EXEMPT should only be specified if the devices in the RDF group are in ASYNC mode
* @param formatVolumeFlagNeeded
* @return the replication setting data instance
*/
private CIMInstance getReplicationSettingDataInstance(final StorageSystem sourceSystem, int modeValue, boolean nonEmptyRDFGroup, boolean formatVolumeFlagNeeded) throws Exception {
CIMInstance modifiedInstance = null;
CIMObjectPath replicationSettingCapabilities = cimPath.getReplicationServiceCapabilitiesPath(sourceSystem);
int replicationType = Mode.ASYNCHRONOUS.getMode() == modeValue ? ASYNC_MIRROR_REMOTE_REPLICATION_TYPE : SYNC_MIRROR_REMOTE_REPLICATION_TYPE;
CIMArgument[] inArgs = helper.getReplicationSettingDataInstance(replicationType);
CIMArgument[] outArgs = new CIMArgument[5];
helper.invokeMethod(sourceSystem, replicationSettingCapabilities, "GetDefaultReplicationSettingData", inArgs, outArgs);
for (CIMArgument<?> outArg : outArgs) {
if (null == outArg) {
continue;
}
if (outArg.getName().equalsIgnoreCase(DEFAULT_INSTANCE)) {
CIMInstance repInstance = (CIMInstance) outArg.getValue();
if (null != repInstance) {
List<CIMProperty<?>> propList = new ArrayList<CIMProperty<?>>();
if (Mode.ASYNCHRONOUS.getMode() == modeValue && nonEmptyRDFGroup) {
CIMProperty<?> existingProp = repInstance.getProperty(EMC_CONSISTENCY_EXEMPT);
CIMProperty<?> prop = null;
if (existingProp == null) {
// ConsistencyExempt property is now part of the smi-s standard. Available in providers 8.0+ (VMAX3 arrays)
// EMCConsistencyExempt property in ReplicationSettingData is removed
existingProp = repInstance.getProperty(CONSISTENCY_EXEMPT);
prop = new CIMProperty<Object>(CONSISTENCY_EXEMPT, existingProp.getDataType(), true);
} else {
prop = new CIMProperty<Object>(EMC_CONSISTENCY_EXEMPT, existingProp.getDataType(), true);
}
propList.add(prop);
}
// Use force flag only if the RDF Group is not empty AND if the source volume doesn't have any data on it.
// Through ViPR only if its change virtual pool operation, the source volume will have data, hence
// formatVolumeFlagNeeded flag will be set to false only during ChangeVirtualPool
log.info("NonEmptyRDFGroup : {}, formatFlagNeeded {} ", nonEmptyRDFGroup, formatVolumeFlagNeeded);
if (nonEmptyRDFGroup && Mode.ACTIVE.getMode() == modeValue && formatVolumeFlagNeeded) {
log.info("Adding format flag to replication Group Instance...");
// NOTE: Format flag will wipe out the data.
// he FORMAT property is not available as part of the default Replication Instance.
// We will be on our own adding this property..
CIMProperty<?> formatData = new CIMProperty<Object>(FORMAT, BOOLEAN_T, true);
List<CIMProperty<?>> dupPropList = new ArrayList<CIMProperty<?>>();
dupPropList.addAll(Arrays.asList(repInstance.getProperties()));
dupPropList.add(formatData);
CIMInstance duplicateRepInstance = new CIMInstance(repInstance.getObjectPath(), dupPropList.toArray(new CIMProperty<?>[] {}));
// Re-assigning
repInstance = duplicateRepInstance;
}
// Set target supplier to Implementation Decides so that the supplied targets can be used
CIMProperty<?> targetElementSupplier = new CIMProperty<Object>(TARGET_ELEMENT_SUPPLIER, UINT16_T, new UnsignedInteger16(IMPLEMENTATION_DECIDES));
propList.add(targetElementSupplier);
modifiedInstance = repInstance.deriveInstance(propList.toArray(new CIMProperty<?>[] {}));
break;
}
}
}
return modifiedInstance;
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SRDFOperations method createSRDFMirror.
public void createSRDFMirror(final StorageSystem systemWithCg, final List<Volume> srcVolumes, final List<Volume> targetVolumes, final boolean storSyncAvailable, final TaskCompleter completer) {
log.info("START createSRDFMirror");
CIMObjectPath srcCGPath = null;
CIMObjectPath tgtCGPath = null;
try {
Volume firstSource = srcVolumes.iterator().next();
Volume firstTarget = targetVolumes.iterator().next();
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, firstSource.getStorageController());
int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(systemWithCg);
srcCGPath = createDeviceGroup(sourceSystem, systemWithCg, srcVolumes, dbClient);
String sourceGroupName = (String) srcCGPath.getKey(CP_INSTANCE_ID).getValue();
log.info("Source Volumes placed into replication group: {}", srcCGPath);
// Note: We switch to the appropriate targetSystem but use sourceSystem for the provider call
tgtCGPath = createDeviceGroup(targetSystem, systemWithCg, targetVolumes, dbClient);
String targetGroupName = (String) tgtCGPath.getKey(CP_INSTANCE_ID).getValue();
log.info("Target Volumes placed into replication group: {}", tgtCGPath);
// FALSE being passed, because the source volume will have data when /continuous-copies/START API is invoked.
CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(systemWithCg, modeValue, true, false);
CIMArgument[] inArgs = null;
CIMArgument[] outArgs = new CIMArgument[5];
if (completer instanceof SRDFLinkStartCompleter) {
((SRDFLinkStartCompleter) completer).setCGName(sourceGroupName, targetGroupName, firstSource.getConsistencyGroup());
}
String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(firstSource, dbClient);
if (storSyncAvailable) {
log.info("Creating Group synchronization between source volume group and target volume group");
// there are storage synchronizations available for these pairs
Collection<CIMObjectPath> elementSynchronizations = utils.getSynchronizations(systemWithCg, firstSource, firstTarget);
inArgs = helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(srcCGPath, tgtCGPath, elementSynchronizations, groupName);
helper.invokeMethod(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
// No Job returned
completer.ready(dbClient);
} else {
CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(systemWithCg, group);
inArgs = helper.getCreateGroupReplicaForSRDFInputArguments(sourceSystem, groupName, srcCGPath, tgtCGPath, repCollectionPath, modeValue, replicationSettingDataInstance);
helper.invokeMethodSynchronously(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, systemWithCg.getId(), completer));
completer.ready(dbClient);
}
} catch (WBEMException wbeme) {
log.error("SMI-S error creating mirror group synchronization", wbeme);
// check whether synchronization really succeeds in Array
if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
completer.ready(dbClient);
} else {
ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
completer.error(dbClient, error);
}
} catch (Exception e) {
log.error("Error creating mirror group synchronization", e);
if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
completer.ready(dbClient);
} else {
if (e.getMessage().contains("Replication Control Succeeded")) {
log.info("Replication Succeeded but save to DB failed exception leaves the SRDF relationship to get established properly after some time. Hence for now succeeding this operation.", e);
completer.ready(dbClient);
return;
}
ServiceError error = SmisException.errors.jobFailed(e.getMessage());
WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
completer.error(dbClient, error);
}
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class ReplicationUtils method deleteTargetDevices.
/**
* Method will invoke the SMI-S operation to return the Volumes represented by the native ids to the storage pool
*
* @param storageSystem - StorageSystem where the pool and volume exist
* @param deviceIds - List of native Ids representing the elements to be returned to the pool
* @param taskCompleter - Completer object used for task status update
*
* @throws DeviceControllerException
*/
public static void deleteTargetDevices(final StorageSystem storageSystem, final String[] deviceIds, final TaskCompleter taskCompleter, final DbClient dbClient, final SmisCommandHelper helper, final CIMObjectPathFactory cimPath) {
_log.info(format("Removing target devices {0} from storage system {1}", Joiner.on(',').join(deviceIds), storageSystem.getId()));
try {
if (storageSystem.checkIfVmax3()) {
helper.removeVolumeFromParkingSLOStorageGroup(storageSystem, deviceIds, false);
_log.info("Done invoking remove volumes from parking SLO storage group");
}
CIMArgument[] outArgs = new CIMArgument[5];
CIMArgument[] inArgs = null;
String method = null;
CIMObjectPath configSvcPath = cimPath.getConfigSvcPath(storageSystem);
if (storageSystem.deviceIsType(Type.vmax)) {
final CIMObjectPath[] theElements = cimPath.getVolumePaths(storageSystem, deviceIds);
inArgs = helper.getReturnElementsToStoragePoolArguments(theElements, SmisConstants.CONTINUE_ON_NONEXISTENT_ELEMENT);
method = RETURN_ELEMENTS_TO_STORAGE_POOL;
} else {
inArgs = helper.getDeleteVolumesInputArguments(storageSystem, deviceIds);
method = EMC_RETURN_TO_STORAGE_POOL;
}
final SmisDeleteVmaxCGTargetVolumesJob job = new SmisDeleteVmaxCGTargetVolumesJob(null, storageSystem.getId(), deviceIds, taskCompleter);
helper.invokeMethodSynchronously(storageSystem, configSvcPath, method, inArgs, outArgs, job);
} catch (Exception e) {
_log.error(format("An error occurred when removing target devices {0} from storage system {1}", deviceIds, storageSystem.getId()), e);
}
}
Aggregations