Search in sources :

Example 11 with PolicyStorageResource

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

the class IsilonFileStorageDevice method doRefreshMirrorLink.

@Override
public BiosCommandResult doRefreshMirrorLink(StorageSystem system, FileShare source) {
    IsilonSyncPolicy syncpolicy = null;
    PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(source, _dbClient);
    if (policyStrRes != null) {
        syncpolicy = policyNativeIdValidation(system, policyStrRes);
        String policyId = syncpolicy.getId();
        return mirrorOperations.doRefreshMirrorFileShareLink(system, source, policyId);
    }
    ServiceError serviceError = DeviceControllerErrors.isilon.unableToCreateFileShare();
    return BiosCommandResult.createErrorResult(serviceError);
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy)

Example 12 with PolicyStorageResource

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

the class FileOrchestrationUtils method getFilePolicyStorageResources.

/**
 * Get the set of file policy storage resource for given policy
 *
 * @param dbClient
 * @param policy
 * @return
 */
public static List<PolicyStorageResource> getFilePolicyStorageResources(DbClient dbClient, VirtualPool vpool, Project project, FileShare fs) {
    // Get the replication policies for vpool/project/fs!!
    List<PolicyStorageResource> policyStorageResources = new ArrayList<PolicyStorageResource>();
    List<FilePolicy> replicationPolicies = getReplicationPolices(dbClient, vpool, project, fs);
    if (replicationPolicies != null && !replicationPolicies.isEmpty()) {
        if (replicationPolicies.size() > 1) {
            _log.error("More than one replication policy could not be applied accross vpool/project/fs");
            throw APIException.badRequests.moreThanOneReplicationPolicySpecified();
        } else {
            FilePolicy policy = replicationPolicies.get(0);
            for (PolicyStorageResource strRes : getFilePolicyStorageResources(dbClient, policy)) {
                if (strRes != null) {
                    if (FilePolicyApplyLevel.project.name().equalsIgnoreCase(policy.getApplyAt()) && strRes.getAppliedAt().toString().equals(project.getId().toString())) {
                        policyStorageResources.add(strRes);
                    } else if (FilePolicyApplyLevel.vpool.name().equalsIgnoreCase(policy.getApplyAt()) && strRes.getAppliedAt().toString().equals(vpool.getId().toString())) {
                        policyStorageResources.add(strRes);
                    }
                }
            }
        }
    }
    return policyStorageResources;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) ArrayList(java.util.ArrayList) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource)

Example 13 with PolicyStorageResource

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

the class FileOrchestrationUtils method getFilePolicyStorageResources.

/**
 * Get the set of file policy storage resource for given policy
 *
 * @param dbClient
 * @param policy
 * @return
 */
public static List<PolicyStorageResource> getFilePolicyStorageResources(DbClient dbClient, FilePolicy policy) {
    URIQueryResultList policyResourceURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getFilePolicyStorageResourceConstraint(policy.getId()), policyResourceURIs);
    List<PolicyStorageResource> policyStorageResources = new ArrayList<PolicyStorageResource>();
    Iterator<URI> policyStorageResIter = policyResourceURIs.iterator();
    while (policyStorageResIter.hasNext()) {
        PolicyStorageResource policyStorageRes = dbClient.queryObject(PolicyStorageResource.class, policyStorageResIter.next());
        if (policyStorageRes != null && !policyStorageRes.getInactive()) {
            policyStorageResources.add(policyStorageRes);
        }
    }
    return policyStorageResources;
}
Also used : ArrayList(java.util.ArrayList) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 14 with PolicyStorageResource

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

the class FileOrchestrationUtils method getAllVpoolLevelPolices.

/**
 * Return list of policies to be applied at vpool
 *
 * @param dbClient
 * @param vpool
 * @param storageSystem
 * @return
 */
public static List<FilePolicy> getAllVpoolLevelPolices(DbClient dbClient, VirtualPool vpool, URI storageSystem, URI nasServer) {
    List<FilePolicy> filePoliciesToCreate = new ArrayList<FilePolicy>();
    StringSet fileVpoolPolicies = vpool.getFilePolicies();
    if (fileVpoolPolicies != null && !fileVpoolPolicies.isEmpty()) {
        for (String fileVpoolPolicy : fileVpoolPolicies) {
            FilePolicy filePolicy = dbClient.queryObject(FilePolicy.class, URIUtil.uri(fileVpoolPolicy));
            filePoliciesToCreate.add(filePolicy);
            StringSet policyStrRes = filePolicy.getPolicyStorageResources();
            if (policyStrRes != null && !policyStrRes.isEmpty()) {
                for (String policyStrRe : policyStrRes) {
                    PolicyStorageResource strRes = dbClient.queryObject(PolicyStorageResource.class, URIUtil.uri(policyStrRe));
                    if (strRes.getAppliedAt().toString().equals(vpool.getId().toString()) && strRes.getStorageSystem().toString().equals(storageSystem.toString()) && strRes.getNasServer().toString().equalsIgnoreCase(nasServer.toString())) {
                        _log.info("File Policy {} is already exists for vpool {} , storage system {} and nas server {}", filePolicy.getFilePolicyName(), vpool.getLabel(), storageSystem.toString(), strRes);
                        filePoliciesToCreate.remove(filePolicy);
                        break;
                    }
                }
            }
        }
    }
    return filePoliciesToCreate;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource)

Example 15 with PolicyStorageResource

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

Aggregations

PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)29 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)14 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)11 ArrayList (java.util.ArrayList)11 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)8 FileShare (com.emc.storageos.db.client.model.FileShare)6 StringSet (com.emc.storageos.db.client.model.StringSet)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 NASServer (com.emc.storageos.db.client.model.NASServer)5 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)5 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)5 URI (java.net.URI)5 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)3 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)3