Search in sources :

Example 76 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class VNXeStorageDevice method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("creating file system {} snap {} ", args.getFsName(), args.getSnapshotLabel());
    VNXeApiClient apiClient = getVnxeClient(storage);
    VNXeCommandJob job = null;
    VNXeFSSnapshotTaskCompleter completer = null;
    try {
        job = apiClient.createFileSystemSnap(args.getFsNativeId(), args.getSnapshotName());
        if (job != null) {
            completer = new VNXeFSSnapshotTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
            VNXeCreateFileSystemSnapshotJob snapJob = new VNXeCreateFileSystemSnapshotJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(snapJob));
        } else {
            _logger.error("No job returned from createFileSystemSnap");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("snapshotFileSystem", "No Job returned from createFileSystemSnap");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Create file system snapshot got the exception", e);
        if (completer != null) {
            completer.error(_dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create file system snpashot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateFileSystemSnapshot", ex.getMessage());
        if (completer != null) {
            completer.error(_dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create filesystem snapshot job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Snapshot(com.emc.storageos.db.client.model.Snapshot) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeCreateFileSystemSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateFileSystemSnapshotJob) VNXeException(com.emc.storageos.vnxe.VNXeException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 77 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class VmaxCloneOperations 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 cloneList [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) {
    _log.info("START create group clone operation");
    // Target group CIM Path
    CIMObjectPath targetGroupPath = null;
    // 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);
        URI tenant = sourceVolume.getTenant().getURI();
        TenantOrg tenantOrg = _dbClient.queryObject(TenantOrg.class, tenant);
        String targetGroupLabel = generateLabel(tenantOrg, sourceVolume);
        // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
        ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        final Map<String, List<Volume>> clonesBySizeMap = new HashMap<String, List<Volume>>();
        List<Volume> clones = _dbClient.queryObject(Volume.class, cloneList);
        // created separately before 'CreateGroupReplica' call.
        if (storage.checkIfVmax3() || !storage.getUsingSmis80()) {
            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);
            }
            // Create target device group
            targetGroupPath = ReplicationUtils.createTargetDeviceGroup(storage, sourceGroupName, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath, SYNC_TYPE.CLONE);
        }
        // Create CG clone
        CIMObjectPath job = VmaxGroupOperationsUtils.internalCreateGroupReplica(storage, sourceGroupName, targetGroupLabel, targetGroupPath, createInactive, taskCompleter, SYNC_TYPE.CLONE, _dbClient, _helper, _cimPath);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCreateCGCloneJob(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, targetGroupPath, 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) SmisCreateCGCloneJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateCGCloneJob) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) ArrayList(java.util.ArrayList) List(java.util.List) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 78 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class VmaxCloneOperations method resyncGroupClones.

/**
 * Implementation for resync clones in CG.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param clones [required] - URIs representing the previously created clones
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
@SuppressWarnings("rawtypes")
public void resyncGroupClones(StorageSystem storage, List<URI> clones, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("START resync group clone operation");
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, clones);
        Volume clone = _dbClient.queryObject(Volume.class, clones.get(0));
        Volume sourceVol = _dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
        String consistencyGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVol, _dbClient);
        String replicationGroupName = clone.getReplicationGroupInstance();
        CIMObjectPath groupSynchronized = _cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, replicationGroupName);
        if (_helper.checkExists(storage, groupSynchronized, false, false) != null) {
            CIMObjectPath cimJob = null;
            CIMArgument[] resyncCGCloneInput = _helper.getResyncReplicaInputArguments(groupSynchronized);
            cimJob = _helper.callModifyReplica(storage, resyncCGCloneInput);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneResyncJob(cimJob, storage.getId(), taskCompleter)));
        } else {
            ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(consistencyGroupName);
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception e) {
        String message = String.format("Exception when trying to resync clones from consistency group on array %s", storage.getSerialNumber());
        _log.error(message, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.resynchronizeFullCopyFailed(e));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) SmisCloneResyncJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneResyncJob) CIMObjectPath(javax.cim.CIMObjectPath) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 79 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class VmaxCloneOperations method restoreGroupClones.

/**
 * Implementation for restoring of clones in CG.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param clones [required] - URIs representing the previously created clones
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 */
@Override
@SuppressWarnings("rawtypes")
public void restoreGroupClones(StorageSystem storage, List<URI> clones, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("START restore group clone operation");
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storage, clones);
        Volume clone = _dbClient.queryObject(Volume.class, clones.get(0));
        Volume sourceVol = _dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
        String consistencyGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVol, _dbClient);
        String replicationGroupName = clone.getReplicationGroupInstance();
        CIMObjectPath groupSynchronized = _cimPath.getGroupSynchronizedPath(storage, consistencyGroupName, replicationGroupName);
        if (_helper.checkExists(storage, groupSynchronized, false, false) != null) {
            CIMObjectPath cimJob = null;
            CIMArgument[] restoreCGCloneInput = _helper.getRestoreFromReplicaInputArgumentsWithForce(groupSynchronized);
            cimJob = _helper.callModifyReplica(storage, restoreCGCloneInput);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneRestoreJob(cimJob, storage.getId(), taskCompleter)));
        } else {
            ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(consistencyGroupName);
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception e) {
        String message = String.format("Exception when trying to restoring clones from consistency group on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreGroupClones", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SmisCloneRestoreJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneRestoreJob) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 80 with QueueJob

use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method doUnexport.

@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    _logger.info("unexporting the file system: " + args.getFsName());
    boolean isFile = args.getFileOperation();
    for (FileExport exp : exportList) {
        VNXeApiClient apiClient = getVnxUnityClient(storage);
        String vnxeShareId = exp.getIsilonId();
        VNXeCommandJob job = null;
        VNXeFileTaskCompleter completer = null;
        try {
            if (isFile) {
                String fsId = args.getFs().getNativeId();
                job = apiClient.removeNfsShare(vnxeShareId, fsId);
            } else {
                job = apiClient.deleteNfsShareForSnapshot(vnxeShareId);
            }
            if (job != null) {
                if (isFile) {
                    completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                } else {
                    completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                }
                FileShareExport export = new FileShareExport(exp);
                VNXeUnexportFileSystemJob unexportFSJob = new VNXeUnexportFileSystemJob(job.getId(), storage.getId(), completer, export, export.getPath(), isFile);
                ControllerServiceImpl.enqueueJob(new QueueJob(unexportFSJob));
            } else {
                _logger.error("No job returned from exportFileSystem");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", "No Job returned from deleteFileSystem");
                return BiosCommandResult.createErrorResult(error);
            }
        } catch (VNXeException e) {
            _logger.error("Unexport file system got the exception", e);
            if (completer != null) {
                completer.error(dbClient, e);
            }
            return BiosCommandResult.createErrorResult(e);
        } catch (Exception ex) {
            _logger.error("Delete file system got the exception", ex);
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
            if (completer != null) {
                completer.error(dbClient, error);
            }
            return BiosCommandResult.createErrorResult(error);
        }
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Unexport filesystem job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
        _logger.info(logMsgBuilder.toString());
    }
    return BiosCommandResult.createPendingResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) FileExport(com.emc.storageos.db.client.model.FileExport) VNXeUnexportFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeUnexportFileSystemJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)109 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)109 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)104 Volume (com.emc.storageos.db.client.model.Volume)51 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)43 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)41 CIMObjectPath (javax.cim.CIMObjectPath)41 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)40 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)40 VNXeException (com.emc.storageos.vnxe.VNXeException)36 WBEMException (javax.wbem.WBEMException)33 ControllerException (com.emc.storageos.volumecontroller.ControllerException)32 CIMArgument (javax.cim.CIMArgument)32 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)25 URI (java.net.URI)23 ArrayList (java.util.ArrayList)23 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)20 Snapshot (com.emc.storageos.db.client.model.Snapshot)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileShare (com.emc.storageos.db.client.model.FileShare)16