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


Java ContextBuilder.newBuilder方法代码示例

本文整理汇总了Java中org.jclouds.ContextBuilder.newBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java ContextBuilder.newBuilder方法的具体用法?Java ContextBuilder.newBuilder怎么用?Java ContextBuilder.newBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jclouds.ContextBuilder的用法示例。


在下文中一共展示了ContextBuilder.newBuilder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createContextBuilder

import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
private static ContextBuilder createContextBuilder(ObjectProperties objectProperties) {
    Set<Module> modules = new HashSet<>();
    modules.add(new DynamicSshClientModule());
    modules.add(new SocketFinderOnlyPublicInterfacesModule());
    modules.add(new SLF4JLoggingModule());

    Properties overrides = new Properties();
    overrides.setProperty("jclouds.ssh.retry-auth", Boolean.FALSE.toString());
    overrides.setProperty("jclouds.ssh.max-retries", Integer.toString(1));

    ContextBuilder contextBuilder = ContextBuilder.newBuilder("openstack-nova");
    String endpoint = objectProperties.getProperty(Config.CloudProvider.Openstack.ENDPOINT);
    if (!Strings.isNullOrEmpty(endpoint)) {
        contextBuilder.endpoint(endpoint);
    }
    contextBuilder
            .credentials(
                    objectProperties.getProperty(Config.CloudProvider.Openstack.USERNAME),
                    objectProperties.getProperty(Config.CloudProvider.Openstack.PASSWORD)
            )
            .overrides(overrides)
            .modules(modules);

    return contextBuilder;
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:26,代码来源:OpenstackCloudProvider.java

示例2: addProviderFromConfig

import org.jclouds.ContextBuilder; //导入方法依赖的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);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:25,代码来源:BounceApplication.java

示例3: createContextBuilder

import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
private static ContextBuilder createContextBuilder(ObjectProperties objectProperties) {
    Properties properties = new Properties();
    final String amiQuery = objectProperties.getProperty(Config.CloudProvider.EC2.AMI_QUERY);
    if (!Strings.isNullOrEmpty(amiQuery)) {
        properties.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, amiQuery);
    }
    final String ec2Regions = objectProperties.getProperty(Config.CloudProvider.EC2.REGION);
    if (!Strings.isNullOrEmpty(ec2Regions)) {
        properties.setProperty(LocationConstants.PROPERTY_REGIONS, ec2Regions);
    }

    Set<Module> modules = new HashSet<>();
    modules.add(new DynamicSshClientModule());
    modules.add(new SocketFinderOnlyPublicInterfacesModule());
    if (Boolean.parseBoolean(objectProperties.getProperty(Config.CloudProvider.EC2.LOG_EC2_OPERATIONS))) {
        // TODO we should add that unconditionally, like we do in all other cloud providers!
        // the reason why we don't [yet] is that the JClouds EC2 provider does some excessive logging,
        // e.g. the names of all available images, and we don't want our users to have to deal with that
        modules.add(new SLF4JLoggingModule());
    }

    final ContextBuilder contextBuilder = ContextBuilder.newBuilder("aws-ec2");
    final String endpoint = objectProperties.getProperty(Config.CloudProvider.EC2.ENDPOINT);
    if (!Strings.isNullOrEmpty(endpoint)) {
        contextBuilder.endpoint(endpoint);
    }
    contextBuilder
            .credentials(
                    objectProperties.getProperty(Config.CloudProvider.EC2.ACCESS_KEY_ID),
                    objectProperties.getProperty(Config.CloudProvider.EC2.SECRET_ACCESS_KEY)
            )
            .overrides(properties).modules(ImmutableSet.copyOf(modules));

    return contextBuilder;
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:36,代码来源:EC2CloudProvider.java

示例4: buildContext

import org.jclouds.ContextBuilder; //导入方法依赖的package包/类
private ContextBuilder buildContext() {
  //todo ugly hack
  final Properties properties = new Properties();
  if (regions != null) {
    properties.setProperty("jclouds.regions", regions);
  }
  if (requestTimeout != null) {
    properties.setProperty(org.jclouds.Constants.PROPERTY_REQUEST_TIMEOUT, requestTimeout);
  }

  //todo duplicates code from NovaApiProvider
  // loading ssh module of jclouds as it seems to be required for google,
  // we are using the jschsshclient as the sshj conflicts with the overthere bouncy castle impl.

  Set<Module> moduleSet = new HashSet<>();
  moduleSet.addAll(overrideModules());
  moduleSet.add(new JCloudsLoggingModule(loggerFactory));

  ContextBuilder contextBuilder = ContextBuilder.newBuilder(cloud.api().providerName());
  contextBuilder.credentials(cloud.credential().user(), cloud.credential().password())
      .modules(moduleSet).overrides(overrideProperties(properties));

  // setting optional endpoint, check for present first
  // as builder does not allow null values...
  if (cloud.endpoint().isPresent()) {
    contextBuilder.endpoint(cloud.endpoint().get());
  }

  return contextBuilder;
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:31,代码来源:BaseJCloudsViewFactory.java


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