morpheus-cli 3.6.15 → 3.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/morpheus/cli/monitoring_apps_command.rb +5 -14
- data/lib/morpheus/cli/monitoring_checks_command.rb +6 -15
- data/lib/morpheus/cli/monitoring_contacts_command.rb +6 -9
- data/lib/morpheus/cli/monitoring_groups_command.rb +3 -2
- data/lib/morpheus/cli/monitoring_incidents_command.rb +3 -2
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/rest_client.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2965857867a8deda2e9e0c8e6033823838c48710cde42a3d6f27b0ee5287faa6
|
4
|
+
data.tar.gz: f16690f4f149d1f17814059ae6e385bc9fe550964044c9deecf54e352c7e333e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 580ca508572a8f69dc7d14626cf24df8fac27f148041272d01a71b943a256fe283ba880141685d243fb08bdb5b82a41f40bd80fd91d8d92227699901401552f2
|
7
|
+
data.tar.gz: 6852abdd9d76fa2f3a20e8e1b268eb3012c08906c02c5404a6fdc33378427036a2dbe66df5000bfa78339e8a10307d3020435cb17fbcc4dffd6171037cb2d53d
|
@@ -14,7 +14,8 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
14
14
|
|
15
15
|
def connect(opts)
|
16
16
|
@api_client = establish_remote_appliance_connection(opts)
|
17
|
-
@
|
17
|
+
@monitoring_interface = @api_client.monitoring
|
18
|
+
@monitoring_apps_interface = @api_client.monitoring.apps
|
18
19
|
end
|
19
20
|
|
20
21
|
def handle(args)
|
@@ -29,14 +30,12 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
29
30
|
opts.on('--status LIST', Array, "Filter by status. error,healthy,warning,muted") do |list|
|
30
31
|
params['status'] = list
|
31
32
|
end
|
32
|
-
build_common_options(opts, options, [:list, :last_updated, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
33
|
+
build_common_options(opts, options, [:list, :query, :last_updated, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
33
34
|
end
|
34
35
|
optparse.parse!(args)
|
35
36
|
connect(options)
|
36
37
|
begin
|
37
|
-
|
38
|
-
params[k] = options[k] unless options[k].nil?
|
39
|
-
end
|
38
|
+
params.merge!(parse_list_options(options))
|
40
39
|
@monitoring_apps_interface.setopts(options)
|
41
40
|
if options[:dry_run]
|
42
41
|
print_dry_run @monitoring_apps_interface.dry.list(params)
|
@@ -57,15 +56,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
57
56
|
monitor_apps = json_response['monitorApps']
|
58
57
|
title = "Morpheus Monitoring Apps"
|
59
58
|
subtitles = []
|
60
|
-
|
61
|
-
# subtitles << "App: #{app['name']}".strip
|
62
|
-
# end
|
63
|
-
# if cloud
|
64
|
-
# subtitles << "Cloud: #{cloud['name']}".strip
|
65
|
-
# end
|
66
|
-
if params[:phrase]
|
67
|
-
subtitles << "Search: #{params[:phrase]}".strip
|
68
|
-
end
|
59
|
+
subtitles += parse_list_subtitles(options)
|
69
60
|
print_h1 title, subtitles
|
70
61
|
if monitor_apps.empty?
|
71
62
|
print cyan,"No monitoring apps found.",reset,"\n"
|
@@ -14,7 +14,8 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
14
14
|
|
15
15
|
def connect(opts)
|
16
16
|
@api_client = establish_remote_appliance_connection(opts)
|
17
|
-
@
|
17
|
+
@monitoring_interface = @api_client.monitoring
|
18
|
+
@monitoring_checks_interface = @api_client.monitoring.checks
|
18
19
|
end
|
19
20
|
|
20
21
|
def handle(args)
|
@@ -33,14 +34,12 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
33
34
|
opts.on('--status VALUE', Array, "Filter by status. error,healthy,warning,muted") do |val|
|
34
35
|
params['status'] = val
|
35
36
|
end
|
36
|
-
build_common_options(opts, options, [:list, :last_updated, :json, :yaml, :csv, :fields, :json, :dry_run, :remote])
|
37
|
+
build_common_options(opts, options, [:list, :query, :last_updated, :json, :yaml, :csv, :fields, :json, :dry_run, :remote])
|
37
38
|
end
|
38
39
|
optparse.parse!(args)
|
39
40
|
connect(options)
|
40
41
|
begin
|
41
|
-
|
42
|
-
params[k] = options[k] unless options[k].nil?
|
43
|
-
end
|
42
|
+
params.merge!(parse_list_options(options))
|
44
43
|
@monitoring_checks_interface.setopts(options)
|
45
44
|
if options[:dry_run]
|
46
45
|
print_dry_run @monitoring_checks_interface.dry.list(params)
|
@@ -60,16 +59,8 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
60
59
|
checks = json_response['checks']
|
61
60
|
title = "Morpheus Monitoring Checks"
|
62
61
|
subtitles = []
|
63
|
-
|
64
|
-
|
65
|
-
# end
|
66
|
-
# if cloud
|
67
|
-
# subtitles << "Cloud: #{cloud['name']}".strip
|
68
|
-
# end
|
69
|
-
if params[:phrase]
|
70
|
-
subtitles << "Search: #{params[:phrase]}".strip
|
71
|
-
end
|
72
|
-
print_h1 title, subtitles
|
62
|
+
subtitles += parse_list_subtitles(options)
|
63
|
+
print_h1 title, subtitles, options
|
73
64
|
if checks.empty?
|
74
65
|
print cyan,"No checks found.",reset,"\n"
|
75
66
|
else
|
@@ -21,7 +21,8 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
21
21
|
|
22
22
|
def connect(opts)
|
23
23
|
@api_client = establish_remote_appliance_connection(opts)
|
24
|
-
@
|
24
|
+
@monitoring_interface = @api_client.monitoring
|
25
|
+
@monitoring_contacts_interface = @api_client.monitoring.contacts
|
25
26
|
end
|
26
27
|
|
27
28
|
def handle(args)
|
@@ -33,14 +34,12 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
33
34
|
params = {}
|
34
35
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
35
36
|
opts.banner = subcommand_usage()
|
36
|
-
build_common_options(opts, options, [:list, :json, :csv, :yaml, :fields, :json, :dry_run])
|
37
|
+
build_common_options(opts, options, [:list, :query, :json, :csv, :yaml, :fields, :json, :dry_run])
|
37
38
|
end
|
38
39
|
optparse.parse!(args)
|
39
40
|
connect(options)
|
40
41
|
begin
|
41
|
-
|
42
|
-
params[k] = options[k] unless options[k].nil?
|
43
|
-
end
|
42
|
+
params.merge!(parse_list_options(options))
|
44
43
|
# JD: lastUpdated 500ing, contacts don't have that property ? =o Fix it!
|
45
44
|
@monitoring_contacts_interface.setopts(options)
|
46
45
|
if options[:dry_run]
|
@@ -62,10 +61,8 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
62
61
|
contacts = json_response['contacts']
|
63
62
|
title = "Morpheus Monitoring Contacts"
|
64
63
|
subtitles = []
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
print_h1 title, subtitles
|
64
|
+
subtitles += parse_list_subtitles(options)
|
65
|
+
print_h1 title, subtitles, options
|
69
66
|
if contacts.empty?
|
70
67
|
print cyan,"No contacts found.",reset,"\n"
|
71
68
|
else
|
@@ -13,7 +13,8 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
13
13
|
|
14
14
|
def connect(opts)
|
15
15
|
@api_client = establish_remote_appliance_connection(opts)
|
16
|
-
@
|
16
|
+
@monitoring_interface = @api_client.monitoring
|
17
|
+
@monitoring_groups_interface = @api_client.monitoring.groups
|
17
18
|
end
|
18
19
|
|
19
20
|
def handle(args)
|
@@ -28,7 +29,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
28
29
|
opts.on('--status VALUE', Array, "Filter by status. error,healthy,warning,muted") do |val|
|
29
30
|
params['status'] = val
|
30
31
|
end
|
31
|
-
build_common_options(opts, options, [:list, :last_updated, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
32
|
+
build_common_options(opts, options, [:list, :query, :last_updated, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
32
33
|
end
|
33
34
|
optparse.parse!(args)
|
34
35
|
connect(options)
|
@@ -12,7 +12,8 @@ class Morpheus::Cli::MonitoringIncidentsCommand
|
|
12
12
|
|
13
13
|
def connect(opts)
|
14
14
|
@api_client = establish_remote_appliance_connection(opts)
|
15
|
-
@
|
15
|
+
@monitoring_interface = @api_client.monitoring
|
16
|
+
@monitoring_incidents_interface = @api_client.monitoring.incidents
|
16
17
|
end
|
17
18
|
|
18
19
|
def handle(args)
|
@@ -30,7 +31,7 @@ class Morpheus::Cli::MonitoringIncidentsCommand
|
|
30
31
|
opts.on('--severity LIST', Array, "Filter by severity. critical, warning, info") do |list|
|
31
32
|
params['severity'] = list
|
32
33
|
end
|
33
|
-
build_common_options(opts, options, [:list, :last_updated, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
34
|
+
build_common_options(opts, options, [:list, :query, :last_updated, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
34
35
|
end
|
35
36
|
optparse.parse!(args)
|
36
37
|
connect(options)
|
data/lib/morpheus/cli/version.rb
CHANGED
data/lib/morpheus/rest_client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rest-client'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
module Morpheus
|
4
5
|
# A wrapper around rest_client so we can more easily deal with passing options (like turning on/off SSL verification)
|
@@ -31,8 +32,27 @@ module Morpheus
|
|
31
32
|
opts[:headers] ||= {}
|
32
33
|
opts[:headers][:user_agent] ||= self.user_agent
|
33
34
|
|
35
|
+
# serialize params oureselves, this way we get arrays without the [] suffix
|
36
|
+
params = nil
|
37
|
+
if opts[:params] && !opts[:params].empty?
|
38
|
+
params = opts.delete(:params)
|
39
|
+
elsif opts[:headers] && opts[:headers][:params]
|
40
|
+
# params inside headers for restclient reasons..
|
41
|
+
params = opts[:headers].delete(:params)
|
42
|
+
elsif opts[:query] && !opts[:query].empty?
|
43
|
+
params = opts.delete(:query)
|
44
|
+
end
|
45
|
+
query_string = params
|
46
|
+
if query_string.respond_to?(:map)
|
47
|
+
query_string = URI.encode_www_form(query_string)
|
48
|
+
end
|
49
|
+
if query_string && !query_string.empty?
|
50
|
+
opts[:url] = "#{opts[:url]}?#{query_string}"
|
51
|
+
end
|
52
|
+
|
34
53
|
::RestClient::Request.execute opts
|
35
54
|
end
|
55
|
+
|
36
56
|
def post(url, payload)
|
37
57
|
execute url: url, payload: payload, method: :post
|
38
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpheus-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-02-
|
14
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|