morpheus-cli 5.4.2 → 5.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/api_client.rb +12 -1
- data/lib/morpheus/api/catalog_item_types_interface.rb +17 -0
- data/lib/morpheus/api/clusters_interface.rb +12 -0
- data/lib/morpheus/api/credential_types_interface.rb +9 -0
- data/lib/morpheus/api/credentials_interface.rb +9 -0
- data/lib/morpheus/api/instances_interface.rb +28 -0
- data/lib/morpheus/api/monitoring_apps_interface.rb +12 -4
- data/lib/morpheus/api/monitoring_checks_interface.rb +12 -4
- data/lib/morpheus/api/monitoring_groups_interface.rb +13 -5
- data/lib/morpheus/api/monitoring_incidents_interface.rb +12 -4
- data/lib/morpheus/api/options_interface.rb +8 -1
- data/lib/morpheus/api/ping_interface.rb +2 -0
- data/lib/morpheus/api/power_schedules_interface.rb +2 -2
- data/lib/morpheus/api/service_plans_interface.rb +6 -0
- data/lib/morpheus/api/setup_interface.rb +4 -0
- data/lib/morpheus/api/snapshots_interface.rb +19 -0
- data/lib/morpheus/cli/cli_command.rb +10 -17
- data/lib/morpheus/cli/commands/catalog_item_types_command.rb +156 -1
- data/lib/morpheus/cli/commands/clusters.rb +177 -50
- data/lib/morpheus/cli/commands/credential_types_command.rb +36 -0
- data/lib/morpheus/cli/commands/credentials_command.rb +124 -0
- data/lib/morpheus/cli/commands/hosts.rb +32 -2
- data/lib/morpheus/cli/commands/instances.rb +255 -2
- data/lib/morpheus/cli/commands/library_instance_types_command.rb +3 -0
- data/lib/morpheus/cli/commands/monitoring_apps_command.rb +8 -8
- data/lib/morpheus/cli/commands/monitoring_checks_command.rb +8 -8
- data/lib/morpheus/cli/commands/monitoring_groups_command.rb +8 -8
- data/lib/morpheus/cli/commands/monitoring_incidents_command.rb +8 -8
- data/lib/morpheus/cli/commands/network_static_routes_command.rb +5 -0
- data/lib/morpheus/cli/commands/networks_command.rb +2 -2
- data/lib/morpheus/cli/commands/ping.rb +3 -5
- data/lib/morpheus/cli/commands/policies_command.rb +1 -1
- data/lib/morpheus/cli/commands/power_schedules_command.rb +189 -258
- data/lib/morpheus/cli/commands/provisioning_settings_command.rb +1 -0
- data/lib/morpheus/cli/commands/remote.rb +16 -10
- data/lib/morpheus/cli/commands/security_groups.rb +2 -2
- data/lib/morpheus/cli/commands/service_plans_command.rb +52 -5
- data/lib/morpheus/cli/commands/setup.rb +1 -1
- data/lib/morpheus/cli/commands/snapshots.rb +139 -0
- data/lib/morpheus/cli/commands/storage_server_types.rb +0 -5
- data/lib/morpheus/cli/commands/storage_servers.rb +0 -6
- data/lib/morpheus/cli/commands/storage_volume_types.rb +0 -5
- data/lib/morpheus/cli/commands/storage_volumes.rb +0 -6
- data/lib/morpheus/cli/commands/tasks.rb +5 -5
- data/lib/morpheus/cli/commands/user_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/virtual_images.rb +4 -1
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +117 -27
- data/lib/morpheus/cli/mixins/rest_command.rb +20 -4
- data/lib/morpheus/cli/mixins/storage_servers_helper.rb +0 -63
- data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +0 -43
- data/lib/morpheus/cli/option_types.rb +27 -11
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/routes.rb +13 -3
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e88f25d69ce8a6c1038899e3671c69a31266607d3370b2c4a20d3fa74d76dc42
|
4
|
+
data.tar.gz: '08ccc023d2cc5908a7a8f9a8a3cde3ec9cd11e08b85e53b1732aecc0e38ab166'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a21ebb4f7b58cbd5aede974f4bb298a19a02c4aad9f92fbe0c149d5cde3a80dfdf141fbf7aca66ce9cf1c2fc9a4495f51e3c6fcea9ee7458a4153ed3c6bb1d9
|
7
|
+
data.tar.gz: f9412dd77a1c90346133832363ac8d756b0f4576b4a3102024552dba4c63d566430b57a3b53395080f928b88b5354f446bdc3bb9df6d1351b5994419ca884623
|
data/Dockerfile
CHANGED
@@ -347,7 +347,6 @@ class Morpheus::APIClient
|
|
347
347
|
end
|
348
348
|
|
349
349
|
def auth
|
350
|
-
# Morpheus::AuthInterface.new(common_interface_options).setopts(@options)
|
351
350
|
Morpheus::AuthInterface.new({url: @base_url, client_id: @client_id, verify_ssl: @verify_ssl}).setopts(@options)
|
352
351
|
end
|
353
352
|
|
@@ -889,6 +888,18 @@ class Morpheus::APIClient
|
|
889
888
|
Morpheus::NetworkStaticRoutesInterface.new(common_interface_options).setopts(@options)
|
890
889
|
end
|
891
890
|
|
891
|
+
def snapshots
|
892
|
+
Morpheus::SnapshotsInterface.new(common_interface_options).setopts(@options)
|
893
|
+
end
|
894
|
+
|
895
|
+
def credentials
|
896
|
+
Morpheus::CredentialsInterface.new(common_interface_options).setopts(@options)
|
897
|
+
end
|
898
|
+
|
899
|
+
def credential_types
|
900
|
+
Morpheus::CredentialTypesInterface.new(common_interface_options).setopts(@options)
|
901
|
+
end
|
902
|
+
|
892
903
|
def rest(endpoint)
|
893
904
|
Morpheus::RestInterface.new(common_interface_options).setopts(@options.merge({base_path: "#{@base_url}/api/#{endpoint}"}))
|
894
905
|
end
|
@@ -6,4 +6,21 @@ class Morpheus::CatalogItemTypesInterface < Morpheus::RestInterface
|
|
6
6
|
"/api/catalog-item-types"
|
7
7
|
end
|
8
8
|
|
9
|
+
# NOT json, multipart file upload, uses PUT update endpoint
|
10
|
+
def update_logo(id, logo_file, dark_logo_file=nil)
|
11
|
+
#url = "#{base_path}/#{id}/update-logo"
|
12
|
+
url = "#{base_path}/#{id}"
|
13
|
+
headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
|
14
|
+
payload = {}
|
15
|
+
payload["catalogItemType"] = {}
|
16
|
+
if logo_file
|
17
|
+
payload["catalogItemType"]["logo"] = logo_file
|
18
|
+
end
|
19
|
+
if dark_logo_file
|
20
|
+
payload["catalogItemType"]["darkLogo"] = dark_logo_file
|
21
|
+
end
|
22
|
+
payload[:multipart] = true
|
23
|
+
execute(method: :put, url: url, headers: headers, payload: payload)
|
24
|
+
end
|
25
|
+
|
9
26
|
end
|
@@ -91,6 +91,18 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
91
91
|
execute(method: :get, url: url, headers: headers)
|
92
92
|
end
|
93
93
|
|
94
|
+
def destroy_worker(id, worker_id, params={})
|
95
|
+
url = "#{base_path}/#{id}/servers/#{worker_id}"
|
96
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
97
|
+
execute(method: :delete, url: url, headers: headers)
|
98
|
+
end
|
99
|
+
|
100
|
+
def update_worker_count(id, params={})
|
101
|
+
url = "#{base_path}/#{id}/worker-count"
|
102
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
103
|
+
execute(method: :put, url: url, headers: headers)
|
104
|
+
end
|
105
|
+
|
94
106
|
def list_services(id, params={})
|
95
107
|
url = "#{base_path}/#{id}/services"
|
96
108
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -262,6 +262,34 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
262
262
|
execute(opts)
|
263
263
|
end
|
264
264
|
|
265
|
+
def revert_to_snapshot(id, snapshot_id, payload={})
|
266
|
+
url = "#{@base_url}/api/instances/#{id}/revert-snapshot/#{snapshot_id}"
|
267
|
+
headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
268
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
269
|
+
execute(opts)
|
270
|
+
end
|
271
|
+
|
272
|
+
def remove_all_container_snapshots(id, container_id, payload={})
|
273
|
+
url = "#{@base_url}/api/instances/#{id}/delete-container-snapshots/#{container_id}"
|
274
|
+
headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
275
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
276
|
+
execute(opts)
|
277
|
+
end
|
278
|
+
|
279
|
+
def remove_all_instance_snapshots(id, payload={})
|
280
|
+
url = "#{@base_url}/api/instances/#{id}/delete-all-snapshots"
|
281
|
+
headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
282
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
283
|
+
execute(opts)
|
284
|
+
end
|
285
|
+
|
286
|
+
def create_linked_clone(id, snapshot_id, payload={})
|
287
|
+
url = "#{@base_url}/api/instances/#{id}/linked-clone/#{snapshot_id}"
|
288
|
+
headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
289
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
290
|
+
execute(opts)
|
291
|
+
end
|
292
|
+
|
265
293
|
def service_plans(params={})
|
266
294
|
url = "#{@base_url}/api/instances/service-plans"
|
267
295
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -38,20 +38,28 @@ class Morpheus::MonitoringAppsInterface < Morpheus::APIClient
|
|
38
38
|
execute(opts)
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
url = "#{@base_url}/api/monitoring/apps/#{id}/
|
41
|
+
def mute(id, payload={})
|
42
|
+
url = "#{@base_url}/api/monitoring/apps/#{id}/mute"
|
43
43
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
44
44
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
45
45
|
execute(opts)
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
url = "#{@base_url}/api/monitoring/apps/
|
48
|
+
def mute_all(payload={})
|
49
|
+
url = "#{@base_url}/api/monitoring/apps/mute-all"
|
50
50
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
51
51
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
52
52
|
execute(opts)
|
53
53
|
end
|
54
54
|
|
55
|
+
def quarantine(id, payload={})
|
56
|
+
mute(id, payload)
|
57
|
+
end
|
58
|
+
|
59
|
+
def quarantine_all(payload={})
|
60
|
+
mute_all(payload)
|
61
|
+
end
|
62
|
+
|
55
63
|
def statistics(id, params={})
|
56
64
|
url = "#{@base_url}/api/monitoring/apps/#{id}/statistics"
|
57
65
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -39,22 +39,30 @@ class Morpheus::MonitoringChecksInterface < Morpheus::APIClient
|
|
39
39
|
execute(opts)
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
url = "#{@base_url}/api/monitoring/checks/#{id}/
|
42
|
+
def mute(id, options={})
|
43
|
+
url = "#{@base_url}/api/monitoring/checks/#{id}/mute"
|
44
44
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
45
45
|
payload = options
|
46
46
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
47
47
|
execute(opts)
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
51
|
-
url = "#{@base_url}/api/monitoring/checks/
|
50
|
+
def mute_all(options={})
|
51
|
+
url = "#{@base_url}/api/monitoring/checks/mute-all"
|
52
52
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
53
53
|
payload = options
|
54
54
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
55
55
|
execute(opts)
|
56
56
|
end
|
57
57
|
|
58
|
+
def quarantine(id, payload={})
|
59
|
+
mute(id, payload)
|
60
|
+
end
|
61
|
+
|
62
|
+
def quarantine_all(payload={})
|
63
|
+
mute_all(payload)
|
64
|
+
end
|
65
|
+
|
58
66
|
def history(id, params={})
|
59
67
|
url = "#{@base_url}/api/monitoring/checks/#{id}/history"
|
60
68
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -38,20 +38,28 @@ class Morpheus::MonitoringGroupsInterface < Morpheus::APIClient
|
|
38
38
|
execute(opts)
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
url = "#{@base_url}/api/monitoring/groups/#{id}/
|
41
|
+
def mute(id, payload={})
|
42
|
+
url = "#{@base_url}/api/monitoring/groups/#{id}/mute"
|
43
43
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
44
44
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
45
45
|
execute(opts)
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
url = "#{@base_url}/api/monitoring/groups/
|
48
|
+
def mute_all(payload={})
|
49
|
+
url = "#{@base_url}/api/monitoring/groups/mute-all"
|
50
50
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
51
51
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
52
52
|
execute(opts)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
|
+
def quarantine(id, payload={})
|
56
|
+
mute(id, payload)
|
57
|
+
end
|
58
|
+
|
59
|
+
def quarantine_all(payload={})
|
60
|
+
mute_all(payload)
|
61
|
+
end
|
62
|
+
|
55
63
|
def history(id, params={})
|
56
64
|
url = "#{@base_url}/api/monitoring/groups/#{id}/history"
|
57
65
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -58,21 +58,29 @@ class Morpheus::MonitoringIncidentsInterface < Morpheus::APIClient
|
|
58
58
|
execute(opts)
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
url = "#{@base_url}/api/monitoring/incidents/#{id}/
|
61
|
+
def mute(id, options={})
|
62
|
+
url = "#{@base_url}/api/monitoring/incidents/#{id}/mute"
|
63
63
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
64
64
|
payload = options
|
65
65
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
66
66
|
execute(opts)
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
70
|
-
url = "#{@base_url}/api/monitoring/incidents/
|
69
|
+
def mute_all(payload={})
|
70
|
+
url = "#{@base_url}/api/monitoring/incidents/mute-all"
|
71
71
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
72
72
|
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
73
73
|
execute(opts)
|
74
74
|
end
|
75
75
|
|
76
|
+
def quarantine(id, payload={})
|
77
|
+
mute(id, payload)
|
78
|
+
end
|
79
|
+
|
80
|
+
def quarantine_all(payload={})
|
81
|
+
mute_all(payload)
|
82
|
+
end
|
83
|
+
|
76
84
|
def history(id, params={})
|
77
85
|
url = "#{@base_url}/api/monitoring/incidents/#{id}/history"
|
78
86
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -2,8 +2,15 @@ require 'morpheus/api/api_client'
|
|
2
2
|
|
3
3
|
class Morpheus::OptionsInterface < Morpheus::APIClient
|
4
4
|
|
5
|
-
def
|
5
|
+
def options_for_type(option_type, params={})
|
6
|
+
options_for_source(option_type['optionSource'], params, option_type['optionSourceType'])
|
7
|
+
end
|
8
|
+
|
9
|
+
def options_for_source(source,params = {}, option_source_type=nil)
|
6
10
|
url = "#{@base_url}/api/options/#{source}"
|
11
|
+
if option_source_type
|
12
|
+
url = "#{@base_url}/api/options/#{option_source_type}/#{source}"
|
13
|
+
end
|
7
14
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
8
15
|
execute(method: :get, url: url, headers: headers)
|
9
16
|
end
|
@@ -14,6 +14,8 @@ class Morpheus::PingInterface < Morpheus::APIClient
|
|
14
14
|
|
15
15
|
def get(params={})
|
16
16
|
headers = {params: params}
|
17
|
+
# use access token if authenticated
|
18
|
+
headers[:authorization] = "Bearer #{@access_token}" if @access_token
|
17
19
|
execute(method: :get, url: "/api/ping", headers: headers)
|
18
20
|
end
|
19
21
|
|
@@ -2,10 +2,10 @@ require 'morpheus/api/api_client'
|
|
2
2
|
|
3
3
|
class Morpheus::PowerSchedulesInterface < Morpheus::APIClient
|
4
4
|
|
5
|
-
def get(id)
|
5
|
+
def get(id, params={})
|
6
6
|
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
7
7
|
url = "#{@base_url}/api/power-schedules/#{id}"
|
8
|
-
headers = { params:
|
8
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
9
9
|
opts = {method: :get, url: url, timeout: 10, headers: headers}
|
10
10
|
execute(opts)
|
11
11
|
end
|
@@ -42,6 +42,12 @@ class Morpheus::ServicePlansInterface < Morpheus::APIClient
|
|
42
42
|
execute(method: :put, url: url, headers: headers)
|
43
43
|
end
|
44
44
|
|
45
|
+
def destroy(id, params={})
|
46
|
+
url = "#{base_path}/#{id}"
|
47
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
48
|
+
execute(method: :delete, url: url, headers: headers)
|
49
|
+
end
|
50
|
+
|
45
51
|
def provision_types(params={})
|
46
52
|
url = "#{base_path}/provision-types"
|
47
53
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -14,12 +14,16 @@ class Morpheus::SetupInterface < Morpheus::APIClient
|
|
14
14
|
|
15
15
|
def get(params={})
|
16
16
|
headers = {params: params}
|
17
|
+
# use access token if authenticated
|
18
|
+
headers[:authorization] = "Bearer #{@access_token}" if @access_token
|
17
19
|
execute(method: :get, url: "/api/setup", headers: headers)
|
18
20
|
end
|
19
21
|
|
20
22
|
#this should go away and just use
|
21
23
|
def check(params={}, timeout=5)
|
22
24
|
headers = {params: params}
|
25
|
+
# use access token if authenticated
|
26
|
+
headers[:authorization] = "Bearer #{@access_token}" if @access_token
|
23
27
|
execute(method: :get, url: "/api/setup/check", headers: headers, timeout: timeout)
|
24
28
|
end
|
25
29
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
# Snapshots API interface.
|
4
|
+
class Morpheus::SnapshotsInterface < Morpheus::APIClient
|
5
|
+
|
6
|
+
def get(snapshot_id)
|
7
|
+
url = "#{@base_url}/api/snapshots/#{snapshot_id}"
|
8
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
9
|
+
opts = {method: :get, url: url, headers: headers}
|
10
|
+
execute(opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def remove(snapshot_id, payload={})
|
14
|
+
url = "#{@base_url}/api/snapshots/#{snapshot_id}"
|
15
|
+
headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
16
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
17
|
+
execute(opts)
|
18
|
+
end
|
19
|
+
end
|
@@ -151,23 +151,13 @@ module Morpheus
|
|
151
151
|
|
152
152
|
# add each one to the OptionParser
|
153
153
|
option_types.each do |option_type|
|
154
|
-
|
155
|
-
|
156
|
-
if field_name.empty?
|
157
|
-
puts "Missing fieldName for option type: #{option_type}" if Morpheus::Logging.debug?
|
154
|
+
if option_type['fieldName'].empty?
|
155
|
+
puts_error "Missing fieldName for option type: #{option_type}" if Morpheus::Logging.debug?
|
158
156
|
next
|
159
157
|
end
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
field_namespace << ns
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
full_field_name = field_name
|
168
|
-
if !field_namespace.empty?
|
169
|
-
full_field_name = "#{field_namespace.join('.')}.#{field_name}"
|
170
|
-
end
|
158
|
+
full_field_name = option_type['fieldContext'].to_s.empty? ? option_type['fieldName'] : "#{option_type['fieldContext']}.#{option_type['fieldName']}"
|
159
|
+
field_namespace = full_field_name.split(".")
|
160
|
+
field_name = field_namespace.pop
|
171
161
|
|
172
162
|
description = "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}"
|
173
163
|
if option_type['description']
|
@@ -1507,8 +1497,11 @@ module Morpheus
|
|
1507
1497
|
type, *ids = args
|
1508
1498
|
type = type.to_s.singularize.underscore
|
1509
1499
|
# still relying on the command or helper to define these _label and _key methods
|
1510
|
-
label = send("#{type}_label")
|
1511
|
-
object_key = send("#{type}_object_key")
|
1500
|
+
# label = send("#{type}_label")
|
1501
|
+
# object_key = send("#{type}_object_key")
|
1502
|
+
# ^ nope, not for long!
|
1503
|
+
object_key = respond_to?("#{type}_object_key", true) ? send("#{type}_object_key") : type.camelcase.singularize
|
1504
|
+
label = respond_to?("#{type}_label", true) ? send("#{type}_label") : type.titleize
|
1512
1505
|
interface_name = "@#{type.pluralize}_interface"
|
1513
1506
|
interface = instance_variable_get(interface_name)
|
1514
1507
|
if interface.nil?
|
@@ -13,6 +13,7 @@ class Morpheus::Cli::CatalogItemTypesCommand
|
|
13
13
|
set_command_description "Self Service: View and manage catalog item types"
|
14
14
|
|
15
15
|
register_subcommands :list, :get, :add, :update, :remove
|
16
|
+
register_subcommands({:'update-logo' => :update_logo, :'update-dark-logo' => :update_dark_logo})
|
16
17
|
|
17
18
|
def connect(opts)
|
18
19
|
@api_client = establish_remote_appliance_connection(opts)
|
@@ -222,6 +223,8 @@ EOT
|
|
222
223
|
def add(args)
|
223
224
|
options = {}
|
224
225
|
params = {}
|
226
|
+
logo_file = nil
|
227
|
+
dark_logo_file = nil
|
225
228
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
226
229
|
opts.banner = subcommand_usage("[name] [options]")
|
227
230
|
# opts.on('-t', '--type [instance|blueprint|workflow]', "Item Type, default is instance.") do |val|
|
@@ -229,6 +232,32 @@ EOT
|
|
229
232
|
# options[:options]['type'] = val.to_s.downcase
|
230
233
|
# end
|
231
234
|
build_option_type_options(opts, options, add_catalog_item_type_option_types)
|
235
|
+
opts.on('--logo FILE', String, "Upload a custom logo icon") do |val|
|
236
|
+
filename = val
|
237
|
+
logo_file = nil
|
238
|
+
if filename == 'null'
|
239
|
+
logo_file = 'null' # clear it
|
240
|
+
else
|
241
|
+
filename = File.expand_path(filename)
|
242
|
+
if !File.exists?(filename)
|
243
|
+
raise_command_error "File not found: #{filename}"
|
244
|
+
end
|
245
|
+
logo_file = File.new(filename, 'rb')
|
246
|
+
end
|
247
|
+
end
|
248
|
+
opts.on('--dark-logo FILE', String, "Upload a custom dark logo icon") do |val|
|
249
|
+
filename = val
|
250
|
+
dark_logo_file = nil
|
251
|
+
if filename == 'null'
|
252
|
+
dark_logo_file = 'null' # clear it
|
253
|
+
else
|
254
|
+
filename = File.expand_path(filename)
|
255
|
+
if !File.exists?(filename)
|
256
|
+
raise_command_error "File not found: #{filename}"
|
257
|
+
end
|
258
|
+
dark_logo_file = File.new(filename, 'rb')
|
259
|
+
end
|
260
|
+
end
|
232
261
|
opts.on('--config-file FILE', String, "Config from a local JSON or YAML file") do |val|
|
233
262
|
options[:config_file] = val.to_s
|
234
263
|
file_content = nil
|
@@ -330,6 +359,16 @@ EOT
|
|
330
359
|
return 0, nil
|
331
360
|
end
|
332
361
|
json_response = @catalog_item_types_interface.create(payload)
|
362
|
+
if json_response['success']
|
363
|
+
if logo_file || dark_logo_file
|
364
|
+
begin
|
365
|
+
@catalog_item_types_interface.update_logo(json_response['catalogItemType']['id'], logo_file, dark_logo_file)
|
366
|
+
rescue RestClient::Exception => e
|
367
|
+
print_red_alert "Failed to save logo!"
|
368
|
+
print_rest_exception(e, options)
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
333
372
|
catalog_item_type = json_response[catalog_item_type_object_key]
|
334
373
|
render_response(json_response, options, catalog_item_type_object_key) do
|
335
374
|
print_green_success "Added catalog item type #{catalog_item_type['name']}"
|
@@ -342,9 +381,37 @@ EOT
|
|
342
381
|
options = {}
|
343
382
|
params = {}
|
344
383
|
payload = {}
|
384
|
+
logo_file = nil
|
385
|
+
dark_logo_file = nil
|
345
386
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
346
387
|
opts.banner = subcommand_usage("[type] [options]")
|
347
388
|
build_option_type_options(opts, options, update_catalog_item_type_option_types)
|
389
|
+
opts.on('--logo FILE', String, "Upload a custom logo icon") do |val|
|
390
|
+
filename = val
|
391
|
+
logo_file = nil
|
392
|
+
if filename == 'null'
|
393
|
+
logo_file = 'null' # clear it
|
394
|
+
else
|
395
|
+
filename = File.expand_path(filename)
|
396
|
+
if !File.exists?(filename)
|
397
|
+
raise_command_error "File not found: #{filename}"
|
398
|
+
end
|
399
|
+
logo_file = File.new(filename, 'rb')
|
400
|
+
end
|
401
|
+
end
|
402
|
+
opts.on('--dark-logo FILE', String, "Upload a custom dark logo icon") do |val|
|
403
|
+
filename = val
|
404
|
+
dark_logo_file = nil
|
405
|
+
if filename == 'null'
|
406
|
+
dark_logo_file = 'null' # clear it
|
407
|
+
else
|
408
|
+
filename = File.expand_path(filename)
|
409
|
+
if !File.exists?(filename)
|
410
|
+
raise_command_error "File not found: #{filename}"
|
411
|
+
end
|
412
|
+
dark_logo_file = File.new(filename, 'rb')
|
413
|
+
end
|
414
|
+
end
|
348
415
|
opts.on('--config-file FILE', String, "Config from a local JSON or YAML file") do |val|
|
349
416
|
options[:config_file] = val.to_s
|
350
417
|
file_content = nil
|
@@ -435,7 +502,7 @@ EOT
|
|
435
502
|
params['workflow'] = {'id' => params['workflow']} if params['workflow'] && !params['workflow'].is_a?(Hash)
|
436
503
|
params['blueprint'] = {'id' => params['blueprint']} if params['blueprint'] && !params['blueprint'].is_a?(Hash)
|
437
504
|
payload.deep_merge!({catalog_item_type_object_key => params})
|
438
|
-
if payload[catalog_item_type_object_key].empty? # || options[:no_prompt]
|
505
|
+
if payload[catalog_item_type_object_key].empty? && (!logo_file && !dark_logo_file)# || options[:no_prompt]
|
439
506
|
raise_command_error "Specify at least one option to update.\n#{optparse}"
|
440
507
|
end
|
441
508
|
end
|
@@ -445,6 +512,16 @@ EOT
|
|
445
512
|
return
|
446
513
|
end
|
447
514
|
json_response = @catalog_item_types_interface.update(catalog_item_type['id'], payload)
|
515
|
+
if json_response['success']
|
516
|
+
if logo_file || dark_logo_file
|
517
|
+
begin
|
518
|
+
@catalog_item_types_interface.update_logo(json_response['catalogItemType']['id'], logo_file, dark_logo_file)
|
519
|
+
rescue RestClient::Exception => e
|
520
|
+
print_red_alert "Failed to save logo!"
|
521
|
+
print_rest_exception(e, options)
|
522
|
+
end
|
523
|
+
end
|
524
|
+
end
|
448
525
|
catalog_item_type = json_response[catalog_item_type_object_key]
|
449
526
|
render_response(json_response, options, catalog_item_type_object_key) do
|
450
527
|
print_green_success "Updated catalog item type #{catalog_item_type['name']}"
|
@@ -453,6 +530,84 @@ EOT
|
|
453
530
|
return 0, nil
|
454
531
|
end
|
455
532
|
|
533
|
+
def update_logo(args)
|
534
|
+
options = {}
|
535
|
+
params = {}
|
536
|
+
filename = nil
|
537
|
+
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
538
|
+
opts.banner = subcommand_usage("[type] [file]")
|
539
|
+
build_common_options(opts, options, [:json, :dry_run, :remote])
|
540
|
+
opts.footer = "Update the logo for a catalog item type." + "\n" +
|
541
|
+
"[type] is required. This is the name or id of a catalog item type." + "\n" +
|
542
|
+
"[file] is required. This is the path of the logo file"
|
543
|
+
end
|
544
|
+
optparse.parse!(args)
|
545
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
546
|
+
connect(options)
|
547
|
+
catalog_item_type = find_catalog_item_type_by_name_or_id(args[0])
|
548
|
+
return 1 if catalog_item_type.nil?
|
549
|
+
filename = args[1]
|
550
|
+
logo_file = nil
|
551
|
+
if filename == 'null'
|
552
|
+
filename = 'null' # clear it
|
553
|
+
else
|
554
|
+
filename = File.expand_path(filename)
|
555
|
+
if !File.exists?(filename)
|
556
|
+
raise_command_error "File not found: #{filename}"
|
557
|
+
end
|
558
|
+
logo_file = File.new(filename, 'rb')
|
559
|
+
end
|
560
|
+
@catalog_item_types_interface.setopts(options)
|
561
|
+
if options[:dry_run]
|
562
|
+
print_dry_run @catalog_item_types_interface.dry.update_logo(catalog_item_type['id'], logo_file)
|
563
|
+
return
|
564
|
+
end
|
565
|
+
json_response = @catalog_item_types_interface.update_logo(catalog_item_type['id'], logo_file)
|
566
|
+
render_response(json_response, options, catalog_item_type_object_key) do
|
567
|
+
print_green_success "Updated catalog item type #{catalog_item_type['name']} logo"
|
568
|
+
return _get(catalog_item_type["id"], {}, options)
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
def update_dark_logo(args)
|
573
|
+
options = {}
|
574
|
+
params = {}
|
575
|
+
filename = nil
|
576
|
+
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
577
|
+
opts.banner = subcommand_usage("[type] [file]")
|
578
|
+
build_common_options(opts, options, [:json, :dry_run, :remote])
|
579
|
+
opts.footer = "Update the dark logo for a catalog item type." + "\n" +
|
580
|
+
"[type] is required. This is the name or id of a catalog item type." + "\n" +
|
581
|
+
"[file] is required. This is the path of the dark logo file"
|
582
|
+
end
|
583
|
+
optparse.parse!(args)
|
584
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
585
|
+
connect(options)
|
586
|
+
catalog_item_type = find_catalog_item_type_by_name_or_id(args[0])
|
587
|
+
return 1 if catalog_item_type.nil?
|
588
|
+
filename = args[1]
|
589
|
+
dark_logo_file = nil
|
590
|
+
if filename == 'null'
|
591
|
+
dark_logo_file = 'null' # clear it
|
592
|
+
else
|
593
|
+
filename = File.expand_path(filename)
|
594
|
+
if !File.exists?(filename)
|
595
|
+
raise_command_error "File not found: #{filename}"
|
596
|
+
end
|
597
|
+
dark_logo_file = File.new(filename, 'rb')
|
598
|
+
end
|
599
|
+
@catalog_item_types_interface.setopts(options)
|
600
|
+
if options[:dry_run]
|
601
|
+
print_dry_run @catalog_item_types_interface.dry.update_logo(catalog_item_type['id'], nil, dark_logo_file)
|
602
|
+
return
|
603
|
+
end
|
604
|
+
json_response = @catalog_item_types_interface.update_logo(catalog_item_type['id'], nil, dark_logo_file)
|
605
|
+
render_response(json_response, options, catalog_item_type_object_key) do
|
606
|
+
print_green_success "Updated catalog item type #{catalog_item_type['name']} logo"
|
607
|
+
return _get(catalog_item_type["id"], {}, options)
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
456
611
|
def remove(args)
|
457
612
|
options = {}
|
458
613
|
params = {}
|