Search in sources :

Example 46 with Snapshot

use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doDeleteShare.

@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    _log.info("Call FileShare doDeleteShare");
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        StorageHADomain dm = null;
        String mountPoint = null;
        if (args.getFileOperation()) {
            mountPoint = args.getFs().getMountPath();
            // Get DataMover
            dm = this.getDataMover(args.getFs());
            if (dm == null) {
                Exception e = new Exception("VNX File Share creation Failed Data Mover not found");
                throw VNXException.exceptions.createExportFailed("VNX File Delete Share Failed Data Mover not found", e);
            }
        } else {
            // Get DataMover
            URI snapshotId = args.getSnapshotId();
            Snapshot snapshot = _dbClient.queryObject(Snapshot.class, snapshotId);
            FileShare fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
            mountPoint = fileshare.getMountPath();
            dm = this.getDataMover(fileshare);
            if (dm == null) {
                Exception e = new Exception("VNX File Share creation Failed Data Mover not found");
                throw VNXException.exceptions.createExportFailed("VNX File Delete Share Failed Data Mover not found", e);
            }
        }
        result = vnxComm.doDeleteShare(storage, dm, smbFileShare.getName(), mountPoint, false, args);
        args.getFileObjShares().remove(smbFileShare.getName());
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToDeleteFileShare(result.getMessage()));
    }
    return cmdResult;
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 47 with Snapshot

use of com.emc.storageos.db.client.model.Snapshot 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 48 with Snapshot

use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.

the class VNXeDeleteFileSystemJob method updateSnapshots.

private void updateSnapshots(DbClient dbClient, FileShare fsObj) {
    _logger.info(" Setting Snapshots to InActive with Force Delete ");
    URIQueryResultList snapIDList = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getFileshareSnapshotConstraint(fsObj.getId()), snapIDList);
    if (!snapIDList.isEmpty()) {
        List<URI> idList = new ArrayList<URI>();
        for (Iterator<URI> iter = snapIDList.iterator(); iter.hasNext(); ) {
            URI id = iter.next();
            idList.add(id);
        }
        List<Snapshot> snapList = dbClient.queryObject(Snapshot.class, snapIDList);
        for (Snapshot snapshot : snapList) {
            _logger.info("Marking Snapshot as InActive Snapshot Id {} Fs Id : {}", snapshot.getId(), snapshot.getParent());
            snapshot.setInactive(true);
            dbClient.persistObject(snapshot);
        }
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 49 with Snapshot

use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.

the class VNXeExportFileSystemJob method updateSnapExport.

/**
 * update snapshot if the export job is for snapshot export
 *
 * @param dbClient
 * @param apiClient
 * @return Snapshot instance
 */
private Snapshot updateSnapExport(DbClient dbClient, VNXeApiClient apiClient, FileExport newExport) {
    _logger.info("upading snap export. ");
    URI snapId = getTaskCompleter().getId();
    Snapshot snapObj = dbClient.queryObject(Snapshot.class, snapId);
    FSExportMap exports = snapObj.getFsExports();
    if (exports == null) {
        exports = new FSExportMap();
    }
    VNXeNfsShare nfsShare = apiClient.findSnapNfsShare(snapObj.getNativeId(), shareName);
    String nfsShareId = nfsShare.getId();
    newExport.setIsilonId(nfsShareId);
    exports.put(newExport.getFileExportKey(), newExport);
    snapObj.setFsExports(exports);
    updateExportRules(snapObj.getId(), newExport, dbClient);
    dbClient.persistObject(snapObj);
    return snapObj;
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) URI(java.net.URI)

Example 50 with Snapshot

use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.

the class VNXeFSSnapshotTaskCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    Snapshot snapshot = dbClient.queryObject(Snapshot.class, getId());
    FileShare fsObj = dbClient.queryObject(FileShare.class, snapshot.getParent());
    switch(status) {
        case error:
            dbClient.error(Snapshot.class, getId(), getOpId(), coded);
            if (fsObj != null) {
                dbClient.error(FileShare.class, fsObj.getId(), getOpId(), coded);
            }
            if (isNotifyWorkflow()) {
                WorkflowStepCompleter.stepFailed(getOpId(), coded);
            }
            break;
        case ready:
            dbClient.ready(Snapshot.class, getId(), getOpId());
            if (fsObj != null) {
                dbClient.ready(FileShare.class, fsObj.getId(), getOpId());
            }
            if (isNotifyWorkflow()) {
                WorkflowStepCompleter.stepSucceded(getOpId());
            }
            _logger.info("Done Snapshot operation {}, with Status: {}", getOpId(), status.name());
            break;
        default:
            if (isNotifyWorkflow()) {
                WorkflowStepCompleter.stepExecuting(getOpId());
            }
            break;
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) FileShare(com.emc.storageos.db.client.model.FileShare)

Aggregations

Snapshot (com.emc.storageos.db.client.model.Snapshot)92 FileShare (com.emc.storageos.db.client.model.FileShare)59 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)52 URI (java.net.URI)36 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)34 ControllerException (com.emc.storageos.volumecontroller.ControllerException)34 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)31 ArrayList (java.util.ArrayList)24 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)23 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 FileObject (com.emc.storageos.db.client.model.FileObject)21 URISyntaxException (java.net.URISyntaxException)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)19 WorkflowException (com.emc.storageos.workflow.WorkflowException)19 MapFileSnapshot (com.emc.storageos.api.mapper.functions.MapFileSnapshot)18 Path (javax.ws.rs.Path)18 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)17 Produces (javax.ws.rs.Produces)17