Java 类com.amazonaws.services.ec2.model.ImportKeyPairRequest 实例源码

项目:dohko    文件:EC2.java   
@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;
    }
}
项目:primecloud-controller    文件:AwsIaasGatewayScriptService.java   
@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 + "のキーをインポートしました。");
}
项目:cerberus-lifecycle-cli    文件:Ec2ServiceTest.java   
@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);
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@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());
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public KeyPair importKeyPair(String publicKeyMaterial, String keyName,
        ResultCapture<ImportKeyPairResult> extractor) {

    ImportKeyPairRequest request = new ImportKeyPairRequest()
        .withPublicKeyMaterial(publicKeyMaterial)
        .withKeyName(keyName);
    return importKeyPair(request, extractor);
}
项目:incubator-provisionr    文件:DeleteKeyPairLiveTest.java   
@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")));
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public ImportKeyPairResult importKeyPair(ImportKeyPairRequest importKeyPairRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public KeyPair importKeyPair(ImportKeyPairRequest request) {
    return importKeyPair(request, null);
}
项目:incubator-provisionr    文件:EnsureKeyPairExists.java   
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());
}
项目:cerberus-lifecycle-cli    文件:Ec2Service.java   
/**
 * 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();
}
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * 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);
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * Performs the <code>ImportKeyPair</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <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, ResultCapture<ImportKeyPairResult> extractor);