Search in sources :

Example 16 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doCreateQuotaDirectory.

@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    ApplicationContext context = null;
    XMLApiResult apiResult = null;
    try {
        _log.info("VNXFileStorageDeviceXML doCreateQuotaDirectory - start");
        String fsName = args.getFsName();
        String quotaTreetreeName = args.getQuotaDirectoryName();
        Boolean oplocks = quotaDir.getOpLock();
        String securityStyle = quotaDir.getSecurityStyle();
        Long size = quotaDir.getSize();
        if (null == fsName) {
            _log.error("VNXFileStorageDeviceXML::doCreateQuotaDirectory failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToCreateQuotaDir();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == quotaTreetreeName) {
            _log.error("VNXFileStorageDeviceXML::doCreateQuotaDirectory failed:  Quota Tree name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToCreateQuotaDir();
            serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        _log.info("FSName: {}", args.getFsName());
        _log.info("Quota tree name: {}", args.getQuotaDirectoryName());
        boolean isMountRequired = !(args.isFileShareMounted());
        _log.info("Mount required or not, to create quota dir requested {}", isMountRequired);
        // Load the context
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        // quota directory create/update takes size in MB as similar to FS create.
        Long sizeMBs = size / BYTESPERMB;
        apiResult = vnxComm.createQuotaDirectory(storage, args.getFsName(), quotaTreetreeName, securityStyle, sizeMBs, oplocks, isMountRequired);
        _log.info("createQuotaDirectory call result : {}", apiResult.isCommandSuccess());
        if (apiResult.isCommandSuccess()) {
            VNXQuotaTree quotaTree = (VNXQuotaTree) apiResult.getObject();
            args.getQuotaDirectory().setNativeId(String.valueOf(quotaTree.getId()));
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    _log.info("Status of the result {}", (result != null) ? result.isCommandSuccess() : result);
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateQuotaDir());
    }
    return cmdResult;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) 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) VNXQuotaTree(com.emc.storageos.vnx.xmlapi.VNXQuotaTree) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 17 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    // generate checkpoint baseline name
    args.setSnaphotCheckPointBaseline(args.getSnapshotName() + "_baseline");
    args.setSnapshotMountPath("/" + args.getSnapshotName());
    _log.info("FileShare, Snapshot {} {}", args.getFsUUID(), args.getSnapshotId());
    _log.info("FSName: {}", args.getFsName());
    _log.info("SnapShotName: {}", args.getSnapshotName());
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        FileShare fileShare = args.getFs();
        result = vnxComm.createSnapshot(storage, args.getFsName(), args.getSnapshotName(), fileShare);
        _log.info("createSnapshot call result : {}", result.isCommandSuccess());
        if (result.isCommandSuccess()) {
            VNXSnapshot vnxSnap = (VNXSnapshot) result.getObject();
            args.setSnapNativeId(String.valueOf(vnxSnap.getId()));
            String path = "/" + args.getSnapshotName();
            // Set path & mountpath
            args.setSnapshotMountPath(path);
            args.setSnapshotPath(path);
        }
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    _log.info("Status of the result {}", (result != null) ? result.isCommandSuccess() : result);
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSnapshot(result.getMessage()));
    }
    return cmdResult;
}
Also used : 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) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 18 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi 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 19 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    Map<String, String> autoExtendAtts = getAutoExtendAttrs(args);
    Long fsSize = args.getFsCapacity() / BYTESPERMB;
    if (fsSize < 1) {
        // Invalid size throw an error
        String errMsg = "doCreateFS failed : FileSystem size in bytes is not valid " + args.getFsCapacity();
        _log.error(errMsg);
        return BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSystem(errMsg));
    }
    _log.info("FileSystem size translation : {} : {} ", args.getFsCapacity(), fsSize);
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        result = vnxComm.createFileSystem(storage, args.getFsName(), // This will be used for CLI create FS
        args.getPoolName(), "1", fsSize, args.getThinProvision(), args.getNativeDeviceFsId(), autoExtendAtts);
        if (result.isCommandSuccess()) {
            VNXFileSystem vnxFS = (VNXFileSystem) result.getObject();
            args.setFsNativeId(String.valueOf(vnxFS.getFsId()));
            String path = "/" + args.getFsName();
            // Set path & mountpath
            args.setFsMountPath(path);
            args.setFsPath(path);
        }
    } catch (VNXException e) {
        throw DeviceControllerException.exceptions.unableToCreateFileSystem(e.getMessage(Locale.getDefault()));
    } finally {
        clearContext(context);
    }
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSystem(result.getMessage()));
    }
    return cmdResult;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult)

Aggregations

VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)19 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)18 ApplicationContext (org.springframework.context.ApplicationContext)18 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)18 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)15 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)15 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)4 VNXFileExport (com.emc.storageos.vnx.xmlapi.VNXFileExport)4 ArrayList (java.util.ArrayList)4 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)3 FileShare (com.emc.storageos.db.client.model.FileShare)3 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 ExportRule (com.emc.storageos.model.file.ExportRule)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 FileExport (com.emc.storageos.db.client.model.FileExport)2 VNXQuotaTree (com.emc.storageos.vnx.xmlapi.VNXQuotaTree)2 VNXSnapshot (com.emc.storageos.vnx.xmlapi.VNXSnapshot)2 HashMap (java.util.HashMap)2