Search in sources :

Example 61 with CIMArgument

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

the class VmaxSnapshotOperations method activateSingleVolumeSnapshot.

/**
 * This interface is for the snapshot active. The createSnapshot may have done
 * whatever is necessary to setup the snapshot for this call. The goal is to
 * make this a quick operation and the create operation has already done a lot
 * of the "heavy lifting".
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshot [required] - BlockSnapshot URI representing the previously created
 *            snap for the volume
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
public void activateSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        if (snapshotObj.getIsSyncActive()) {
            _log.warn("Trying to activate snapshot, which is already active", snapshotObj.getId().toString());
            return;
        }
        _log.info("activateSingleVolumeSnapshot operation START");
        CIMArgument[] inArgs = _helper.getActivateSnapshotInputArguments(storage, snapshotObj);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.callModifyReplica(storage, inArgs, outArgs);
        setIsSyncActive(snapshotObj, true);
        snapshotObj.setRefreshRequired(true);
        _dbClient.persistObject(snapshotObj);
        // Success -- Update status
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } finally {
        _log.info("activateSingleVolumeSnapshot operation END");
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 62 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)

Example 63 with CIMArgument

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

the class VnxMirrorOperations method createGroupMirrors.

/**
 * Should implement create of a mirror 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 mirrorList [required] - mirror URI list
 * @param createInactive whether the mirror 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 createGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("createGroupMirrors operation START");
    List<BlockMirror> mirrors = null;
    List<String> targetDeviceIds = null;
    try {
        mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        BlockMirror firstMirror = mirrors.get(0);
        Volume sourceVolume = _dbClient.queryObject(Volume.class, firstMirror.getSource());
        String 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);
        }
        List<String> sourceIds = new ArrayList<String>();
        targetDeviceIds = new ArrayList<String>();
        Map<String, String> tgtToSrcMap = new HashMap<String, String>();
        for (BlockMirror mirror : mirrors) {
            final URI poolId = mirror.getPool();
            final Volume source = _dbClient.queryObject(Volume.class, mirror.getSource());
            sourceIds.add(source.getNativeId());
            // Create target devices
            final List<String> newDeviceIds = ReplicationUtils.createTargetDevices(storage, sourceGroupName, mirror.getLabel(), createInactive, 1, poolId, mirror.getCapacity(), source.getThinlyProvisioned(), null, taskCompleter, _dbClient, _helper, _cimPath);
            targetDeviceIds.addAll(newDeviceIds);
            tgtToSrcMap.put(newDeviceIds.get(0), source.getNativeId());
        }
        CIMObjectPath[] targetDevicePaths = _cimPath.getVolumePaths(storage, targetDeviceIds.toArray(new String[targetDeviceIds.size()]));
        CIMObjectPath[] sourceDevicePaths = _cimPath.getVolumePaths(storage, sourceIds.toArray(new String[sourceIds.size()]));
        // Create list replica
        CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = _helper.getCreateListReplicaInputArguments(storage, sourceDevicePaths, targetDevicePaths);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_LIST_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        ControllerServiceImpl.enqueueJob(new QueueJob(new SmisVnxCreateCGMirrorJob(job, storage.getId(), tgtToSrcMap, taskCompleter)));
        for (BlockMirror mirror : mirrors) {
            mirror.setSyncState(SynchronizationState.SYNCHRONIZED.name());
        }
        _dbClient.persistObject(mirrors);
    } catch (Exception e) {
        _log.error("Problem making SMI-S call: ", e);
        // Roll back changes
        ReplicationUtils.rollbackCreateReplica(storage, null, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath);
        if (mirrors != null && !mirrors.isEmpty()) {
            for (BlockMirror mirror : mirrors) {
                mirror.setInactive(true);
            }
        }
        _dbClient.persistObject(mirrors);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupMirrors", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info("createGroupMirrors operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) SmisVnxCreateCGMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGMirrorJob) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Example 64 with CIMArgument

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) WBEMException(javax.wbem.WBEMException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) SmisBlockCreateCGSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Example 65 with CIMArgument

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

the class VnxSnapshotOperations method deleteSingleVolumeSnapshot.

/**
 * Should implement deletion of single volume snapshot. That is, deleting a snap that was
 * created independent of other volumes.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshot [required] - BlockSnapshot URI representing the previously created
 *            snap for the volume
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
        BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, snap);
        if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.callModifyReplica(storage, _helper.getDeleteSnapshotSynchronousInputArguments(syncObjectPath), outArgs);
            snap.setInactive(true);
            snap.setIsSyncActive(false);
            _dbClient.updateObject(snap);
            taskCompleter.ready(_dbClient);
        } else {
            // Perhaps, it's already been deleted or was deleted on the array.
            // In that case, we'll just say all is well, so that this operation
            // is idempotent.
            snap.setInactive(true);
            snap.setIsSyncActive(false);
            _dbClient.updateObject(snap);
            taskCompleter.ready(_dbClient);
        }
    } catch (WBEMException e) {
        String message = String.format("Error encountered during delete snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } catch (Exception e) {
        String message = String.format("Generic exception when trying to delete snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("deleteSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) WBEMException(javax.wbem.WBEMException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) 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