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

项目:aws-doc-sdk-examples    文件:CreateKeyPair.java   
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply a key pair name\n" +
        "Ex: CreateKeyPair <key-pair-name>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String key_name = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    CreateKeyPairRequest request = new CreateKeyPairRequest()
        .withKeyName(key_name);

    CreateKeyPairResult response = ec2.createKeyPair(request);

    System.out.printf(
        "Successfulyl created key pair named %s",
        key_name);
}
项目:aws-cluster-toolkit    文件:AwsClusterManager.java   
private void createKeyPair() throws IOException, FileNotFoundException {
    DescribeKeyPairsResult response = ec2.describeKeyPairs();
    boolean check_key=false;
    for(KeyPairInfo key_pair : response.getKeyPairs()) {
        if(key_pair.getKeyName().equalsIgnoreCase(MY_KEY))
        {
            check_key=true;
            break;
        }
    }
    if(!check_key)
    {
        File file=new File(System.getProperty("user.home")+"/.aws/"+MY_KEY+".pem");
        if(!file.exists()) file.createNewFile();
        else{
            System.err.println("Connot create the key pair to access to the cluster!");
            System.exit(1);
        }
        System.out.println("Create new key pair ~/.aws/"+MY_KEY+".pem");
        CreateKeyPairRequest request = new CreateKeyPairRequest()
        .withKeyName(MY_KEY);

        CreateKeyPairResult responsetocreate = ec2.createKeyPair(request);


        PrintWriter print = new PrintWriter(file);
        print.print(responsetocreate.getKeyPair().getKeyMaterial());
        print.close();
        Runtime.getRuntime().exec("chmod 0400 "+System.getProperty("user.home")+"/.aws/"+MY_KEY+".pem");
    }
}
项目:swordfish-service    文件:EC2KeyPairImpl.java   
@Override
public String create(Instance instance) {
    CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest();
    createKeyPairRequest.withKeyName(instance.getKeyName());
    CreateKeyPairResult createKeyPairResult = ec2UserClient.amazonEC2Async().createKeyPair(createKeyPairRequest);

    KeyPair keyPair = createKeyPairResult.getKeyPair();

    return keyPair.getKeyMaterial();
}
项目:incubator-gobblin    文件:AWSSdkClient.java   
/***
 * Creates a 2048-bit RSA key pair with the specified name
 *
 * @param keyName Key name to use
 * @return Unencrypted PEM encoded PKCS#8 private key
 */
public String createKeyValuePair(String keyName) {

  final AmazonEC2 amazonEC2 = getEc2Client();

  final CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest().withKeyName(keyName);
  final CreateKeyPairResult createKeyPairResult = amazonEC2.createKeyPair(createKeyPairRequest);
  final KeyPair keyPair = createKeyPairResult.getKeyPair();
  final String material = keyPair.getKeyMaterial();
  LOGGER.info("Created key: " + keyName);
  LOGGER.debug("Created material: " + material);

  return material;
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public KeyPair createKeyPair(CreateKeyPairRequest request,
        ResultCapture<CreateKeyPairResult> extractor) {

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

    if (result == null) return null;
    return new KeyPairImpl(result.getResource());
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public KeyPair createKeyPair(String keyName,
        ResultCapture<CreateKeyPairResult> extractor) {

    CreateKeyPairRequest request = new CreateKeyPairRequest()
        .withKeyName(keyName);
    return createKeyPair(request, extractor);
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public CreateKeyPairResult createKeyPair(CreateKeyPairRequest createKeyPairRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:cmn-project    文件:EC2.java   
public KeyPair createKeyPair(String keyName) {
    logger.info("create key pair, keyName={}", keyName);
    CreateKeyPairResult result = ec2.createKeyPair(new CreateKeyPairRequest().withKeyName(keyName));
    return result.getKeyPair();
}
项目:sequenceiq-samples    文件:SimpleKeyPairService.java   
public CreateKeyPairResult createKeyPair(AmazonEC2Client client, String keyName) {
    CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest().withKeyName(keyName);
    CreateKeyPairResult createKeyPairResult = client.createKeyPair(createKeyPairRequest);
    return createKeyPairResult;
}
项目:sequenceiq-samples    文件:SimpleKeyPairService.java   
@Override
public CreateKeyPairResult createKeyPair(AWSCredentials credentials, String keyName) {
    return createKeyPair(amazonEC2ClientFactory.createAmazonEC2Client(credentials), keyName);
}
项目:sequenceiq-samples    文件:KeyPairsConroller.java   
@RequestMapping(method = RequestMethod.GET, value = {"/keypairs/create"})
@ResponseBody
public CreateKeyPairResult createKeyPairs(@RequestParam("name") String name, @RequestParam("accessKey") String accessKey,
        @RequestParam("secretKey") String secretKey) {
    return awsec2Service.createKeyPair(awsCredentialsFactory.createSimpleAWSCredentials(accessKey, secretKey), name);
}
项目:aws-sdk-java-resources    文件:EC2Impl.java   
@Override
public KeyPair createKeyPair(String keyName) {
    return createKeyPair(keyName, (ResultCapture<CreateKeyPairResult>)null);
}
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * Performs the <code>CreateKeyPair</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 CreateKeyPairRequest
 */
com.amazonaws.resources.ec2.KeyPair createKeyPair(CreateKeyPairRequest
        request, ResultCapture<CreateKeyPairResult> extractor);
项目:aws-sdk-java-resources    文件:EC2.java   
/**
 * The convenient method form for the <code>CreateKeyPair</code> action.
 *
 * @see #createKeyPair(CreateKeyPairRequest, ResultCapture)
 */
com.amazonaws.resources.ec2.KeyPair createKeyPair(String keyName,
        ResultCapture<CreateKeyPairResult> extractor);
项目:sequenceiq-samples    文件:KeyPairService.java   
CreateKeyPairResult createKeyPair(AWSCredentials credentials, String keyName);