Search in sources :

Example 11 with ViPRHttpException

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

the class ObjectBuckets method bucket.

public static void bucket(String bucketId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    BucketRestRep bucket = null;
    if (isBucketId(bucketId)) {
        try {
            bucket = client.objectBuckets().get(uri(bucketId));
        } catch (ViPRHttpException e) {
            if (e.getHttpCode() == 404) {
                flash.error(MessagesUtils.get(UNKNOWN, bucketId));
                buckets(null);
            }
            throw e;
        }
    }
    if (bucket == null) {
        notFound(Messages.get("resources.bucket.notfound"));
    }
    if (bucket.getVirtualArray() != null) {
        // NOSONAR
        // ("Suppressing Sonar violation of Possible null pointer dereference of volume. When volume is null, the previous if condition handles with throw")
        renderArgs.put("virtualArray", VirtualArrayUtils.getVirtualArrayRef(bucket.getVirtualArray()));
    }
    if (bucket.getVirtualPool() != null) {
        renderArgs.put("virtualPool", VirtualPoolUtils.getObjectVirtualPoolRef(bucket.getVirtualPool()));
    }
    Tasks<BucketRestRep> tasksResponse = client.objectBuckets().getTasks(bucket.getId());
    List<Task<BucketRestRep>> tasks = tasksResponse.getTasks();
    renderArgs.put("tasks", tasks);
    render(bucket);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BucketRestRep(com.emc.storageos.model.object.BucketRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 12 with ViPRHttpException

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

the class FileSnapshots method snapshot.

public static void snapshot(String snapshotId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    FileSnapshotRestRep snapshot = null;
    try {
        snapshot = client.fileSnapshots().get(uri(snapshotId));
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404 || e.getHttpCode() == 400) {
            flash.error(MessagesUtils.get(UNKNOWN, snapshotId));
            snapshots(null);
        }
        throw e;
    }
    if (snapshot != null) {
        if (snapshot.getParent() != null) {
            FileShareRestRep fileSystem = client.fileSystems().get(snapshot.getParent());
            renderArgs.put("fileSystem", fileSystem);
        }
        Tasks<FileSnapshotRestRep> tasksResponse = client.fileSnapshots().getTasks(snapshot.getId());
        List<Task<FileSnapshotRestRep>> tasks = tasksResponse.getTasks();
        renderArgs.put("tasks", tasks);
    } else {
        flash.error(MessagesUtils.get(UNKNOWN, snapshotId));
        snapshots(null);
    }
    render(snapshot);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FileSnapshotRestRep(com.emc.storageos.model.file.FileSnapshotRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 13 with ViPRHttpException

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

the class BlockVolumes method volume.

public static void volume(String volumeId, String continuousCopyId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    VolumeRestRep volume = null;
    if (isVolumeId(volumeId)) {
        if (isContinuousCopyId(continuousCopyId)) {
            volume = client.blockVolumes().getContinuousCopy(uri(volumeId), uri(continuousCopyId));
            renderArgs.put("isContinuousCopy", Boolean.TRUE);
            renderArgs.put("isBlockContinuousCopy", isBlockContinuousCopyId(continuousCopyId));
            renderArgs.put("isVplexContinuousCopy", isVplexContinuousCopyId(continuousCopyId));
        } else {
            try {
                volume = client.blockVolumes().get(uri(volumeId));
            } catch (ViPRHttpException e) {
                if (e.getHttpCode() == 404) {
                    flash.error(MessagesUtils.get(UNKNOWN, volumeId));
                    volumes(null);
                }
                throw e;
            }
        }
    }
    if (volume == null) {
        notFound(Messages.get("resources.volume.notfound"));
    }
    if (volume.getVirtualArray() != null) {
        // NOSONAR
        // ("Suppressing Sonar violation of Possible null pointer dereference of volume. When volume is null, the previous if condition handles with throw")
        renderArgs.put("virtualArray", VirtualArrayUtils.getVirtualArrayRef(volume.getVirtualArray()));
    }
    if (volume.getVirtualPool() != null) {
        renderArgs.put("virtualPool", VirtualPoolUtils.getBlockVirtualPoolRef(volume.getVirtualPool()));
    }
    if (volume.getConsistencyGroup() != null) {
        renderArgs.put("consistencyGroup", BlockConsistencyGroupUtils.getBlockConsistencyGroupRef(volume.getConsistencyGroup()));
    }
    if (volume.getStorageController() != null) {
        renderArgs.put("storageSystem", StorageSystemUtils.getStorageSystemRef(volume.getStorageController()));
    }
    if (volume.getCompressionRatio() != null) {
        renderArgs.put("compressionRatio", volume.getCompressionRatio());
    }
    if (volume.getAccessState() == null || volume.getAccessState().isEmpty()) {
        renderArgs.put("isAccessStateEmpty", "true");
    }
    Tasks<VolumeRestRep> tasksResponse = client.blockVolumes().getTasks(volume.getId());
    List<Task<VolumeRestRep>> tasks = tasksResponse.getTasks();
    renderArgs.put("tasks", tasks);
    render(volume);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) 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