use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class VnxSnapshotOperations method createGroupSnapshots.
/**
* Should implement create of a snapshot from a source volume that is part of a
* consistency group.
*
* @param storage [required] - StorageSystem object representing the array
* @param snapshot [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param createInactive - Indicates if the snapshots should be created but not
* activated
* @param readOnly - Indicates if the snapshot should be read only.
* @param taskCompleter - TaskCompleter object used for the updating operation status.
* @throws DeviceControllerException
*/
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
URI snapshot = snapshotList.get(0);
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
if (ControllerUtils.isNotInRealVNXRG(volume, _dbClient)) {
throw DeviceControllerException.exceptions.groupSnapshotNotSupported(volume.getReplicationGroupInstance());
}
// CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, snapshotObj, _dbClient, _helper, _cimPath);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, _dbClient);
CIMObjectPath cgPath = _cimPath.getReplicationGroupPath(storage, groupName);
CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
CIMArgument[] inArgs = _helper.getCreateGroupReplicaInputArgumentsForVNX(storage, cgPath, createInactive, snapLabelToUse, SYNC_TYPE.SNAPSHOT.getValue());
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGSnapshotJob(job, storage.getId(), !createInactive, null, taskCompleter)));
}
} catch (Exception e) {
_log.info("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
setInactive(((BlockSnapshotCreateCompleter) taskCompleter).getSnapshotURIs(), true);
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doAddToReplicationGroup.
@Override
public void doAddToReplicationGroup(final StorageSystem storage, final URI consistencyGroupId, final String replicationGroupName, final List<URI> replicas, final TaskCompleter taskCompleter) throws DeviceControllerException {
// 8.0.3 will support adding replicas to replication group but the replicas should be added to the
// device masking group corresponding to the consistency group
_log.info("Adding replicas to Device Masking Group equivalent to its ReplicationGroup {}", replicationGroupName);
List<URI> replicasToAdd;
try {
if (!storage.deviceIsType(Type.vnxblock)) {
replicasToAdd = _helper.filterReplicasAlreadyPartOfReplicationGroup(storage, replicationGroupName, replicas);
if (!replicasToAdd.isEmpty()) {
CIMArgument[] inArgsAdd;
inArgsAdd = _helper.getAddVolumesToMaskingGroupInputArguments(storage, replicationGroupName, replicasToAdd, null, true);
CIMArgument[] outArgsAdd = new CIMArgument[5];
_helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), SmisConstants.ADD_MEMBERS, inArgsAdd, outArgsAdd, null);
} else {
_log.info("Requested replicas {} are already part of the Replication Group {}, hence skipping AddMembers call..", Joiner.on(", ").join(replicas), replicationGroupName);
}
} else {
_log.info("There is no corresponding replication group for VNX mirrors and clones");
}
// persist group name/settings instance (for VMAX3) in replica objects
List<BlockObject> replicaList = new ArrayList<BlockObject>();
String settingsInst = null;
if (storage.checkIfVmax3() && URIUtil.isType(replicas.get(0), BlockSnapshot.class)) {
List<BlockSnapshot> blockSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(replicationGroupName, storage.getId(), _dbClient);
if (blockSnapshots != null && !blockSnapshots.isEmpty()) {
settingsInst = blockSnapshots.get(0).getSettingsInstance();
}
}
for (URI replica : replicas) {
BlockObject replicaObj = BlockObject.fetch(_dbClient, replica);
replicaObj.setReplicationGroupInstance(replicationGroupName);
// don't set CG on Clones
if (replicaObj instanceof BlockMirror || replicaObj instanceof BlockSnapshot) {
replicaObj.setConsistencyGroup(consistencyGroupId);
if (replicaObj instanceof BlockMirror) {
String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(replicaObj, _dbClient);
CIMObjectPath syncPath = _cimPath.getGroupSynchronizedPath(storage, groupName, replicationGroupName);
((BlockMirror) replicaObj).setSynchronizedInstance(syncPath.toString());
} else if (replicaObj instanceof BlockSnapshot) {
if (settingsInst != null) {
((BlockSnapshot) replicaObj).setSettingsInstance(settingsInst);
}
}
}
replicaList.add(replicaObj);
}
_dbClient.updateAndReindexObject(replicaList);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Problem while adding replica to device masking group :{}", consistencyGroupId, e);
if (null != replicas && !replicas.isEmpty()) {
for (URI replicaURI : replicas) {
BlockObject blockObj = _dbClient.queryObject(BlockObject.class, replicaURI);
blockObj.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
_dbClient.updateObject(blockObj);
}
}
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.failedToAddMembersToReplicationGroup(replicationGroupName, storage.getLabel(), e.getMessage()));
return;
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doCreateVolumes.
@Override
public void doCreateVolumes(final StorageSystem storageSystem, final StoragePool storagePool, final String opId, final List<Volume> volumes, final VirtualPoolCapabilityValuesWrapper capabilities, final TaskCompleter taskCompleter) throws DeviceControllerException {
String label = null;
Long capacity = null;
Long thinVolumePreAllocationSize = null;
CIMInstance poolSetting = null;
boolean opCreationFailed = false;
StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
StorageSystem forProvider = _helper.getStorageSystemForProvider(storageSystem, volumes.get(0));
// volumeGroupObjectPath is required for VMAX3
CIMObjectPath volumeGroupObjectPath = _helper.getVolumeGroupPath(forProvider, storageSystem, volumes.get(0), storagePool);
List<String> volumeLabels = new ArrayList<>();
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned()));
String tenantName = "";
try {
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
tenantName = tenant.getLabel();
} catch (DatabaseException e) {
_log.error("Error lookup TenantOrb object", e);
}
label = _nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
volumeLabels.add(label);
if (capacity == null) {
capacity = volume.getCapacity();
}
if (thinVolumePreAllocationSize == null && volume.getThinVolumePreAllocationSize() > 0) {
thinVolumePreAllocationSize = volume.getThinVolumePreAllocationSize();
}
}
_log.info(logMsgBuilder.toString());
boolean isThinlyProvisioned = volumes.get(0).getThinlyProvisioned();
try {
CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
CIMArgument[] inArgs = null;
// I didn't find any ways to add this branching logic based on device Types.
if (DiscoveredDataObject.Type.vnxblock.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
String autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volumes.get(0).getId(), _dbClient);
if (autoTierPolicyName.equals(Constants.NONE)) {
autoTierPolicyName = null;
}
inArgs = _helper.getCreateVolumesInputArgumentsOnFastEnabledPool(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, autoTierPolicyName);
} else {
if (!storageSystem.checkIfVmax3() && isThinlyProvisioned && null != thinVolumePreAllocationSize) {
poolSetting = _smisStorageDevicePreProcessor.createStoragePoolSetting(storageSystem, storagePool, thinVolumePreAllocationSize);
}
if (storageSystem.checkIfVmax3()) {
inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, true, volumeGroupObjectPath, (null != thinVolumePreAllocationSize));
} else {
inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, poolSetting, true);
}
}
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(forProvider, configSvcPath, _helper.createVolumesMethodName(forProvider), inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
SmisJob createSmisJob = volumes.size() > 1 ? new SmisCreateMultiVolumeJob(job, forProvider.getId(), storagePool.getId(), volumes.size(), taskCompleter) : new SmisCreateVolumeJob(job, forProvider.getId(), storagePool.getId(), taskCompleter);
ControllerServiceImpl.enqueueJob(new QueueJob(createSmisJob));
}
} catch (final InternalException e) {
_log.error("Problem in doCreateVolumes: ", e);
opCreationFailed = true;
taskCompleter.error(_dbClient, e);
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
opCreationFailed = true;
ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, serviceError);
} catch (Exception e) {
_log.error("Problem in doCreateVolumes: ", e);
opCreationFailed = true;
ServiceError serviceError = DeviceControllerErrors.smis.methodFailed("doCreateVolumes", e.getMessage());
taskCompleter.error(_dbClient, serviceError);
}
if (opCreationFailed) {
for (Volume vol : volumes) {
vol.setInactive(true);
_dbClient.updateObject(vol);
}
}
logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
_log.info(logMsgBuilder.toString());
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doInitiatorAliasSet.
/**
* This method will be used to set the Initiator Alias for a given initiator.
* The SMI-S version that supports this operation is Version 8.2 onwards.
* The initiator must be part of the an Initiator Group for the Value to be set
*
* @param storage
* - StorageSystem object
* @param initiator
* - Initiator Object for which the Alias needs to be set
* @param initiatorAlias
* - User Friendly Name
* @throws Exception
*/
@Override
public void doInitiatorAliasSet(StorageSystem storage, Initiator initiator, String initiatorAlias) throws Exception {
try {
checkIfProviderSupportsAliasOperations(storage);
CIMObjectPath hwManagementIDSvcPath = _cimPath.getStorageHardwareIDManagementService(storage);
CIMObjectPath shidPath = getSHIDPathForAliasOperation(storage, hwManagementIDSvcPath, initiator);
CIMArgument[] inArgs = _helper.getEMCInitiatorAliasSetArgs(shidPath, initiatorAlias);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, hwManagementIDSvcPath, SmisConstants.INITIATOR_ALIAS_SET, inArgs, outArgs);
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
throw e;
} catch (Exception e) {
_log.error("Unexpected error: EMCInitiatorAliasSet failed.", e);
throw e;
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class SmisStorageDevice method cleanupAnyGroupBackupSnapshots.
/**
* Method will look up backup snapshots that were created when a snapshot restore operation was
* performed, then clean them up. This would be required in order to delete the ReplicationGroup.
*
* @param storage
* [required] - StorageSystem object representing the array
* @param replicationGroupPath
* [required] - CIMObjectPath object representing the ReplicationGroup
*/
private void cleanupAnyGroupBackupSnapshots(StorageSystem storage, CIMObjectPath replicationGroupPath) {
_log.info("Cleaning up backup snapshots for: {}", replicationGroupPath);
CloseableIterator<CIMObjectPath> settings = null;
try {
settings = _helper.getReference(storage, replicationGroupPath, SmisConstants.CLAR_SETTINGS_DEFINE_STATE_RG_SAFS, null);
while (settings.hasNext()) {
CIMObjectPath path = settings.next();
CIMArgument[] inArgs = _helper.getDeleteSettingsForSnapshotInputArguments(path, true);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifySettingsDefineState(storage, inArgs, outArgs);
}
} catch (Exception e) {
_log.warn("Problem making SMI-S call: ", e);
} finally {
if (settings != null) {
settings.close();
}
}
}
Aggregations