use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method terminateAnyRestoreSessionsForVolume.
/**
* Look up any snapshot objects associated with the give volume. For each, can to terminate
* any existing restore sessions.
*
* @param storage [in] - StorageSystem object representing the array
* @param volume [in] - Volume to use for lookup
* @param taskCompleter [in] - TaskCompleter used for updating status of operation
* @throws Exception
*/
private void terminateAnyRestoreSessionsForVolume(StorageSystem storage, BlockObject volume, TaskCompleter taskCompleter) throws Exception {
if (storage.checkIfVmax3()) {
terminateAnyRestoreSessions(storage, null, volume.getId(), taskCompleter);
return;
}
NamedElementQueryResultList snapshots = new NamedElementQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), snapshots);
for (NamedElementQueryResultList.NamedElement ne : snapshots) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, ne.getId());
if (snapshot != null && !snapshot.getInactive()) {
CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, snapshot);
if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
terminateAnyRestoreSessions(storage, volume, snapshot.getId(), taskCompleter);
}
}
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations 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
*/
private void deleteTargetDevices(final StorageSystem storageSystem, final String[] deviceIds, final TaskCompleter taskCompleter) {
_log.info(format("Removing target devices {0} from storage system {1}", Joiner.on("\t").join(deviceIds), storageSystem.getId()));
try {
if (storageSystem.checkIfVmax3()) {
_helper.removeVolumeFromParkingSLOStorageGroup(storageSystem, deviceIds, false);
_log.info("Done invoking remove volumes from parking SLO storage group");
}
final CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
final CIMObjectPath[] theElements = _cimPath.getVolumePaths(storageSystem, deviceIds);
final CIMArgument[] inArgs = _helper.getReturnElementsToStoragePoolArguments(theElements, SmisConstants.CONTINUE_ON_NONEXISTENT_ELEMENT);
final CIMArgument[] outArgs = new CIMArgument[5];
final SmisDeleteVmaxCGTargetVolumesJob job = new SmisDeleteVmaxCGTargetVolumesJob(null, storageSystem.getId(), deviceIds, taskCompleter);
_helper.invokeMethodSynchronously(storageSystem, configSvcPath, RETURN_ELEMENTS_TO_STORAGE_POOL, inArgs, outArgs, job);
} catch (Exception e) {
_log.error(format("An error occurred when removing target devices {0} from storage system {1}", Joiner.on("\t").join(deviceIds), storageSystem.getId()), e);
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method unlinkSnapshotSessionTarget.
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public void unlinkSnapshotSessionTarget(StorageSystem system, URI snapSessionURI, URI snapshotURI, Boolean deleteTarget, TaskCompleter completer) throws DeviceControllerException {
// Only supported for VMAX3 storage systems.
if (!system.checkIfVmax3()) {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
try {
_log.info("Unlink target {} from snapshot session {} START", snapshotURI, snapSessionURI);
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
String targetDeviceId = snapshot.getNativeId();
if (isNullOrEmpty(targetDeviceId)) {
// The snapshot has no target device id. This means we must
// have failed creating the target device for a link target
// request and unlink target is being called in rollback.
// Since the target was never created, we just return
// success.
_log.info("Snapshot target {} was never created.", snapshotURI);
completer.ready(_dbClient);
return;
}
// If the snapshot has a native id, then we at least
// know the target device was created. Now we try and get
// the sync object path representing the linked target so
// that it can be detached.
boolean syncObjectFound = false;
List<BlockSnapshot> snapshots = null;
BlockObject sourceObj = BlockObject.fetch(_dbClient, snapshot.getParent().getURI());
CIMObjectPath syncObjectPath = SmisConstants.NULL_CIM_OBJECT_PATH;
if (snapshot.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapshot.getReplicationGroupInstance())) {
String replicationGroupName = snapshot.getReplicationGroupInstance();
String sourceReplicationGroupName = sourceObj.getReplicationGroupInstance();
List<CIMObjectPath> groupSyncs = getAllGroupSyncObjects(system, snapshot);
if (groupSyncs != null && !groupSyncs.isEmpty()) {
// the passed snapshot is the sync'd element.
for (CIMObjectPath groupSynchronized : groupSyncs) {
String syncElementPath = groupSynchronized.getKeyValue(SmisConstants.CP_SYNCED_ELEMENT).toString();
String systemElementPath = groupSynchronized.getKeyValue(SmisConstants.CP_SYSTEM_ELEMENT).toString();
if (syncElementPath.contains(replicationGroupName) && systemElementPath.contains(sourceReplicationGroupName)) {
syncObjectPath = groupSynchronized;
break;
}
}
}
snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, _dbClient);
} else {
syncObjectPath = getSyncObject(system, snapshot, sourceObj);
snapshots = Lists.newArrayList(snapshot);
}
if (!SmisConstants.NULL_CIM_OBJECT_PATH.equals(syncObjectPath)) {
syncObjectFound = true;
CIMArgument[] inArgs = _helper.getUnlinkBlockSnapshotSessionTargetInputArguments(syncObjectPath);
CIMArgument[] outArgs = new CIMArgument[5];
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
SmisBlockSnapshotSessionUnlinkTargetJob job = new SmisBlockSnapshotSessionUnlinkTargetJob(null, system.getId(), completer);
_helper.invokeMethodSynchronously(system, replicationSvcPath, SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, inArgs, outArgs, job);
// Succeeded in unlinking the target from the snapshot.
for (BlockSnapshot snapshotToUpdate : snapshots) {
snapshotToUpdate.setSettingsInstance(NullColumnValueGetter.getNullStr());
}
_dbClient.updateObject(snapshots);
} else {
// For some reason we could not find the path for the
// CIM_StorageSychronized instance for the linked target.
// If the settingsInstance for the snapshot is not set,
// this may mean we just failed a link target request
// and unlink target is being called in rollback. In this
// case we successfully created the target volume, but
// failed to link the target to the snapshot, in which
// case the settingsInstance would be null. Otherwise,
// we could be retrying a failed unlink request. In this
// case, we must have succeeded in unlinking the target
// from the array snapshot, but failed attempting to
// delete the target volume. If the unlink is successful,
// the settingsInstance is reset to null. So, if the
// settingsInstance is null, we move on without failing.
// Otherwise, we should throw an exception.
String settingsInstance = snapshot.getSettingsInstance();
if (NullColumnValueGetter.isNotNullValue(settingsInstance)) {
throw DeviceControllerException.exceptions.couldNotFindSyncObjectToUnlinkTarget(targetDeviceId);
}
}
if (deleteTarget) {
_log.info("Delete target device {} :{}", targetDeviceId, snapshotURI);
Collection<String> nativeIds = transform(snapshots, fctnBlockObjectToNativeID());
if (snapshot.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapshot.getReplicationGroupInstance())) {
try {
checkReplicationGroupAccessibleOrFail(system, snapshot, _dbClient, _helper, _cimPath);
deleteTargetGroup(system, snapshot.getReplicationGroupInstance());
} catch (DeviceControllerException | WBEMException e) {
_log.info("Failed to delete the target group. It may have already been deleted.");
}
}
// remove snapshot from them before deleting it.
for (BlockSnapshot snap : snapshots) {
try {
_helper.removeVolumeFromStorageGroupsIfVolumeIsNotInAnyMV(system, snap);
} catch (Exception e) {
_log.info("Failed to remove snap {} from storage groups. It may have already been removed.", snap.getNativeGuid());
}
}
callEMCRefresh(_helper, system, true);
deleteTargetDevices(system, nativeIds.toArray(new String[] {}), completer);
_log.info("Delete target device complete");
} else if (!syncObjectFound) {
// Need to be sure the completer is called.
completer.ready(_dbClient);
}
} catch (Exception e) {
_log.error("Exception unlinking snapshot session target", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
completer.error(_dbClient, error);
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method establishVolumeSnapshotGroupRelation.
@Override
public void establishVolumeSnapshotGroupRelation(StorageSystem storage, URI sourceVolume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("establishVolumeSnapshotGroupRelation operation START");
try {
/**
* get groupPath for source volume
* get groupPath for snapshot
* get snapshots belonging to the same Replication Group
* get Element synchronizations between volumes and snapshots
* call CreateGroupReplicaFromElementSynchronizations
*/
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
CIMObjectPath srcRepSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
String volumeGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volumeObj, _dbClient);
CIMObjectPath volumeGroupPath = _cimPath.getReplicationGroupPath(storage, volumeGroupName);
CIMObjectPath snapshotGroupPath = _cimPath.getReplicationGroupPath(storage, snapshotObj.getReplicationGroupInstance());
// Check if snapshot is referenced by a BlockSnapshotSession
// if so, we must pass in the RelationshipName with the value of the session name.
// NB. a SourceGroup aspect must exist
List<BlockSnapshotSession> snapshotSessions = queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, getLinkedTargetSnapshotSessionConstraint(snapshot));
String relationshipName = null;
if (!snapshotSessions.isEmpty()) {
relationshipName = snapshotSessions.get(0).getSessionLabel();
_log.info("Found snapshot session relationship: {}", relationshipName);
}
CIMObjectPath groupSynchronizedPath = _cimPath.getGroupSynchronized(volumeGroupPath, snapshotGroupPath);
CIMInstance syncInstance = _helper.checkExists(storage, groupSynchronizedPath, false, false);
if (syncInstance == null) {
// get all snapshots belonging to a Replication Group. There may be multiple snapshots available for a Volume
List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
List<CIMObjectPath> elementSynchronizations = new ArrayList<CIMObjectPath>();
for (BlockSnapshot snapshotObject : snapshots) {
Volume volume = _dbClient.queryObject(Volume.class, snapshotObject.getParent());
elementSynchronizations.add(_cimPath.getStorageSynchronized(storage, volume, storage, snapshotObject));
}
_log.info("Creating Group synchronization between volume group and snapshot group");
CIMArgument[] inArgs = _helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(volumeGroupPath, snapshotGroupPath, elementSynchronizations, relationshipName);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
// No Job returned
} else {
_log.info("Link already established..");
}
taskCompleter.ready(_dbClient);
} catch (Exception e) {
String msg = String.format("Failed to establish group relation between volume group and snapshot group. Volume: %s, Snapshot: %s", sourceVolume, snapshot);
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method getAllGroupSyncObjects.
/**
* Acquires ReplicationGroup's associated with the block object, then further acquires the GroupSynchonized
* instances that reference them.
*
* @param storage StorageSystem that holds the GroupSynchronized instances.
* @param blockObject BlockObject representing the source of replication.
* @return A List of CIMObjectPath's for each GroupSynchronized instance.
* @throws WBEMException
*/
private List<CIMObjectPath> getAllGroupSyncObjects(StorageSystem storage, BlockObject blockObject) throws WBEMException {
List<CIMObjectPath> groupSyncPaths = new ArrayList<>();
CIMObjectPath blockObjectPath = _cimPath.getBlockObjectPath(storage, blockObject);
CloseableIterator<CIMObjectPath> associatorNames = null;
CloseableIterator<CIMObjectPath> groupSyncRefs = null;
try {
associatorNames = _helper.getAssociatorNames(storage, blockObjectPath, null, SE_REPLICATION_GROUP, null, null);
while (associatorNames.hasNext()) {
CIMObjectPath repGrpPath = associatorNames.next();
_log.info(String.format("Source %s has associated ReplicationGroup %s", blockObjectPath, repGrpPath));
groupSyncRefs = _helper.getReference(storage, repGrpPath, SE_GROUP_SYNCHRONIZED_RG_RG, null);
while (groupSyncRefs.hasNext()) {
CIMObjectPath grpSyncPath = groupSyncRefs.next();
_log.info(String.format("ReplicationGroup %s is referenced by %s", repGrpPath, grpSyncPath));
groupSyncPaths.add(grpSyncPath);
}
}
} finally {
if (associatorNames != null) {
associatorNames.close();
}
if (groupSyncRefs != null) {
groupSyncRefs.close();
}
}
return groupSyncPaths;
}
Aggregations