Class: Cliaws::Cli::Ec2

Inherits:
Thor
  • Object
show all
Defined in:
lib/cliaws/cli/ec2.rb

Instance Method Summary collapse

Instance Method Details

#allocate_addressObject



52
53
54
55
# File 'lib/cliaws/cli/ec2.rb', line 52

def allocate_address
  address = Cliaws.ec2.allocate_address
  puts "Allocated: #{address}"
end

#associate_addressObject



71
72
73
74
75
76
# File 'lib/cliaws/cli/ec2.rb', line 71

def associate_address
  address  = options[:address]
  instance = options[:instance]
  Cliaws.ec2.associate_address(:address => address, :instance => instance)
  puts "Associated:\n  #{instance}: #{address.inspect}"
end

#deallocate_address(address) ⇒ Object



61
62
63
64
# File 'lib/cliaws/cli/ec2.rb', line 61

def deallocate_address(address)
  Cliaws.ec2.deallocate_address(address)
  puts "Deallocated: #{address}"
end

#describe_addressesObject



92
93
94
# File 'lib/cliaws/cli/ec2.rb', line 92

def describe_addresses
  puts Cliaws.ec2.describe_addresses.to_yaml
end

#disassociate_address(address) ⇒ Object



82
83
84
85
86
# File 'lib/cliaws/cli/ec2.rb', line 82

def disassociate_address(address)
  address = options[:address]
  Cliaws.ec2.disassociate_address(address)
  puts "Disassociated: #{address}"
end

#listObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cliaws/cli/ec2.rb', line 14

def list
  instances = Cliaws.ec2.list
  if options[:yaml] then
    puts instances.map {|i| i.raw_data}.to_yaml
  else
    printf "%-10s %-50s %-12s %s\n", "ID", "DNS Name", "State", "Groups"
    printf "-"*120
    print "\n"
    instances.each do |instance|
      printf "%-10s %-50s %-12s %s\n", instance.instance_id, instance.public_dns_name, instance.state, instance.groups.join(", ")
    end
  end
end

#run(ami) ⇒ Object



33
34
35
36
37
# File 'lib/cliaws/cli/ec2.rb', line 33

def run(ami)
  instances = Cliaws.ec2.run(ami, :type => options[:type], :count => options[:count], :keypair => options[:keypair], :groups => options[:group])
  result = {"Started" => instances.map {|i| i.instance_id}}
  puts result.to_yaml
end

#terminate(*instance_ids) ⇒ Object



42
43
44
45
46
# File 'lib/cliaws/cli/ec2.rb', line 42

def terminate(*instance_ids)
  instances = Cliaws.ec2.terminate(instance_ids)
  result = {"Terminating" => instances.map {|i| i.instance_id}}
  puts result.to_yaml
end