Search in sources :

Example 26 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method deleteTargetGroup.

/**
 * Method will invoke the SMI-S operation to delete the ReplicationGroup.
 *
 * @param system StorageSystem where the pool and volume exist
 * @param replicationGroupInstance InstanceID of the SMI-S ReplicationGroup
 * @throws Exception
 */
private void deleteTargetGroup(StorageSystem system, String replicationGroupInstance) throws Exception {
    /*
         * FIXME Inconsistencies with BlockSnapshot#getReplicationGroupInstance format
         *
         * CoprHD-created linked targets will have this field value in the format "<system-serial>+<instance>".
         *
         * Ingested linked targets will have this field value in the more simple format, "<instance>"
         */
    if (system.getUsingSmis80()) {
        if (!replicationGroupInstance.contains("+")) {
            replicationGroupInstance = String.format("%s+%s", system.getSerialNumber(), replicationGroupInstance);
        }
    }
    CIMObjectPath groupPath = _cimPath.getReplicationGroupObjectPath(system, replicationGroupInstance);
    CIMArgument[] outArgs = new CIMArgument[5];
    CIMArgument[] deleteGroupInArgs = _helper.getDeleteReplicationGroupInputArguments(system, groupPath, true);
    _helper.invokeMethod(system, _cimPath.getControllerReplicationSvcPath(system), DELETE_GROUP, deleteGroupInArgs, outArgs);
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Example 27 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method restoreSnapshotSession.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void restoreSnapshotSession(StorageSystem system, URI snapSessionURI, TaskCompleter completer) throws DeviceControllerException {
    if (system.checkIfVmax3()) {
        // Only supported for VMAX3 storage systems.
        try {
            _log.info("Restore snapshot session {} START", snapSessionURI);
            BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
            String syncAspectPath = snapSession.getSessionInstance();
            CIMObjectPath settingsStatePath = null;
            BlockObject sourceObj = null;
            if (snapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapSession.getReplicationGroupInstance())) {
                _log.info("Restoring group snapshot session");
                // We need a single source volume for the session.
                BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapSession.getConsistencyGroup());
                List<Volume> nativeVolumes = BlockConsistencyGroupUtils.getActiveNativeVolumesInCG(cg, _dbClient);
                // get source group name from the session.
                String sourceGroupName = snapSession.getReplicationGroupInstance();
                settingsStatePath = _cimPath.getGroupSynchronizedSettingsPath(system, sourceGroupName, syncAspectPath);
                for (Volume volume : nativeVolumes) {
                    if (sourceGroupName.equals(volume.getReplicationGroupInstance())) {
                        sourceObj = volume;
                        // get source volume which matches session's RG name
                        break;
                    }
                }
            } else {
                _log.info("Restoring single volume snapshot session");
                sourceObj = BlockObject.fetch(_dbClient, snapSession.getParent().getURI());
                CIMObjectPath sourcePath = _cimPath.getVolumePath(system, sourceObj.getNativeId());
                settingsStatePath = _cimPath.getSyncSettingsPath(system, sourcePath, syncAspectPath);
            }
            // Terminate restore sessions.
            terminateAnyRestoreSessions(system, null, sourceObj.getId(), completer);
            // Invoke SMI-S method to restore snapshot session.
            CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
            CIMArgument[] inArgs = null;
            CIMArgument[] outArgs = new CIMArgument[5];
            inArgs = _helper.getRestoreFromSettingsStateInputArguments(settingsStatePath, true);
            _helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
            CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionRestoreJob(jobPath, system.getId(), completer)));
        } catch (Exception e) {
            _log.error("Exception restoring snapshot session", e);
            ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
            completer.error(_dbClient, error);
        }
    } else {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
}
Also used : SmisBlockSnapshotSessionRestoreJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionRestoreJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) CIMObjectPath(javax.cim.CIMObjectPath) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Example 28 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method createSingleVolumeSnapshot.

/**
 * Should implement creation of a single volume snapshot. That is a volume that
 * is not in any 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 - whether the snapshot needs to to be created with sync_active=true/false
 * @param readOnly - Indicates if the snapshot should be read only.
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    // List of target device ids
    List<String> targetDeviceIds = null;
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        _log.info("createSingleVolumeSnapshot operation START");
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        // Need to terminate an restore sessions, so that we can
        // restore from the same snapshot multiple times
        terminateAnyRestoreSessionsForVolume(storage, volume, taskCompleter);
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', storage.getUsingSmis80() ? SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH : SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = null;
        CIMArgument[] outArgs = new CIMArgument[5];
        if (storage.checkIfVmax3()) {
            CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, storage, volume, null);
            // COP-17240: For VMAX3, we will derive the target volumes from the source volumes SRP Pool
            CIMObjectPath poolPath = _helper.getVolumeStoragePoolPath(storage, volume);
            targetDeviceIds = createTargetDevices(storage, poolPath, volumeGroupPath, null, "SingleSnapshot", snapLabelToUse, createInactive, 1, volume.getCapacity(), taskCompleter);
            CIMInstance replicaSettingData = _helper.getReplicationSettingData(storage, targetDeviceIds.get(0), false);
            inArgs = _helper.getCreateElementReplicaSnapInputArgumentsWithTargetAndSetting(storage, volume, targetDeviceIds.get(0), replicaSettingData, createInactive, snapLabelToUse);
        } else {
            if (volume.getThinlyProvisioned()) {
                CIMInstance replicationSetting = ReplicationUtils.getVPSnapReplicationSetting(storage, _helper, _cimPath);
                inArgs = _helper.getCreateElementReplicaVPSnapInputArguments(storage, volume, createInactive, snapLabelToUse, replicationSetting);
            } else {
                inArgs = _helper.getCreateElementReplicaSnapInputArguments(storage, volume, createInactive, snapLabelToUse);
            }
        }
        _helper.invokeMethod(storage, replicationSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateSnapshotJob(job, storage.getId(), !createInactive, taskCompleter)));
        }
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
        setInactive(snapshot, true);
        // Roll back changes
        if (storage.checkIfVmax3()) {
            rollbackCreateSnapshot(storage, null, targetDeviceIds, taskCompleter);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisBlockCreateSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateSnapshotJob) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Example 29 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method deleteTargetDeviceGroup.

/**
 * Deletes a target group represented by the given target group path
 *
 * @param storage - StorageSystem where the target group is
 * @param targetGroupPath - Path representing target group to be deleted
 *
 * @throws DeviceControllerException
 */
private void deleteTargetDeviceGroup(final StorageSystem storage, final CIMObjectPath targetGroupPath) {
    _log.info(format("Removing target device group {0} from storage system {1}", targetGroupPath, storage.getId()));
    try {
        CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] outArgs = new CIMArgument[5];
        CIMArgument[] inArgs = _helper.getDeleteReplicationGroupInputArguments(storage, targetGroupPath, true);
        _helper.invokeMethod(storage, replicationSvc, DELETE_GROUP, inArgs, outArgs);
    } catch (Exception e) {
        _log.error(format("An error occurred when removing target device group {0} from storage system {1}", targetGroupPath, storage.getId()), e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 30 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VnxCloneOperations method createGroupClone.

/**
 * Should implement create of a clone from a source volume that is part of a
 * consistency group.
 *
 * Implementation note: In this method we will kick of the asynchronous creation
 * of the target devices required for the CG clones. Upon the successful
 * device creation, the post operations will take place, which will include the
 * creation of the target group and the group clone operation.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param clonetList [required] - clone URI list
 * @param createInactive whether the clone needs to to be created with sync_active=true/false
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 * @throws DeviceControllerException
 */
@Override
public void createGroupClone(StorageSystem storage, List<URI> cloneList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("START create group clone operation");
    // List of target device ids
    List<String> targetDeviceIds = null;
    // The source consistency group name
    String sourceGroupName = null;
    try {
        final Volume first = _dbClient.queryObject(Volume.class, cloneList.get(0));
        Volume sourceVolume = _dbClient.queryObject(Volume.class, first.getAssociatedSourceVolume());
        sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVolume, _dbClient);
        if (!ControllerUtils.isNotInRealVNXRG(sourceVolume, _dbClient)) {
            // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
            ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        }
        // Group volumes by pool and size
        List<String> sourceIds = new ArrayList<String>();
        List<Volume> clones = _dbClient.queryObject(Volume.class, cloneList);
        for (Volume clone : clones) {
            final Volume volume = _dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
            sourceIds.add(volume.getNativeId());
        }
        targetDeviceIds = new ArrayList<String>();
        for (Volume clone : clones) {
            final URI poolId = clone.getPool();
            Volume source = _dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
            // Create target devices
            final List<String> newDeviceIds = ReplicationUtils.createTargetDevices(storage, sourceGroupName, clone.getLabel(), createInactive, 1, poolId, clone.getCapacity(), source.getThinlyProvisioned(), source, taskCompleter, _dbClient, _helper, _cimPath);
            targetDeviceIds.addAll(newDeviceIds);
        }
        CIMObjectPath[] cloneVolumePaths = _cimPath.getVolumePaths(storage, targetDeviceIds.toArray(new String[targetDeviceIds.size()]));
        CIMObjectPath[] sourceVolumePaths = _cimPath.getVolumePaths(storage, sourceIds.toArray(new String[sourceIds.size()]));
        // Create list replica
        CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = _helper.getCreateListReplicaInputArguments(storage, sourceVolumePaths, cloneVolumePaths);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, replicationSvc, CREATE_LIST_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisVnxCreateCGCloneJob(job, storage.getId(), !createInactive, taskCompleter)));
        }
    } catch (Exception e) {
        final String errMsg = format("An exception occurred when trying to create clones for consistency group {0} on storage system {1}", sourceGroupName, storage.getId());
        log.error(errMsg, e);
        // Roll back changes
        ReplicationUtils.rollbackCreateReplica(storage, null, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath);
        List<Volume> clones = _dbClient.queryObject(Volume.class, cloneList);
        for (Volume clone : clones) {
            clone.setInactive(true);
        }
        _dbClient.persistObject(clones);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupClones", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    log.info("createGroupClone operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) SmisVnxCreateCGCloneJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGCloneJob) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) List(java.util.List) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Aggregations

CIMArgument (javax.cim.CIMArgument)234 CIMObjectPath (javax.cim.CIMObjectPath)190 WBEMException (javax.wbem.WBEMException)129 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)127 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)80 ArrayList (java.util.ArrayList)74 CIMInstance (javax.cim.CIMInstance)71 Volume (com.emc.storageos.db.client.model.Volume)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 URI (java.net.URI)39 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)36 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)32 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)29 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)26 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)23 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)22 HashSet (java.util.HashSet)16 List (java.util.List)16 CIMProperty (javax.cim.CIMProperty)16