Class: EcsCmd::Services
- Inherits:
-
Object
- Object
- EcsCmd::Services
- Defined in:
- lib/ecs_cmd/services.rb
Instance Method Summary collapse
- #get_services ⇒ Object
-
#initialize(region, cluster) ⇒ Services
constructor
A new instance of Services.
- #list_services ⇒ Object
Constructor Details
#initialize(region, cluster) ⇒ Services
Returns a new instance of Services.
6 7 8 9 10 |
# File 'lib/ecs_cmd/services.rb', line 6 def initialize(region, cluster) @client = Aws::ECS::Client.new(region: region) @reg = region @cluster = cluster end |
Instance Method Details
#get_services ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ecs_cmd/services.rb', line 12 def get_services @service_arns = [] @client.list_services(cluster: @cluster).each do |r| @service_arns << r[0] @service_arns.flatten! end @service_arns end |
#list_services ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ecs_cmd/services.rb', line 21 def list_services @service_list = get_services rows = [] @service_list.map do |service| service_name = service.split(%r{/}).last serv = EcsCmd::Service.new(@cluster, service_name, @reg) rows << [service_name, serv.desired_count, serv.running_count, serv.pending_count] end table = Terminal::Table.new headings: ['SERVICE NAME', 'DESIRED_COUNT', 'RUNNING_COUNT', 'PENDING_COUNT'], rows: rows puts table end |