Search in sources :

Example 86 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class BlockProvider method getExportSnapshotForHostPortGroups.

@Asset("exportSnapshotForHostPortGroups")
@AssetDependencies({ "unassignedBlockSnapshot", "host", "project" })
public List<AssetOption> getExportSnapshotForHostPortGroups(AssetOptionsContext ctx, String selectedSnapshots, URI hostOrClusterId, URI projectId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        List<URI> snapshotIds = Lists.newArrayList();
        info("Snapshots selected by user: %s", selectedSnapshots);
        List<String> parsedSnapshotIds = TextUtils.parseCSV(selectedSnapshots);
        for (String id : parsedSnapshotIds) {
            snapshotIds.add(uri(id));
        }
        List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByIds(snapshotIds);
        Set<URI> virtualArrays = new HashSet<URI>();
        Set<URI> storageSystems = new HashSet<URI>();
        for (BlockSnapshotRestRep snapshot : snapshots) {
            virtualArrays.add(snapshot.getVirtualArray().getId());
            storageSystems.add(snapshot.getStorageController());
        }
        if (virtualArrays.size() == 1 && storageSystems.size() == 1) {
            Iterator<URI> it = virtualArrays.iterator();
            URI varrayId = it.next();
            ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
            Iterator<URI> ssIt = storageSystems.iterator();
            StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), null, null, true);
            return createPortGroupOptions(portGroups.getStoragePortGroups());
        }
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) URI(java.net.URI) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 87 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationSnapshotVirtualArrays.

@Asset("applicationSnapshotVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationSnapshotVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
    final ViPRCoreClient client = api(ctx);
    List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
    List<AssetOption> options = new ArrayList<AssetOption>();
    boolean isVplex = false;
    boolean isRP = false;
    URI sourceVarrayId = null;
    List<VolumeRestRep> allRPSourceVols = null;
    if (volList != null && !volList.isEmpty()) {
        VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
        StorageSystemRestRep sys = client.storageSystems().get(vol.getStorageController());
        if (sys.getSystemType().equals("vplex")) {
            isVplex = true;
            sourceVarrayId = vol.getVirtualArray().getId();
        }
        if (BlockProviderUtils.isVolumeRP(vol)) {
            isRP = true;
            allRPSourceVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.SOURCE);
            if (allRPSourceVols != null && !allRPSourceVols.isEmpty()) {
                VolumeRestRep rpvol = allRPSourceVols.get(0);
                sourceVarrayId = rpvol.getVirtualArray().getId();
            }
        }
    } else {
        return options;
    }
    // if it's neither RP nor vplex, it's just a simple block volume application; site is not needed
    if (!isVplex && !isRP) {
        options.add(newAssetOption(URI.create("none"), "None"));
    }
    // if the volumes are vplex or RP display source as an option
    if (isVplex || isRP) {
        options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
    }
    // if the volumes are RP (vplex or not) add the RP targets as options
    if (isRP) {
        Set<URI> targetVarrayIds = new HashSet<URI>();
        List<AssetOption> targetOptions = new ArrayList<AssetOption>();
        List<VolumeRestRep> allRPTargetVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.TARGET);
        for (VolumeRestRep targetVol : allRPTargetVols) {
            targetVarrayIds.add(targetVol.getVirtualArray().getId());
        }
        List<VirtualArrayRestRep> targetVarrays = client.varrays().getByIds(targetVarrayIds);
        for (VirtualArrayRestRep targetVarray : targetVarrays) {
            targetOptions.add(newAssetOption(String.format("tgt:%s", targetVarray.getId().toString()), "protection.site.type.target", targetVarray.getName()));
        }
        // sort the targets
        AssetOptionsUtils.sortOptionsByLabel(targetOptions);
        options.addAll(targetOptions);
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 88 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class ComputeImageProvider method getComputeImageOptions.

@Asset("computeImage")
public List<AssetOption> getComputeImageOptions(AssetOptionsContext ctx) {
    debug("getting compute images");
    List<ComputeImageRestRep> availCis = new ArrayList<ComputeImageRestRep>();
    for (ComputeImageRestRep ci : getComputeImages(ctx)) {
        if (ComputeImage.ComputeImageStatus.AVAILABLE.name().equals(ci.getComputeImageStatus())) {
            availCis.add(ci);
        }
    }
    return createBaseResourceOptions(availCis);
}
Also used : ComputeImageRestRep(com.emc.storageos.model.compute.ComputeImageRestRep) ArrayList(java.util.ArrayList) Asset(com.emc.sa.asset.annotation.Asset)

Example 89 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class ComputeProvider method getComputeVirtualPoolOptions.

@Asset("computeVirtualPool")
public List<AssetOption> getComputeVirtualPoolOptions(AssetOptionsContext ctx) {
    debug("getting compute virtual pools");
    Collection<ComputeVirtualPoolRestRep> computeVirtualPools = getComputeVirtualPools(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (ComputeVirtualPoolRestRep value : computeVirtualPools) {
        options.add(createComputeVirtualPoolOption(ctx, value));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) Asset(com.emc.sa.asset.annotation.Asset)

Example 90 with Asset

use of com.emc.sa.asset.annotation.Asset in project coprhd-controller by CoprHD.

the class ConsistencyGroupProvider method getAllConsistencyGroup.

@Asset("consistencyGroupAll")
public List<AssetOption> getAllConsistencyGroup(AssetOptionsContext ctx) {
    List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
    List<BlockConsistencyGroupRestRep> cgs = Lists.newArrayList();
    for (ProjectRestRep project : projects) {
        cgs.addAll(api(ctx).blockConsistencyGroups().findByProject(project));
    }
    List<AssetOption> options = createBaseResourceOptions(cgs);
    return options;
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

Asset (com.emc.sa.asset.annotation.Asset)119 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)102 AssetOption (com.emc.vipr.model.catalog.AssetOption)74 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)72 URI (java.net.URI)47 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)35 ArrayList (java.util.ArrayList)23 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)17 HashSet (java.util.HashSet)15 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)13 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)12 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)11 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)10 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)8 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)8 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)8 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6