本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例6: getKeypairApi
import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
public AWSKeyPairApi getKeypairApi() {
return keypairApi;
}
示例7: getKeyPairApi
import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Delegate
@Override
Optional<? extends AWSKeyPairApi> getKeyPairApi();
示例8: getKeyPairApiForRegion
import org.jclouds.aws.ec2.features.AWSKeyPairApi; //导入依赖的package包/类
@Delegate
@Override
Optional<? extends AWSKeyPairApi> getKeyPairApiForRegion(
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
示例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);
}