Class: Standup::EC2::ElasticIP
- Defined in:
- lib/standup/ec2/elastic_ip.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attach_to(instance) ⇒ Object
- #destroy ⇒ Object
- #detach ⇒ Object
-
#initialize(ip, info = false) ⇒ ElasticIP
constructor
A new instance of ElasticIP.
- #load_info ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(ip, info = false) ⇒ ElasticIP
Returns a new instance of ElasticIP.
4 5 6 7 |
# File 'lib/standup/ec2/elastic_ip.rb', line 4 def initialize ip, info = false @ip = ip super info end |
Class Method Details
.create ⇒ Object
22 23 24 25 |
# File 'lib/standup/ec2/elastic_ip.rb', line 22 def self.create ip = api.allocate_address.publicIp list[ip] = ElasticIP.new ip end |
.list(reload = false) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/standup/ec2/elastic_ip.rb', line 11 def self.list reload = false if !class_variable_defined?(:@@list) || reload @@list = {} result = api.describe_addresses result.addressesSet.item.each do |item| @@list[item.publicIp] = new item.publicIp, :attached_to => Instance.new(item.instanceId) end if result.addressesSet end @@list end |
Instance Method Details
#attach_to(instance) ⇒ Object
32 33 34 35 36 |
# File 'lib/standup/ec2/elastic_ip.rb', line 32 def attach_to instance api.associate_address :instance_id => instance.id, :public_ip => @ip @attached_to = instance end |
#destroy ⇒ Object
27 28 29 30 |
# File 'lib/standup/ec2/elastic_ip.rb', line 27 def destroy api.release_address :public_ip => @ip list.delete @ip end |
#detach ⇒ Object
38 39 40 41 |
# File 'lib/standup/ec2/elastic_ip.rb', line 38 def detach api.disassociate_address :public_ip => @ip @attached_to = nil end |