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


Java AWSKeyPairApi类代码示例

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


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

示例1: testApplyWithIllegalStateExceptionReturnsExistingKey

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
@Test
public void testApplyWithIllegalStateExceptionReturnsExistingKey() {
   AWSEC2Api client = createMock(AWSEC2Api.class);
   AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);

   expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

   expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
            new IllegalStateException());
   expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.of(pair));

   replay(client);
   replay(keyApi);

   ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);

   // enriching to include the ssh fingerprint so that ssh logs are easier to correlate
   assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);

   verify(client);
   verify(keyApi);

}
 
开发者ID:apache,项目名称:stratos,代码行数:24,代码来源:ImportOrReturnExistingKeypairTest.java

示例2: testApplyWithIllegalStateExceptionRetriesWhenExistingKeyNotFound

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
@Test
public void testApplyWithIllegalStateExceptionRetriesWhenExistingKeyNotFound() {
   AWSEC2Api client = createMock(AWSEC2Api.class);
   AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);

   expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

   expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
            new IllegalStateException());
   expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of());
   expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
            new IllegalStateException());
   expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of(pair));

   replay(client);
   replay(keyApi);

   ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);

   assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);

   verify(client);
   verify(keyApi);

}
 
开发者ID:apache,项目名称:stratos,代码行数:26,代码来源:ImportOrReturnExistingKeypairTest.java

示例3: Ec2Context

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
public Ec2Context(Ec2Credentials credentials) {
  this.credentials = credentials;
  Properties properties = new Properties();
  long scriptTimeout = TimeUnit.MILLISECONDS.convert(50, TimeUnit.MINUTES);
  properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
  properties.setProperty(TIMEOUT_PORT_OPEN, scriptTimeout + "");
  properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, scriptTimeout + "");
  properties.setProperty(PROPERTY_EC2_AMI_QUERY, "owner-id=137112412989;state=available;image-type=machine");
  properties.setProperty(PROPERTY_EC2_CC_AMI_QUERY, "");
  properties.setProperty(Constants.PROPERTY_MAX_RETRIES, Settings.JCLOUDS_PROPERTY_MAX_RETRIES + "");
  properties.setProperty(Constants.PROPERTY_RETRY_DELAY_START, Settings.JCLOUDS_PROPERTY_RETRY_DELAY_START + "");

  Iterable<Module> modules = ImmutableSet.<Module>of(
      new SshjSshClientModule(),
      new SLF4JLoggingModule(),
      new EnterpriseConfigurationModule());

  ContextBuilder build = ContextBuilder.newBuilder("aws-ec2")
      .credentials(credentials.getAccessKey(), credentials.getSecretKey())
      .modules(modules)
      .overrides(properties);
  ComputeServiceContext context = build.buildView(ComputeServiceContext.class);
  this.computeService = (AWSEC2ComputeService) context.getComputeService();
  this.ec2api = computeService.getContext().unwrapApi(EC2Api.class);
  this.securityGroupApi = ec2api.getSecurityGroupApi().get();
  this.keypairApi = (AWSKeyPairApi) ec2api.getKeyPairApi().get();

  vmBatchSize = Settings.AWS_VM_BATCH_SIZE();
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:30,代码来源:Ec2Context.java

示例4: Ec2Context

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
public Ec2Context(Ec2Credentials credentials) {
  this.credentials = credentials;
  Properties properties = new Properties();
  long scriptTimeout = TimeUnit.MILLISECONDS.convert(50, TimeUnit.MINUTES);
  properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
  properties.setProperty(TIMEOUT_PORT_OPEN, scriptTimeout + "");
  properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, scriptTimeout + "");
  properties.setProperty(PROPERTY_EC2_AMI_QUERY, "owner-id=137112412989;state=available;image-type=machine");
  properties.setProperty(PROPERTY_EC2_CC_AMI_QUERY, "");
  properties.setProperty(Constants.PROPERTY_MAX_RETRIES, Settings.JCLOUDS_PROPERTY_MAX_RETRIES + "");
  properties.setProperty(Constants.PROPERTY_RETRY_DELAY_START, Settings.JCLOUDS_PROPERTY_RETRY_DELAY_START + "");

  Iterable<Module> modules = ImmutableSet.<Module>of(
      new SshjSshClientModule(),
      new SLF4JLoggingModule(),
      new EnterpriseConfigurationModule());

  ContextBuilder build = ContextBuilder.newBuilder("aws-ec2")
      .credentials(credentials.getAccessKey(), credentials.getSecretKey())
      .modules(modules)
      .overrides(properties);
  ComputeServiceContext context = build.buildView(ComputeServiceContext.class);
  this.computeService = (AWSEC2ComputeService) context.getComputeService();
  this.ec2api = computeService.getContext().unwrapApi(EC2Api.class);
  this.aWSEC2Api = computeService.getContext().unwrapApi(AWSEC2Api.class);

  this.securityGroupApi = ec2api.getSecurityGroupApi().get();
  this.keypairApi = (AWSKeyPairApi) ec2api.getKeyPairApi().get();
  this.spotInstanceApi = (SpotInstanceApi) aWSEC2Api.getSpotInstanceApi().get();
  this.configuredRegions = aWSEC2Api.getConfiguredRegions();
}
 
开发者ID:karamelchef,项目名称:kandy,代码行数:32,代码来源:Ec2Context.java

示例5: createKeyPairFromPublicKey

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
@Override
public synchronized boolean createKeyPairFromPublicKey(String region, String keyPairName, String publicKey) {
    IaasProvider iaasInfo = getIaasProvider();
    String ec2Msg = " ec2. Region: " + region + " - Key Pair Name: ";
    ComputeServiceContext context = iaasInfo.getComputeService().getContext();
    AWSKeyPairApi keyPairApi = context.unwrapApi(AWSEC2Api.class).getKeyPairApiForRegion(region).get();
    KeyPair keyPair = keyPairApi.importKeyPairInRegion(region, keyPairName, publicKey);
    if (keyPair != null) {
        iaasInfo.getTemplate().getOptions().as(AWSEC2TemplateOptions.class).keyPair(keyPair.getKeyName());
        log.info(SUCCESSFUL_LOG_LINE + ec2Msg + keyPair.getKeyName());
        return true;
    }
    log.error(FAILED_LOG_LINE + ec2Msg);
    return false;
}
 
开发者ID:apache,项目名称:stratos,代码行数:16,代码来源:EC2Iaas.java

示例6: getKeypairApi

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
public AWSKeyPairApi getKeypairApi() {
  return keypairApi;
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:4,代码来源:Ec2Context.java

示例7: getKeyPairApi

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Delegate
@Override
Optional<? extends AWSKeyPairApi> getKeyPairApi();
 
开发者ID:apache,项目名称:stratos,代码行数:7,代码来源:AWSEC2Api.java

示例8: getKeyPairApiForRegion

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
@Delegate
@Override
Optional<? extends AWSKeyPairApi> getKeyPairApiForRegion(
         @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
 
开发者ID:apache,项目名称:stratos,代码行数:5,代码来源:AWSEC2Api.java

示例9: testApply

import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
@Test
public void testApply() {
   AWSEC2Api client = createMock(AWSEC2Api.class);
   AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);

   expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

   expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andReturn(pair);

   replay(client);
   replay(keyApi);

   ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);

   assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint);

   verify(client);
   verify(keyApi);
}
 
开发者ID:apache,项目名称:stratos,代码行数:20,代码来源:ImportOrReturnExistingKeypairTest.java


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