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


Java ImportKeyPairRequest类代码示例

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


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

示例1: importKeyPair

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
@Override
public String importKeyPair(final KeyPair keyPair)
{
    synchronized (lock_)
    {
        String fingerprint;

        checkState(!isNullOrEmpty(keyPair.getKeyName()));
        checkState(!isNullOrEmpty(keyPair.getKeyMaterial()));

        KeyPair keyPair2 = getKeyPair(keyPair.getKeyName());

        if (keyPair2 == null)
        {
            fingerprint = new AmazonEC2Client(awsCredentials_).importKeyPair(new ImportKeyPairRequest(keyPair.getKeyName(), keyPair.getKeyMaterial())).getKeyFingerprint();
        }
        else
        {
            fingerprint = keyPair2.getKeyFingerprint();
        }
        
        return fingerprint;
    }
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:25,代码来源:EC2.java

示例2: importKeyPair

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
@Override
public void importKeyPair(String keyName, String publicKey) throws AutoException {
    // キーペアがすでに登録されていたら何もしない
    DescribeKeyPairsRequest request = new DescribeKeyPairsRequest();
    DescribeKeyPairsResult result = ec2Client.describeKeyPairs(request);
    List<KeyPairInfo> keyPairs = result.getKeyPairs();

    for (KeyPairInfo keyPair : keyPairs) {
        if (keyPair.getKeyName().equals(keyName)) {
            log.info(platform.getPlatformName() + " の " + keyName + " はすでに登録されている為、キーのインポートをスキップします");
            System.out.println("IMPORT_SKIPPED");
            return;
        }
    }

    // インポート
    ImportKeyPairRequest request2 = new ImportKeyPairRequest();
    request2.withKeyName(keyName);
    request2.withPublicKeyMaterial(publicKey);
    ec2Client.importKeyPair(request2);

    log.info(keyName + "のキーをインポートしました。");
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:24,代码来源:AwsIaasGatewayScriptService.java

示例3: testImportKey

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
@Test
public void testImportKey() {

    String keyName = "key-name";
    String publicKeyMaterial = "public-key-material";
    String keyNameResult = "key-name-result";

    when(ec2Client.importKeyPair(new ImportKeyPairRequest(keyName, publicKeyMaterial)))
            .thenReturn(new ImportKeyPairResult().withKeyName(keyNameResult));

    // invoke method under test
    String result = ec2Service.importKey(keyName, publicKeyMaterial);

    assertEquals(keyNameResult, result);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:16,代码来源:Ec2ServiceTest.java

示例4: importKeyPair

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
@Override
public KeyPair importKeyPair(ImportKeyPairRequest request,
        ResultCapture<ImportKeyPairResult> extractor) {

    ActionResult result = service.performAction("ImportKeyPair", request,
            extractor);

    if (result == null) return null;
    return new KeyPairImpl(result.getResource());
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:EC2Impl.java

示例5: setUp

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();

    client.importKeyPair(new ImportKeyPairRequest().withKeyName(KEYPAIR_NAME)
        .withPublicKeyMaterial(getResourceAsString("/org/apache/provisionr/test/id_rsa_test.pub")));
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:8,代码来源:DeleteKeyPairLiveTest.java

示例6: importKeyPair

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
@Override
public ImportKeyPairResult importKeyPair(ImportKeyPairRequest importKeyPairRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java

示例7: importPoolPublicKeyPair

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
private void importPoolPublicKeyPair(AmazonEC2 client, String keyName, String publicKey) {
    ImportKeyPairResult result = client.importKeyPair(new ImportKeyPairRequest()
        .withKeyName(keyName).withPublicKeyMaterial(publicKey));
    LOG.info("<< Created remote key with fingerprint {}", result.getKeyFingerprint());
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:6,代码来源:EnsureKeyPairExists.java

示例8: importKey

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
/**
 * Import a key pair to AWS EC2.
 *
 * @param keyName Friendly name for the key
 * @param publicKeyMaterial Public key
 * @return Key name
 */
public String importKey(final String keyName, final String publicKeyMaterial) {
    final ImportKeyPairRequest request = new ImportKeyPairRequest(keyName, publicKeyMaterial);
    final ImportKeyPairResult result = ec2Client.importKeyPair(request);
    return result.getKeyName();
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:13,代码来源:Ec2Service.java

示例9: importKeyPair

import com.amazonaws.services.ec2.model.ImportKeyPairRequest; //导入依赖的package包/类
/**
 * Performs the <code>ImportKeyPair</code> action.
 *
 * <p>
 *
 * @return The <code>KeyPair</code> resource object associated with the
 *         result of this action.
 * @see ImportKeyPairRequest
 */
com.amazonaws.resources.ec2.KeyPair importKeyPair(ImportKeyPairRequest
        request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:12,代码来源:EC2.java


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