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


Java AWSEC2Constants类代码示例

本文整理汇总了Java中org.jclouds.aws.ec2.reference.AWSEC2Constants的典型用法代码示例。如果您正苦于以下问题:Java AWSEC2Constants类的具体用法?Java AWSEC2Constants怎么用?Java AWSEC2Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AWSEC2Constants类属于org.jclouds.aws.ec2.reference包,在下文中一共展示了AWSEC2Constants类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: JCloudsConnector

import org.jclouds.aws.ec2.reference.AWSEC2Constants; //导入依赖的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

示例2: createContextBuilder

import org.jclouds.aws.ec2.reference.AWSEC2Constants; //导入依赖的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

示例3: mungeProperties

import org.jclouds.aws.ec2.reference.AWSEC2Constants; //导入依赖的package包/类
@Override
public void mungeProperties(Properties properties) {
	properties.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, getOwnerId());
	// Confine jclouds to a single region. Since the Toolbox only supports a
	// single region, there is no point in querying others. This has been
	// added because I was seeing intermittent timeouts with other regions
	// (i.e. South America).
	properties.setProperty(LocationConstants.PROPERTY_REGIONS, getRegion());
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:10,代码来源:EC2CloudTLCInstanceParameters.java

示例4: overrideProperties

import org.jclouds.aws.ec2.reference.AWSEC2Constants; //导入依赖的package包/类
@Override
protected Properties overrideProperties(Properties properties) {
  if (amiQuery != null) {
    properties.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, amiQuery);
  }
  if (amiCcQuery != null) {
    properties.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, amiCcQuery);
  }
  return properties;
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:11,代码来源:EC2JCloudsViewFactory.java

示例5: run

import org.jclouds.aws.ec2.reference.AWSEC2Constants; //导入依赖的package包/类
private void run() throws Exception {
   Properties overrides = new Properties();
   overrides.put(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "owner-id=" + arguments.getAmiOwner() + ";state=available;image-type=machine");

   ImmutableSet<Module> modules = ImmutableSet.<Module>of(
      new SLF4JLoggingModule(), // OverThere uses SLF4J so we will as well
      new BouncyCastleCryptoModule() // needed to decrypt the password from EC2
   );
   context = ContextBuilder.newBuilder("aws-ec2")
      .credentials(arguments.getIdentity(), arguments.getCredential())
      .overrides(overrides)
      .modules(modules)
      .build(ComputeServiceContext.class);

   try {
      computeService = context.getComputeService();
      Set<String> regions = Sets.newHashSet(Iterables.transform(Iterables.filter(computeService.listAssignableLocations(), LocationPredicates.isRegion()), new Function<Location, String>() {
         @Override
         public String apply(@Nullable Location location) {
            return (location != null) ? location.getId() : null;
         }
      }));

      if (!regions.contains(arguments.getRegion())) {
         System.err.println("Region \"" + arguments.getRegion() + "\" is not known. Known regions are:");
         for (String r : regions) {
            System.err.println("    " + r);
         }
         System.exit(1);
      }

      WindowsInstanceStarter app = new WindowsInstanceStarter(arguments, context);
      app.run();
   } finally {
      context.close();
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:38,代码来源:MainApp.java


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