Search in sources :

Example 66 with ViPRCoreClient

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

the class VdcApiProxyUserTest method setupProxyuser.

@BeforeClass
public static synchronized void setupProxyuser() throws Exception {
    logger.info("Setup for VdcApiProxyUserTest");
    String user = getUserByRole(null, RoleOrAcl.SecurityAdmin);
    ViPRCoreClient client = new ViPRCoreClient(controllerNodeEndpoint, true).withLogin(user, PASSWORD);
    String rootProxyToken = client.auth().proxyToken();
    client.auth().logout();
    proxyClient = new ViPRCoreClient(controllerNodeEndpoint, true).withLogin("proxyuser", "ChangeMe");
    proxyClient.setProxyToken(rootProxyToken);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BeforeClass(org.junit.BeforeClass)

Example 67 with ViPRCoreClient

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

the class BlockProvider method getRemoveMobilityGroupResources.

@Asset("removeMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getRemoveMobilityGroupResources(AssetOptionsContext ctx, URI mobilityGroupId) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
    if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
        return createNamedResourceOptions(client.application().listVolumes(mobilityGroupId));
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
        return createNamedResourceOptions(client.application().getHosts(mobilityGroupId));
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
        return createNamedResourceOptions(client.application().getClusters(mobilityGroupId));
    } else {
        return Lists.newArrayList();
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 68 with ViPRCoreClient

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

the class BlockProvider method getVolumesWithFullCopies.

@Asset("volumeWithFullCopies")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getVolumesWithFullCopies(AssetOptionsContext ctx, URI project, String volumeOrConsistencyType) {
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        List<VolumeRestRep> volumes = findVolumesByProject(client, project);
        List<VolumeRestRep> filteredVols = new ArrayList<>();
        for (VolumeRestRep vol : volumes) {
            if (vol.getProtection() == null || vol.getProtection().getFullCopyRep() == null || vol.getProtection().getFullCopyRep().getFullCopyVolumes() == null || vol.getProtection().getFullCopyRep().getFullCopyVolumes().isEmpty() || !StringUtils.isEmpty(vol.getReplicationGroupInstance())) {
                continue;
            }
            filteredVols.add(vol);
        }
        log.info("Got volumes with full copies: [{}]", filteredVols.size());
        return createVolumeOptions(client, filteredVols);
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = api(ctx).blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 69 with ViPRCoreClient

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

the class BlockProvider method getFullCopiesForApplication.

private List<VolumeRestRep> getFullCopiesForApplication(AssetOptionsContext ctx, URI applicationId) {
    List<VolumeRestRep> fullCopies = new ArrayList<VolumeRestRep>();
    final ViPRCoreClient client = api(ctx);
    NamedVolumesList volList = client.application().getFullCopiesByApplication(applicationId);
    if (volList != null && volList.getVolumes() != null && !volList.getVolumes().isEmpty()) {
        List<URI> ids = new ArrayList<URI>();
        for (NamedRelatedResourceRep volId : volList.getVolumes()) {
            ids.add(volId.getId());
        }
        fullCopies.addAll(client.blockVolumes().getByIds(ids));
    }
    return fullCopies;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ArrayList(java.util.ArrayList) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 70 with ViPRCoreClient

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

the class BlockProvider method getBlockVolumesWithSnapshot.

@Asset("blockVolumeWithSnapshot")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getBlockVolumesWithSnapshot(AssetOptionsContext context, URI project, String volumeOrConsistencyType) {
    final ViPRCoreClient client = api(context);
    if (isVolumeType(volumeOrConsistencyType)) {
        Set<URI> volIdSet = new HashSet<>();
        List<BlockSnapshotRestRep> snapshots = findSnapshotsByProject(client, project);
        for (BlockSnapshotRestRep snapshot : snapshots) {
            volIdSet.add(snapshot.getParent().getId());
        }
        // Have to get volumes just as it needs vol's mount point which snapshot doesn't have.
        List<VolumeRestRep> volumes = getVolumesByIds(client, volIdSet);
        List<VolumeRestRep> filteredVols = new ArrayList<>();
        for (VolumeRestRep vol : volumes) {
            if (StringUtils.isEmpty(vol.getReplicationGroupInstance())) {
                filteredVols.add(vol);
            }
        }
        return createVolumeOptions(client, filteredVols);
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)225 Asset (com.emc.sa.asset.annotation.Asset)72 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)66 URI (java.net.URI)66 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)49 FlashException (controllers.util.FlashException)48 AssetOption (com.emc.vipr.model.catalog.AssetOption)41 ArrayList (java.util.ArrayList)34 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)29 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)27 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)24 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)20 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)15 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)15 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)13 HashSet (java.util.HashSet)13 Task (com.emc.vipr.client.Task)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)10 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)8