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);
}
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();
}
}
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);
}
}
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;
}
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);
}
}
Aggregations