Class: Awscli::EC2::Eip
- Inherits:
-
Object
- Object
- Awscli::EC2::Eip
- Defined in:
- lib/awscli/ec2.rb
Overview
> SG
Instance Method Summary collapse
- #associate(options) ⇒ Object
- #create ⇒ Object
- #delete(options) ⇒ Object
- #disassociate(options) ⇒ Object
-
#initialize(connection) ⇒ Eip
constructor
A new instance of Eip.
- #list ⇒ Object
Constructor Details
#initialize(connection) ⇒ Eip
Returns a new instance of Eip.
357 358 359 |
# File 'lib/awscli/ec2.rb', line 357 def initialize(connection) @conn = connection end |
Instance Method Details
#associate(options) ⇒ Object
378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/awscli/ec2.rb', line 378 def associate() abort "Invalid IP Format" unless [:eip] =~ /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/ eip = @conn.addresses.get([:eip]) abort "Cannot find eip: #{[:eip]}" unless eip server = @conn.servers.get([:instance_id]) abort "Cannot find server with id: #{[:instance_id]}" unless server begin eip.server = server puts "Associated EIP: #{[:eip]} with Instance: #{[:instance_id]}" rescue Fog::Compute::AWS::Error abort "Error: #{$!}" end end |
#create ⇒ Object
365 366 367 368 |
# File 'lib/awscli/ec2.rb', line 365 def create eip = @conn.addresses.create puts "Created EIP: #{eip.public_ip}" end |
#delete(options) ⇒ Object
370 371 372 373 374 375 376 |
# File 'lib/awscli/ec2.rb', line 370 def delete() abort "Invalid IP Format" unless [:eip] =~ /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/ eip = @conn.addresses.get([:eip]) abort "Cannot find IP: #{[:eip]}" unless eip eip.destroy puts "Deleted EIP: #{eip.public_ip}" end |
#disassociate(options) ⇒ Object
392 393 394 395 396 397 |
# File 'lib/awscli/ec2.rb', line 392 def disassociate() abort "Invalid IP Format" unless [:eip] =~ /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/ abort "Cannot find EIP: #{[:eip]}" unless @conn.addresses.get([:eip]) @conn.disassociate_address([:eip]) puts "Disassociated EIP: #{[:eip]}" end |
#list ⇒ Object
361 362 363 |
# File 'lib/awscli/ec2.rb', line 361 def list @conn.addresses.table end |