contexto 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/contexto/contextualize.rb +33 -29
- data/lib/contexto/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de77f650841b467399bee6dbf2d29a5696109e56
|
4
|
+
data.tar.gz: 828dd1907ca53b14b6a157993f60e7c4ca2582f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89c7a8bd03f7354bdebe06e4160801f19984ed5ff55da37366287733ce8f74f2241a7d6e0410c0c8709c3484ad02525427d48d173fc7914e4391dce37156bacf
|
7
|
+
data.tar.gz: 041afed7733f84b832d593498cacce3bc7ae833f93d8c8e5e7c70ba4a44c4759328109f425fb5419801b6b5f55520d6a062e50b0cdd96cd682a0e406d5825ed5
|
@@ -4,7 +4,7 @@ require 'aws-sdk'
|
|
4
4
|
module Contexto
|
5
5
|
# ECS class
|
6
6
|
class Contextualize
|
7
|
-
attr_reader :display, :cluster, :service
|
7
|
+
attr_reader :display, :cluster, :service, :container, :console, :rake
|
8
8
|
|
9
9
|
def initialize(params = {})
|
10
10
|
@cluster = params.fetch(:cluster) if params[:cluster]
|
@@ -16,37 +16,41 @@ module Contexto
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
-
if
|
19
|
+
if ssh?
|
20
20
|
task = describe_tasks
|
21
21
|
ec2_instance_id = describe_container_instance(task[:container_instance_arn])
|
22
|
-
@ssh = Contexto::SSH.new(describe_instances(ec2_instance_id),
|
23
|
-
if
|
22
|
+
@ssh = Contexto::SSH.new(describe_instances(ec2_instance_id), cluster, service, container)
|
23
|
+
if console
|
24
24
|
@ssh.console
|
25
|
-
elsif
|
26
|
-
@ssh.rake(
|
25
|
+
elsif rake
|
26
|
+
@ssh.rake(rake)
|
27
27
|
end
|
28
28
|
return
|
29
29
|
end
|
30
|
-
if
|
31
|
-
|
30
|
+
if !cluster
|
31
|
+
show_clusters
|
32
32
|
return
|
33
33
|
end
|
34
|
-
|
34
|
+
show_cluster
|
35
35
|
puts "\n"
|
36
|
-
if
|
37
|
-
|
36
|
+
if !service
|
37
|
+
show_services
|
38
38
|
end
|
39
|
-
if
|
39
|
+
if service
|
40
40
|
puts "\n"
|
41
|
-
|
41
|
+
show_service
|
42
42
|
puts "\n"
|
43
|
-
|
43
|
+
show_tasks
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def
|
49
|
+
def ssh?
|
50
|
+
(console || rake)
|
51
|
+
end
|
52
|
+
|
53
|
+
def show_clusters
|
50
54
|
title = "Clusters"
|
51
55
|
headings = %w(Name)
|
52
56
|
clusters = list_clusters
|
@@ -57,8 +61,8 @@ module Contexto
|
|
57
61
|
@display.create_display(title, headings, rows)
|
58
62
|
end
|
59
63
|
|
60
|
-
def
|
61
|
-
title = "Cluster #{
|
64
|
+
def show_cluster
|
65
|
+
title = "Cluster #{cluster}"
|
62
66
|
headings = %w(Name Status Instances Services RunningTasks PendingTasks)
|
63
67
|
cluster = describe_clusters
|
64
68
|
rows = []
|
@@ -66,7 +70,7 @@ module Contexto
|
|
66
70
|
@display.create_display(title, headings, rows)
|
67
71
|
end
|
68
72
|
|
69
|
-
def
|
73
|
+
def show_services
|
70
74
|
title = "Services"
|
71
75
|
headings = %w(Name)
|
72
76
|
services = list_services
|
@@ -77,8 +81,8 @@ module Contexto
|
|
77
81
|
@display.create_display(title, headings, rows)
|
78
82
|
end
|
79
83
|
|
80
|
-
def
|
81
|
-
title = "Service #{
|
84
|
+
def show_service
|
85
|
+
title = "Service #{service}"
|
82
86
|
headings = %w(Name Status Desired Running Pending)
|
83
87
|
service = describe_services
|
84
88
|
rows = []
|
@@ -88,7 +92,7 @@ module Contexto
|
|
88
92
|
puts 'Service not found'
|
89
93
|
end
|
90
94
|
|
91
|
-
def
|
95
|
+
def show_tasks
|
92
96
|
task = describe_tasks
|
93
97
|
containers = task[:containers]
|
94
98
|
ec2_instance_id = describe_container_instance(task[:container_instance_arn])
|
@@ -109,7 +113,7 @@ module Contexto
|
|
109
113
|
def describe_clusters
|
110
114
|
resp = ecs_client.describe_clusters(
|
111
115
|
clusters: [
|
112
|
-
|
116
|
+
cluster
|
113
117
|
]
|
114
118
|
)
|
115
119
|
resp.clusters[0].to_h
|
@@ -117,16 +121,16 @@ module Contexto
|
|
117
121
|
|
118
122
|
def list_services
|
119
123
|
resp = ecs_client.list_services(
|
120
|
-
cluster:
|
124
|
+
cluster: cluster
|
121
125
|
)
|
122
126
|
resp.service_arns
|
123
127
|
end
|
124
128
|
|
125
129
|
def describe_services
|
126
130
|
resp = ecs_client.describe_services(
|
127
|
-
cluster:
|
131
|
+
cluster: cluster,
|
128
132
|
services: [
|
129
|
-
|
133
|
+
service
|
130
134
|
]
|
131
135
|
)
|
132
136
|
resp.services[0].to_h
|
@@ -134,7 +138,7 @@ module Contexto
|
|
134
138
|
|
135
139
|
def describe_tasks
|
136
140
|
resp = ecs_client.describe_tasks(
|
137
|
-
cluster:
|
141
|
+
cluster: cluster,
|
138
142
|
tasks: [task_arn]
|
139
143
|
)
|
140
144
|
resp.tasks[0].to_h
|
@@ -142,15 +146,15 @@ module Contexto
|
|
142
146
|
|
143
147
|
def task_arn
|
144
148
|
resp = ecs_client.list_tasks(
|
145
|
-
cluster:
|
146
|
-
service_name:
|
149
|
+
cluster: cluster,
|
150
|
+
service_name: service
|
147
151
|
)
|
148
152
|
resp.task_arns[0]
|
149
153
|
end
|
150
154
|
|
151
155
|
def describe_container_instance(container_instance_arn)
|
152
156
|
resp = ecs_client.describe_container_instances(
|
153
|
-
cluster:
|
157
|
+
cluster: cluster,
|
154
158
|
container_instances: [
|
155
159
|
container_instance_arn
|
156
160
|
]
|
data/lib/contexto/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contexto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Turnbull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|