Search in sources :

Example 1 with NASServer

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

the class UnManagedFilesystemService method doesNASServerSupportVPoolProtocols.

/**
 * Checks the NAS server protocols with vpool protocols
 *
 * @param nasUri the NAS server ID
 * @param vpoolProtocols the protocols configured in vpool
 * @return true if NAS server protocols matches with vpool protocols; false otherwise
 */
private boolean doesNASServerSupportVPoolProtocols(String nasUri, StringSet vpoolProtocols) {
    NASServer nasServer = null;
    boolean supports = false;
    boolean isVNAS = false;
    if (StringUtils.equals("VirtualNAS", URIUtil.getTypeName(nasUri))) {
        nasServer = _dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
        isVNAS = true;
    } else {
        nasServer = _dbClient.queryObject(PhysicalNAS.class, URI.create(nasUri));
    }
    if (nasServer != null) {
        StringSet nasProtocols = nasServer.getProtocols();
        if (isVNAS) {
            if (VirtualNasState.LOADED.name().equals(nasServer.getNasState())) {
                _logger.info("NAS server is: {}. Supported protocols: {}. Vpool protocols: {}", nasServer.getNasName(), nasProtocols, vpoolProtocols);
                supports = nasProtocols.containsAll(vpoolProtocols);
            } else {
                _logger.warn("NAS server: {} not in LOADED state. So this vNAS server is not supported.", nasServer.getNasName());
                supports = false;
            }
        } else {
            // Perform check on Physical NAS
            supports = nasProtocols.containsAll(vpoolProtocols);
        }
    }
    return supports;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 2 with NASServer

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

the class FileSnapshotPolicyMigration method updatePolicyStorageResouce.

private void updatePolicyStorageResouce(StorageSystem system, FilePolicy fileSnapshotPolicy, FileShare fs) {
    logger.info("Creating policy storage resource for storage {} fs {} and policy {} ", system.getLabel(), fs.getLabel(), fileSnapshotPolicy.getFilePolicyName());
    PolicyStorageResource policyStorageResource = new PolicyStorageResource();
    policyStorageResource.setId(URIUtil.createId(PolicyStorageResource.class));
    policyStorageResource.setFilePolicyId(fileSnapshotPolicy.getId());
    policyStorageResource.setStorageSystem(system.getId());
    policyStorageResource.setPolicyNativeId(fileSnapshotPolicy.getFilePolicyName() + "_" + fs.getName());
    policyStorageResource.setAppliedAt(fs.getId());
    policyStorageResource.setResourcePath(fs.getNativeId());
    NASServer nasServer = null;
    if (fs.getVirtualNAS() != null) {
        nasServer = dbClient.queryObject(VirtualNAS.class, fs.getVirtualNAS());
    } else {
        // Get the physical NAS for the storage system!!
        PhysicalNAS pNAS = getSystemPhysicalNAS(system);
        if (pNAS != null) {
            nasServer = pNAS;
        }
    }
    if (nasServer != null) {
        logger.info("Found NAS server {} ", nasServer.getNasName());
        policyStorageResource.setNasServer(nasServer.getId());
        policyStorageResource.setNativeGuid(generateNativeGuidForFilePolicyResource(system, nasServer.getNasName(), fileSnapshotPolicy.getFilePolicyType(), fs.getNativeId()));
    }
    dbClient.createObject(policyStorageResource);
    fileSnapshotPolicy.addPolicyStorageResources(policyStorageResource.getId());
    fileSnapshotPolicy.addAssignedResources(fs.getId());
    logger.info("PolicyStorageResource object created successfully for {} ", system.getLabel() + policyStorageResource.getAppliedAt());
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 3 with NASServer

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

the class VirtualPoolFileReplicationPolicyMigration method updatePolicyStorageResouce.

private void updatePolicyStorageResouce(StorageSystem system, FilePolicy filePolicy, FileShare fs) {
    logger.info("Creating policy storage resource for storage {} fs {} and policy {} ", system.getLabel(), fs.getLabel(), filePolicy.getFilePolicyName());
    PolicyStorageResource policyStorageResource = new PolicyStorageResource();
    policyStorageResource.setId(URIUtil.createId(PolicyStorageResource.class));
    policyStorageResource.setFilePolicyId(filePolicy.getId());
    policyStorageResource.setStorageSystem(system.getId());
    policyStorageResource.setPolicyNativeId(fs.getName());
    policyStorageResource.setAppliedAt(fs.getId());
    policyStorageResource.setResourcePath(fs.getNativeId());
    NASServer nasServer = null;
    if (fs.getVirtualNAS() != null) {
        nasServer = dbClient.queryObject(VirtualNAS.class, fs.getVirtualNAS());
    } else {
        // Get the physical NAS for the storage system!!
        PhysicalNAS pNAS = getSystemPhysicalNAS(system);
        if (pNAS != null) {
            nasServer = pNAS;
        }
    }
    if (nasServer != null) {
        logger.info("Found NAS server {} ", nasServer.getNasName());
        policyStorageResource.setNasServer(nasServer.getId());
        policyStorageResource.setNativeGuid(generateNativeGuidForFilePolicyResource(system, nasServer.getNasName(), filePolicy.getFilePolicyType(), fs.getNativeId()));
    }
    if (fs.getMirrorfsTargets() != null && !fs.getMirrorfsTargets().isEmpty()) {
        String[] targetFSs = fs.getMirrorfsTargets().toArray(new String[fs.getMirrorfsTargets().size()]);
        // Today we support single target!!
        FileShare fsTarget = dbClient.queryObject(FileShare.class, URI.create(targetFSs[0]));
        // In older release, policy name was set to target file system lable!!
        policyStorageResource.setPolicyNativeId(fsTarget.getLabel());
        // Update the target resource details!!!
        FileReplicaPolicyTargetMap fileReplicaPolicyTargetMap = new FileReplicaPolicyTargetMap();
        FileReplicaPolicyTarget target = new FileReplicaPolicyTarget();
        target.setAppliedAt(filePolicy.getApplyAt());
        target.setStorageSystem(fsTarget.getStorageDevice().toString());
        target.setPath(fsTarget.getNativeId());
        NASServer targetNasServer = null;
        if (fsTarget.getVirtualNAS() != null) {
            targetNasServer = dbClient.queryObject(VirtualNAS.class, fsTarget.getVirtualNAS());
        } else {
            StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, fsTarget.getStorageDevice());
            // Get the physical NAS for the storage system!!
            PhysicalNAS pNAS = getSystemPhysicalNAS(targetSystem);
            if (pNAS != null) {
                targetNasServer = pNAS;
            }
        }
        if (targetNasServer != null) {
            target.setNasServer(targetNasServer.getId().toString());
        }
        String key = target.getFileTargetReplicaKey();
        fileReplicaPolicyTargetMap.put(key, target);
        policyStorageResource.setFileReplicaPolicyTargetMap(fileReplicaPolicyTargetMap);
    }
    dbClient.createObject(policyStorageResource);
    filePolicy.addPolicyStorageResources(policyStorageResource.getId());
    filePolicy.addAssignedResources(fs.getId());
    logger.info("PolicyStorageResource object created successfully for {} ", system.getLabel() + policyStorageResource.getAppliedAt());
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) 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) FileShare(com.emc.storageos.db.client.model.FileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with NASServer

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

the class IsilonFileStorageDevice method doApplyFileReplicationPolicy.

private BiosCommandResult doApplyFileReplicationPolicy(FilePolicy filePolicy, FileDeviceInputOutput args, FileShare fs, StorageSystem storageObj) {
    IsilonApi isi = getIsilonDevice(storageObj);
    FileShare targetFS = null;
    String sourcePath = generatePathForPolicy(filePolicy, fs, args);
    String scheduleValue = getIsilonPolicySchedule(filePolicy);
    String targetPath = null;
    String targetHost = null;
    StorageSystem targetSystem = null;
    NASServer targetNasServer = null;
    if (fs.getPersonality() != null && PersonalityTypes.SOURCE.name().equalsIgnoreCase(fs.getPersonality())) {
        String targetFs = fs.getMirrorfsTargets().iterator().next();
        targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetFs));
        targetPath = generatePathForPolicy(filePolicy, targetFS, args);
        // Add the suffix only for local replication policy at higher level
        if (filePolicy.getFileReplicationType().equalsIgnoreCase(FileReplicationType.LOCAL.name()) && !FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(filePolicy.getApplyAt())) {
            targetPath = targetPath + "_localTarget";
        }
        // Get the target smart connect zone!!
        targetHost = FileOrchestrationUtils.getTargetHostPortForReplication(_dbClient, targetFS);
        targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
        if (targetFS.getVirtualNAS() != null) {
            targetNasServer = _dbClient.queryObject(VirtualNAS.class, targetFS.getVirtualNAS());
        }
    }
    IsilonApi isiApiOfTarget = getIsilonDevice(targetSystem);
    String targetClusterName = isiApiOfTarget.getClusterConfig().getName();
    String sourceClustername = isi.getClusterConfig().getName();
    String policyName = FileOrchestrationUtils.generateNameForSyncIQPolicy(sourceClustername, targetClusterName, filePolicy, fs, args, sourcePath);
    IsilonSyncPolicy isiSynIQPolicy = getEquivalentIsilonSyncIQPolicy(isi, sourcePath);
    PolicyStorageResource policyStorageResource = null;
    if (isiSynIQPolicy != null) {
        boolean validPolicy = validateIsilonReplicationPolicy(isiSynIQPolicy, filePolicy, targetPath, targetSystem, storageObj);
        if (validPolicy) {
            _log.info("File Policy {} is already applied and running.", filePolicy.toString());
            // Verify the policy was mapped to FileStorageResource
            if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, sourcePath)) {
                _log.info("Isilon policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
                // update the policy object in DB
                policyStorageResource = FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, sourcePath, isiSynIQPolicy.getName(), isiSynIQPolicy.getId(), targetSystem, targetNasServer, targetPath);
                // for existing policy's on device
                // label - label is generated from ViPR
                policyStorageResource.setLabel(policyName);
                _dbClient.updateObject(policyStorageResource);
            }
            return BiosCommandResult.createSuccessfulResult();
        } else {
            throw DeviceControllerException.exceptions.assignFilePolicyFailed(filePolicy.getFilePolicyName(), filePolicy.getApplyAt(), "File policy and Isilon syncIQ policy differs for path: " + sourcePath);
        }
    } else {
        IsilonSyncPolicy policy = new IsilonSyncPolicy(policyName, sourcePath, targetPath, targetHost, IsilonSyncPolicy.Action.sync);
        IsilonSyncPolicy8Above policycopy = new IsilonSyncPolicy8Above();
        if (scheduleValue != null && !scheduleValue.isEmpty()) {
            policy.setSchedule(scheduleValue);
        }
        if (filePolicy.getFilePolicyDescription() != null) {
            policy.setDescription(filePolicy.getFilePolicyDescription());
        }
        if (filePolicy.getNumWorkerThreads() != null && filePolicy.getNumWorkerThreads() > 0) {
            policy.setWorkersPerNode(filePolicy.getNumWorkerThreads().intValue());
        }
        policy.setEnabled(true);
        String policyId = null;
        if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageObj.getFirmwareVersion()) >= 0) {
            if (filePolicy.getPriority() != null) {
                policycopy = policycopy.copy(policy);
                policycopy.setPriority(FilePolicyPriority.valueOf(filePolicy.getPriority()).ordinal());
            }
            policyId = isi.createReplicationPolicy8above(policycopy);
        } else {
            policyId = isi.createReplicationPolicy(policy);
        }
        if (policyId != null) {
            _log.info("Isilon File Policy {} created successfully with id {}", policyName, policyId);
            // update the policy object in DB
            FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, sourcePath, policyName, policyId, targetSystem, targetNasServer, targetPath);
            return BiosCommandResult.createSuccessfulResult();
        }
    }
    return BiosCommandResult.createSuccessfulResult();
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) 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) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSyncPolicy8Above(com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with NASServer

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

the class IsilonFileStorageDevice method getNasServerForFileSystem.

/**
 * To get NasServer form for the file system
 *
 * @param args
 * @param storage
 * @return NASServer if found or null value
 */
private NASServer getNasServerForFileSystem(FileDeviceInputOutput args, StorageSystem storage) {
    NASServer nas = null;
    // Check VirtualNAS is associated with file system or not.
    if (args.getvNAS() != null) {
        nas = args.getvNAS();
    } else {
        // mean it file is created on system access zone.
        // We do not have direct reference of physical nas servers from StorageSystem or fsobj
        URIQueryResultList pNasURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDevicePhysicalNASConstraint(storage.getId()), pNasURIs);
        if (pNasURIs.iterator().hasNext()) {
            // storage system should have only one PhysicalNAS instance.
            URI pNasURI = pNasURIs.iterator().next();
            nas = _dbClient.queryObject(PhysicalNAS.class, pNasURI);
        }
    }
    return nas;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

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