Class: Awshark::Ec2::Subcommand

Inherits:
Thor
  • Object
show all
Includes:
ClassOptions
Defined in:
lib/awshark/ec2/subcommand.rb

Instance Method Summary collapse

Methods included from ClassOptions

#process_class_options

Instance Method Details

#authorizeObject



54
55
56
57
58
59
# File 'lib/awshark/ec2/subcommand.rb', line 54

def authorize
  process_class_options

  group = Ec2::SecurityGroup.new(id: security_group_id, username: username)
  group.authorize(ip: my_ip, ports: ports)
end

#list(state = 'running') ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/awshark/ec2/subcommand.rb', line 23

def list(state = 'running')
  process_class_options

  instances = manager.public_send("#{state}_instances")
  instances = instances.sort_by(&:name)

  instances.each do |i|
    args = { name: i.name, type: i.type, public_dns: i.public_dns_name, state: i.state }
    printf "%-40<name>s %-12<type>s %-60<public_dns>s %<state>s\n", args
  end
end

#unauthorizeObject



76
77
78
79
80
81
# File 'lib/awshark/ec2/subcommand.rb', line 76

def unauthorize
  process_class_options

  group = Ec2::SecurityGroup.new(id: security_group_id, username: username)
  group.unauthorize
end