aws 2.6.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/ec2/ec2.rb +23 -0
  2. metadata +2 -2
@@ -1028,6 +1028,23 @@ module Aws
1028
1028
  on_exception
1029
1029
  end
1030
1030
 
1031
+ # Import existing SSH key. Returns a hash of the key's data or an exception.
1032
+ #
1033
+ # ec2.import_key_pair('my_awesome_key',
1034
+ # 'ssh-rsa AABB3NzaC1yc2FSAAADAQABAAABAQCntvz2Cpx8EE4lBRjQKOtwNaGeJXjgnFLaxnQH4HB+dRTinjlew+153KLCjAMbbanD9Wym/b1FfSHywP299RdTPpBZ2QD7Hh7qKp8penGszFQbaSewYQTBP9Htjn7NDg3VeVcIx0LP3lmp4ZNnYDZGLKCGJJ+ldT/cljW3FAA2/xwco98BujLlKUcU/BZlZ4zvESM3S0gF3pgOjuz2UKAEbsbuuaEQP88NZ/GXXIUgGNFoJSpxDrNCHA7pap/3gdyPq3zTkt4YK/bSxSJ24FMfYtehB36V9rqV8RsIro+yrzRBW4XcA976OKQbh5pS75rp herp@derp')
1035
+ # #=>
1036
+ # {:aws_key_name => "my_awesome_key",
1037
+ # :aws_fingerprint => "01:02:03:f4:25:e6:97:e8:9b:02:1a:26:32:4e:58:6b:7a:8c:9f:03"}
1038
+ #
1039
+ def import_key_pair(name, public_key)
1040
+ link = generate_request("ImportKeyPair",
1041
+ "KeyName" => name.to_s,
1042
+ "PublicKeyMaterial"=>Base64.encode64(public_key.to_s))
1043
+ request_info(link, QEc2ImportPublicKeyParser.new(:logger => @logger))
1044
+ rescue Exception
1045
+ on_exception
1046
+ end
1047
+
1031
1048
  # Delete a key pair. Returns +true+ or an exception.
1032
1049
  #
1033
1050
  # ec2.delete_key_pair('my_awesome_key') #=> true
@@ -1603,6 +1620,12 @@ module Aws
1603
1620
  end
1604
1621
  end
1605
1622
 
1623
+ class QEc2ImportPublicKeyParser < QEc2CreateKeyPairParser #:nodoc:
1624
+ def tagstart(name, attributes)
1625
+ @result = {} if name == 'ImportKeyPairResponse'
1626
+ end
1627
+ end
1628
+
1606
1629
  #-----------------------------------------------------------------
1607
1630
  # PARSERS: Security Groups
1608
1631
  #-----------------------------------------------------------------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-28 00:00:00.000000000 Z
14
+ date: 2013-02-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: uuidtools