本文整理匯總了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);
}