Search in sources :

Example 61 with VNXeCommandJob

use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.

the class VNXUnitySnapshotOperations method createSingleVolumeSnapshot.

@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        if (readOnly) {
            snapshotObj.setIsReadOnly(readOnly);
            _dbClient.updateObject(snapshotObj);
        }
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        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);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeCommandJob job = apiClient.createSnap(volume.getNativeId(), snapLabelToUse, readOnly);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockSnapshotCreateJob(job.getId(), storage.getId(), !createInactive, taskCompleter)));
        }
    } catch (Exception ex) {
        log.error("Create volume snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumeSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) VNXeBlockSnapshotCreateJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockSnapshotCreateJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 62 with VNXeCommandJob

use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.

the class VNXUnitySnapshotOperations method restoreGroupSnapshots.

@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        VNXeApiClient apiClient = getVnxeClient(storage);
        Snap groupSnap = apiClient.getSnapshot(snapshotObj.getReplicationGroupInstance());
        Snap snap = apiClient.getSnapshot(snapshotObj.getNativeId());
        // Error out if the snapshot is attached
        if (snap.isAttached()) {
            log.error("Snapshot {})is exported and cannot be used for restore", snapshotObj.getLabel());
            ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshotObj.getLabel());
            taskCompleter.error(_dbClient, error);
        }
        VNXeCommandJob job = apiClient.restoreSnap(groupSnap.getId());
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXUnityRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
        }
    } catch (Exception ex) {
        log.error("Restore group snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXUnityRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityRestoreSnapshotJob) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Snap(com.emc.storageos.vnxe.models.Snap) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 63 with VNXeCommandJob

use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.

the class VNXeApiClient method removeCifsShare.

/**
 * Delete cifsShare
 *
 * @param cifsShareId
 *            cifsShare Id
 * @param fsId
 *            file system Id
 * @return VNXeCommandJob
 */
public VNXeCommandJob removeCifsShare(String cifsShareId, String fsId) {
    VNXeCommandJob job = null;
    _logger.info("deleting cifs share" + cifsShareId);
    FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
    VNXeFileSystem fs = fsRequest.get();
    if (fs == null) {
        _logger.info("Could not find file system in the vxne");
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
    }
    String resourceId = fs.getStorageResource().getId();
    ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
    // set cifsShare delete parm
    CifsShareDeleteParam deleteParam = new CifsShareDeleteParam();
    VNXeBase share = new VNXeBase();
    share.setId(cifsShareId);
    deleteParam.setCifsShare(share);
    List<CifsShareDeleteParam> deleteList = new ArrayList<CifsShareDeleteParam>();
    deleteList.add(deleteParam);
    modifyFSParm.setCifsShareDelete(deleteList);
    FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
    job = req.modifyFileSystemAsync(modifyFSParm, resourceId);
    return job;
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileSystemRequest(com.emc.storageos.vnxe.requests.FileSystemRequest) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) CifsShareDeleteParam(com.emc.storageos.vnxe.models.CifsShareDeleteParam) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) ArrayList(java.util.ArrayList) ModifyFileSystemParam(com.emc.storageos.vnxe.models.ModifyFileSystemParam) FileSystemActionRequest(com.emc.storageos.vnxe.requests.FileSystemActionRequest)

Example 64 with VNXeCommandJob

use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.

the class KHRequests method postRequestAsync.

public VNXeCommandJob postRequestAsync(ParamBase param) {
    setAsyncMode();
    ClientResponse response = postRequest(param);
    VNXeCommandJob job;
    String resString = response.getEntity(String.class);
    ObjectMapper mapper = new ObjectMapper();
    try {
        job = mapper.readValue(resString, VNXeCommandJob.class);
    } catch (JsonParseException e) {
        _logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
        throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
    } catch (JsonMappingException e) {
        _logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
        throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
    } catch (IOException e) {
        _logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
        throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
    }
    if (job != null) {
        _logger.info("submitted the job: " + job.getId());
    } else {
        _logger.warn("No job returned.");
    }
    return job;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 65 with VNXeCommandJob

use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.

the class KHRequests method deleteRequestAsync.

/*
     * Send DELETE request to KittyHawk server in async mode
     * 
     * @param resource webResource
     * 
     * @param param parameters for delete
     * 
     * @return VNXeCommandJob
     * 
     * @throws VNXeException
     */
public VNXeCommandJob deleteRequestAsync(Object param) throws VNXeException {
    _logger.debug("delete data: " + _url);
    setAsyncMode();
    ClientResponse response = deleteRequest(param);
    VNXeCommandJob job;
    String resString = response.getEntity(String.class);
    ObjectMapper mapper = new ObjectMapper();
    try {
        job = mapper.readValue(resString, VNXeCommandJob.class);
    } catch (JsonParseException e) {
        _logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
        throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
    } catch (JsonMappingException e) {
        _logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
        throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
    } catch (IOException e) {
        _logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
        throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
    }
    if (job != null) {
        _logger.info("submitted the deleting file system job: {} ", job.getId());
    }
    return job;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Aggregations

VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)73 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)48 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)41 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)40 VNXeException (com.emc.storageos.vnxe.VNXeException)40 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)40 ControllerException (com.emc.storageos.volumecontroller.ControllerException)30 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)24 Snapshot (com.emc.storageos.db.client.model.Snapshot)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 ArrayList (java.util.ArrayList)18 FileShare (com.emc.storageos.db.client.model.FileShare)17 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)16 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)16 Volume (com.emc.storageos.db.client.model.Volume)13 URI (java.net.URI)10 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)9 FileExport (com.emc.storageos.db.client.model.FileExport)8 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)8 DbClient (com.emc.storageos.db.client.DbClient)7