Class: EcsCmd::Clusters
- Inherits:
-
Object
- Object
- EcsCmd::Clusters
- Defined in:
- lib/ecs_cmd/clusters.rb
Instance Method Summary collapse
- #cluster_names ⇒ Object
- #get_clusters ⇒ Object
- #get_container_instance_count(stats) ⇒ Object
- #get_pending_task_count(stats) ⇒ Object
- #get_running_task_count(stats) ⇒ Object
- #get_service_count(stats) ⇒ Object
-
#initialize(region) ⇒ Clusters
constructor
A new instance of Clusters.
- #list_clusters ⇒ Object
Constructor Details
#initialize(region) ⇒ Clusters
Returns a new instance of Clusters.
6 7 8 |
# File 'lib/ecs_cmd/clusters.rb', line 6 def initialize(region) @client = Aws::ECS::Client.new(region: region) end |
Instance Method Details
#cluster_names ⇒ Object
30 31 32 |
# File 'lib/ecs_cmd/clusters.rb', line 30 def cluster_names get_clusters[0] end |
#get_clusters ⇒ Object
10 11 12 |
# File 'lib/ecs_cmd/clusters.rb', line 10 def get_clusters @cluster_arns = @client.list_clusters end |
#get_container_instance_count(stats) ⇒ Object
14 15 16 |
# File 'lib/ecs_cmd/clusters.rb', line 14 def get_container_instance_count(stats) stats['registered_container_instances_count'] end |
#get_pending_task_count(stats) ⇒ Object
26 27 28 |
# File 'lib/ecs_cmd/clusters.rb', line 26 def get_pending_task_count(stats) stats['pending_tasks_count'] end |
#get_running_task_count(stats) ⇒ Object
22 23 24 |
# File 'lib/ecs_cmd/clusters.rb', line 22 def get_running_task_count(stats) stats['running_tasks_count'] end |
#get_service_count(stats) ⇒ Object
18 19 20 |
# File 'lib/ecs_cmd/clusters.rb', line 18 def get_service_count(stats) stats['active_services_count'] end |
#list_clusters ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ecs_cmd/clusters.rb', line 34 def list_clusters rows = [] cluster_names.map do |c| cluster_name = c.split('/')[1] stats = @client.describe_clusters(clusters: [cluster_name])[0][0] rows << [cluster_name, get_container_instance_count(stats), get_service_count(stats), get_running_task_count(stats), get_pending_task_count(stats)] end table = Terminal::Table.new headings: ['CLUSTER NAME', 'CONTAINER_INSTANCE_COUNT', 'SERVICES', 'RUNNING_TASKS', 'PENDING_TASKS'], rows: rows puts table end |