當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。