Search in sources :

Example 1 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class AssetOptionService method getAssetOptions.

@POST
@Path("/{assetType}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public AssetOptionsResponse getAssetOptions(@PathParam("assetType") String assetType, AssetOptionsRequest request) {
    final Map<String, String> availableAssets = request.getAvailableAssets();
    final AssetOptionsContext context = createAssetOptionsContext(request);
    final Map<String, String> sanitizedAvailableAssets = SecurityUtils.stripMapXSS(availableAssets);
    final String sanitizedAssetType = SecurityUtils.stripXSS(assetType);
    log.info("Retrieving asset options for " + sanitizedAssetType + " with available assets : " + StringUtils.join(sanitizedAvailableAssets.keySet(), ", "));
    try {
        List<AssetOption> options = assetOptionsManager.getOptions(context, sanitizedAssetType, sanitizedAvailableAssets);
        AssetOptionsResponse response = new AssetOptionsResponse();
        response.setAssetType(sanitizedAssetType);
        response.setAvailableAssets(sanitizedAvailableAssets);
        response.setOptions(options);
        return response;
    } catch (IllegalStateException e) {
        Response response = Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
        throw new WebApplicationException(response);
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            Response response = Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build();
            throw new WebApplicationException(response);
        }
        throw new WebApplicationException(e);
    }
}
Also used : AssetDependencyResponse(com.emc.vipr.model.catalog.AssetDependencyResponse) Response(javax.ws.rs.core.Response) AssetOptionsResponse(com.emc.vipr.model.catalog.AssetOptionsResponse) AssetOption(com.emc.vipr.model.catalog.AssetOption) WebApplicationException(javax.ws.rs.WebApplicationException) AssetOptionsResponse(com.emc.vipr.model.catalog.AssetOptionsResponse) AssetOptionsContext(com.emc.sa.asset.AssetOptionsContext) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 2 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class VcenterClusterProvider method getNewClusterOptions.

@Asset("newVcenterCluster")
public List<AssetOption> getNewClusterOptions(AssetOptionsContext ctx) {
    debug("getting clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (ClusterRestRep value : clusters) {
        if (value.getVcenterDataCenter() == null) {
            options.add(createClusterOption(ctx, value, false, "", ""));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class VcenterClusterProvider method getClusterOptions.

@Asset("vcenterCluster")
public List<AssetOption> getClusterOptions(AssetOptionsContext ctx) {
    debug("getting clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    Map<URI, String> vcenterMap = getVcenters(ctx);
    Map<URI, String> dataCenterNameMap = new HashMap<URI, String>();
    Map<URI, String> dataCenterVcenterMap = new HashMap<URI, String>();
    String vcenterName;
    String datacenterName;
    for (ClusterRestRep value : clusters) {
        if (value.getVcenterDataCenter() != null) {
            RelatedResourceRep datacenterVal = value.getVcenterDataCenter();
            if (datacenterVal != null) {
                if (dataCenterVcenterMap.get(datacenterVal.getId()) == null) {
                    VcenterDataCenterRestRep restResponse = api(ctx).vcenterDataCenters().get(datacenterVal.getId());
                    datacenterName = restResponse.getName();
                    dataCenterNameMap.put(datacenterVal.getId(), datacenterName);
                    RelatedResourceRep vcenterResp = restResponse.getVcenter();
                    if (vcenterMap.get(vcenterResp.getId()) == null) {
                        VcenterRestRep vcenterRep = api(ctx).vcenters().get(vcenterResp);
                        vcenterMap.put(vcenterResp.getId(), vcenterRep.getName());
                        vcenterName = vcenterRep.getName();
                        dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
                    } else {
                        vcenterName = vcenterMap.get(vcenterResp.getId());
                        dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
                    }
                } else {
                    datacenterName = dataCenterNameMap.get(datacenterVal.getId());
                    vcenterName = dataCenterVcenterMap.get(datacenterVal.getId());
                }
                options.add(createClusterOption(ctx, value, true, vcenterName, datacenterName));
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) HashMap(java.util.HashMap) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep) URI(java.net.URI) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class VirtualDataCenterProvider method getUnmanagedVolumeByStorageSystem.

@Asset("unmanagedVolumeByStorageSystem")
@AssetDependencies({ "unmanagedBlockStorageSystem", "unmanagedBlockVirtualPool" })
public List<AssetOption> getUnmanagedVolumeByStorageSystem(AssetOptionsContext ctx, URI storageSystemId, URI vpool) {
    List<AssetOption> options = Lists.newArrayList();
    for (UnManagedVolumeRestRep volume : listUnmanagedVolumes(ctx, storageSystemId)) {
        if (matchesVpool(volume, vpool) && !isNonRPExported(volume.getVolumeCharacteristics())) {
            options.add(toAssetOption(volume));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) UnManagedVolumeRestRep(com.emc.storageos.model.block.UnManagedVolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class VirtualDataCenterProvider method getUnmanagedVolumeVirtualPoolsForHost.

@Asset("unmanagedBlockVirtualPool")
@AssetDependencies({ "host", "virtualArray" })
public List<AssetOption> getUnmanagedVolumeVirtualPoolsForHost(AssetOptionsContext ctx, URI host, URI virtualArray) {
    Map<URI, Integer> vpools = getBlockVirtualPools(listUnmanagedVolumesByHost(ctx, host));
    Map<URI, BlockVirtualPoolRestRep> virtualPoolMap = BlockProvider.getBlockVirtualPools(api(ctx), vpools.keySet());
    List<AssetOption> options = Lists.newArrayList();
    for (Map.Entry<URI, Integer> entry : vpools.entrySet()) {
        BlockVirtualPoolRestRep vpool = virtualPoolMap.get(entry.getKey());
        if (isVirtualPoolInVirtualArray(vpool, virtualArray)) {
            options.add(newAssetOption(vpool.getId().toString(), "block.virtualPool.unmanaged", vpool.getName(), entry.getValue()));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) URI(java.net.URI) Map(java.util.Map) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

AssetOption (com.emc.vipr.model.catalog.AssetOption)107 Asset (com.emc.sa.asset.annotation.Asset)73 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)62 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)40 URI (java.net.URI)37 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)21 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)14 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)14 ArrayList (java.util.ArrayList)13 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)10 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)10 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)9 Map (java.util.Map)9 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)8 HashMap (java.util.HashMap)8 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)6 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)6 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)6 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)6