aws-sdk 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,7 +34,6 @@
34
34
  :inputs:
35
35
  InstanceId:
36
36
  - :string
37
- - :required
38
37
  PublicIp:
39
38
  - :string
40
39
  AllocationId:
@@ -61,7 +61,7 @@ require 'aws/core/autoloader'
61
61
  module AWS
62
62
 
63
63
  # Current version of the AWS SDK for Ruby
64
- VERSION = "1.5.3"
64
+ VERSION = "1.5.4"
65
65
 
66
66
  register_autoloads(self) do
67
67
  autoload :Errors, 'errors'
@@ -103,7 +103,7 @@ module AWS
103
103
  #
104
104
  # === Options:
105
105
  #
106
- # * +:instance_id+ - *required* - (String) The instance to associate with
106
+ # * +:instance_id+ - (String) The instance to associate with
107
107
  # the IP address.
108
108
  # * +:public_ip+ - (String) IP address that you are assigning to the
109
109
  # instance.
@@ -21,13 +21,14 @@ module AWS
21
21
  # The ID representing the allocation of the address for use with Amazon
22
22
  # VPC.
23
23
  #
24
- # @attr_reader [String] Indicates whether this elastic ip address is for
25
- # EC2 instances ('standard') or VPC instances ('vpc').
24
+ # @attr_reader [String] domain Indicates whether this elastic ip address
25
+ # is for EC2 instances ('standard') or VPC instances ('vpc').
26
26
  #
27
- # @attr_reader [String,nil] The ID of the association between this elastic
28
- # ip address and an EC2 VPC instance (VPC only).
27
+ # @attr_reader [String,nil] association_id The ID of the association
28
+ # between this elastic ip address and an EC2 VPC instance (VPC only).
29
29
  #
30
- # @attr_reader [String,nil] The ID of the network interface (VPC only).
30
+ # @attr_reader [String,nil] network_interface_id The ID of the network
31
+ # interface (VPC only).
31
32
  #
32
33
  # @attr_reader [String,nil] network_interface_owner_id
33
34
  # The ID of the AWS account that owns the network interface (VPC only).
@@ -67,10 +68,10 @@ module AWS
67
68
  domain == 'vpc'
68
69
  end
69
70
 
70
- # @return [Boolean] Returns true if this IP address is attached to
71
- # an EC2 instance.
71
+ # @return [Boolean] Returns true if this IP address is associated
72
+ # with an EC2 instance or a network interface.
72
73
  def associated?
73
- !!instance_id
74
+ !!(instance_id || association_id)
74
75
  end
75
76
 
76
77
  alias_method :attached?, :associated?
@@ -83,6 +84,15 @@ module AWS
83
84
  end
84
85
  end
85
86
 
87
+ # @return [NetworkInterface,nil] Returns the network interface this
88
+ # elastic ip is associated with. Returns +nil+ if this is not
89
+ # associated with an elastic ip address.
90
+ def network_interface
91
+ if nid = network_interface_id
92
+ NetworkInterface.new(nid, :config => config)
93
+ end
94
+ end
95
+
86
96
  # Releases the elastic IP address.
87
97
  #
88
98
  # (For non-VPC elastic ips) Releasing an IP address automatically
@@ -99,6 +109,47 @@ module AWS
99
109
  end
100
110
  alias_method :release, :delete
101
111
 
112
+ # Associates this elastic IP address with an instance or a network
113
+ # interface. You may provide +:instance+ or +:network_interface+
114
+ # but not both options.
115
+ #
116
+ # # associate with an instance
117
+ # eip.associate :instance => 'i-12345678'
118
+ #
119
+ # # associate with a network interface
120
+ # eip.associate :network_interface => 'ni-12345678'
121
+ #
122
+ # @param [Hash] options
123
+ #
124
+ # @option options [String,Instance] :instance The id of an instance
125
+ # or an {Instance} object.
126
+ #
127
+ # @option options [String,NetworkInterface] :network_interface The id
128
+ # of a network interface or a {NetworkInterface} object.
129
+ #
130
+ # @return [String] Returns the resulting association id.
131
+ #
132
+ def associate options
133
+
134
+ client_opts = {}
135
+
136
+ [:instance,:network_interface].each do |opt|
137
+ if value = options[opt]
138
+ client_opts[:"#{opt}_id"] = value.is_a?(Resource) ? value.id : value
139
+ end
140
+ end
141
+
142
+ if vpc?
143
+ client_opts[:allocation_id] = allocation_id
144
+ else
145
+ client_opts[:public_ip] = public_ip
146
+ end
147
+
148
+ resp = client.associate_address(client_opts)
149
+ resp.data[:association_id]
150
+
151
+ end
152
+
102
153
  # Disassociates this elastic IP address from an EC2 instance.
103
154
  # Raises an exception if this elastic IP is not currently
104
155
  # associated with an instance.
@@ -24,7 +24,7 @@ module AWS
24
24
  #
25
25
  # To run an instance:
26
26
  #
27
- # ec2.instances.create(:image_id => "ami-8c1fece5")
27
+ # ec2.instances.create(:image_id => "ami-1b814f72")
28
28
  #
29
29
  # To get an instance by ID:
30
30
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-11 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: uuidtools
@@ -490,7 +490,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
490
490
  version: '0'
491
491
  segments:
492
492
  - 0
493
- hash: -352312075848361752
493
+ hash: -1968762056350445253
494
494
  required_rubygems_version: !ruby/object:Gem::Requirement
495
495
  none: false
496
496
  requirements: