Search in sources :

Example 1 with ViPRCoreClient

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();
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) DRNatCheckResponse(com.emc.storageos.model.dr.DRNatCheckResponse) DRNatCheckParam(com.emc.storageos.model.dr.DRNatCheckParam) SiteConfigRestRep(com.emc.storageos.model.dr.SiteConfigRestRep) Matchers.anyString(org.mockito.Matchers.anyString) SiteConfigParam(com.emc.storageos.model.dr.SiteConfigParam)

Example 2 with ViPRCoreClient

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;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AuthClient(com.emc.vipr.client.AuthClient) ClientConfig(com.emc.vipr.client.ClientConfig)

Example 3 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 4 with ViPRCoreClient

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;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with ViPRCoreClient

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);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) URI(java.net.URI) VplexVolumeFilter(com.emc.vipr.client.core.filters.VplexVolumeFilter) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) CachedResources(com.emc.vipr.client.core.util.CachedResources) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) VplexVolumeVirtualPoolFilter(com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)226 Asset (com.emc.sa.asset.annotation.Asset)72 URI (java.net.URI)68 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)66 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)50 FlashException (controllers.util.FlashException)48 AssetOption (com.emc.vipr.model.catalog.AssetOption)40 ArrayList (java.util.ArrayList)35 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)29 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)27 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)25 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)21 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)15 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)15 HashSet (java.util.HashSet)14 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)12 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