Search in sources :

Example 51 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doModifyFS.

@Override
public BiosCommandResult doModifyFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doModifyFS {} - start", args.getFsId());
        IsilonApi isi = getIsilonDevice(storage);
        String quotaId = null;
        if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
            quotaId = args.getFsExtensions().get(QUOTA);
        } else {
            final ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
            _log.error(serviceError.getMessage());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        IsilonSmartQuota expandedQuota = getExpandedQuota(isi, args, args.getFsCapacity());
        isi.modifyQuota(quotaId, expandedQuota);
        _log.info("IsilonFileStorageDevice doModifyFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doModifyFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("doModifyFS failed.", e);
        // convert this to a ServiceError and create/or reuse a service
        // code
        ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
        return BiosCommandResult.createErrorResult(serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 52 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method extraExportRuleFromArray.

/**
 * Get the export rule which are present in arry but not in CoprHD Database.
 *
 * @param storage
 * @param args
 * @return map with security flavor and export rule
 */
private Map<String, ExportRule> extraExportRuleFromArray(StorageSystem storage, FileDeviceInputOutput args) {
    // map to store the export rule grouped by sec flavor
    Map<String, ExportRule> exportRuleMap = new HashMap<>();
    List<IsilonExport> exportsList = new ArrayList<IsilonExport>();
    Set<String> arrayReadOnlyHost = new HashSet<>();
    Set<String> arrayReadWriteHost = new HashSet<>();
    Set<String> arrayRootHost = new HashSet<>();
    Set<String> dbReadOnlyHost = new HashSet<>();
    Set<String> dbReadWriteHost = new HashSet<>();
    Set<String> dbRootHost = new HashSet<>();
    // get all export rule from CoprHD data base
    List<ExportRule> existingDBExportRules = args.getExistingDBExportRules();
    // get the all the export from the storage system.
    IsilonApi isi = getIsilonDevice(storage);
    for (ExportRule exportRule : existingDBExportRules) {
        if (exportRule.getReadOnlyHosts() != null) {
            dbReadOnlyHost.addAll(exportRule.getReadOnlyHosts());
        }
        if (exportRule.getReadWriteHosts() != null) {
            dbReadWriteHost.addAll(exportRule.getReadWriteHosts());
        }
        if (exportRule.getRootHosts() != null) {
            dbRootHost.addAll(exportRule.getRootHosts());
        }
        String isilonExportId = exportRule.getDeviceExportId();
        if (isilonExportId != null) {
            IsilonExport isilonExport = null;
            String zoneName = getZoneName(args.getvNAS());
            if (zoneName != null) {
                isilonExport = isi.getExport(isilonExportId, zoneName);
            } else {
                isilonExport = isi.getExport(isilonExportId);
            }
            exportsList.add(isilonExport);
            arrayReadOnlyHost.addAll(isilonExport.getReadOnlyClients());
            arrayReadWriteHost.addAll(isilonExport.getReadWriteClients());
            arrayRootHost.addAll(isilonExport.getRootClients());
        }
        // find out the change between array and CoprHD database.
        Set<String> arrayExtraReadOnlyHost = Sets.difference(arrayReadOnlyHost, dbReadOnlyHost);
        Set<String> arrayExtraReadWriteHost = Sets.difference(arrayReadWriteHost, dbReadWriteHost);
        Set<String> arrayExtraRootHost = Sets.difference(arrayRootHost, dbRootHost);
        // if change found update the exportRuleMap
        if (!arrayExtraReadOnlyHost.isEmpty() || !arrayExtraReadWriteHost.isEmpty() || !arrayExtraRootHost.isEmpty()) {
            ExportRule extraRuleFromArray = new ExportRule();
            extraRuleFromArray.setDeviceExportId(exportRule.getDeviceExportId());
            extraRuleFromArray.setAnon(exportRule.getAnon());
            extraRuleFromArray.setSecFlavor(exportRule.getSecFlavor());
            extraRuleFromArray.setExportPath(exportRule.getExportPath());
            extraRuleFromArray.setReadOnlyHosts(arrayExtraReadOnlyHost);
            extraRuleFromArray.setReadWriteHosts(arrayExtraReadWriteHost);
            extraRuleFromArray.setRootHosts(arrayExtraRootHost);
            exportRuleMap.put(exportRule.getSecFlavor(), extraRuleFromArray);
        }
    }
    return exportRuleMap;
}
Also used : IsilonExport(com.emc.storageos.isilon.restapi.IsilonExport) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) HashSet(java.util.HashSet)

Example 53 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doConnect.

@Override
public void doConnect(StorageSystem storage) throws ControllerException {
    try {
        _log.info("doConnect {} - start", storage.getId());
        IsilonApi isi = getIsilonDevice(storage);
        isi.getClusterInfo();
        String msg = String.format("doConnect %1$s - complete", storage.getId());
        _log.info(msg);
    } catch (IsilonException e) {
        _log.error("doConnect failed.", e);
        throw DeviceControllerException.exceptions.connectStorageFailed(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 54 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method deleteNfsACLs.

@Override
public BiosCommandResult deleteNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
    IsilonNFSACL isilonAcl = new IsilonNFSACL();
    ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
    List<NfsACE> aceToDelete = args.getNfsAclsToDelete();
    for (NfsACE nfsACE : aceToDelete) {
        Acl acl = getIsilonAclFromNfsACE(nfsACE);
        acl.setOp("delete");
        aclCompleteList.add(acl);
    }
    isilonAcl.setAction("update");
    isilonAcl.setAuthoritative("acl");
    isilonAcl.setAcl(aclCompleteList);
    String path = args.getFileSystemPath();
    if (args.getSubDirectory() != null && !args.getSubDirectory().isEmpty()) {
        path = path + "/" + args.getSubDirectory();
    }
    // Process new ACLs
    IsilonApi isi = getIsilonDevice(storage);
    _log.info("Calling Isilon API: to delete NFS Acl for  {}, acl  {}", args.getFileSystemPath(), isilonAcl);
    isi.modifyNFSACL(path, isilonAcl);
    _log.info("End deleteNfsACLs");
    BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
    return result;
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) IsilonNFSACL(com.emc.storageos.isilon.restapi.IsilonNFSACL) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) Acl(com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi)

Example 55 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doUnexport.

@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doUnexport: {} - start", args.getFileObjId());
        IsilonApi isi = getIsilonDevice(storage);
        isiUnexport(isi, args, exportList);
        _log.info("IsilonFileStorageDevice doUnexport {} - complete", args.getFileObjId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doUnexport failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Aggregations

IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)81 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)64 URISyntaxException (java.net.URISyntaxException)31 URI (java.net.URI)22 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)21 ArrayList (java.util.ArrayList)18 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 IOException (java.io.IOException)12 JSONException (org.codehaus.jettison.json.JSONException)12 FileShare (com.emc.storageos.db.client.model.FileShare)11 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)11 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)10 HashMap (java.util.HashMap)10 ControllerException (com.emc.storageos.volumecontroller.ControllerException)9 Test (org.junit.Test)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7