aptible-cli 0.24.1 → 0.24.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +16 -1
- data/Gemfile.lock +1 -1
- data/lib/aptible/cli/agent.rb +9 -1
- data/lib/aptible/cli/helpers/app.rb +16 -1
- data/lib/aptible/cli/helpers/database.rb +20 -5
- data/lib/aptible/cli/helpers/environment.rb +28 -3
- data/lib/aptible/cli/helpers/operation.rb +11 -4
- data/lib/aptible/cli/helpers/telemetry.rb +58 -0
- data/lib/aptible/cli/helpers/token.rb +6 -0
- data/lib/aptible/cli/renderer.rb +5 -1
- data/lib/aptible/cli/resource_formatter.rb +7 -0
- data/lib/aptible/cli/subcommands/apps.rb +31 -2
- data/lib/aptible/cli/subcommands/backup.rb +9 -0
- data/lib/aptible/cli/subcommands/backup_retention_policy.rb +5 -0
- data/lib/aptible/cli/subcommands/config.rb +11 -0
- data/lib/aptible/cli/subcommands/db.rb +68 -3
- data/lib/aptible/cli/subcommands/deploy.rb +3 -0
- data/lib/aptible/cli/subcommands/endpoints.rb +26 -0
- data/lib/aptible/cli/subcommands/environment.rb +11 -0
- data/lib/aptible/cli/subcommands/log_drain.rb +26 -5
- data/lib/aptible/cli/subcommands/logs.rb +5 -0
- data/lib/aptible/cli/subcommands/maintenance.rb +5 -0
- data/lib/aptible/cli/subcommands/metric_drain.rb +25 -5
- data/lib/aptible/cli/subcommands/operation.rb +7 -0
- data/lib/aptible/cli/subcommands/rebuild.rb +3 -0
- data/lib/aptible/cli/subcommands/restart.rb +3 -0
- data/lib/aptible/cli/subcommands/services.rb +12 -3
- data/lib/aptible/cli/subcommands/ssh.rb +3 -0
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/subcommands/apps_spec.rb +13 -1
- data/spec/aptible/cli/subcommands/config_spec.rb +4 -2
- data/spec/aptible/cli/subcommands/db_spec.rb +7 -1
- data/spec/aptible/cli/subcommands/endpoints_spec.rb +9 -3
- data/spec/aptible/cli/subcommands/environment_spec.rb +3 -1
- data/spec/aptible/cli/subcommands/log_drain_spec.rb +15 -2
- data/spec/aptible/cli/subcommands/maintenance_spec.rb +3 -2
- data/spec/aptible/cli/subcommands/metric_drain_spec.rb +15 -2
- data/spec/aptible/cli/subcommands/operation_spec.rb +4 -2
- data/spec/aptible/cli/subcommands/services_spec.rb +3 -1
- data/spec/fabricators/account_fabricator.rb +8 -0
- data/spec/fabricators/app_fabricator.rb +9 -0
- data/spec/fabricators/database_fabricator.rb +8 -0
- data/spec/fabricators/log_drain_fabricator.rb +8 -0
- data/spec/fabricators/metric_drain_fabricator.rb +8 -0
- data/spec/spec_helper.rb +9 -1
- metadata +6 -5
@@ -12,19 +12,40 @@ module Aptible
|
|
12
12
|
include Helpers::Database
|
13
13
|
include Helpers::Token
|
14
14
|
include Term::ANSIColor
|
15
|
+
include Helpers::Telemetry
|
15
16
|
|
16
17
|
desc 'db:list', 'List all databases'
|
17
18
|
option :environment, aliases: '--env'
|
18
19
|
define_method 'db:list' do
|
20
|
+
telemetry(__method__, options)
|
21
|
+
|
19
22
|
Formatter.render(Renderer.current) do |root|
|
20
23
|
root.grouped_keyed_list(
|
21
24
|
{ 'environment' => 'handle' },
|
22
25
|
'handle'
|
23
26
|
) do |node|
|
24
|
-
scoped_environments(options)
|
25
|
-
|
27
|
+
accounts = scoped_environments(options)
|
28
|
+
acc_map = environment_map(accounts)
|
29
|
+
|
30
|
+
if Renderer.format == 'json'
|
31
|
+
accounts.each do |account|
|
32
|
+
account.each_database do |db|
|
33
|
+
node.object do |n|
|
34
|
+
ResourceFormatter.inject_database(n, db, account)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
databases_all.each do |db|
|
40
|
+
account = acc_map[db.links.account.href]
|
41
|
+
next if account.nil?
|
42
|
+
|
26
43
|
node.object do |n|
|
27
|
-
ResourceFormatter.
|
44
|
+
ResourceFormatter.inject_database_minimal(
|
45
|
+
n,
|
46
|
+
db,
|
47
|
+
account
|
48
|
+
)
|
28
49
|
end
|
29
50
|
end
|
30
51
|
end
|
@@ -34,6 +55,8 @@ module Aptible
|
|
34
55
|
|
35
56
|
desc 'db:versions', 'List available database versions'
|
36
57
|
define_method 'db:versions' do
|
58
|
+
telemetry(__method__, options)
|
59
|
+
|
37
60
|
Formatter.render(Renderer.current) do |root|
|
38
61
|
root.grouped_keyed_list('type', 'version') do |node|
|
39
62
|
Aptible::Api::DatabaseImage.all(
|
@@ -68,6 +91,8 @@ module Aptible
|
|
68
91
|
desc: 'Examples: m c r'
|
69
92
|
option :iops, type: :numeric
|
70
93
|
define_method 'db:create' do |handle|
|
94
|
+
telemetry(__method__, options.merge(handle: handle))
|
95
|
+
|
71
96
|
account = ensure_environment(options)
|
72
97
|
|
73
98
|
db_opts = {
|
@@ -128,6 +153,12 @@ module Aptible
|
|
128
153
|
desc 'db:clone SOURCE DEST', 'Clone a database to create a new one'
|
129
154
|
option :environment, aliases: '--env'
|
130
155
|
define_method 'db:clone' do |source_handle, dest_handle|
|
156
|
+
opts = options.merge(
|
157
|
+
source_handle: source_handle,
|
158
|
+
dest_handle: dest_handle
|
159
|
+
)
|
160
|
+
telemetry(__method__, opts)
|
161
|
+
|
131
162
|
# TODO: Deprecate + recommend backup
|
132
163
|
source = ensure_database(options.merge(db: source_handle))
|
133
164
|
database = clone_database(source, dest_handle)
|
@@ -150,6 +181,12 @@ module Aptible
|
|
150
181
|
desc: 'Examples: m c r'
|
151
182
|
option :iops, type: :numeric
|
152
183
|
define_method 'db:replicate' do |source_handle, dest_handle|
|
184
|
+
opts = options.merge(
|
185
|
+
source_handle: source_handle,
|
186
|
+
dest_handle: dest_handle
|
187
|
+
)
|
188
|
+
telemetry(__method__, opts)
|
189
|
+
|
153
190
|
source = ensure_database(options.merge(db: source_handle))
|
154
191
|
|
155
192
|
if options[:logical]
|
@@ -193,6 +230,8 @@ module Aptible
|
|
193
230
|
'Dump a remote database to file'
|
194
231
|
option :environment, aliases: '--env'
|
195
232
|
define_method 'db:dump' do |handle, *dump_options|
|
233
|
+
telemetry(__method__, options.merge(handle: handle))
|
234
|
+
|
196
235
|
database = ensure_database(options.merge(db: handle))
|
197
236
|
with_postgres_tunnel(database) do |url|
|
198
237
|
filename = "#{handle}.dump"
|
@@ -207,6 +246,12 @@ module Aptible
|
|
207
246
|
option :environment, aliases: '--env'
|
208
247
|
option :on_error_stop, type: :boolean
|
209
248
|
define_method 'db:execute' do |handle, sql_path|
|
249
|
+
opts = options.merge(
|
250
|
+
handle: handle,
|
251
|
+
sql_path: sql_path
|
252
|
+
)
|
253
|
+
telemetry(__method__, opts)
|
254
|
+
|
210
255
|
database = ensure_database(options.merge(db: handle))
|
211
256
|
with_postgres_tunnel(database) do |url|
|
212
257
|
CLI.logger.info "Executing #{sql_path} against #{handle}"
|
@@ -221,6 +266,8 @@ module Aptible
|
|
221
266
|
option :port, type: :numeric
|
222
267
|
option :type, type: :string
|
223
268
|
define_method 'db:tunnel' do |handle|
|
269
|
+
telemetry(__method__, options.merge(handle: handle))
|
270
|
+
|
224
271
|
desired_port = Integer(options[:port] || 0)
|
225
272
|
database = ensure_database(options.merge(db: handle))
|
226
273
|
|
@@ -264,6 +311,8 @@ module Aptible
|
|
264
311
|
desc 'db:deprovision HANDLE', 'Deprovision a database'
|
265
312
|
option :environment, aliases: '--env'
|
266
313
|
define_method 'db:deprovision' do |handle|
|
314
|
+
telemetry(__method__, options.merge(handle: handle))
|
315
|
+
|
267
316
|
database = ensure_database(options.merge(db: handle))
|
268
317
|
CLI.logger.info "Deprovisioning #{database.handle}..."
|
269
318
|
op = database.create_operation!(type: 'deprovision')
|
@@ -280,6 +329,8 @@ module Aptible
|
|
280
329
|
desc 'db:backup HANDLE', 'Backup a database'
|
281
330
|
option :environment, aliases: '--env'
|
282
331
|
define_method 'db:backup' do |handle|
|
332
|
+
telemetry(__method__, options.merge(handle: handle))
|
333
|
+
|
283
334
|
database = ensure_database(options.merge(db: handle))
|
284
335
|
CLI.logger.info "Backing up #{database.handle}..."
|
285
336
|
op = database.create_operation!(type: 'backup')
|
@@ -289,6 +340,8 @@ module Aptible
|
|
289
340
|
desc 'db:reload HANDLE', 'Reload a database'
|
290
341
|
option :environment, aliases: '--env'
|
291
342
|
define_method 'db:reload' do |handle|
|
343
|
+
telemetry(__method__, options.merge(handle: handle))
|
344
|
+
|
292
345
|
database = ensure_database(options.merge(db: handle))
|
293
346
|
CLI.logger.info "Reloading #{database.handle}..."
|
294
347
|
op = database.create_operation!(type: 'reload')
|
@@ -309,6 +362,8 @@ module Aptible
|
|
309
362
|
option :iops, type: :numeric
|
310
363
|
option :volume_type
|
311
364
|
define_method 'db:restart' do |handle|
|
365
|
+
telemetry(__method__, options.merge(handle: handle))
|
366
|
+
|
312
367
|
database = ensure_database(options.merge(db: handle))
|
313
368
|
|
314
369
|
opts = {
|
@@ -339,6 +394,8 @@ module Aptible
|
|
339
394
|
option :iops, type: :numeric
|
340
395
|
option :volume_type
|
341
396
|
define_method 'db:modify' do |handle|
|
397
|
+
telemetry(__method__, options.merge(handle: handle))
|
398
|
+
|
342
399
|
database = ensure_database(options.merge(db: handle))
|
343
400
|
|
344
401
|
opts = {
|
@@ -357,6 +414,8 @@ module Aptible
|
|
357
414
|
option :environment, aliases: '--env'
|
358
415
|
option :type, type: :string
|
359
416
|
define_method 'db:url' do |handle|
|
417
|
+
telemetry(__method__, options.merge(handle: handle))
|
418
|
+
|
360
419
|
database = ensure_database(options.merge(db: handle))
|
361
420
|
credential = find_credential(database, options[:type])
|
362
421
|
|
@@ -373,6 +432,12 @@ module Aptible
|
|
373
432
|
' metric drain destinations, you must reload the database.'
|
374
433
|
option :environment, aliases: '--env'
|
375
434
|
define_method 'db:rename' do |old_handle, new_handle|
|
435
|
+
opts = options.merge(
|
436
|
+
old_handle: old_handle,
|
437
|
+
new_handle: new_handle
|
438
|
+
)
|
439
|
+
telemetry(__method__, opts)
|
440
|
+
|
376
441
|
env = ensure_environment(options)
|
377
442
|
db = ensure_database(options.merge(db: old_handle))
|
378
443
|
db.update!(handle: new_handle)
|
@@ -18,6 +18,7 @@ module Aptible
|
|
18
18
|
thor.class_eval do
|
19
19
|
include Helpers::Operation
|
20
20
|
include Helpers::App
|
21
|
+
include Helpers::Telemetry
|
21
22
|
|
22
23
|
desc 'deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...]',
|
23
24
|
'Deploy an app'
|
@@ -46,6 +47,8 @@ module Aptible
|
|
46
47
|
end
|
47
48
|
app_options
|
48
49
|
def deploy(*args)
|
50
|
+
telemetry(__method__, options)
|
51
|
+
|
49
52
|
app = ensure_app(options)
|
50
53
|
|
51
54
|
git_ref = options[:git_commitish]
|
@@ -10,6 +10,7 @@ module Aptible
|
|
10
10
|
include Helpers::Operation
|
11
11
|
include Helpers::AppOrDatabase
|
12
12
|
include Helpers::Vhost
|
13
|
+
include Helpers::Telemetry
|
13
14
|
|
14
15
|
database_create_flags = Helpers::Vhost::OptionSetBuilder.new do
|
15
16
|
create!
|
@@ -20,6 +21,8 @@ module Aptible
|
|
20
21
|
'Create a Database Endpoint'
|
21
22
|
database_create_flags.declare_options(self)
|
22
23
|
define_method 'endpoints:database:create' do |handle|
|
24
|
+
telemetry(__method__, options.merge(handle: handle))
|
25
|
+
|
23
26
|
database = ensure_database(options.merge(db: handle))
|
24
27
|
service = database.service
|
25
28
|
raise Thor::Error, 'Database is not provisioned' if service.nil?
|
@@ -42,6 +45,8 @@ module Aptible
|
|
42
45
|
'Modify a Database Endpoint'
|
43
46
|
database_modify_flags.declare_options(self)
|
44
47
|
define_method 'endpoints:database:modify' do |hostname|
|
48
|
+
telemetry(__method__, options.merge(hostname: hostname))
|
49
|
+
|
45
50
|
database = ensure_database(options.merge(db: options[:database]))
|
46
51
|
vhost = find_vhost(each_service(database), hostname)
|
47
52
|
vhost.update!(**database_modify_flags.prepare(database.account,
|
@@ -59,6 +64,8 @@ module Aptible
|
|
59
64
|
'Create an App TCP Endpoint'
|
60
65
|
tcp_create_flags.declare_options(self)
|
61
66
|
define_method 'endpoints:tcp:create' do |type|
|
67
|
+
telemetry(__method__, options.merge(type: type))
|
68
|
+
|
62
69
|
create_app_vhost(
|
63
70
|
tcp_create_flags, options, type,
|
64
71
|
type: 'tcp', platform: 'elb'
|
@@ -74,6 +81,8 @@ module Aptible
|
|
74
81
|
'Modify an App TCP Endpoint'
|
75
82
|
tcp_modify_flags.declare_options(self)
|
76
83
|
define_method 'endpoints:tcp:modify' do |hostname|
|
84
|
+
telemetry(__method__, options.merge(hostname: hostname))
|
85
|
+
|
77
86
|
modify_app_vhost(tcp_modify_flags, options, hostname)
|
78
87
|
end
|
79
88
|
|
@@ -88,6 +97,8 @@ module Aptible
|
|
88
97
|
'Create an App TLS Endpoint'
|
89
98
|
tls_create_flags.declare_options(self)
|
90
99
|
define_method 'endpoints:tls:create' do |type|
|
100
|
+
telemetry(__method__, options.merge(type: type))
|
101
|
+
|
91
102
|
create_app_vhost(
|
92
103
|
tls_create_flags, options, type,
|
93
104
|
type: 'tls', platform: 'elb'
|
@@ -104,6 +115,8 @@ module Aptible
|
|
104
115
|
'Modify an App TLS Endpoint'
|
105
116
|
tls_modify_flags.declare_options(self)
|
106
117
|
define_method 'endpoints:tls:modify' do |hostname|
|
118
|
+
telemetry(__method__, options.merge(hostname: hostname))
|
119
|
+
|
107
120
|
modify_app_vhost(tls_modify_flags, options, hostname)
|
108
121
|
end
|
109
122
|
|
@@ -118,6 +131,8 @@ module Aptible
|
|
118
131
|
'Create an App gRPC Endpoint'
|
119
132
|
grpc_create_flags.declare_options(self)
|
120
133
|
define_method 'endpoints:grpc:create' do |type|
|
134
|
+
telemetry(__method__, options.merge(type: type))
|
135
|
+
|
121
136
|
create_app_vhost(
|
122
137
|
grpc_create_flags, options, type,
|
123
138
|
type: 'grpc', platform: 'elb'
|
@@ -134,6 +149,8 @@ module Aptible
|
|
134
149
|
'Modify an App gRPC Endpoint'
|
135
150
|
grpc_modify_flags.declare_options(self)
|
136
151
|
define_method 'endpoints:grpc:modify' do |hostname|
|
152
|
+
telemetry(__method__, options.merge(hostname: hostname))
|
153
|
+
|
137
154
|
modify_app_vhost(grpc_modify_flags, options, hostname)
|
138
155
|
end
|
139
156
|
|
@@ -148,6 +165,8 @@ module Aptible
|
|
148
165
|
'Create an App HTTPS Endpoint'
|
149
166
|
https_create_flags.declare_options(self)
|
150
167
|
define_method 'endpoints:https:create' do |type|
|
168
|
+
telemetry(__method__, options.merge(type: type))
|
169
|
+
|
151
170
|
create_app_vhost(
|
152
171
|
https_create_flags, options, type,
|
153
172
|
type: 'http', platform: 'alb'
|
@@ -164,6 +183,7 @@ module Aptible
|
|
164
183
|
'Modify an App HTTPS Endpoint'
|
165
184
|
https_modify_flags.declare_options(self)
|
166
185
|
define_method 'endpoints:https:modify' do |hostname|
|
186
|
+
telemetry(__method__, options.merge(hostname: hostname))
|
167
187
|
modify_app_vhost(https_modify_flags, options, hostname)
|
168
188
|
end
|
169
189
|
|
@@ -171,6 +191,8 @@ module Aptible
|
|
171
191
|
'List Endpoints for an App or Database'
|
172
192
|
app_or_database_options
|
173
193
|
define_method 'endpoints:list' do
|
194
|
+
telemetry(__method__, options)
|
195
|
+
|
174
196
|
resource = ensure_app_or_database(options)
|
175
197
|
|
176
198
|
Formatter.render(Renderer.current) do |root|
|
@@ -191,6 +213,8 @@ module Aptible
|
|
191
213
|
'Deprovision an App or Database Endpoint'
|
192
214
|
app_or_database_options
|
193
215
|
define_method 'endpoints:deprovision' do |hostname|
|
216
|
+
telemetry(__method__, options.merge(hostname: hostname))
|
217
|
+
|
194
218
|
resource = ensure_app_or_database(options)
|
195
219
|
vhost = find_vhost(each_service(resource), hostname)
|
196
220
|
op = vhost.create_operation!(type: 'deprovision')
|
@@ -209,6 +233,8 @@ module Aptible
|
|
209
233
|
LONGDESC
|
210
234
|
app_options
|
211
235
|
define_method 'endpoints:renew' do |hostname|
|
236
|
+
telemetry(__method__, options.merge(hostname: hostname))
|
237
|
+
|
212
238
|
app = ensure_app(options)
|
213
239
|
vhost = find_vhost(app.each_service, hostname)
|
214
240
|
op = vhost.create_operation!(type: 'renew')
|
@@ -6,10 +6,13 @@ module Aptible
|
|
6
6
|
thor.class_eval do
|
7
7
|
include Helpers::Environment
|
8
8
|
include Helpers::Token
|
9
|
+
include Helpers::Telemetry
|
9
10
|
|
10
11
|
desc 'environment:list', 'List all environments'
|
11
12
|
option :environment, aliases: '--env'
|
12
13
|
define_method 'environment:list' do
|
14
|
+
telemetry(__method__, options)
|
15
|
+
|
13
16
|
Formatter.render(Renderer.current) do |root|
|
14
17
|
root.keyed_list(
|
15
18
|
'handle'
|
@@ -27,6 +30,8 @@ module Aptible
|
|
27
30
|
'Retrieve the CA certificate associated with the environment'
|
28
31
|
option :environment, aliases: '--env'
|
29
32
|
define_method 'environment:ca_cert' do
|
33
|
+
telemetry(__method__, options)
|
34
|
+
|
30
35
|
Formatter.render(Renderer.current) do |root|
|
31
36
|
root.grouped_keyed_list(
|
32
37
|
'handle',
|
@@ -48,6 +53,12 @@ module Aptible
|
|
48
53
|
' destinations, you must restart the apps/databases in'\
|
49
54
|
' this environment.'
|
50
55
|
define_method 'environment:rename' do |old_handle, new_handle|
|
56
|
+
opts = options.merge(
|
57
|
+
old_handle: old_handle,
|
58
|
+
new_handle: new_handle
|
59
|
+
)
|
60
|
+
telemetry(__method__, opts)
|
61
|
+
|
51
62
|
env = ensure_environment(options.merge(environment: old_handle))
|
52
63
|
env.update!(handle: new_handle)
|
53
64
|
m1 = "In order for the new environment handle (#{new_handle})"\
|
@@ -7,6 +7,7 @@ module Aptible
|
|
7
7
|
include Helpers::Token
|
8
8
|
include Helpers::Database
|
9
9
|
include Helpers::LogDrain
|
10
|
+
include Helpers::Telemetry
|
10
11
|
|
11
12
|
drain_flags = '--environment ENVIRONMENT ' \
|
12
13
|
'[--drain-apps true/false] ' \
|
@@ -25,16 +26,25 @@ module Aptible
|
|
25
26
|
desc 'log_drain:list', 'List all Log Drains'
|
26
27
|
option :environment, aliases: '--env'
|
27
28
|
define_method 'log_drain:list' do
|
29
|
+
telemetry(__method__, options)
|
30
|
+
|
28
31
|
Formatter.render(Renderer.current) do |root|
|
29
32
|
root.grouped_keyed_list(
|
30
33
|
{ 'environment' => 'handle' },
|
31
34
|
'handle'
|
32
35
|
) do |node|
|
33
|
-
scoped_environments(options)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
accounts = scoped_environments(options)
|
37
|
+
acc_map = environment_map(accounts)
|
38
|
+
|
39
|
+
Aptible::Api::LogDrain.all(
|
40
|
+
token: fetch_token,
|
41
|
+
href: '/log_drains?per_page=5000'
|
42
|
+
).each do |drain|
|
43
|
+
account = acc_map[drain.links.account.href]
|
44
|
+
next if account.nil?
|
45
|
+
|
46
|
+
node.object do |n|
|
47
|
+
ResourceFormatter.inject_log_drain(n, drain, account)
|
38
48
|
end
|
39
49
|
end
|
40
50
|
end
|
@@ -49,6 +59,8 @@ module Aptible
|
|
49
59
|
option :db, type: :string
|
50
60
|
option :pipeline, type: :string
|
51
61
|
define_method 'log_drain:create:elasticsearch' do |handle|
|
62
|
+
telemetry(__method__, options.merge(handle: handle))
|
63
|
+
|
52
64
|
account = ensure_environment(options)
|
53
65
|
database = ensure_database(options)
|
54
66
|
|
@@ -73,6 +85,8 @@ module Aptible
|
|
73
85
|
drain_options
|
74
86
|
option :url, type: :string
|
75
87
|
define_method 'log_drain:create:datadog' do |handle|
|
88
|
+
telemetry(__method__, options.merge(handle: handle))
|
89
|
+
|
76
90
|
msg = 'Must be in the format of ' \
|
77
91
|
'"https://http-intake.logs.datadoghq.com' \
|
78
92
|
'/v1/input/<DD_API_KEY>".'
|
@@ -86,6 +100,7 @@ module Aptible
|
|
86
100
|
option :url, type: :string
|
87
101
|
drain_options
|
88
102
|
define_method 'log_drain:create:https' do |handle|
|
103
|
+
telemetry(__method__, options.merge(handle: handle))
|
89
104
|
create_https_based_log_drain(handle, options)
|
90
105
|
end
|
91
106
|
|
@@ -96,6 +111,7 @@ module Aptible
|
|
96
111
|
option :url, type: :string
|
97
112
|
drain_options
|
98
113
|
define_method 'log_drain:create:sumologic' do |handle|
|
114
|
+
telemetry(__method__, options.merge(handle: handle))
|
99
115
|
create_https_based_log_drain(handle, options)
|
100
116
|
end
|
101
117
|
|
@@ -106,6 +122,8 @@ module Aptible
|
|
106
122
|
option :url, type: :string
|
107
123
|
drain_options
|
108
124
|
define_method 'log_drain:create:logdna' do |handle|
|
125
|
+
telemetry(__method__, options.merge(handle: handle))
|
126
|
+
|
109
127
|
msg = 'Must be in the format of ' \
|
110
128
|
'"https://logs.logdna.com/aptible/ingest/<INGESTION KEY>".'
|
111
129
|
create_https_based_log_drain(handle, options, url_format_msg: msg)
|
@@ -119,6 +137,7 @@ module Aptible
|
|
119
137
|
option :port, type: :string
|
120
138
|
drain_options
|
121
139
|
define_method 'log_drain:create:papertrail' do |handle|
|
140
|
+
telemetry(__method__, options.merge(handle: handle))
|
122
141
|
create_syslog_based_log_drain(handle, options)
|
123
142
|
end
|
124
143
|
|
@@ -132,6 +151,7 @@ module Aptible
|
|
132
151
|
option :token, type: :string
|
133
152
|
drain_options
|
134
153
|
define_method 'log_drain:create:syslog' do |handle|
|
154
|
+
telemetry(__method__, options.merge(handle: handle))
|
135
155
|
create_syslog_based_log_drain(handle, options)
|
136
156
|
end
|
137
157
|
|
@@ -139,6 +159,7 @@ module Aptible
|
|
139
159
|
'Deprovisions a log drain'
|
140
160
|
option :environment, aliases: '--env'
|
141
161
|
define_method 'log_drain:deprovision' do |handle|
|
162
|
+
telemetry(__method__, options.merge(handle: handle))
|
142
163
|
account = ensure_environment(options)
|
143
164
|
drain = ensure_log_drain(account, handle)
|
144
165
|
op = drain.create_operation(type: :deprovision)
|
@@ -12,11 +12,14 @@ module Aptible
|
|
12
12
|
include Helpers::AppOrDatabase
|
13
13
|
include Helpers::S3LogHelpers
|
14
14
|
include Helpers::DateHelpers
|
15
|
+
include Helpers::Telemetry
|
15
16
|
|
16
17
|
desc 'logs [--app APP | --database DATABASE]',
|
17
18
|
'Follows logs from a running app or database'
|
18
19
|
app_or_database_options
|
19
20
|
def logs
|
21
|
+
telemetry(__method__, options)
|
22
|
+
|
20
23
|
resource = ensure_app_or_database(options)
|
21
24
|
|
22
25
|
unless resource.status == 'provisioned'
|
@@ -89,6 +92,8 @@ module Aptible
|
|
89
92
|
type: :string
|
90
93
|
|
91
94
|
def logs_from_archive
|
95
|
+
telemetry(__method__, options)
|
96
|
+
|
92
97
|
ensure_aws_creds
|
93
98
|
validate_log_search_options(options)
|
94
99
|
|
@@ -7,12 +7,15 @@ module Aptible
|
|
7
7
|
include Helpers::Environment
|
8
8
|
include Helpers::Maintenance
|
9
9
|
include Helpers::Token
|
10
|
+
include Helpers::Telemetry
|
10
11
|
|
11
12
|
desc 'maintenance:apps',
|
12
13
|
'List Apps impacted by maintenance schedules where '\
|
13
14
|
'restarts are required'
|
14
15
|
option :environment, aliases: '--env'
|
15
16
|
define_method 'maintenance:apps' do
|
17
|
+
telemetry(__method__, options)
|
18
|
+
|
16
19
|
found_maintenance = false
|
17
20
|
m = maintenance_apps
|
18
21
|
Formatter.render(Renderer.current) do |root|
|
@@ -48,6 +51,8 @@ module Aptible
|
|
48
51
|
'restarts are required'
|
49
52
|
option :environment, aliases: '--env'
|
50
53
|
define_method 'maintenance:dbs' do
|
54
|
+
telemetry(__method__, options)
|
55
|
+
|
51
56
|
found_maintenance = false
|
52
57
|
m = maintenance_databases
|
53
58
|
Formatter.render(Renderer.current) do |root|
|
@@ -16,20 +16,30 @@ module Aptible
|
|
16
16
|
include Helpers::Token
|
17
17
|
include Helpers::Database
|
18
18
|
include Helpers::MetricDrain
|
19
|
+
include Helpers::Telemetry
|
19
20
|
|
20
21
|
desc 'metric_drain:list', 'List all Metric Drains'
|
21
22
|
option :environment, aliases: '--env'
|
22
23
|
define_method 'metric_drain:list' do
|
24
|
+
telemetry(__method__, options)
|
25
|
+
|
23
26
|
Formatter.render(Renderer.current) do |root|
|
24
27
|
root.grouped_keyed_list(
|
25
28
|
{ 'environment' => 'handle' },
|
26
29
|
'handle'
|
27
30
|
) do |node|
|
28
|
-
scoped_environments(options)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
accounts = scoped_environments(options)
|
32
|
+
acc_map = environment_map(accounts)
|
33
|
+
|
34
|
+
Aptible::Api::MetricDrain.all(
|
35
|
+
token: fetch_token,
|
36
|
+
href: '/metric_drains?per_page=5000'
|
37
|
+
).each do |drain|
|
38
|
+
account = acc_map[drain.links.account.href]
|
39
|
+
next if account.nil?
|
40
|
+
|
41
|
+
node.object do |n|
|
42
|
+
ResourceFormatter.inject_metric_drain(n, drain, account)
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -43,6 +53,8 @@ module Aptible
|
|
43
53
|
option :environment, aliases: '--env'
|
44
54
|
|
45
55
|
define_method 'metric_drain:create:influxdb' do |handle|
|
56
|
+
telemetry(__method__, options.merge(handle: handle))
|
57
|
+
|
46
58
|
account = ensure_environment(options)
|
47
59
|
database = ensure_database(options)
|
48
60
|
|
@@ -68,6 +80,8 @@ module Aptible
|
|
68
80
|
option :db, type: :string
|
69
81
|
option :environment, aliases: '--env'
|
70
82
|
define_method 'metric_drain:create:influxdb:custom' do |handle|
|
83
|
+
telemetry(__method__, options.merge(handle: handle))
|
84
|
+
|
71
85
|
account = ensure_environment(options)
|
72
86
|
|
73
87
|
config = {
|
@@ -97,6 +111,8 @@ module Aptible
|
|
97
111
|
option :url, type: :string
|
98
112
|
option :environment, aliases: '--env'
|
99
113
|
define_method 'metric_drain:create:influxdb:customv2' do |handle|
|
114
|
+
telemetry(__method__, options.merge(handle: handle))
|
115
|
+
|
100
116
|
account = ensure_environment(options)
|
101
117
|
|
102
118
|
config = {
|
@@ -123,6 +139,8 @@ module Aptible
|
|
123
139
|
option :site, type: :string
|
124
140
|
option :environment, aliases: '--env'
|
125
141
|
define_method 'metric_drain:create:datadog' do |handle|
|
142
|
+
telemetry(__method__, options.merge(handle: handle))
|
143
|
+
|
126
144
|
account = ensure_environment(options)
|
127
145
|
|
128
146
|
config = {
|
@@ -152,6 +170,8 @@ module Aptible
|
|
152
170
|
'Deprovisions a Metric Drain'
|
153
171
|
option :environment, aliases: '--env'
|
154
172
|
define_method 'metric_drain:deprovision' do |handle|
|
173
|
+
telemetry(__method__, options.merge(handle: handle))
|
174
|
+
|
155
175
|
account = ensure_environment(options)
|
156
176
|
drain = ensure_metric_drain(account, handle)
|
157
177
|
op = drain.create_operation(type: :deprovision)
|
@@ -6,9 +6,12 @@ module Aptible
|
|
6
6
|
thor.class_eval do
|
7
7
|
include Helpers::Token
|
8
8
|
include Helpers::Operation
|
9
|
+
include Helpers::Telemetry
|
9
10
|
|
10
11
|
desc 'operation:cancel OPERATION_ID', 'Cancel a running operation'
|
11
12
|
define_method 'operation:cancel' do |operation_id|
|
13
|
+
telemetry(__method__, options.merge(operation_id: operation_id))
|
14
|
+
|
12
15
|
o = Aptible::Api::Operation.find(operation_id, token: fetch_token)
|
13
16
|
raise "Operation ##{operation_id} not found" if o.nil?
|
14
17
|
|
@@ -20,6 +23,8 @@ module Aptible
|
|
20
23
|
desc 'operation:follow OPERATION_ID',
|
21
24
|
'Follow logs of a running operation'
|
22
25
|
define_method 'operation:follow' do |operation_id|
|
26
|
+
telemetry(__method__, options.merge(operation_id: operation_id))
|
27
|
+
|
23
28
|
o = Aptible::Api::Operation.find(operation_id, token: fetch_token)
|
24
29
|
raise "Operation ##{operation_id} not found" if o.nil?
|
25
30
|
|
@@ -37,6 +42,8 @@ module Aptible
|
|
37
42
|
|
38
43
|
desc 'operation:logs OPERATION_ID', 'View logs for given operation'
|
39
44
|
define_method 'operation:logs' do |operation_id|
|
45
|
+
telemetry(__method__, options.merge(operation_id: operation_id))
|
46
|
+
|
40
47
|
o = Aptible::Api::Operation.find(operation_id, token: fetch_token)
|
41
48
|
raise "Operation ##{operation_id} not found" if o.nil?
|
42
49
|
|
@@ -6,10 +6,13 @@ module Aptible
|
|
6
6
|
thor.class_eval do
|
7
7
|
include Helpers::Operation
|
8
8
|
include Helpers::App
|
9
|
+
include Helpers::Telemetry
|
9
10
|
|
10
11
|
desc 'rebuild', 'Rebuild an app, and restart its services'
|
11
12
|
app_options
|
12
13
|
def rebuild
|
14
|
+
telemetry(__method__, options)
|
15
|
+
|
13
16
|
app = ensure_app(options)
|
14
17
|
operation = app.create_operation!(type: 'rebuild')
|
15
18
|
CLI.logger.info 'Rebuilding app...'
|
@@ -6,6 +6,7 @@ module Aptible
|
|
6
6
|
thor.class_eval do
|
7
7
|
include Helpers::Operation
|
8
8
|
include Helpers::App
|
9
|
+
include Helpers::Telemetry
|
9
10
|
|
10
11
|
desc 'restart', 'Restart all services associated with an app'
|
11
12
|
option :simulate_oom,
|
@@ -20,6 +21,8 @@ module Aptible
|
|
20
21
|
'default.'
|
21
22
|
app_options
|
22
23
|
def restart
|
24
|
+
telemetry(__method__, options)
|
25
|
+
|
23
26
|
app = ensure_app(options)
|
24
27
|
type = 'restart'
|
25
28
|
|