当前位置: 首页>>代码示例>>Java>>正文


Java ContextBuilder.buildApi方法代码示例

本文整理汇总了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();
}
 
开发者ID:jasonrig,项目名称:openstack-queue,代码行数:24,代码来源:OSConnection.java

示例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;
    }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:22,代码来源:MainApp.java

示例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;
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:26,代码来源:JCloudsConnector.java

示例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);
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:13,代码来源:CloudSigmaConnector.java

示例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);
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:16,代码来源:OpenStackConnector.java


注:本文中的org.jclouds.ContextBuilder.buildApi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。