morpheus-cli 7.0.6 → 8.0.0
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 +11 -0
- data/lib/morpheus/api/clusters_interface.rb +25 -0
- data/lib/morpheus/api/datastores_interface.rb +6 -0
- data/lib/morpheus/api/library_operating_systems_interface.rb +63 -0
- data/lib/morpheus/api/processes_interface.rb +17 -5
- data/lib/morpheus/cli/commands/backup_jobs_command.rb +50 -17
- data/lib/morpheus/cli/commands/backups_command.rb +36 -9
- data/lib/morpheus/cli/commands/clusters.rb +398 -25
- data/lib/morpheus/cli/commands/hosts.rb +3 -0
- data/lib/morpheus/cli/commands/instances.rb +33 -4
- data/lib/morpheus/cli/commands/library_container_types_command.rb +6 -0
- data/lib/morpheus/cli/commands/library_operating_systems_command.rb +671 -0
- data/lib/morpheus/cli/commands/license.rb +11 -1
- data/lib/morpheus/cli/commands/plugins.rb +2 -2
- data/lib/morpheus/cli/commands/processes_command.rb +71 -1
- data/lib/morpheus/cli/commands/setup.rb +32 -18
- data/lib/morpheus/cli/commands/virtual_images.rb +10 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +28 -2
- data/lib/morpheus/cli/option_types.rb +9 -2
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/formatters.rb +12 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49afeaaa11ed794659cc20a46d3fc145990269dc96f1394a1cd95160bbc2f786
|
4
|
+
data.tar.gz: cdcf88755b1638f3d1816dde28dcfea8f8c6be27b9300bdfc3c6e4798d3937dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56f27f9ab0323061846e4b3df32d570efff1b944083fe27700a9d729540ad605a1a39a5c2005cc5a0e19880d5f039a7aa3dbc12ff2c31c9b511426ec736f83a7
|
7
|
+
data.tar.gz: 7d98ac1e35e7929f3f73ff3968d3a2d1221629d1a2c07d7cdd916b2aa184ca2d30041eaeaf2ac5d53c653650a0a36e0c39a33bebbb9bf02bdcf3e4f84e5173c8
|
data/Dockerfile
CHANGED
@@ -950,6 +950,14 @@ class Morpheus::APIClient
|
|
950
950
|
Morpheus::NetworkServerGroupsInterface.new(common_interface_options).setopts(@options)
|
951
951
|
end
|
952
952
|
|
953
|
+
def network_server_services
|
954
|
+
Morpheus::NetworkServerServicesInterface.new(common_interface_options).setopts(@options)
|
955
|
+
end
|
956
|
+
|
957
|
+
def network_resource_types
|
958
|
+
Morpheus::NetworkResourceTypesInterface.new(common_interface_options).setopts(@options)
|
959
|
+
end
|
960
|
+
|
953
961
|
def network_edge_clusters
|
954
962
|
Morpheus::NetworkEdgeClustersInterface.new(common_interface_options).setopts(@options)
|
955
963
|
end
|
@@ -1002,6 +1010,9 @@ class Morpheus::APIClient
|
|
1002
1010
|
Morpheus::EmailTemplatesInterface.new(common_interface_options).setopts(@options)
|
1003
1011
|
end
|
1004
1012
|
|
1013
|
+
def library_operating_systems
|
1014
|
+
Morpheus::LibraryOperatingSystemsInterface.new(common_interface_options).setopts(@options)
|
1015
|
+
end
|
1005
1016
|
|
1006
1017
|
def rest(endpoint)
|
1007
1018
|
Morpheus::RestInterface.new(common_interface_options).setopts(@options.merge({base_path: "#{@base_url}/api/#{endpoint}"}))
|
@@ -228,6 +228,12 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
228
228
|
execute(method: :get, url: url, headers: headers)
|
229
229
|
end
|
230
230
|
|
231
|
+
def get_container_group(cluster_id, resource_type, id, params={})
|
232
|
+
url = "#{base_path}/#{cluster_id}/#{resource_type}s/#{id}"
|
233
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
234
|
+
execute(method: :get, url: url, headers: headers)
|
235
|
+
end
|
236
|
+
|
231
237
|
def restart_container_group(id, container_group_id, resource_type, params={})
|
232
238
|
url = "#{base_path}/#{id}/#{resource_type}s/#{container_group_id}/restart"
|
233
239
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -259,12 +265,24 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
259
265
|
execute(method: :get, url: url, headers: headers)
|
260
266
|
end
|
261
267
|
|
268
|
+
def create_datastore(id, payload)
|
269
|
+
url = "#{base_path}/#{id}/data-stores"
|
270
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
271
|
+
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
272
|
+
end
|
273
|
+
|
262
274
|
def update_datastore(id, datastore_id, payload)
|
263
275
|
url = "#{base_path}/#{id}/datastores/#{datastore_id}"
|
264
276
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
265
277
|
execute(method: :put, url: url, headers: headers, payload: payload.to_json)
|
266
278
|
end
|
267
279
|
|
280
|
+
def destroy_datastore(id, datastore_id, params={})
|
281
|
+
url = "#{base_path}/#{id}/datastores/#{datastore_id}"
|
282
|
+
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
283
|
+
execute(method: :delete, url: url, headers: headers)
|
284
|
+
end
|
285
|
+
|
268
286
|
def wiki(id, params)
|
269
287
|
url = "#{@base_url}/api/clusters/#{id}/wiki"
|
270
288
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
@@ -320,4 +338,11 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
320
338
|
opts = {method: :get, url: url, headers: headers}
|
321
339
|
execute(opts)
|
322
340
|
end
|
341
|
+
|
342
|
+
def list_resources(id, resources, params={})
|
343
|
+
url = "#{base_path}/#{id}/#{resources}"
|
344
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
345
|
+
execute(method: :get, url: url, headers: headers)
|
346
|
+
end
|
347
|
+
|
323
348
|
end
|
@@ -12,4 +12,10 @@ class Morpheus::DatastoresInterface < Morpheus::APIClient
|
|
12
12
|
execute(method: :get, url: url, headers: headers)
|
13
13
|
end
|
14
14
|
|
15
|
+
def types(params={})
|
16
|
+
url = "/api/data-store-types"
|
17
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
18
|
+
opts = {method: :get, url: url, headers: headers}
|
19
|
+
execute(opts)
|
20
|
+
end
|
15
21
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::LibraryOperatingSystemsInterface < Morpheus::APIClient
|
4
|
+
|
5
|
+
def list_os_types(params={})
|
6
|
+
url = "#{@base_url}/api/library/operating-systems/os-types"
|
7
|
+
params['pageConfig'] = { sort:'owner,name', order:'desc,asc' }
|
8
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
9
|
+
opts = {method: :get, url: url, headers: headers}
|
10
|
+
execute(opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(id, params={})
|
14
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
15
|
+
url = "#{@base_url}/api/library/operating-systems/os-types/#{id}"
|
16
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
17
|
+
opts = {method: :get, url: url, headers: headers}
|
18
|
+
execute(opts)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(id, payload)
|
22
|
+
url = "#{@base_url}/api/library/operating-systems/#{id}"
|
23
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
24
|
+
opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
|
25
|
+
execute(opts)
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_image(id, params={})
|
29
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
30
|
+
url = "#{@base_url}/api/library/operating-systems/os-types/images/#{id}"
|
31
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
32
|
+
opts = {method: :get, url: url, headers: headers}
|
33
|
+
execute(opts)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_image(payload)
|
37
|
+
url = "#{@base_url}/api/library/operating-systems/os-types/create-image"
|
38
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
39
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
40
|
+
execute(opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create(payload)
|
44
|
+
url = "#{@base_url}/api/library/operating-systems"
|
45
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
46
|
+
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
47
|
+
execute(opts)
|
48
|
+
end
|
49
|
+
|
50
|
+
def destroy_image(id, payload={})
|
51
|
+
url = "#{@base_url}/api/library/operating-systems/os-types/images/#{id}"
|
52
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
53
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
54
|
+
execute(opts)
|
55
|
+
end
|
56
|
+
|
57
|
+
def destroy(id, payload={})
|
58
|
+
url = "#{@base_url}/api/library/operating-systems/#{id}"
|
59
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
60
|
+
opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
|
61
|
+
execute(opts)
|
62
|
+
end
|
63
|
+
end
|
@@ -2,8 +2,12 @@ require 'morpheus/api/api_client'
|
|
2
2
|
|
3
3
|
class Morpheus::ProcessesInterface < Morpheus::APIClient
|
4
4
|
|
5
|
+
def base_path
|
6
|
+
"/api/processes"
|
7
|
+
end
|
8
|
+
|
5
9
|
def list(params={})
|
6
|
-
url =
|
10
|
+
url = base_path
|
7
11
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
8
12
|
opts = {method: :get, url: url, headers: headers}
|
9
13
|
execute(opts)
|
@@ -11,18 +15,26 @@ class Morpheus::ProcessesInterface < Morpheus::APIClient
|
|
11
15
|
|
12
16
|
def get(id, params={})
|
13
17
|
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
14
|
-
url = "#{
|
18
|
+
url = "#{base_path}/#{CGI::escape(id.to_s)}"
|
15
19
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
16
20
|
opts = {method: :get, url: url, headers: headers}
|
17
21
|
execute(opts)
|
18
22
|
end
|
19
23
|
|
20
|
-
def get_event(
|
21
|
-
raise "#{self.class}.get() passed a blank id!" if
|
22
|
-
url = "#{
|
24
|
+
def get_event(event_id, params={})
|
25
|
+
raise "#{self.class}.get() passed a blank event id!" if event_id.to_s == ''
|
26
|
+
url = "#{base_path}/events/#{CGI::escape(event_id.to_s)}"
|
23
27
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
24
28
|
opts = {method: :get, url: url, headers: headers}
|
25
29
|
execute(opts)
|
26
30
|
end
|
27
31
|
|
32
|
+
def retry(id, payload={}, params={}, headers={})
|
33
|
+
execute(method: :post, url: "#{base_path}/#{CGI::escape(id.to_s)}/retry", params: params, payload: payload, headers: headers)
|
34
|
+
end
|
35
|
+
|
36
|
+
def cancel(id, payload={}, params={}, headers={})
|
37
|
+
execute(method: :post, url: "#{base_path}/#{CGI::escape(id.to_s)}/cancel", params: params, payload: payload, headers: headers)
|
38
|
+
end
|
39
|
+
|
28
40
|
end
|
@@ -16,6 +16,8 @@ class Morpheus::Cli::BackupJobsCommand
|
|
16
16
|
@api_client = establish_remote_appliance_connection(opts)
|
17
17
|
@backups_interface = @api_client.backups
|
18
18
|
@backup_jobs_interface = @api_client.backup_jobs
|
19
|
+
@backup_settings_interface = @api_client.backup_settings
|
20
|
+
@options_interface = @api_client.options
|
19
21
|
end
|
20
22
|
|
21
23
|
def handle(args)
|
@@ -107,6 +109,9 @@ EOT
|
|
107
109
|
columns = backup_job_column_definitions
|
108
110
|
columns.delete("Provider") if backup_job['backupProvider'].nil?
|
109
111
|
columns.delete("Repository") if backup_job['backupRepository'].nil?
|
112
|
+
columns.delete("Synthetic Full Enabled") if backup_job['syntheticFull'].nil?
|
113
|
+
columns.delete("Synthetic Full Schedule") if backup_job['syntheticFull'].nil?
|
114
|
+
columns.delete("Synthetic Full Next") if backup_job['syntheticFull'].nil?
|
110
115
|
print_description_list(columns, backup_job)
|
111
116
|
# print reset,"\n"
|
112
117
|
print_h2 "Backups", options
|
@@ -123,10 +128,10 @@ EOT
|
|
123
128
|
def add(args)
|
124
129
|
options = {}
|
125
130
|
params = {}
|
131
|
+
|
126
132
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
127
133
|
opts.banner = "Usage: #{prog_name} backups add-job [name]"
|
128
134
|
build_option_type_options(opts, options, add_backup_job_option_types)
|
129
|
-
build_option_type_options(opts, options, add_backup_job_advanced_option_types)
|
130
135
|
build_standard_add_options(opts, options)
|
131
136
|
opts.footer = <<-EOT
|
132
137
|
Create a new backup job
|
@@ -142,14 +147,23 @@ EOT
|
|
142
147
|
payload.deep_merge!({'job' => parse_passed_options(options)})
|
143
148
|
else
|
144
149
|
payload.deep_merge!({'job' => parse_passed_options(options)})
|
145
|
-
|
150
|
+
|
151
|
+
avail_job_types = @options_interface.options_for_source('backupJobTypes',{})['data']
|
152
|
+
if avail_job_types.empty?
|
153
|
+
raise_command_error "No available backup job types found"
|
154
|
+
else
|
155
|
+
params["jobTypeId"] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'jobTypeId', 'fieldLabel' => 'Type', 'type' => 'select', 'selectOptions' => avail_job_types, 'defaultValue' => avail_job_types[0] ? avail_job_types[0]['name'] : nil, 'required' => true}], options[:options], @api_client)["jobTypeId"]
|
156
|
+
end
|
157
|
+
|
158
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt(add_backup_job_option_types, options[:options], @api_client, options[:params])
|
146
159
|
params.deep_merge!(v_prompt)
|
147
160
|
if params['scheduleId'] == 'manual' || params['scheduleId'] == ''
|
148
161
|
params['scheduleId'] = nil
|
149
162
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
163
|
+
|
164
|
+
job_type_config = Morpheus::Cli::OptionTypes.prompt(add_backup_job_type_option_types("new", params["jobTypeId"], options), options[:options].deep_merge({ :context_map => { 'domain' => ''}}), @api_client, options[:params])
|
165
|
+
job_type_config.deep_compact!
|
166
|
+
params.deep_merge!(job_type_config)
|
153
167
|
payload['job'].deep_merge!(params)
|
154
168
|
end
|
155
169
|
@backup_jobs_interface.setopts(options)
|
@@ -173,7 +187,6 @@ EOT
|
|
173
187
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
174
188
|
opts.banner = "Usage: #{prog_name} backups update-job [job]"
|
175
189
|
build_option_type_options(opts, options, update_backup_job_option_types)
|
176
|
-
build_option_type_options(opts, options, update_backup_job_advanced_option_types)
|
177
190
|
build_standard_update_options(opts, options)
|
178
191
|
opts.footer = <<-EOT
|
179
192
|
Update a backup job.
|
@@ -197,7 +210,7 @@ EOT
|
|
197
210
|
v_prompt['scheduleId'] = nil
|
198
211
|
end
|
199
212
|
params.deep_merge!(v_prompt)
|
200
|
-
advanced_config = Morpheus::Cli::OptionTypes.no_prompt(
|
213
|
+
advanced_config = Morpheus::Cli::OptionTypes.no_prompt(update_backup_job_type_option_types("new", get_object_value(backup_job, "jobType.id"), options[:params]), options[:options], @api_client, options[:params])
|
201
214
|
advanced_config.deep_compact!
|
202
215
|
params.deep_merge!(advanced_config)
|
203
216
|
payload.deep_merge!({'job' => params})
|
@@ -278,6 +291,9 @@ EOT
|
|
278
291
|
"Schedule" => lambda {|it| it['schedule']['name'] rescue '' },
|
279
292
|
"Next" => lambda {|it| format_local_dt(it['nextFire']) },
|
280
293
|
"Retention Count" => lambda {|it| it['retentionCount'] rescue '' },
|
294
|
+
"Synthetic Full Enabled" => lambda {|it| it['syntheticFull']['enabled'] rescue ''},
|
295
|
+
"Synthetic Full Schedule" => lambda {|it| it['syntheticFull']['schedule']['name'] rescue ''},
|
296
|
+
"Synthetic Full Next" => lambda {|it| format_local_dt(it['syntheticFull']['nextFire']) rescue ''},
|
281
297
|
"Provider" => lambda {|it| it['backupProvider']['name'] rescue '' },
|
282
298
|
"Repository" => lambda {|it| it['backupRepository']['name'] rescue '' },
|
283
299
|
"Source" => lambda {|it| it['source'] },
|
@@ -301,17 +317,34 @@ EOT
|
|
301
317
|
def add_backup_job_option_types
|
302
318
|
[
|
303
319
|
{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'displayOrder' => 1},
|
304
|
-
{'fieldName' => 'code', 'fieldLabel' => 'Code', 'type' => 'text', 'required' => false, 'displayOrder' => 2}
|
305
|
-
{'fieldName' => 'retentionCount', 'fieldLabel' => 'Retention Count', 'type' => 'number', 'displayOrder' => 3},
|
306
|
-
{'fieldName' => 'scheduleId', 'fieldLabel' => 'Schedule', 'type' => 'select', 'optionSource' => lambda { |api_client, api_params|
|
307
|
-
schedules = api_client.options.options_for_source('executeSchedules',{})['data']
|
308
|
-
[{"name" => "Manual", "value" => "manual"}] + schedules
|
309
|
-
}, 'displayOrder' => 4},
|
320
|
+
{'fieldName' => 'code', 'fieldLabel' => 'Code', 'type' => 'text', 'required' => false, 'displayOrder' => 2}
|
310
321
|
]
|
311
322
|
end
|
312
323
|
|
313
|
-
def
|
314
|
-
[]
|
324
|
+
def add_backup_job_type_option_types(job_action, backup_job_type, options)
|
325
|
+
backup_settings = @backup_settings_interface.get(options)["backupSettings"] || {}
|
326
|
+
# get job defaults
|
327
|
+
default_retention_count = options&.dig('backupJob', 'retentionCount') || get_object_value(backup_settings, "retentionCount")
|
328
|
+
default_schedule = options&.dig('backupJob', 'scheduleTypeId') || get_object_value(backup_settings, "defaultSchedule.id")
|
329
|
+
default_synthetic_enabled = options&.dig('backupJob', 'syntheticFullEnabled') || get_object_value(backup_settings, "defaultSyntheticFullBackupsEnabled")
|
330
|
+
default_synthetic_schedule = options&.dig('backupJob', 'syntheticFullSchedule') || get_object_value(backup_settings, "defaultSyntheticFullBackupSchedule.id")
|
331
|
+
job_input_params = {jobAction: job_action, id: backup_job_type}
|
332
|
+
job_inputs = @options_interface.options_for_source('backupJobOptionTypes', job_input_params)['data']['optionTypes']
|
333
|
+
job_inputs.each do | input |
|
334
|
+
# set input defaults from global settings
|
335
|
+
input['defaultValue'] = case input['fieldName']
|
336
|
+
when "retentionCount"
|
337
|
+
default_retention_count
|
338
|
+
when "scheduleTypeId"
|
339
|
+
default_schedule
|
340
|
+
when "syntheticFullEnabled"
|
341
|
+
default_synthetic_enabled
|
342
|
+
when "syntheticFullSchedule"
|
343
|
+
default_synthetic_schedule
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
job_inputs
|
315
348
|
end
|
316
349
|
|
317
350
|
def update_backup_job_option_types
|
@@ -322,8 +355,8 @@ EOT
|
|
322
355
|
}
|
323
356
|
end
|
324
357
|
|
325
|
-
def
|
326
|
-
|
358
|
+
def update_backup_job_type_option_types(job_action, backup_job_type, options)
|
359
|
+
add_backup_job_type_option_types(job_action, backup_job_type, options).collect {|it|
|
327
360
|
it.delete('required')
|
328
361
|
it.delete('defaultValue')
|
329
362
|
it
|
@@ -22,6 +22,7 @@ class Morpheus::Cli::BackupsCommand
|
|
22
22
|
@backup_restores_interface = @api_client.backup_restores
|
23
23
|
@instances_interface = @api_client.instances
|
24
24
|
@servers_interface = @api_client.servers
|
25
|
+
@options_interface = @api_client.options
|
25
26
|
end
|
26
27
|
|
27
28
|
def handle(args)
|
@@ -188,15 +189,6 @@ EOT
|
|
188
189
|
params['jobAction'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'jobAction', 'fieldLabel' => 'Backup Job Type', 'type' => 'select', 'optionSource' => 'backupJobActions', 'required' => true, 'defaultValue' => 'new'}], options[:options], @api_client)['jobAction']
|
189
190
|
if params['jobAction'] == 'new'
|
190
191
|
params['jobName'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'jobName', 'fieldLabel' => 'Job Name', 'type' => 'text', 'required' => false, 'defaultValue' => nil}], options[:options], @api_client)['jobName']
|
191
|
-
default_retention_count = (create_results['backup'] && create_results['backup']['retentionCount']) ? create_results['backup']['retentionCount'] : ((create_results['backupSettings'] && create_results['backupSettings']['retentionCount']) ? create_results['backupSettings']['retentionCount'] : nil)
|
192
|
-
params['retentionCount'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'retentionCount', 'fieldLabel' => 'Retention Count', 'type' => 'number', 'required' => false, 'defaultValue' => default_retention_count}], options[:options], @api_client)['retentionCount']
|
193
|
-
params['jobSchedule'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'jobSchedule', 'fieldLabel' => 'Backup Schedule', 'type' => 'select', 'optionSource' => lambda { |api_client, api_params|
|
194
|
-
schedules = api_client.options.options_for_source('executeSchedules',{})['data']
|
195
|
-
[{"name" => "Manual", "value" => "manual"}] + schedules
|
196
|
-
}, 'required' => false}], options[:options], @api_client)['jobSchedule']
|
197
|
-
if params['jobSchedule'] == 'manual' || params['jobSchedule'] == ''
|
198
|
-
params.delete('jobSchedule')
|
199
|
-
end
|
200
192
|
elsif params['jobAction'] == 'clone'
|
201
193
|
params['jobId'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'jobId', 'fieldLabel' => 'Backup Job', 'type' => 'select', 'optionSource' => lambda { |api_client, api_params|
|
202
194
|
@backup_jobs_interface.list({max:10000})['jobs'].collect {|backup_job|
|
@@ -211,9 +203,20 @@ EOT
|
|
211
203
|
}
|
212
204
|
}, 'required' => true}], options[:options], @api_client)['jobId']
|
213
205
|
end
|
206
|
+
|
207
|
+
# new job option types
|
208
|
+
job_inputs = build_backup_job_option_types(params['jobAction'], params['backupType'], create_results)
|
209
|
+
job_opt_parser = Morpheus::Cli::OptionParser.new do |opts|
|
210
|
+
build_option_type_options(opts, options, job_inputs)
|
211
|
+
end
|
212
|
+
job_opt_parser.parse!(args)
|
213
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt(job_inputs, options[:options].deep_merge({:context_map => {'domain' => 'backupJob'}}), @api_client)
|
214
|
+
v_prompt.deep_compact!.booleanize! # remove empty values and convert checkbox "on" and "off" to true and false
|
215
|
+
params.deep_merge!(v_prompt)
|
214
216
|
end
|
215
217
|
payload['backup'].deep_merge!(params)
|
216
218
|
end
|
219
|
+
#options[:payload] = payload
|
217
220
|
execute_api(@backups_interface, :create, [], options, 'backup') do |json_response|
|
218
221
|
backup = json_response['backup']
|
219
222
|
print_green_success "Added backup #{backup['name']}"
|
@@ -482,6 +485,30 @@ EOT
|
|
482
485
|
private
|
483
486
|
|
484
487
|
## Backups
|
488
|
+
def build_backup_job_option_types(job_action, backup_type, config_opts)
|
489
|
+
# get job defaults
|
490
|
+
default_retention_count = config_opts.dig('backup', 'retentionCount') || config_opts.dig('backupSettings', 'retentionCount')
|
491
|
+
default_schedule = config_opts.dig('backup', 'scheduleTypeId') || config_opts.dig('backup', 'backupJob', 'scheduleTypeId') || config_opts.dig('backupSettings', 'defaultBackupSchedule')
|
492
|
+
default_synthetic_enabled = config_opts.dig('backup', 'backupJob', 'syntheticFullEnabled') || config_opts.dig('backupSettings', 'defaultSyntheticFullBackupsEnabled')
|
493
|
+
default_synthetic_schedule = config_opts.dig('backup', 'backupJob', 'syntheticFullSchedule') || config_opts.dig('backupSettings', 'defaultSyntheticFullBackupSchedule')
|
494
|
+
job_input_params = {jobAction: job_action, backupTypeCode: backup_type}
|
495
|
+
job_inputs = @options_interface.options_for_source('backupJobOptionTypes', job_input_params)['data']['optionTypes']
|
496
|
+
job_inputs.each do | input |
|
497
|
+
# set input defaults from global settings
|
498
|
+
input['defaultValue'] = case input['fieldName']
|
499
|
+
when "retentionCount"
|
500
|
+
default_retention_count
|
501
|
+
when "scheduleTypeId"
|
502
|
+
default_schedule
|
503
|
+
when "syntheticFullEnabled"
|
504
|
+
default_synthetic_enabled
|
505
|
+
when "syntheticFullSchedule"
|
506
|
+
default_synthetic_schedule
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
job_inputs
|
511
|
+
end
|
485
512
|
|
486
513
|
def backup_list_column_definitions()
|
487
514
|
{
|