Class: EcsCmd::Services
- Inherits:
-
Object
- Object
- EcsCmd::Services
- Defined in:
- lib/ecs_cmd/services.rb
Instance Method Summary collapse
- #get_services(cluster) ⇒ Object
-
#initialize(region) ⇒ Services
constructor
A new instance of Services.
- #list_services(cluster, reg = @reg) ⇒ Object
Constructor Details
#initialize(region) ⇒ Services
Returns a new instance of Services.
6 7 8 9 |
# File 'lib/ecs_cmd/services.rb', line 6 def initialize(region) @client = Aws::ECS::Client.new(region: region) @reg = region end |
Instance Method Details
#get_services(cluster) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ecs_cmd/services.rb', line 11 def get_services(cluster) @service_arns = [] @client.list_services(cluster: cluster).each do |r| @service_arns << r[0] @service_arns.flatten! end @service_arns end |
#list_services(cluster, reg = @reg) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ecs_cmd/services.rb', line 20 def list_services(cluster, reg = @reg) @service_list = get_services(cluster) rows = [] @service_list.map do |service| service_name = service.split('/')[1] 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 |