本文整理汇总了Java中org.jclouds.ContextBuilder.buildApi方法的典型用法代码示例。如果您正苦于以下问题:Java ContextBuilder.buildApi方法的具体用法?Java ContextBuilder.buildApi怎么用?Java ContextBuilder.buildApi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jclouds.ContextBuilder
的用法示例。
在下文中一共展示了ContextBuilder.buildApi方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OSConnection
import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
/**
* Establishes a connection the OpenStack with the given credentials
*
* @param credentials
* @param endpointURL e.g. https://keystone.rc.nectar.org.au:5000/v2.0/
*/
public OSConnection(OSCredentials credentials, String endpointURL) {
Iterable<Module> modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(),
new JschSshClientModule());
String provider = "openstack-nova";
String identity = credentials.getTenantId()+":"+credentials.getUserName();
String credential = credentials.getPassword();
ContextBuilder contextBuilder = ContextBuilder.newBuilder(provider)
.endpoint(endpointURL)
.credentials(identity, credential)
.modules(modules);
novaApi = contextBuilder.buildApi(NovaApi.class);
computeService = contextBuilder.buildView(ComputeServiceContext.class).getComputeService();
DEFAULT_ZONE = novaApi.getConfiguredZones().iterator().next();
}
示例2: initChefService
import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
private static ChefApi initChefService(final String client, final String validator) {
try {
Properties chefConfig = new Properties();
chefConfig.put(ChefProperties.CHEF_VALIDATOR_NAME, validator);
chefConfig
.put(ChefProperties.CHEF_VALIDATOR_CREDENTIAL, credentialForClient(validator));
ContextBuilder builder = ContextBuilder.newBuilder(new ChefApiMetadata()) //
.credentials(client, credentialForClient(client)) //
.modules(ImmutableSet.<Module>of(new SLF4JLoggingModule())) //
.overrides(chefConfig); //
System.out.printf(">> initializing %s%n", builder.getApiMetadata());
return builder.buildApi(ChefApi.class);
} catch (Exception e) {
System.err.println("error reading private key " + e.getMessage());
System.exit(1);
return null;
}
}
示例3: JCloudsConnector
import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
public JCloudsConnector(String provider,String login,String secretKey){
journal.log(Level.INFO, ">> Connecting to "+provider+" ...");
Properties overrides = new Properties();
if(provider.equals("aws-ec2")){
// choose only amazon images that are ebs-backed
//overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_OWNERS,"107378836295");
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY,
"owner-id=137112412989,107378836295,099720109477;state=available;image-type=machine;root-device-type=ebs");
}
overrides.setProperty(PROPERTY_CONNECTION_TIMEOUT, 0 + "");
overrides.setProperty(PROPERTY_SO_TIMEOUT, 0 + "");
overrides.setProperty(PROPERTY_REQUEST_TIMEOUT, 0 + "");
overrides.setProperty(PROPERTY_RETRY_DELAY_START, 0 + "");
Iterable<Module> modules = ImmutableSet.<Module> of(
new SshjSshClientModule(),
new NullLoggingModule());
ContextBuilder builder = ContextBuilder.newBuilder(provider).credentials(login, secretKey).modules(modules).overrides(overrides);
journal.log(Level.INFO, ">> Authenticating ...");
computeContext=builder.buildView(ComputeServiceContext.class);
ec2api=builder.buildApi(EC2Api.class);
//loadBalancerCtx=builder.buildView(LoadBalancerServiceContext.class);
compute=computeContext.getComputeService();
this.provider = provider;
}
示例4: CloudSigmaConnector
import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
public CloudSigmaConnector(String provider,String login,String secretKey){
journal.log(Level.INFO, ">> Connecting to "+provider+" ...");
Iterable<Module> modules = ImmutableSet.<Module> of(
new SshjSshClientModule(),
new NullLoggingModule());
ContextBuilder builder = ContextBuilder.newBuilder(provider)
.credentials(login, secretKey)
.modules(modules);
journal.log(Level.INFO, ">> Authenticating ...");
this.provider = provider;
cloudSigmaApi=builder.buildApi(CloudSigma2Api.class);
}
示例5: OpenStackConnector
import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
public OpenStackConnector(String endPoint,String provider,String login,String secretKey){
this.endpoint=endPoint;
journal.log(Level.INFO, ">> Connecting to "+provider+" ...");
Iterable<Module> modules = ImmutableSet.<Module> of(
new SshjSshClientModule(),
new NullLoggingModule());
ContextBuilder builder = ContextBuilder.newBuilder(provider)
.endpoint(endPoint)
.credentials(login, secretKey)
.modules(modules);
journal.log(Level.INFO, ">> Authenticating ...");
computeContext=builder.buildView(ComputeServiceContext.class);
novaComputeService= computeContext.getComputeService();
serverApi=builder.buildApi(NovaApi.class);
}