Search in sources :

Example 56 with IsilonApi

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

the class IsilonFileStorageDevice method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    // Snapshot Export operation is not supported by ISILON.
    if (args.getFileOperation() == false) {
        return BiosCommandResult.createErrorResult(DeviceControllerErrors.isilon.unSupportedOperation(EXPORT_OP_NAME));
    }
    try {
        _log.info("IsilonFileStorageDevice doExport {} - start", args.getFileObjId());
        IsilonApi isi = getIsilonDevice(storage);
        isiExport(isi, args, exportList);
        _log.info("IsilonFileStorageDevice doExport {} - complete", args.getFileObjId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doExport failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 57 with IsilonApi

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

the class IsilonFileStorageDevice method extraShareACLBySidFromArray.

/**
 * By using Sid get the CIFS Share ACL which are present in array but not in CoprHD Database .
 *
 * @param storage
 * @param args
 * @return Map with user sid with ShareACL
 */
private Map<String, ShareACL> extraShareACLBySidFromArray(StorageSystem storage, FileDeviceInputOutput args) {
    // get all Share ACL from CoprHD data base
    List<ShareACL> existingDBShareACL = args.getExistingShareAcls();
    NASServer nas = getNasServerForFileSystem(args, storage);
    Map<String, ShareACL> arrayShareACLMap = new HashMap<>();
    // get the all the Share ACL from the storage system.
    IsilonApi isi = getIsilonDevice(storage);
    String zoneName = getZoneName(args.getvNAS());
    IsilonSMBShare share = null;
    if (zoneName != null) {
        share = isi.getShare(args.getShareName(), zoneName);
    } else {
        share = isi.getShare(args.getShareName());
    }
    if (share != null) {
        List<Permission> permissions = share.getPermissions();
        for (Permission perm : permissions) {
            if (perm.getPermissionType().equalsIgnoreCase(Permission.PERMISSION_TYPE_ALLOW)) {
                ShareACL shareACL = new ShareACL();
                shareACL.setPermission(perm.getPermission());
                String userAndDomain = perm.getTrustee().getName();
                String[] trustees = new String[2];
                trustees = userAndDomain.split("\\\\");
                String trusteesType = perm.getTrustee().getType();
                if (trustees.length > 1) {
                    shareACL.setDomain(trustees[0]);
                    if (trusteesType.equals("group")) {
                        shareACL.setGroup(trustees[1]);
                    } else {
                        shareACL.setUser(trustees[1]);
                    }
                } else {
                    if (trusteesType.equals("group")) {
                        shareACL.setGroup(trustees[0]);
                    } else {
                        shareACL.setUser(trustees[0]);
                    }
                }
                arrayShareACLMap.put(perm.getTrustee().getId(), shareACL);
            }
        }
        for (Iterator<ShareACL> iterator = existingDBShareACL.iterator(); iterator.hasNext(); ) {
            ShareACL shareACL = iterator.next();
            String name = "";
            String domain = shareACL.getDomain();
            String user = shareACL.getUser();
            String group = shareACL.getGroup();
            String type = "user";
            if (user != null && !user.isEmpty()) {
                name = user;
            } else if (group != null && !group.isEmpty()) {
                name = group;
                type = "group";
            }
            String sid = getIdForDomainUserOrGroup(isi, nas, domain, name, type, false);
            if (arrayShareACLMap.containsKey(sid)) {
                arrayShareACLMap.remove(sid);
            }
        }
    }
    return arrayShareACLMap;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) HashMap(java.util.HashMap) IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) Permission(com.emc.storageos.isilon.restapi.IsilonSMBShare.Permission) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) ShareACL(com.emc.storageos.model.file.ShareACL)

Example 58 with IsilonApi

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

the class IsilonFileStorageDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    Boolean fsDirExists = true;
    Boolean fsDirCreatedByMe = false;
    try {
        _log.info("IsilonFileStorageDevice doCreateFS {} with name {} - start", args.getFsId(), args.getFsName());
        IsilonApi isi = getIsilonDevice(storage);
        VirtualNAS vNAS = args.getvNAS();
        String vNASPath = null;
        // get the custom path from the controller configuration
        String customPath = getCustomPath(storage, args);
        if (vNAS != null) {
            vNASPath = vNAS.getBaseDirPath();
            _log.info("vNAS base directory path: {}", vNASPath);
        }
        String usePhysicalNASForProvisioning = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.USE_PHYSICAL_NAS_FOR_PROVISIONING, "isilon", null);
        _log.info("Use System access zone to provision filesystem? {}", usePhysicalNASForProvisioning);
        String mountPath = null;
        String fsName = args.getFsName();
        if (args.getFs().getPersonality() != null && args.getFs().getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
            FileShare fsParent = _dbClient.queryObject(FileShare.class, args.getFs().getParentFileShare().getURI());
            fsName = fsParent.getName();
            // Add if there is any suffix in target fs label!!
            if (args.getFs().getLabel().contains("-target")) {
                String[] fsNameSuffix = args.getFs().getLabel().split(fsParent.getName() + "-target");
                if (fsNameSuffix != null && fsNameSuffix.length > 1 && !fsNameSuffix[1].isEmpty()) {
                    fsName = fsName + fsNameSuffix[1];
                }
            } else if (args.getFs().getLabel().contains("-localTarget")) {
                String[] fsNameSuffix = args.getFs().getLabel().split(fsParent.getName() + "-localTarget");
                if (fsNameSuffix != null && fsNameSuffix.length > 1 && !fsNameSuffix[1].isEmpty()) {
                    fsName = fsName + fsNameSuffix[1];
                }
            }
        }
        // Update the mount path as required
        if (vNASPath != null && !vNASPath.trim().isEmpty()) {
            mountPath = vNASPath + FW_SLASH + customPath + FW_SLASH + fsName;
        } else if (Boolean.valueOf(usePhysicalNASForProvisioning)) {
            mountPath = IFS_ROOT + FW_SLASH + getSystemAccessZoneNamespace() + FW_SLASH + customPath + FW_SLASH + fsName;
        } else {
            _log.error("No suitable access zone found for provisioning. Provisioning on System access zone is disabled");
            throw DeviceControllerException.exceptions.createFileSystemOnPhysicalNASDisabled();
        }
        // replace extra forward slash with single one
        mountPath = mountPath.replaceAll("/+", "/");
        _log.info("Mount path to mount the Isilon File System {}", mountPath);
        args.setFsMountPath(mountPath);
        args.setFsNativeGuid(args.getFsMountPath());
        args.setFsNativeId(args.getFsMountPath());
        args.setFsPath(args.getFsMountPath());
        // Update the mount path for local target!!!
        updateLocalTargetFileSystemPath(storage, args);
        // Create the target directory only if the replication policy was not applied!!
        // If policy was applied at higher level, policy would create target file system directories!
        boolean replicationExistsOnTarget = FileOrchestrationUtils.isReplicationPolicyExistsOnTarget(_dbClient, storage, args.getVPool(), args.getProject(), args.getFs());
        if (FileOrchestrationUtils.isPrimaryFileSystemOrNormalFileSystem(args.getFs()) || !replicationExistsOnTarget) {
            if (!replicationExistsOnTarget) {
                // Verify if the path of the new policy to be created only if the policy does not exist in the storage system
                checkNewPolicyPathHasData(args.getVPool(), args.getProject(), args.getFs(), args.getvNAS(), isi);
            }
            // Verify the file system directory exists or not!!
            fsDirExists = isi.existsDir(args.getFsMountPath());
            if (!fsDirExists) {
                // create directory for the file share
                isi.createDir(args.getFsMountPath(), true);
                fsDirCreatedByMe = true;
            } else {
                // Fail to create file system, as the directory already exists!!
                _log.error("File system creation failed due to directory path {} already exists.", args.getFsMountPath());
                throw DeviceControllerException.exceptions.failToCreateFileSystem(args.getFsMountPath());
            }
            Long softGrace = null;
            if (args.getFsSoftGracePeriod() != null) {
                softGrace = Long.valueOf(args.getFsSoftGracePeriod());
            }
            // set quota - save the quota id to extensions
            String qid = createQuotaWithThreshold(args.getFsMountPath(), args.getFsCapacity(), args.getFsSoftLimit(), args.getFsNotificationLimit(), softGrace, null, isi);
            if (args.getFsExtensions() == null) {
                args.initFsExtensions();
            }
            args.getFsExtensions().put(QUOTA, qid);
        }
        // set protection level
        // String protection = args.getFSProtectionLevel();
        // Call isilon api to set protection level
        _log.info("IsilonFileStorageDevice doCreateFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doCreateFS failed.", e);
        // delete the fs directory alone!!!
        if (fsDirCreatedByMe) {
            // delete isilon directory
            _log.info("doCreateFS failed, deleting the isilon directory {} which has been created in this workflow", args.getFsMountPath());
            IsilonApi isi = getIsilonDevice(storage);
            isi.deleteDir(args.getFsMountPath());
        }
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 59 with IsilonApi

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

the class IsilonFileStorageDevice method doCreateQuotaDirectory.

@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
    // Get Parent FS mount path
    // Get Quota Directory Name
    // Get Quota Size
    // Call create Directory
    // Call create Quota (Aways use that quota for updating the size)
    String fsMountPath = args.getFsMountPath();
    Long qDirSize = quotaDir.getSize();
    String qDirPath = fsMountPath + "/" + quotaDir.getName();
    _log.info("IsilonFileStorageDevice doCreateQuotaDirectory {} with size {} - start", qDirPath, qDirSize);
    Boolean fsDirCreatedByMe = false;
    try {
        IsilonApi isi = getIsilonDevice(storage);
        // Verify the quota directory path exists or not!!
        if (!isi.existsDir(qDirPath)) {
            // create directory for the quota directory
            isi.createDir(qDirPath, true);
            fsDirCreatedByMe = true;
        } else {
            // Fail to create quota directory, as the directory already exists!!
            _log.error("Quota directory creation failed due to directory path {} already exists.", qDirPath);
            throw DeviceControllerException.exceptions.failToCreateQuotaDirectory(qDirPath);
        }
        String qid = checkThresholdAndcreateQuota(quotaDir, qDirSize, qDirPath, args.getFsCapacity(), isi);
        if (args.getQuotaDirExtensions() == null) {
            args.initQuotaDirExtensions();
        }
        args.getQuotaDirExtensions().put(QUOTA, qid);
        _log.info("IsilonFileStorageDevice doCreateQuotaDirectory {} with size {} - complete", qDirPath, qDirSize);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        // delete the directory alone with recursive false!!!
        if (fsDirCreatedByMe) {
            // delete isilon directory
            _log.info("doCreateQuotaDirectory failed, deleting the isilon directory {} which has been created in this workflow", qDirPath);
            IsilonApi isi = getIsilonDevice(storage);
            isi.deleteDir(qDirPath);
        }
        _log.error("doCreateQuotaDirectory failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 60 with IsilonApi

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

the class IsilonFileStorageDevice method doCheckFSExists.

@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("checking file system existence on array: {}", args.getFsName());
    // setting true by default for safer side
    boolean isFSExists = true;
    try {
        IsilonApi isi = getIsilonDevice(storage);
        isFSExists = isi.existsDir(args.getFsMountPath());
    } catch (IsilonException e) {
        _log.error("Querying FS failed", e);
    }
    return isFSExists;
}
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