Class: Awshark::Ecs::Manager
- Inherits:
-
Object
- Object
- Awshark::Ecs::Manager
- Defined in:
- lib/awshark/ecs/manager.rb
Instance Method Summary collapse
- #clusters ⇒ Object
- #inspect_cluster(cluster) ⇒ Object
- #inspect_container(container) ⇒ Object
- #inspect_service(service) ⇒ Object
- #inspect_task(task) ⇒ Object
- #task_definition(family) ⇒ Object
Instance Method Details
#clusters ⇒ Object
6 7 8 9 |
# File 'lib/awshark/ecs/manager.rb', line 6 def clusters response = client.list_clusters response.cluster_arns.map { |arn| Ecs::Cluster.new(arn) } end |
#inspect_cluster(cluster) ⇒ Object
11 12 13 14 |
# File 'lib/awshark/ecs/manager.rb', line 11 def inspect_cluster(cluster) args = { name: cluster.name, services: cluster.services.size, tasks: cluster.tasks.size } format("Cluster: %-20<name>s %<services>s services %<tasks>s tasks\n", args) end |
#inspect_container(container) ⇒ Object
19 20 21 22 |
# File 'lib/awshark/ecs/manager.rb', line 19 def inspect_container(container) args = { name: container.name, health: container.health_status, status: container.last_status } format("- %-15<name>s status: %<status>s\n", args) end |
#inspect_service(service) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/awshark/ecs/manager.rb', line 27 def inspect_service(service) task = task_definition(service.task_definition) lines = [] args = { name: service.service_name, status: service.status, running: service.running_count, cpu: "#{task.cpu}MB", memory: "#{task.memory}MB" } lines << format('Service: %-30<name>s status: %-8<status>s running: %-4<running>s ' \ "cpu: %-8<cpu>s mem: %<memory>s\n", args) task.container_definitions.each do |c| lines << format("- %-15<name>s\n", name: c.name) end lines.join end |
#inspect_task(task) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/awshark/ecs/manager.rb', line 50 def inspect_task(task) lines = [] args = { type: task.launch_type, cpu: "#{task.cpu} MB", memory: "#{task.memory} MB" } lines << format("Task: %-20<type>s cpu: %-10<cpu>s memory: %<memory>s\n", args) task.containers.each { |c| lines << inspect_container(c) } lines.join end |
#task_definition(family) ⇒ Object
61 62 63 64 |
# File 'lib/awshark/ecs/manager.rb', line 61 def task_definition(family) response = client.describe_task_definition(task_definition: family) response.task_definition end |