本文整理汇总了Java中org.jclouds.compute.ComputeServiceContext.getComputeService方法的典型用法代码示例。如果您正苦于以下问题:Java ComputeServiceContext.getComputeService方法的具体用法?Java ComputeServiceContext.getComputeService怎么用?Java ComputeServiceContext.getComputeService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jclouds.compute.ComputeServiceContext
的用法示例。
在下文中一共展示了ComputeServiceContext.getComputeService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CloudServersPublish
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public CloudServersPublish(List<String> args) {
String username = args.get(0);
String apiKey = args.get(1);
numServers = args.size() == 3 ? Integer.valueOf(args.get(2)) : 1;
Iterable<Module> modules = ImmutableSet.<Module> of(new SshjSshClientModule());
// These properties control how often jclouds polls for a status update
Properties overrides = new Properties();
overrides.setProperty(POLL_INITIAL_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
overrides.setProperty(POLL_MAX_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
ComputeServiceContext context = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.overrides(overrides)
.modules(modules)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
}
示例2: CreateServerWithKeyPair
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public CreateServerWithKeyPair(String username, String apiKey) {
Iterable<Module> modules = ImmutableSet.<Module> of(new SshjSshClientModule());
// These properties control how often jclouds polls for a status update
Properties overrides = new Properties();
overrides.setProperty(POLL_INITIAL_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
overrides.setProperty(POLL_MAX_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
ComputeServiceContext context = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.overrides(overrides)
.modules(modules)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
novaApi = context.unwrapApi(NovaApi.class);
}
示例3: DetachVolume
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public DetachVolume(String username, String apiKey) {
// The provider configures jclouds To use the Rackspace Cloud (US)
// To use the Rackspace Cloud (UK) set the system property or default value to "rackspace-cloudservers-uk"
String provider = System.getProperty("provider.cs", "rackspace-cloudservers-us");
Iterable<Module> modules = ImmutableSet.<Module> of(new SshjSshClientModule());
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.credentials(username, apiKey)
.modules(modules)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
NovaApi novaApi = context.unwrapApi(NovaApi.class);
serverApi = novaApi.getServerApi(REGION);
volumeAttachmentApi = novaApi.getVolumeAttachmentApi(REGION).get();
cinderApi = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.buildApi(CinderApi.class);
volumeApi = cinderApi.getVolumeApi(REGION);
}
示例4: CreateVolumeAndAttach
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public CreateVolumeAndAttach(String username, String apiKey) {
// The provider configures jclouds To use the Rackspace Cloud (US)
// To use the Rackspace Cloud (UK) set the system property or default value to "rackspace-cloudservers-uk"
String provider = System.getProperty("provider.cs", "rackspace-cloudservers-us");
// These properties control how often jclouds polls for a status udpate
Properties overrides = new Properties();
overrides.setProperty(POLL_INITIAL_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
overrides.setProperty(POLL_MAX_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
Iterable<Module> modules = ImmutableSet.<Module> of(new SshjSshClientModule());
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.credentials(username, apiKey)
.modules(modules)
.overrides(overrides)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
novaApi = context.unwrapApi(NovaApi.class);
volumeAttachmentApi = novaApi.getVolumeAttachmentApi(REGION).get();
cinderApi = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.buildApi(CinderApi.class);
volumeApi = cinderApi.getVolumeApi(REGION);
}
示例5: beforeSuite
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
@BeforeSuite
public void beforeSuite() {
BasicConfigurator.configure();
ComputeServiceContext context = ContextBuilder
.newBuilder(provider)
.credentials(key, secret)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
}
示例6: destroyNodes
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
private static void destroyNodes(final ComputeServiceContext ctx, final String groupname) {
// Destroy all workers identified by the given group
final ComputeService computeService = ctx.getComputeService();
if (computeService != null) {
Set<? extends NodeMetadata> destroyed = computeService
.destroyNodesMatching(
Predicates.<NodeMetadata> and(not(TERMINATED),
inGroup(groupname)));
System.out.printf("<< destroyed nodes %s%n", destroyed);
}
}
示例7: NovaContext
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public NovaContext(NovaCredentials credentials, ContextBuilder builder) {
this.novaCredentials = credentials;
ComputeServiceContext context = builder.credentials(credentials.getAccountName(),credentials.getAccountPass())
.endpoint(credentials.getEndpoint())
.buildView(ComputeServiceContext.class);
this.computeService = context.getComputeService();
this.novaApi = computeService.getContext().unwrapApi(NovaApi.class);
this.securityGroupApi = novaApi.getSecurityGroupApi(credentials.getRegion()).get();
this.keyPairApi = novaApi.getKeyPairApi(credentials.getRegion()).get();
}
示例8: GceContext
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public GceContext(Credentials credentials) {
ComputeServiceContext context = ContextBuilder.newBuilder("google-compute-engine")
.modules(Arrays.asList(
new SshjSshClientModule(),
new EnterpriseConfigurationModule(),
new SLF4JLoggingModule()))
.credentials(credentials.identity, credentials.credential)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
gceApi = context.unwrapApi(GoogleComputeEngineApi.class);
fireWallApi = gceApi.firewalls();
networkApi = gceApi.networks();
routeApi = gceApi.routes();
this.credentials = credentials;
}
示例9: Ec2Context
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public Ec2Context(Ec2Credentials credentials) {
this.credentials = credentials;
Properties properties = new Properties();
long scriptTimeout = TimeUnit.MILLISECONDS.convert(50, TimeUnit.MINUTES);
properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
properties.setProperty(TIMEOUT_PORT_OPEN, scriptTimeout + "");
properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, scriptTimeout + "");
properties.setProperty(PROPERTY_EC2_AMI_QUERY, "owner-id=137112412989;state=available;image-type=machine");
properties.setProperty(PROPERTY_EC2_CC_AMI_QUERY, "");
properties.setProperty(Constants.PROPERTY_MAX_RETRIES, Settings.JCLOUDS_PROPERTY_MAX_RETRIES + "");
properties.setProperty(Constants.PROPERTY_RETRY_DELAY_START, Settings.JCLOUDS_PROPERTY_RETRY_DELAY_START + "");
Iterable<Module> modules = ImmutableSet.<Module>of(
new SshjSshClientModule(),
new SLF4JLoggingModule(),
new EnterpriseConfigurationModule());
ContextBuilder build = ContextBuilder.newBuilder("aws-ec2")
.credentials(credentials.getAccessKey(), credentials.getSecretKey())
.modules(modules)
.overrides(properties);
ComputeServiceContext context = build.buildView(ComputeServiceContext.class);
this.computeService = (AWSEC2ComputeService) context.getComputeService();
this.ec2api = computeService.getContext().unwrapApi(EC2Api.class);
this.securityGroupApi = ec2api.getSecurityGroupApi().get();
this.keypairApi = (AWSKeyPairApi) ec2api.getKeyPairApi().get();
vmBatchSize = Settings.AWS_VM_BATCH_SIZE();
}
示例10: Ec2Context
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public Ec2Context(Ec2Credentials credentials) {
this.credentials = credentials;
Properties properties = new Properties();
long scriptTimeout = TimeUnit.MILLISECONDS.convert(50, TimeUnit.MINUTES);
properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
properties.setProperty(TIMEOUT_PORT_OPEN, scriptTimeout + "");
properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, scriptTimeout + "");
properties.setProperty(PROPERTY_EC2_AMI_QUERY, "owner-id=137112412989;state=available;image-type=machine");
properties.setProperty(PROPERTY_EC2_CC_AMI_QUERY, "");
properties.setProperty(Constants.PROPERTY_MAX_RETRIES, Settings.JCLOUDS_PROPERTY_MAX_RETRIES + "");
properties.setProperty(Constants.PROPERTY_RETRY_DELAY_START, Settings.JCLOUDS_PROPERTY_RETRY_DELAY_START + "");
Iterable<Module> modules = ImmutableSet.<Module>of(
new SshjSshClientModule(),
new SLF4JLoggingModule(),
new EnterpriseConfigurationModule());
ContextBuilder build = ContextBuilder.newBuilder("aws-ec2")
.credentials(credentials.getAccessKey(), credentials.getSecretKey())
.modules(modules)
.overrides(properties);
ComputeServiceContext context = build.buildView(ComputeServiceContext.class);
this.computeService = (AWSEC2ComputeService) context.getComputeService();
this.ec2api = computeService.getContext().unwrapApi(EC2Api.class);
this.aWSEC2Api = computeService.getContext().unwrapApi(AWSEC2Api.class);
this.securityGroupApi = ec2api.getSecurityGroupApi().get();
this.keypairApi = (AWSKeyPairApi) ec2api.getKeyPairApi().get();
this.spotInstanceApi = (SpotInstanceApi) aWSEC2Api.getSpotInstanceApi().get();
this.configuredRegions = aWSEC2Api.getConfiguredRegions();
}
示例11: jcloudContext
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
/**
* Creates a JCloud context.
* @param targetProperties the target properties
* @return a non-null object
* @throws TargetException if the target properties are invalid
*/
ComputeService jcloudContext( Map<String,String> targetProperties ) throws TargetException {
validate( targetProperties );
ComputeServiceContext context = ContextBuilder
.newBuilder( targetProperties.get( PROVIDER_ID ))
.endpoint( targetProperties.get( ENDPOINT ))
.credentials( targetProperties.get( IDENTITY ), targetProperties.get( CREDENTIAL ))
.buildView( ComputeServiceContext.class );
return context.getComputeService();
}
示例12: CreateServer
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public CreateServer(String username, String apiKey) {
// These properties control how often jclouds polls for a status update
Properties overrides = new Properties();
overrides.setProperty(POLL_INITIAL_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
overrides.setProperty(POLL_MAX_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
ComputeServiceContext context = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.overrides(overrides)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
}
示例13: ServerMetadata
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public ServerMetadata(String username, String apiKey) {
ComputeServiceContext context = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
NovaApi novaApi = context.unwrapApi(NovaApi.class);
serverApi = novaApi.getServerApi(REGION);
}
示例14: ListServersWithFiltering
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public ListServersWithFiltering(String username, String apiKey) {
ComputeServiceContext context = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
}
示例15: DeleteServer
import org.jclouds.compute.ComputeServiceContext; //导入方法依赖的package包/类
public DeleteServer(String username, String apiKey) {
// These properties control how often jclouds polls for a status udpate
Properties overrides = new Properties();
overrides.setProperty(POLL_INITIAL_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
overrides.setProperty(POLL_MAX_PERIOD, POLL_PERIOD_TWENTY_SECONDS);
ComputeServiceContext context = ContextBuilder.newBuilder(PROVIDER)
.credentials(username, apiKey)
.overrides(overrides)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
}