Search in sources :

Example 31 with RelatedResourceRep

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

the class BlockProvider method getCopyNameByConsistencyGroup.

@Asset("journalCopyName")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getCopyNameByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
    ViPRCoreClient client = api(ctx);
    List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
    Set<String> copyNames = Sets.newHashSet();
    if (volumes != null && !volumes.isEmpty()) {
        RelatedResourceRep volume = volumes.get(0);
        VolumeRestRep volumeRep = client.blockVolumes().get(volume);
        if (volumeRep.getProtection() != null && volumeRep.getProtection().getRpRep() != null) {
            if (volumeRep.getProtection().getRpRep().getCopyName() != null) {
                String copyName = volumeRep.getProtection().getRpRep().getCopyName();
                copyNames.add(copyName);
            }
            /* getByIds(haVolumeIds, null) is returning a empty list which was the cause of COP-36489.
                Details: 
                getByIds() will eventually call AbstractResources.accept() method. This method has a condition to 
                remove items (HaVolumes) which have their internal flag set to True. HA Volumes have this flag set.
                Hence we can't use getByIds(...) with filter or without it to get HA Volume list. 
                Hence implementing the below code which resolves COP-36489.
                */
            if (volumeRep.getHaVolumes() != null) {
                List<RelatedResourceRep> haVolumes = volumeRep.getHaVolumes();
                for (RelatedResourceRep haVolume : haVolumes) {
                    VolumeRestRep haVolumeRep = client.blockVolumes().get(haVolume);
                    if (haVolumeRep.getProtection() != null && haVolumeRep.getProtection().getRpRep() != null && haVolumeRep.getProtection().getRpRep().getCopyName() != null) {
                        String copyName = haVolumeRep.getProtection().getRpRep().getCopyName();
                        copyNames.add(copyName);
                    }
                }
            }
            if (volumeRep.getProtection().getRpRep().getRpTargets() != null) {
                List<VirtualArrayRelatedResourceRep> targetVolumes = volumeRep.getProtection().getRpRep().getRpTargets();
                List<URI> targetVolumeIds = new ArrayList<URI>();
                for (VirtualArrayRelatedResourceRep targetVolume : targetVolumes) {
                    targetVolumeIds.add(targetVolume.getId());
                }
                List<VolumeRestRep> targetVolumeReps = client.blockVolumes().getByIds(targetVolumeIds, null);
                for (VolumeRestRep targetVolumeRep : targetVolumeReps) {
                    String copyName = targetVolumeRep.getProtection().getRpRep().getCopyName();
                    copyNames.add(copyName);
                }
            }
        }
    }
    List<AssetOption> copyNameAssets = Lists.newArrayList();
    for (String copyName : copyNames) {
        copyNameAssets.add(newAssetOption(copyName, copyName));
    }
    AssetOptionsUtils.sortOptionsByLabel(copyNameAssets);
    return copyNameAssets;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) URI(java.net.URI) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 32 with RelatedResourceRep

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

the class OrdersApi method bulkGetOrders.

public static void bulkGetOrders(String startTime, String endTime) {
    List<? extends RelatedResourceRep> elements = queryOrders(startTime, endTime);
    List<URI> orders = Lists.newArrayList();
    for (RelatedResourceRep element : elements) {
        orders.add(element.getId());
    }
    renderApi(new BulkIdParam(orders));
}
Also used : NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) BulkIdParam(com.emc.storageos.model.BulkIdParam) URI(java.net.URI)

Example 33 with RelatedResourceRep

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

the class OrdersApi method allOrders.

@Restrict("TENANT_ADMIN")
public static void allOrders(String startTime, String endTime) {
    List<? extends RelatedResourceRep> elements = queryOrders(startTime, endTime);
    List<Reference> orders = Lists.newArrayList();
    for (RelatedResourceRep element : elements) {
        orders.add(newOrderReference(element.getId().toString()));
    }
    renderApi(orders);
}
Also used : NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) Reference(com.emc.vipr.model.catalog.Reference) ApiMapperUtils.newOrderReference(util.api.ApiMapperUtils.newOrderReference) Restrict(controllers.deadbolt.Restrict)

Example 34 with RelatedResourceRep

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

the class BlockSnapshotSessions method snapshotSessionLinkTarget.

public static void snapshotSessionLinkTarget(String snapshotSessionId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<RelatedResourceRep> targets = client.blockSnapshotSessions().get(uri(snapshotSessionId)).getLinkedTarget();
    List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByRefs(targets);
    render(snapshots, snapshotSessionId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep)

Example 35 with RelatedResourceRep

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

the class ServiceCatalog method createBreadCrumbs.

/**
 * Creates the breadcrumbs for the catalog service.
 *
 * @param service
 *            the catalog service.
 * @return the breadcrumb list.
 */
@Util
public static List<BreadCrumb> createBreadCrumbs(String tenantId, CatalogServiceRestRep service) {
    RelatedResourceRep categoryId = service.getCatalogCategory();
    String parentId = getParentId(categoryId);
    List<BreadCrumb> breadcrumbs = createBreadCrumbs(parentId, getCatalog(tenantId));
    String id = service.getId() != null ? service.getId().toString() : "";
    addBreadCrumb(breadcrumbs, id, service.getName(), service.getTitle());
    return breadcrumbs;
}
Also used : RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) BreadCrumb(models.BreadCrumb) Util(play.mvc.Util)

Aggregations

RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)41 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)25 ArrayList (java.util.ArrayList)19 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)14 URI (java.net.URI)12 Asset (com.emc.sa.asset.annotation.Asset)8 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)5 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)5 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 StoragePortList (com.emc.storageos.model.ports.StoragePortList)4 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)3