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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations