本文整理汇总了Java中org.jclouds.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.jclouds包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DimensionDataCloudControllerComputeService
import org.jclouds.Constants; //导入依赖的package包/类
@Inject
protected DimensionDataCloudControllerComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
@Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
@Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
@Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
CleanupServer cleanupServer,
Optional<ImageExtension> imageExtension,
Optional<SecurityGroupExtension> securityGroupExtension) {
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
this.cleanupServer = checkNotNull(cleanupServer, "cleanupServer");
}
示例2: setupProperties
import org.jclouds.Constants; //导入依赖的package包/类
@Override
protected Properties setupProperties() {
try {
proxy = TestUtils.setupAndStartProxy();
} catch (Exception e) {
throw propagate(e);
}
Properties props = super.setupProperties();
identity = "test:tester";
credential = "testing";
endpoint = proxy.getEndpoint().toString() + "/auth/v1.0";
props.setProperty(KeystoneProperties.CREDENTIAL_TYPE, "tempAuthCredentials");
props.setProperty(Constants.PROPERTY_IDENTITY, identity);
props.setProperty(Constants.PROPERTY_CREDENTIAL, credential);
props.setProperty(Constants.PROPERTY_ENDPOINT, endpoint);
return props;
}
示例3: setupAndStartProxy
import org.jclouds.Constants; //导入依赖的package包/类
public static SwiftProxy setupAndStartProxy() throws Exception {
Properties properties = new Properties();
try (InputStream is = Resources.asByteSource(Resources.getResource(
"swiftproxy.conf")).openStream()) {
properties.load(is);
}
String provider = properties.getProperty(Constants.PROPERTY_PROVIDER);
String credential = properties.getProperty(Constants.PROPERTY_CREDENTIAL);
if (provider != null && credential != null && provider.equals("google-cloud-storage")) {
File credentialFile = new File(credential);
if (credentialFile.exists()) {
credential = Files.toString(credentialFile,
StandardCharsets.UTF_8);
}
properties.put(Constants.PROPERTY_CREDENTIAL, credential);
}
SwiftProxy proxy = SwiftProxy.Builder.builder()
.overrides(properties)
.build();
proxy.start();
return proxy;
}
示例4: setupProperties
import org.jclouds.Constants; //导入依赖的package包/类
@Override
protected Properties setupProperties() {
TestUtils.S3ProxyLaunchInfo info;
try {
info = TestUtils.startS3Proxy("s3proxy.conf");
s3Proxy = info.getS3Proxy();
context = info.getBlobStore().getContext();
blobStoreType = context.unwrap().getProviderMetadata().getId();
} catch (Exception e) {
throw new RuntimeException(e);
}
Properties props = super.setupProperties();
props.setProperty(Constants.PROPERTY_IDENTITY, info.getS3Identity());
props.setProperty(Constants.PROPERTY_CREDENTIAL,
info.getS3Credential());
props.setProperty(Constants.PROPERTY_ENDPOINT,
info.getEndpoint().toString() + info.getServicePath());
props.setProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER, "true");
props.setProperty(S3Constants.PROPERTY_S3_SERVICE_PATH,
info.getServicePath());
endpoint = info.getEndpoint().toString() + info.getServicePath();
return props;
}
示例5: setupProperties
import org.jclouds.Constants; //导入依赖的package包/类
@Override
protected Properties setupProperties() {
TestUtils.S3ProxyLaunchInfo info;
try {
info = TestUtils.startS3Proxy("s3proxy.conf");
s3Proxy = info.getS3Proxy();
context = info.getBlobStore().getContext();
blobStoreType = context.unwrap().getProviderMetadata().getId();
} catch (Exception e) {
throw new RuntimeException(e);
}
Properties props = super.setupProperties();
props.setProperty(Constants.PROPERTY_IDENTITY, info.getS3Identity());
props.setProperty(Constants.PROPERTY_CREDENTIAL,
info.getS3Credential());
props.setProperty(Constants.PROPERTY_ENDPOINT,
info.getEndpoint().toString() + info.getServicePath());
props.setProperty(S3Constants.PROPERTY_S3_SERVICE_PATH,
info.getServicePath());
props.setProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER, "true");
return props;
}
示例6: setupProperties
import org.jclouds.Constants; //导入依赖的package包/类
@Override
protected Properties setupProperties() {
TestUtils.S3ProxyLaunchInfo info;
try {
info = TestUtils.startS3Proxy("s3proxy.conf");
s3Proxy = info.getS3Proxy();
context = info.getBlobStore().getContext();
} catch (Exception e) {
throw new RuntimeException(e);
}
Properties props = super.setupProperties();
props.setProperty(Constants.PROPERTY_IDENTITY, info.getS3Identity());
props.setProperty(Constants.PROPERTY_CREDENTIAL,
info.getS3Credential());
props.setProperty(Constants.PROPERTY_ENDPOINT,
info.getEndpoint().toString() + info.getServicePath());
props.setProperty(S3Constants.PROPERTY_S3_SERVICE_PATH,
info.getServicePath());
props.setProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER, "true");
endpoint = info.getEndpoint().toString();
return props;
}
示例7: novaApi
import org.jclouds.Constants; //导入依赖的package包/类
@Bean
@ConditionalOnProperty("openstack.endpoint")
NovaApi novaApi(@Value("${openstack.endpoint}") String endpoint,
@Value("${openstack.tenant}") String tenant,
@Value("${openstack.username}") String username,
@Value("${openstack.password}") String password) {
String identity = String.format("%s:%s", tenant, username);
// see https://issues.apache.org/jira/browse/JCLOUDS-816
Properties overrides = new Properties();
overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true");
return ContextBuilder.newBuilder("openstack-nova")
.endpoint(endpoint)
.credentials(identity, password)
.modules(Collections.singleton(new SLF4JLoggingModule()))
.overrides(overrides)
.buildApi(NovaApi.class);
}
示例8: addProviderFromConfig
import org.jclouds.Constants; //导入依赖的package包/类
private void addProviderFromConfig(String prefix, String provider) {
String id = prefix.substring(prefix.lastIndexOf('.')).substring(1);
logger.info("adding provider from {} id: {}", prefix, id);
Configuration c = config.subset(prefix);
BlobStoreContext context;
try {
ContextBuilder builder = ContextBuilder.newBuilder(provider);
String identity = c.getString(Constants.PROPERTY_IDENTITY);
if (identity != null) {
builder.credentials(identity, c.getString(Constants.PROPERTY_CREDENTIAL));
}
c.addProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER, "true");
context = builder.overrides(new ConfigurationPropertiesView(c))
.modules(ImmutableList.of(new SLF4JLoggingModule()))
.build(BlobStoreContext.class);
logger.info("added provider {} id {}", context.unwrap().getId(), id);
} catch (CreationException e) {
e.printStackTrace();
throw propagate(e);
}
BlobStore blobStore = new LoggingBlobStore(context.getBlobStore(), id, this);
providers.put(Integer.valueOf(id), blobStore);
}
示例9: setUp
import org.jclouds.Constants; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
containerName = Utils.createRandomContainerName();
Properties properties = new Properties();
properties.putAll(ImmutableMap.of(
Constants.PROPERTY_PROVIDER, "encrypted",
EncryptedBlobStore.KEY, "foobar",
EncryptedBlobStore.SALT, "salty"
));
Utils.insertAllWithPrefix(properties,
EncryptedBlobStore.BACKEND + ".",
ImmutableMap.of(
Constants.PROPERTY_PROVIDER, "transient"
));
context = ContextBuilder
.newBuilder("encrypted")
.overrides(properties)
.build(BlobStoreContext.class);
blobStore = (EncryptedBlobStore) context.getBlobStore();
blobStore.createContainerInLocation(null, containerName);
}
示例10: blobStoreContextFromProperties
import org.jclouds.Constants; //导入依赖的package包/类
private static BlobStoreContext blobStoreContextFromProperties(
Properties properties) {
String provider = properties.getProperty(Constants.PROPERTY_PROVIDER);
String identity = properties.getProperty(Constants.PROPERTY_IDENTITY);
String credential = properties.getProperty(
Constants.PROPERTY_CREDENTIAL);
String endpoint = properties.getProperty(Constants.PROPERTY_ENDPOINT);
if (provider == null || identity == null || credential == null) {
System.err.println("Properties file must contain:\n" +
Constants.PROPERTY_PROVIDER + "\n" +
Constants.PROPERTY_IDENTITY + "\n" +
Constants.PROPERTY_CREDENTIAL);
System.exit(1);
}
ContextBuilder builder = ContextBuilder
.newBuilder(provider)
.credentials(identity, credential)
.modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
.overrides(properties);
if (endpoint != null) {
builder = builder.endpoint(endpoint);
}
return builder.build(BlobStoreContext.class);
}
示例11: getFreshSwiftClient
import org.jclouds.Constants; //导入依赖的package包/类
private SwiftClient getFreshSwiftClient() {
String trimmedAuthUrl = // JClouds expects authURL with no version
authUrl.substring(0, authUrl.lastIndexOf("/"));
Iterable<Module> modules =
ImmutableSet.<Module> of(new SLF4JLoggingModule());
Properties properties = new Properties();
properties.setProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER,
"true");
return ContextBuilder.newBuilder(new SwiftApiMetadata())
.endpoint(trimmedAuthUrl)
.credentials(username, password)
.modules(modules)
// For JClouds 1.7.1 - 1.7.2
.overrides(properties)
.buildApi(SwiftClient.class);
// For JClouds 1.5.5
// .build(SwiftApiMetadata.CONTEXT_TOKEN).getApi();
}
示例12: ECSComputeService
import org.jclouds.Constants; //导入依赖的package包/类
@Inject
protected ECSComputeService(
ComputeServiceContext context,
ECSComputeServiceAdapter client,
Map<String, Credentials> credentialStore,
@Memoized Supplier<Set<? extends Image>> images,
Supplier<Set<? extends Hardware>> hardwareProfiles,
@Memoized Supplier<Set<? extends Location>> locations,
ListNodesStrategy listNodesStrategy,
GetImageStrategy getImageStrategy,
GetNodeMetadataStrategy getNodeMetadataStrategy,
CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
RebootNodeStrategy rebootNodeStrategy,
DestroyNodeStrategy destroyNodeStrategy,
ResumeNodeStrategy resumeNodeStrategy,
SuspendNodeStrategy suspendNodeStrategy,
@Named("ECS") Provider<TemplateBuilder> templateBuilderProvider,
@Named("ECS") Provider<TemplateOptions> templateOptionsProvider,
@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
@Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
@Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
Factory initScriptRunnerFactory,
InitAdminAccess initAdminAccess,
org.jclouds.compute.callables.RunScriptOnNode.Factory runScriptOnNodeFactory,
PersistNodeCredentials persistNodeCredentials,
Timeouts timeouts,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
Optional<ImageExtension> imageExtension,
Optional<SecurityGroupExtension> securityGroupExtension) {
super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy,
getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, resumeNodeStrategy,
suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, persistNodeCredentials, timeouts, userExecutor,
imageExtension, securityGroupExtension);
this.client = client;
}
示例13: tryAuthenticate
import org.jclouds.Constants; //导入依赖的package包/类
private AuthenticatedBlobStore tryAuthenticate(String identity, String credential) {
if (locator != null) {
Map.Entry<String, BlobStore> entry = locator.locateBlobStore(identity, null, null);
if (entry != null && entry.getKey().equals(credential)) {
logger.debug("blob store for {} found", identity);
return (container, key) -> locator.locateBlobStore(identity, container, key).getValue();
} else {
logger.debug("blob store for {} not found", identity);
}
} else {
logger.debug("fallback to authenticate with configured provider");
String provider = properties.getProperty(Constants.PROPERTY_PROVIDER);
if (provider.equals("transient")) {
/* there's no authentication for transient blobstores, so simply re-use
the previous blobstore so that multiple authentication will reuse the
same namespace */
AuthenticatedBlobStore blobStore = identitiesToBlobStore.getIfPresent(identity);
if (blobStore != null) {
return blobStore;
}
}
try {
BlobStoreContext context = ContextBuilder
.newBuilder(provider)
.overrides(properties)
.credentials(identity, credential)
.modules(ImmutableSet.<Module>of(new SLF4JLoggingModule()))
.build(BlobStoreContext.class);
return (container, key) -> context.getBlobStore();
} catch (Throwable e) {
throw propagate(e);
}
}
return null;
}
示例14: storeFromProperties
import org.jclouds.Constants; //导入依赖的package包/类
public static BlobStore storeFromProperties(Properties properties) {
String provider = properties.getProperty(Constants.PROPERTY_PROVIDER);
ContextBuilder builder = ContextBuilder
.newBuilder(provider)
.modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
.overrides(properties);
BlobStoreContext context = builder.build(BlobStoreContext.class);
return context.getBlobStore();
}
示例15: getAuthToken
import org.jclouds.Constants; //导入依赖的package包/类
public static String getAuthToken(WebTarget target) {
Properties properties = new Properties();
try (InputStream is = Resources.asByteSource(Resources.getResource(
"swiftproxy.conf")).openStream()) {
properties.load(is);
} catch (IOException e) {
return null;
}
Response resp = target.path("/auth/v1.0").request()
.header("X-auth-user", properties.getProperty(Constants.PROPERTY_IDENTITY))
.header("X-auth-key", properties.getProperty(Constants.PROPERTY_CREDENTIAL))
.get();
return resp.getHeaderString("x-auth-token");
}