Search in sources :

Example 86 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class VirtualArrayService method getServiceProfileTemplatesForComputeSystem.

private List<NamedRelatedResourceRep> getServiceProfileTemplatesForComputeSystem(URI computeSystemId, URI varrayId) {
    List<NamedRelatedResourceRep> templates = new ArrayList<NamedRelatedResourceRep>();
    ComputeSystem computeSystem = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayId);
    _log.debug("Finding SPTs from Compute System:" + computeSystem.getLabel() + " valid for varray:" + varray.getLabel());
    List<NamedRelatedResourceRep> spts = computeSystemService.getServiceProfileTemplatesForComputeSystem(computeSystem, _dbClient);
    StringSet varrays = new StringSet();
    varrays.add(varrayId.toString());
    // Filter SPTs that are not valid for the varrays for the UCS in this vcp
    for (NamedRelatedResourceRep spt : spts) {
        if (computeSystemService.isServiceProfileTemplateValidForVarrays(varrays, spt.getId())) {
            templates.add(spt);
            _log.debug("SPT " + spt.getName() + " is valid for the varray:" + varray.getLabel());
        } else {
            _log.debug("SPT " + spt.getName() + " is not valid for the varray:" + varray.getLabel());
        }
    }
    return templates;
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ArrayList(java.util.ArrayList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 87 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class TaskService method getAllTasks.

// Original method to return task list. Will be used when max_count is either NOT specified or set but > max limit like 10K.
// This could cause out of memory issue
private TasksList getAllTasks(Set<URI> tenantIds, String startTime, String endTime, Integer maxCount) {
    // Entries from the index, sorted with most recent first
    Set<TimestampedURIQueryResult.TimestampedURI> sortedIndexEntries = Sets.newTreeSet(new TaskComparator());
    Date startWindowDate = TimeUtils.getDateTimestamp(startTime);
    Date endWindowDate = TimeUtils.getDateTimestamp(endTime);
    // Fetch index entries and load into sorted set
    List<NamedRelatedResourceRep> resourceReps = Lists.newArrayList();
    for (URI normalizedTenantId : tenantIds) {
        TimestampedURIQueryResult taskIds = new TimestampedURIQueryResult();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getTimedTenantOrgTaskConstraint(normalizedTenantId, startWindowDate, endWindowDate), taskIds);
        Iterator<TimestampedURIQueryResult.TimestampedURI> it = taskIds.iterator();
        while (it.hasNext()) {
            TimestampedURIQueryResult.TimestampedURI timestampedURI = it.next();
            sortedIndexEntries.add(timestampedURI);
        }
    }
    if (maxCount == null || maxCount < 0) {
        maxCount = FETCH_ALL;
    } else {
        maxCount = Math.min(maxCount, sortedIndexEntries.size());
    }
    // Produce the requested number of results
    Iterator<TimestampedURIQueryResult.TimestampedURI> it = sortedIndexEntries.iterator();
    int pos = 0;
    while (it.hasNext() && (maxCount == FETCH_ALL || pos < maxCount)) {
        TimestampedURIQueryResult.TimestampedURI uri = it.next();
        RestLinkRep link = new RestLinkRep("self", RestLinkFactory.newLink(ResourceTypeEnum.TASK, uri.getUri()));
        resourceReps.add(new NamedRelatedResourceRep(uri.getUri(), link, uri.getName()));
        pos++;
    }
    return new TasksList(resourceReps);
}
Also used : RestLinkRep(com.emc.storageos.model.RestLinkRep) TimestampedURIQueryResult(com.emc.storageos.db.client.TimestampedURIQueryResult) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Date(java.util.Date) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) TasksList(com.emc.storageos.model.tasks.TasksList)

Example 88 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class OrdersApi method orders.

public static void orders() {
    ViPRCatalogClient2 catalog = getCatalogClient();
    List<Reference> orders = Lists.newArrayList();
    for (NamedRelatedResourceRep element : catalog.orders().listByUserTenant()) {
        orders.add(newOrderReference(element.getId().toString()));
    }
    renderApi(orders);
}
Also used : Reference(com.emc.vipr.model.catalog.Reference) ApiMapperUtils.newOrderReference(util.api.ApiMapperUtils.newOrderReference) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 89 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class FileProtectionPolicies method getAllVarrays.

private static List<StringOption> getAllVarrays() {
    List<StringOption> varrayList = Lists.newArrayList();
    List<NamedRelatedResourceRep> allVarrays = getViprClient().varrays().list();
    for (NamedRelatedResourceRep varray : allVarrays) {
        varrayList.add(new StringOption(varray.getId().toString(), varray.getName()));
    }
    return varrayList;
}
Also used : StringOption(util.StringOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 90 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class FileProtectionPolicies method getVpoolForProtectionPolicy.

/**
 * This call return the pool or pools which can be associated with policy.
 * Currently this does not check vpool is assigned to another policy.
 * As we do not have direct reference of policy in file vpool and looping all
 * policy and then its assigned resource to figure out it is assign or not
 * is causing slowness in GUI.Will address this in future release
 *
 * @param id
 */
public static void getVpoolForProtectionPolicy(String id) {
    Collection<FileVirtualPoolRestRep> vPools = Lists.newArrayList();
    FilePolicyRestRep policy = getViprClient().fileProtectionPolicies().get(uri(id));
    if (policy.getAssignedResources() != null && !policy.getAssignedResources().isEmpty()) {
        NamedRelatedResourceRep vpoolNameRes = null;
        // get the first vpool and return it.
        if (policy.getAppliedAt().equalsIgnoreCase(FilePolicyApplyLevel.vpool.name())) {
            vpoolNameRes = policy.getAssignedResources().get(0);
        } else if (policy.getAppliedAt().equalsIgnoreCase(FilePolicyApplyLevel.project.name())) {
            vpoolNameRes = policy.getVpool();
        }
        if (vpoolNameRes != null) {
            FileVirtualPoolRestRep vpolRestep = getViprClient().fileVpools().get(vpoolNameRes.getId());
            vPools.add(vpolRestep);
            renderJSON(vPools);
            return;
        }
    }
    List<FileVirtualPoolRestRep> virtualPools = getViprClient().fileVpools().getAll();
    for (FileVirtualPoolRestRep vpool : virtualPools) {
        // first level filter based on the protection is enabled or not
        FileVirtualPoolProtectionParam protectParam = vpool.getProtection();
        if (protectParam == null) {
            continue;
        }
        // 2nde level filter based on the applied level of policy and the pool
        if (FilePolicyApplyLevel.project.name().equalsIgnoreCase(policy.getAppliedAt()) && !protectParam.getAllowFilePolicyAtProjectLevel()) {
            continue;
        }
        if (FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(policy.getAppliedAt()) && !protectParam.getAllowFilePolicyAtFSLevel()) {
            continue;
        }
        // now add pool into list if matches protection type with policy
        if (FilePolicyType.file_snapshot.name().equalsIgnoreCase(policy.getType()) && protectParam.getScheduleSnapshots()) {
            vPools.add(vpool);
        } else if (FilePolicyType.file_replication.name().equalsIgnoreCase(policy.getType()) && protectParam.getReplicationSupported()) {
            vPools.add(vpool);
        }
    }
    renderJSON(vPools);
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) FileVirtualPoolProtectionParam(com.emc.storageos.model.vpool.FileVirtualPoolProtectionParam) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Aggregations

NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)111 URI (java.net.URI)47 ArrayList (java.util.ArrayList)28 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)22 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)18 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 AssetOption (com.emc.vipr.model.catalog.AssetOption)9 HashMap (java.util.HashMap)8 GET (javax.ws.rs.GET)8 Produces (javax.ws.rs.Produces)8 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)7 Path (javax.ws.rs.Path)7 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 SnapshotList (com.emc.storageos.model.SnapshotList)5 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)5 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)5 HashSet (java.util.HashSet)5 List (java.util.List)5