use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class DisasterRecoveryServiceTest method mockViPRCoreClient.
protected ViPRCoreClient mockViPRCoreClient(final String uuid) {
class MockViPRCoreClient extends ViPRCoreClient {
@Override
public com.emc.vipr.client.core.Site site() {
com.emc.vipr.client.core.Site site = mock(com.emc.vipr.client.core.Site.class);
SiteConfigRestRep config = new SiteConfigRestRep();
config.setUuid(uuid);
config.setHostIPv4AddressMap(new HashMap<String, String>());
config.setHostIPv6AddressMap(new HashMap<String, String>());
doReturn(config).when(site).getStandbyConfig();
doReturn(null).when(site).syncSite(anyString(), any(SiteConfigParam.class));
doReturn(new DRNatCheckResponse()).when(site).checkIfBehindNat(any(DRNatCheckParam.class));
return site;
}
}
return new MockViPRCoreClient();
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class ApisvcTestBase method getViprClient.
/**
* Get a logged in ViPR client instance.
* @param viprIP -- IP address (or FQDN) of Vipr server or devkit.
* @param userName -- String user name.
* @param password -- String password (unobfuscated).
* @return ViPRCoreClient that has been authenticated
*/
public ViPRCoreClient getViprClient(String viprIP, String userName, String password) {
ClientConfig clientConfig = new ClientConfig().withHost(viprIP).withRequestLoggingDisabled().withMaxRetries(10).withMediaType("application/json").withIgnoringCertificates(true);
viprCoreClient = new ViPRCoreClient(clientConfig);
AuthClient auth = viprCoreClient.auth();
String token = auth.login(userName, password);
viprCoreClient.setAuthToken(token);
log.info("Auth token is: " + token);
return 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);
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class VirtualDataCenterProvider method getUnexportedIngestionMethod.
@Asset("unexportedIngestionMethod")
@AssetDependencies({ "unmanagedBlockStorageSystem" })
public List<AssetOption> getUnexportedIngestionMethod(AssetOptionsContext ctx, URI storageSystemId) {
ViPRCoreClient client = api(ctx);
StorageSystemRestRep storageSystemRestRep = client.storageSystems().get(storageSystemId);
List<AssetOption> options = Lists.newArrayList();
options.add(newAssetOption(IngestionMethodEnum.FULL.toString(), "unmanagedVolume.ingestMethod.full"));
if (BlockProviderUtils.isVplex(storageSystemRestRep)) {
options.add(newAssetOption(IngestionMethodEnum.VIRTUAL_VOLUMES_ONLY.toString(), "unmanagedVolume.ingestMethod.virtualVolumesOnly"));
}
return options;
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockVolumes.
@Asset("unassignedVplexBlockVolume")
@AssetDependencies({ "project", "host", "virtualArray" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, final URI projectId, URI hostOrClusterId, URI virtualArrayId) {
// get a list of all 'source' volumes that :
// - are in this project and not exported to the given host/cluster
// - are a 'source' volume
// - are vplex volumes
ViPRCoreClient client = api(ctx);
Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, virtualArrayId);
UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
VplexVolumeFilter vplexVolumeFilter = new VplexVolumeFilter();
CachedResources<BlockVirtualPoolRestRep> blockVpools = new CachedResources<>(client.blockVpools());
VplexVolumeVirtualPoolFilter virtualPoolFilter = new VplexVolumeVirtualPoolFilter(blockVpools);
BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
FilterChain<VolumeRestRep> filter = sourceTargetVolumesFilter.and(unexportedFilter).and(bootVolumeFilter.not()).and(vplexVolumeFilter.or(virtualPoolFilter));
// perform the query and apply the filter
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, filter);
// get a list of all volumes from our list that are in the target VArray, or use the target VArray for protection
List<BlockObjectRestRep> acceptedVolumes = getVPlexVolumesInTargetVArray(client, virtualArrayId, volumes);
return createVolumeOptions(client, acceptedVolumes);
}
Aggregations