Search in sources :

Example 1 with ViPRHttpException

use of com.emc.vipr.client.exceptions.ViPRHttpException 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 ViPRHttpException

use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.

the class BlockExportGroups method exportGroup.

public static void exportGroup(String exportGroupId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    ExportGroupRestRep exportGroup = null;
    try {
        exportGroup = client.blockExports().get(uri(exportGroupId));
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            flash.error(MessagesUtils.get(UNKNOWN, exportGroupId));
            exportGroups(null);
        }
        throw e;
    }
    VirtualArrayRestRep virtualArray = null;
    if (exportGroup != null) {
        virtualArray = client.varrays().get(exportGroup.getVirtualArray());
    } else {
        notFound("Export Group " + exportGroupId);
    }
    renderArgs.put("volumeDataTable", new BlockExportGroupVolumesDataTable());
    renderArgs.put("snapshotDataTable", new BlockExportGroupSnapshotsDataTable());
    SimpleHostDataTable hostsDataTable = new SimpleHostDataTable();
    NetworkEndpointDataTable initiatorsDataTable = NetworkEndpointDataTable.createDataTable("FC");
    initiatorsDataTable.alterColumn("portGroup").hidden().setSearchable(false);
    initiatorsDataTable.alterColumn("storageSystem").hidden().setSearchable(false);
    initiatorsDataTable.alterColumn("discovered").hidden().setSearchable(false);
    HostClusterDataTable clustersDataTable = new HostClusterDataTable();
    render(hostsDataTable, initiatorsDataTable, clustersDataTable, exportGroup, virtualArray);
}
Also used : HostClusterDataTable(models.datatable.HostClusterDataTable) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) NetworkEndpointDataTable(models.datatable.NetworkEndpointDataTable) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) BlockExportGroupSnapshotsDataTable(models.datatable.BlockExportGroupSnapshotsDataTable) BlockExportGroupVolumesDataTable(models.datatable.BlockExportGroupVolumesDataTable) SimpleHostDataTable(models.datatable.SimpleHostDataTable) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 3 with ViPRHttpException

use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.

the class ComputeImageServerUtils method getComputeImageServerByName.

public static ComputeImageServerRestRep getComputeImageServerByName(String name) {
    try {
        ComputeImageServerRestRep computeImageServer = null;
        List<ComputeImageServerRestRep> computeImageServersList = getComputeImageServers();
        for (ComputeImageServerRestRep cisrr : computeImageServersList) {
            if (cisrr.getName().equalsIgnoreCase(name)) {
                computeImageServer = cisrr;
            }
        }
        return computeImageServer;
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            return null;
        }
        throw e;
    }
}
Also used : ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 4 with ViPRHttpException

use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.

the class CatalogServiceUtils method getCatalogService.

public static CatalogServiceRestRep getCatalogService(URI id) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    CatalogServiceRestRep service = null;
    try {
        service = catalog.services().get(id);
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            service = null;
        } else {
            throw e;
        }
    }
    return service;
}
Also used : ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 5 with ViPRHttpException

use of com.emc.vipr.client.exceptions.ViPRHttpException in project coprhd-controller by CoprHD.

the class Maintenance method clusterState.

public static void clusterState() {
    request.format = "json";
    ClusterInfo clusterInfo = null;
    try {
        clusterInfo = getClusterState();
        Logger.info("cluster status %s", clusterInfo.getCurrentState());
    } catch (ViPRHttpException e) {
        Common.handleExpiredToken(e);
        Logger.error(e, "Failed to get cluster state");
        error(e.getHttpCode(), e.getMessage());
    } catch (Exception e) {
        Logger.error(e, "Failed to get cluster state");
        error(e.getMessage());
    }
    renderJSON(clusterInfo);
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Aggregations

ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)13 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 Task (com.emc.vipr.client.Task)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)2 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)2 AssetOptionsContext (com.emc.sa.asset.AssetOptionsContext)1 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)1 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)1 ComputeImageServerRestRep (com.emc.storageos.model.compute.ComputeImageServerRestRep)1 ServiceErrorRestRep (com.emc.storageos.model.errorhandling.ServiceErrorRestRep)1 FileSnapshotRestRep (com.emc.storageos.model.file.FileSnapshotRestRep)1 BucketRestRep (com.emc.storageos.model.object.BucketRestRep)1 StoragePoolRestRep (com.emc.storageos.model.pools.StoragePoolRestRep)1 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)1 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)1 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1 AssetDependencyResponse (com.emc.vipr.model.catalog.AssetDependencyResponse)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1