Search in sources :

Example 6 with NASServer

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

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

the class FileOrchestrationUtils method updatePolicyStorageResource.

/**
 * Create/Update the File policy resource
 *
 * @param dbClient
 * @param system
 * @param filePolicy
 * @param args
 * @param sourcePath
 * @return
 */
public static PolicyStorageResource updatePolicyStorageResource(DbClient dbClient, StorageSystem system, FilePolicy filePolicy, FileDeviceInputOutput args, String sourcePath, String name, String policyNativeId, StorageSystem targetSystem, NASServer targetNasServer, String targetPath) {
    PolicyStorageResource policyStorageResource = new PolicyStorageResource();
    policyStorageResource.setId(URIUtil.createId(PolicyStorageResource.class));
    policyStorageResource.setFilePolicyId(filePolicy.getId());
    policyStorageResource.setStorageSystem(system.getId());
    policyStorageResource.setPolicyNativeId(policyNativeId);
    policyStorageResource.setName(name);
    policyStorageResource.setLabel(name);
    policyStorageResource.setResourcePath(sourcePath);
    NASServer nasServer = null;
    if (args.getvNAS() != null) {
        nasServer = args.getvNAS();
    } else {
        // Get the physical NAS for the storage system!!
        PhysicalNAS pNAS = getSystemPhysicalNAS(dbClient, system);
        if (pNAS != null) {
            nasServer = pNAS;
        }
    }
    policyStorageResource.setNasServer(nasServer.getId());
    setPolicyStorageAppliedAt(filePolicy, args, policyStorageResource);
    policyStorageResource.setNativeGuid(NativeGUIDGenerator.generateNativeGuidForFilePolicyResource(system, nasServer.getNasName(), filePolicy.getFilePolicyType(), sourcePath, NativeGUIDGenerator.FILE_STORAGE_RESOURCE));
    if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicy.FilePolicyType.file_replication.name())) {
        // Update the target resource details!!!
        FileReplicaPolicyTargetMap fileReplicaPolicyTargetMap = new FileReplicaPolicyTargetMap();
        FileReplicaPolicyTarget target = new FileReplicaPolicyTarget();
        if (targetNasServer != null) {
            target.setNasServer(targetNasServer.getId().toString());
        } else {
            PhysicalNAS pNAS = FileOrchestrationUtils.getSystemPhysicalNAS(dbClient, targetSystem);
            if (pNAS != null) {
                target.setNasServer(pNAS.getId().toString());
            }
        }
        target.setAppliedAt(filePolicy.getApplyAt());
        target.setStorageSystem(targetSystem.getId().toString());
        target.setPath(targetPath);
        String key = target.getFileTargetReplicaKey();
        fileReplicaPolicyTargetMap.put(key, target);
        policyStorageResource.setFileReplicaPolicyTargetMap(fileReplicaPolicyTargetMap);
    }
    dbClient.createObject(policyStorageResource);
    filePolicy.addPolicyStorageResources(policyStorageResource.getId());
    dbClient.updateObject(filePolicy);
    _log.info("PolicyStorageResource object created successfully for {} ", system.getLabel() + policyStorageResource.getAppliedAt());
    return policyStorageResource;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) FileReplicaPolicyTargetMap(com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap) FileReplicaPolicyTarget(com.emc.storageos.db.client.model.FileReplicaPolicyTarget) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 8 with NASServer

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

the class FileOrchestrationUtils method isReplicationPolicyExistsOnTarget.

/**
 * Verify the replication policy was applied at given level
 *
 * @param dbClient
 * @param system
 * @param nasServer
 * @param vpool
 * @param project
 * @param fs
 * @return
 */
public static Boolean isReplicationPolicyExistsOnTarget(DbClient dbClient, StorageSystem system, VirtualPool vpool, Project project, FileShare fs) {
    if (fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
        List<FilePolicy> replicationPolicies = getReplicationPolices(dbClient, vpool, project, fs);
        if (replicationPolicies != null && !replicationPolicies.isEmpty()) {
            if (replicationPolicies.size() > 1) {
                _log.warn("More than one replication policy found {}", replicationPolicies.size());
            } else {
                FilePolicy replPolicy = replicationPolicies.get(0);
                FileShare sourceFS = dbClient.queryObject(FileShare.class, fs.getParentFileShare().getURI());
                StorageSystem sourceStorage = dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
                NASServer nasServer = null;
                if (sourceFS != null && sourceFS.getVirtualNAS() != null) {
                    nasServer = dbClient.queryObject(VirtualNAS.class, sourceFS.getVirtualNAS());
                } else {
                    // Get the physical NAS for the storage system!!
                    nasServer = FileOrchestrationUtils.getSystemPhysicalNAS(dbClient, sourceStorage);
                }
                if (replPolicy.getApplyAt().equalsIgnoreCase(FilePolicyApplyLevel.vpool.name())) {
                    return isvPoolPolicyAppliedOnStorageSystem(dbClient, sourceStorage, nasServer, vpool, replPolicy);
                } else if (replPolicy.getApplyAt().equalsIgnoreCase(FilePolicyApplyLevel.project.name())) {
                    return isProjectPolicyAppliedOnStorageSystem(dbClient, sourceStorage, nasServer, project, replPolicy);
                } else if (replPolicy.getApplyAt().equalsIgnoreCase(FilePolicyApplyLevel.file_system.name())) {
                    FileShare fsParent = dbClient.queryObject(FileShare.class, fs.getParentFileShare());
                    return isFSPolicyAppliedOnStorageSystem(dbClient, sourceStorage, nasServer, fsParent, replPolicy);
                }
            }
        }
    }
    return false;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) FileShare(com.emc.storageos.db.client.model.FileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with NASServer

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

the class FileOrchestrationUtils method findPolicyStorageResourceByNativeId.

/**
 * Find the file storage resource by Native ID
 *
 * @param dbClient
 *
 * @param system
 *            storage system
 * @param filePolicy
 *            file policy
 * @param args
 *
 * @param path
 *            storage path
 * @return policy storage resource
 */
public static PolicyStorageResource findPolicyStorageResourceByNativeId(DbClient dbClient, StorageSystem system, FilePolicy filePolicy, FileDeviceInputOutput args, String path) {
    URIQueryResultList results = new URIQueryResultList();
    PolicyStorageResource storageRes = null;
    NASServer nasServer = null;
    if (args.getvNAS() != null) {
        nasServer = args.getvNAS();
    } else {
        // Get the physical NAS for the storage system!!
        PhysicalNAS pNAS = getSystemPhysicalNAS(dbClient, system);
        if (pNAS != null) {
            nasServer = pNAS;
        } else {
            _log.error("Unable to find physical NAS on storage system {}", system.getLabel());
            return null;
        }
    }
    // Set storage port details to vNas
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuidForFilePolicyResource(system, nasServer.getNasName(), filePolicy.getFilePolicyType(), path, NativeGUIDGenerator.FILE_STORAGE_RESOURCE);
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getPolicyStorageResourceByNativeGuidConstraint(nasNativeGuid), results);
    Iterator<URI> iter = results.iterator();
    PolicyStorageResource tmpStorageres = null;
    while (iter.hasNext()) {
        tmpStorageres = dbClient.queryObject(PolicyStorageResource.class, iter.next());
        if (tmpStorageres != null && !tmpStorageres.getInactive()) {
            storageRes = tmpStorageres;
            _log.info("found File policy storage resource for {}", tmpStorageres.getNativeGuid() + ":" + tmpStorageres.getFilePolicyId());
            break;
        }
    }
    return storageRes;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 10 with NASServer

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

the class UnManagedFilesystemService method getIsilonStoragePort.

/**
 * This function will return one of the NAS server port which is part of given virtual array
 * it return null, if any of the NAS server port is not part of given virtual array
 *
 * @param umfsStoragePort
 *            port which is assigned to file system while UMFS discovery
 * @param nasUri
 *            NAS server URI
 * @param virtualArray
 *            virtual array
 */
private StoragePort getIsilonStoragePort(StoragePort umfsStoragePort, String nasUri, URI virtualArray) {
    StoragePort sp = null;
    NASServer nasServer = null;
    if (StringUtils.equals("VirtualNAS", URIUtil.getTypeName(nasUri))) {
        nasServer = _dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
    } else {
        nasServer = _dbClient.queryObject(PhysicalNAS.class, URI.create(nasUri));
    }
    if (nasServer != null) {
        List<URI> virtualArrayPorts = returnAllPortsInVArray(virtualArray);
        StringSet virtualArrayPortsSet = new StringSet();
        StringSet storagePorts = nasServer.getStoragePorts();
        for (URI tempVarrayPort : virtualArrayPorts) {
            virtualArrayPortsSet.add(tempVarrayPort.toString());
        }
        StringSet commonPorts = null;
        if (virtualArrayPorts != null && storagePorts != null) {
            commonPorts = new StringSet(storagePorts);
            commonPorts.retainAll(virtualArrayPortsSet);
        }
        if (commonPorts != null && !commonPorts.isEmpty()) {
            List<String> tempList = new ArrayList<String>(commonPorts);
            Collections.shuffle(tempList);
            sp = _dbClient.queryObject(StoragePort.class, URI.create(tempList.get(0)));
            return sp;
        }
    }
    return null;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StoragePort(com.emc.storageos.db.client.model.StoragePort) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

NASServer (com.emc.storageos.db.client.model.NASServer)12 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)7 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)6 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)5 FileShare (com.emc.storageos.db.client.model.FileShare)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 URI (java.net.URI)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)2 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 IsilonAccessZone (com.emc.storageos.isilon.restapi.IsilonAccessZone)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1