morpheus-cli 4.1.6 → 4.1.7
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/api/api_client.rb +8 -0
- data/lib/morpheus/api/backup_settings_interface.rb +23 -0
- data/lib/morpheus/api/log_settings_interface.rb +41 -0
- data/lib/morpheus/api/servers_interface.rb +2 -1
- data/lib/morpheus/cli.rb +2 -0
- data/lib/morpheus/cli/appliance_settings_command.rb +2 -2
- data/lib/morpheus/cli/backup_settings_command.rb +181 -0
- data/lib/morpheus/cli/deployments.rb +1 -1
- data/lib/morpheus/cli/hosts.rb +21 -8
- data/lib/morpheus/cli/instances.rb +1 -1
- data/lib/morpheus/cli/license.rb +9 -3
- data/lib/morpheus/cli/log_settings_command.rb +396 -0
- data/lib/morpheus/cli/mixins/infrastructure_helper.rb +4 -4
- data/lib/morpheus/cli/network_groups_command.rb +23 -4
- data/lib/morpheus/cli/networks_command.rb +11 -7
- data/lib/morpheus/cli/security_groups.rb +152 -2
- data/lib/morpheus/cli/subnets_command.rb +46 -19
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +17 -11
- metadata +6 -2
@@ -459,13 +459,13 @@ module Morpheus::Cli::InfrastructureHelper
|
|
459
459
|
bad_ids = []
|
460
460
|
if record_list && record_list.size > 0
|
461
461
|
record_list.each do |it|
|
462
|
-
|
462
|
+
found_subnet = nil
|
463
463
|
begin
|
464
|
-
|
464
|
+
found_subnet = find_subnet_by_name_or_id(it)
|
465
465
|
rescue SystemExit => cmdexit
|
466
466
|
end
|
467
|
-
if
|
468
|
-
record_ids <<
|
467
|
+
if found_subnet
|
468
|
+
record_ids << found_subnet['id']
|
469
469
|
else
|
470
470
|
bad_ids << it
|
471
471
|
end
|
@@ -75,12 +75,13 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
75
75
|
# networks: network_group['networks'] ? network_group['networks'].collect {|it| it['name'] }.uniq.join(', ') : '',
|
76
76
|
networks: network_group['networks'] ? network_group['networks'].size : 0,
|
77
77
|
subnets: network_group['subnets'] ? network_group['subnets'].size : 0,
|
78
|
+
active: format_boolean(network_group['active']),
|
78
79
|
visibility: network_group['visibility'].to_s.capitalize,
|
79
80
|
tenants: network_group['tenants'] ? network_group['tenants'].collect {|it| it['name'] }.uniq.join(', ') : ''
|
80
81
|
}
|
81
82
|
row
|
82
83
|
}
|
83
|
-
columns = [:id, :name, :description, :networks, :subnets, :visibility, :tenants]
|
84
|
+
columns = [:id, :name, :description, :networks, :subnets, :active, :visibility, :tenants]
|
84
85
|
if options[:include_fields]
|
85
86
|
columns = options[:include_fields]
|
86
87
|
end
|
@@ -143,9 +144,9 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
143
144
|
"Description" => 'description',
|
144
145
|
"Networks" => lambda {|it| it['networks'].size rescue 'n/a' },
|
145
146
|
"Subnets" => lambda {|it| it['subnets'].size rescue 'n/a' },
|
147
|
+
"Active" => lambda {|it| it['active'].to_s.capitalize },
|
146
148
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
147
149
|
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
148
|
-
# "Owner" => lambda {|it| it['owner'] ? it['owner']['name'] : '' },
|
149
150
|
}
|
150
151
|
print_description_list(description_cols, network_group)
|
151
152
|
|
@@ -159,8 +160,9 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
159
160
|
#"Description" => 'description',
|
160
161
|
"Type" => lambda {|it| it['type']['name'] rescue it['type'] },
|
161
162
|
"CIDR" => lambda {|it| it['cidr'] },
|
163
|
+
"Active" => lambda {|it| it['active'].to_s.capitalize },
|
162
164
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
163
|
-
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' }
|
165
|
+
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
164
166
|
}
|
165
167
|
print cyan
|
166
168
|
print as_pretty_table(networks, subnet_columns)
|
@@ -177,8 +179,9 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
177
179
|
#"Description" => 'description',
|
178
180
|
"Type" => lambda {|it| it['type']['name'] rescue it['type'] },
|
179
181
|
"CIDR" => lambda {|it| it['cidr'] },
|
182
|
+
"Active" => lambda {|it| it['active'].to_s.capitalize },
|
180
183
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
181
|
-
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' }
|
184
|
+
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
182
185
|
}
|
183
186
|
print cyan
|
184
187
|
print as_pretty_table(subnets, subnet_columns)
|
@@ -276,6 +279,9 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
276
279
|
opts.on('--visibility [private|public]', String, "Visibility") do |val|
|
277
280
|
options['visibility'] = val
|
278
281
|
end
|
282
|
+
opts.on('--active [on|off]', String, "Can be used to disable a network group") do |val|
|
283
|
+
options['active'] = val.to_s == 'on' || val.to_s == 'true'
|
284
|
+
end
|
279
285
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
|
280
286
|
opts.footer = "Create a new network group." + "\n" +
|
281
287
|
"[name] is required and can be passed as --name instead."
|
@@ -379,6 +385,11 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
379
385
|
payload['networkGroup']['visibility'] = options['visibility']
|
380
386
|
end
|
381
387
|
|
388
|
+
# Active
|
389
|
+
if options['active'] != nil
|
390
|
+
payload['networkGroup']['active'] = options['active']
|
391
|
+
end
|
392
|
+
|
382
393
|
end
|
383
394
|
|
384
395
|
@network_groups_interface.setopts(options)
|
@@ -464,6 +475,9 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
464
475
|
opts.on('--visibility [private|public]', String, "Visibility") do |val|
|
465
476
|
options['visibility'] = val
|
466
477
|
end
|
478
|
+
opts.on('--active [on|off]', String, "Can be used to disable a network group") do |val|
|
479
|
+
options['active'] = val.to_s == 'on' || val.to_s == 'true'
|
480
|
+
end
|
467
481
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
468
482
|
opts.footer = "Update a network group." + "\n" +
|
469
483
|
"[network-group] is required. This is the id of a network group."
|
@@ -560,6 +574,11 @@ class Morpheus::Cli::NetworkGroupsCommand
|
|
560
574
|
payload['networkGroup']['visibility'] = options['visibility']
|
561
575
|
end
|
562
576
|
|
577
|
+
# Active
|
578
|
+
if options['active'] != nil
|
579
|
+
payload['networkGroup']['active'] = options['active']
|
580
|
+
end
|
581
|
+
|
563
582
|
end
|
564
583
|
@network_groups_interface.setopts(options)
|
565
584
|
if options[:dry_run]
|
@@ -14,7 +14,7 @@ class Morpheus::Cli::NetworksCommand
|
|
14
14
|
register_subcommands :'types' => :list_types
|
15
15
|
register_subcommands :'get-type' => :get_type
|
16
16
|
|
17
|
-
register_subcommands :list_subnets, # :get_subnet, :add_subnet, :update_subnet, :remove_subnet
|
17
|
+
#register_subcommands :list_subnets, # :get_subnet, :add_subnet, :update_subnet, :remove_subnet
|
18
18
|
|
19
19
|
def initialize()
|
20
20
|
# @appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
@@ -39,7 +39,7 @@ class Morpheus::Cli::NetworksCommand
|
|
39
39
|
params = {}
|
40
40
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
41
41
|
opts.banner = subcommand_usage()
|
42
|
-
opts.on( '-c', '--cloud CLOUD', "Cloud" ) do |val|
|
42
|
+
opts.on( '-c', '--cloud CLOUD', "Filter by Cloud" ) do |val|
|
43
43
|
options[:cloud] = val
|
44
44
|
end
|
45
45
|
opts.on('--cidr VALUE', String, "Filter by cidr, matches beginning of value.") do |val|
|
@@ -103,6 +103,7 @@ class Morpheus::Cli::NetworksCommand
|
|
103
103
|
dhcp: network['dhcpServer'] ? 'Yes' : 'No',
|
104
104
|
subnets: (network['subnets'].size rescue 'n/a'),
|
105
105
|
visibility: network['visibility'].to_s.capitalize,
|
106
|
+
active: format_boolean(network['active']),
|
106
107
|
tenants: network['tenants'] ? network['tenants'].collect {|it| it['name'] }.uniq.join(', ') : ''
|
107
108
|
}
|
108
109
|
rows << row
|
@@ -118,13 +119,14 @@ class Morpheus::Cli::NetworksCommand
|
|
118
119
|
pool: subnet['pool'] ? subnet['pool']['name'] : '',
|
119
120
|
dhcp: subnet['dhcpServer'] ? 'Yes' : 'No',
|
120
121
|
visibility: subnet['visibility'].to_s.capitalize,
|
122
|
+
active: format_boolean(network['active']),
|
121
123
|
tenants: subnet['tenants'] ? subnet['tenants'].collect {|it| it['name'] }.uniq.join(', ') : ''
|
122
124
|
}
|
123
125
|
rows << subnet_row
|
124
126
|
end
|
125
127
|
end
|
126
128
|
end
|
127
|
-
columns = [:id, :name, :type, :cloud, :cidr, :pool, :dhcp, :subnets, :visibility, :tenants]
|
129
|
+
columns = [:id, :name, :type, :cloud, :cidr, :pool, :dhcp, :subnets, :active, :visibility, :tenants]
|
128
130
|
if options[:include_fields]
|
129
131
|
columns = options[:include_fields]
|
130
132
|
end
|
@@ -198,10 +200,10 @@ class Morpheus::Cli::NetworksCommand
|
|
198
200
|
"Pool" => lambda {|it| it['pool'] ? it['pool']['name'] : '' },
|
199
201
|
"VPC" => lambda {|it| it['zonePool'] ? it['zonePool']['name'] : '' },
|
200
202
|
"DHCP" => lambda {|it| it['dhcpServer'] ? 'Yes' : 'No' },
|
203
|
+
"Active" => lambda {|it| format_boolean(it['active']) },
|
201
204
|
"Allow IP Override" => lambda {|it| it['allowStaticOverride'] ? 'Yes' : 'No' },
|
202
205
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
203
206
|
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
204
|
-
# "Owner" => lambda {|it| it['owner'] ? it['owner']['name'] : '' },
|
205
207
|
}
|
206
208
|
print_description_list(description_cols, network)
|
207
209
|
|
@@ -243,10 +245,11 @@ class Morpheus::Cli::NetworksCommand
|
|
243
245
|
pool: subnet['pool'] ? subnet['pool']['name'] : '',
|
244
246
|
dhcp: subnet['dhcpServer'] ? 'Yes' : 'No',
|
245
247
|
visibility: subnet['visibility'].to_s.capitalize,
|
248
|
+
active: format_boolean(subnet['active']),
|
246
249
|
tenants: subnet['tenants'] ? subnet['tenants'].collect {|it| it['name'] }.uniq.join(', ') : ''
|
247
250
|
}
|
248
251
|
}
|
249
|
-
columns = [:id, :name, :cidr, :dhcp, :visibility]
|
252
|
+
columns = [:id, :name, :cidr, :dhcp, :active, :visibility]
|
250
253
|
print cyan
|
251
254
|
print as_pretty_table(subnet_rows, columns, options)
|
252
255
|
print reset
|
@@ -451,7 +454,7 @@ class Morpheus::Cli::NetworksCommand
|
|
451
454
|
# if option_type['fieldContext'] == 'domain'
|
452
455
|
# option_type['fieldContext'] = 'network'
|
453
456
|
# end
|
454
|
-
option_type['fieldContext'] = nil
|
457
|
+
#option_type['fieldContext'] = nil
|
455
458
|
end
|
456
459
|
network_type_params = Morpheus::Cli::OptionTypes.prompt(network_type_option_types,options[:options],@api_client, {zoneId: cloud['id']})
|
457
460
|
payload['network'].deep_merge!(network_type_params)
|
@@ -1199,8 +1202,9 @@ class Morpheus::Cli::NetworksCommand
|
|
1199
1202
|
#"Description" => 'description',
|
1200
1203
|
"Type" => lambda {|it| it['type']['name'] rescue it['type'] },
|
1201
1204
|
"CIDR" => lambda {|it| it['cidr'] },
|
1205
|
+
"Active" => lambda {|it| format_boolean(it['active']) },
|
1202
1206
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
1203
|
-
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' }
|
1207
|
+
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
1204
1208
|
}
|
1205
1209
|
print cyan
|
1206
1210
|
print as_pretty_table(subnets, subnet_columns)
|
@@ -154,11 +154,35 @@ class Morpheus::Cli::SecurityGroups
|
|
154
154
|
"Name" => 'name',
|
155
155
|
"Description" => 'description',
|
156
156
|
"Scoped Cloud" => lambda {|it| it['zone'] ? it['zone']['name'] : 'All' },
|
157
|
-
"Source" => lambda {|it| it['syncSource'] == 'external' ? 'SYNCED' : 'CREATED' }
|
157
|
+
"Source" => lambda {|it| it['syncSource'] == 'external' ? 'SYNCED' : 'CREATED' },
|
158
|
+
# "Active" => lambda {|it| format_boolean(it['active']) },
|
159
|
+
"Visibility" => 'visibility',
|
160
|
+
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.sort.join(', ') : '' },
|
158
161
|
}
|
159
162
|
print_description_list(description_cols, security_group)
|
160
163
|
# print reset,"\n"
|
161
164
|
|
165
|
+
if security_group['resourcePermission'].nil?
|
166
|
+
#print "\n", "No group access found", "\n"
|
167
|
+
else
|
168
|
+
print_h2 "Group Access"
|
169
|
+
rows = []
|
170
|
+
if security_group['resourcePermission']['all']
|
171
|
+
rows.push({"name" => 'All'})
|
172
|
+
end
|
173
|
+
if security_group['resourcePermission']['sites']
|
174
|
+
security_group['resourcePermission']['sites'].each do |site|
|
175
|
+
rows.push(site)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
rows = rows.collect do |site|
|
179
|
+
{group: site['name'], default: site['default'] ? 'Yes' : ''}
|
180
|
+
end
|
181
|
+
columns = [:group, :default]
|
182
|
+
print cyan
|
183
|
+
print as_pretty_table(rows, columns)
|
184
|
+
end
|
185
|
+
|
162
186
|
if security_group_locations && security_group_locations.size > 0
|
163
187
|
print_h2 "Locations"
|
164
188
|
print cyan
|
@@ -225,6 +249,10 @@ class Morpheus::Cli::SecurityGroups
|
|
225
249
|
params = {}
|
226
250
|
options = {:options => {}}
|
227
251
|
cloud_id = nil
|
252
|
+
tenants = nil
|
253
|
+
group_access_all = nil
|
254
|
+
group_access_list = nil
|
255
|
+
group_defaults_list = nil
|
228
256
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
229
257
|
opts.banner = subcommand_usage("[name] [options]")
|
230
258
|
opts.on( '--name Name', String, "Name of the security group" ) do |val|
|
@@ -236,6 +264,33 @@ class Morpheus::Cli::SecurityGroups
|
|
236
264
|
opts.on( '-c', '--cloud CLOUD', "Scoped Cloud Name or ID" ) do |val|
|
237
265
|
cloud_id = val
|
238
266
|
end
|
267
|
+
opts.on('--group-access-all [on|off]', String, "Toggle Access for all groups.") do |val|
|
268
|
+
group_access_all = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
|
269
|
+
end
|
270
|
+
opts.on('--group-access LIST', Array, "Group Access, comma separated list of group IDs.") do |list|
|
271
|
+
if list.size == 1 && list[0] == 'null' # hacky way to clear it
|
272
|
+
group_access_list = []
|
273
|
+
else
|
274
|
+
group_access_list = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
275
|
+
end
|
276
|
+
end
|
277
|
+
opts.on('--group-defaults LIST', Array, "Group Default Selection, comma separated list of group IDs") do |list|
|
278
|
+
if list.size == 1 && list[0] == 'null' # hacky way to clear it
|
279
|
+
group_defaults_list = []
|
280
|
+
else
|
281
|
+
group_defaults_list = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
282
|
+
end
|
283
|
+
end
|
284
|
+
opts.on('--tenants LIST', Array, "Tenant Access, comma separated list of account IDs") do |list|
|
285
|
+
if list.size == 1 && list[0] == 'null' # hacky way to clear it
|
286
|
+
options['tenants'] = []
|
287
|
+
else
|
288
|
+
options['tenants'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
289
|
+
end
|
290
|
+
end
|
291
|
+
opts.on('--visibility [private|public]', String, "Visibility") do |val|
|
292
|
+
options['visibility'] = val
|
293
|
+
end
|
239
294
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
240
295
|
opts.footer = "Create a security group." + "\n" +
|
241
296
|
"[name] is required. This is the name of the security group."
|
@@ -303,6 +358,38 @@ class Morpheus::Cli::SecurityGroups
|
|
303
358
|
print yellow,"Failed to determine the available scoped clouds.",reset,"\n"
|
304
359
|
end
|
305
360
|
|
361
|
+
# Group Access
|
362
|
+
if group_access_all != nil
|
363
|
+
payload['resourcePermissions'] ||= {}
|
364
|
+
payload['resourcePermissions']['all'] = group_access_all
|
365
|
+
end
|
366
|
+
if group_access_list != nil
|
367
|
+
payload['resourcePermissions'] ||= {}
|
368
|
+
payload['resourcePermissions']['sites'] = group_access_list.collect do |site_id|
|
369
|
+
site = {"id" => site_id.to_i}
|
370
|
+
if group_defaults_list && group_defaults_list.include?(site_id)
|
371
|
+
site["default"] = true
|
372
|
+
end
|
373
|
+
site
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
# Tenants
|
378
|
+
if options['tenants']
|
379
|
+
payload['tenantPermissions'] = {}
|
380
|
+
payload['tenantPermissions']['accounts'] = options['tenants']
|
381
|
+
end
|
382
|
+
|
383
|
+
# Visibility
|
384
|
+
if options['visibility'] != nil
|
385
|
+
payload['securityGroup']['visibility'] = options['visibility']
|
386
|
+
end
|
387
|
+
|
388
|
+
# Active
|
389
|
+
if options['active'] != nil
|
390
|
+
payload['securityGroup']['active'] = options['active']
|
391
|
+
end
|
392
|
+
|
306
393
|
end
|
307
394
|
|
308
395
|
@security_groups_interface.setopts(options)
|
@@ -326,6 +413,10 @@ class Morpheus::Cli::SecurityGroups
|
|
326
413
|
def update(args)
|
327
414
|
params = {}
|
328
415
|
options = {:options => {}}
|
416
|
+
tenants = nil
|
417
|
+
group_access_all = nil
|
418
|
+
group_access_list = nil
|
419
|
+
group_defaults_list = nil
|
329
420
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
330
421
|
opts.banner = subcommand_usage("[security-group] [options]")
|
331
422
|
opts.on( '--name Name', String, "Name of the security group" ) do |val|
|
@@ -334,6 +425,33 @@ class Morpheus::Cli::SecurityGroups
|
|
334
425
|
opts.on( '--description Description', String, "Description of the security group" ) do |val|
|
335
426
|
options[:options]['description'] = val
|
336
427
|
end
|
428
|
+
opts.on('--group-access-all [on|off]', String, "Toggle Access for all groups.") do |val|
|
429
|
+
group_access_all = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
|
430
|
+
end
|
431
|
+
opts.on('--group-access LIST', Array, "Group Access, comma separated list of group IDs.") do |list|
|
432
|
+
if list.size == 1 && list[0] == 'null' # hacky way to clear it
|
433
|
+
group_access_list = []
|
434
|
+
else
|
435
|
+
group_access_list = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
436
|
+
end
|
437
|
+
end
|
438
|
+
opts.on('--group-defaults LIST', Array, "Group Default Selection, comma separated list of group IDs") do |list|
|
439
|
+
if list.size == 1 && list[0] == 'null' # hacky way to clear it
|
440
|
+
group_defaults_list = []
|
441
|
+
else
|
442
|
+
group_defaults_list = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
443
|
+
end
|
444
|
+
end
|
445
|
+
opts.on('--tenants LIST', Array, "Tenant Access, comma separated list of account IDs") do |list|
|
446
|
+
if list.size == 1 && list[0] == 'null' # hacky way to clear it
|
447
|
+
options['tenants'] = []
|
448
|
+
else
|
449
|
+
options['tenants'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
450
|
+
end
|
451
|
+
end
|
452
|
+
opts.on('--visibility [private|public]', String, "Visibility") do |val|
|
453
|
+
options['visibility'] = val
|
454
|
+
end
|
337
455
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
338
456
|
opts.footer = "Update a security group." + "\n" +
|
339
457
|
"[security-group] is required. This is the name or id of the security group."
|
@@ -362,7 +480,39 @@ class Morpheus::Cli::SecurityGroups
|
|
362
480
|
# allow arbitrary -O options
|
363
481
|
payload['securityGroup'].deep_merge!(passed_options) unless passed_options.empty?
|
364
482
|
|
365
|
-
|
483
|
+
# Group Access
|
484
|
+
if group_access_all != nil
|
485
|
+
payload['resourcePermissions'] ||= {}
|
486
|
+
payload['resourcePermissions']['all'] = group_access_all
|
487
|
+
end
|
488
|
+
if group_access_list != nil
|
489
|
+
payload['resourcePermissions'] ||= {}
|
490
|
+
payload['resourcePermissions']['sites'] = group_access_list.collect do |site_id|
|
491
|
+
site = {"id" => site_id.to_i}
|
492
|
+
if group_defaults_list && group_defaults_list.include?(site_id)
|
493
|
+
site["default"] = true
|
494
|
+
end
|
495
|
+
site
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
# Tenants
|
500
|
+
if options['tenants']
|
501
|
+
payload['tenantPermissions'] = {}
|
502
|
+
payload['tenantPermissions']['accounts'] = options['tenants']
|
503
|
+
end
|
504
|
+
|
505
|
+
# Visibility
|
506
|
+
if options['visibility'] != nil
|
507
|
+
payload['securityGroup']['visibility'] = options['visibility']
|
508
|
+
end
|
509
|
+
|
510
|
+
# Active
|
511
|
+
if options['active'] != nil
|
512
|
+
payload['securityGroup']['active'] = options['active']
|
513
|
+
end
|
514
|
+
|
515
|
+
if payload['securityGroup'].empty? && payload['tenantPermissions'].nil? && payload['resourcePermissions'].nil?
|
366
516
|
raise_command_error "Specify at least one option to update.\n#{optparse}"
|
367
517
|
end
|
368
518
|
|
@@ -41,7 +41,10 @@ class Morpheus::Cli::SubnetsCommand
|
|
41
41
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
42
42
|
opts.banner = subcommand_usage("")
|
43
43
|
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
44
|
-
opts.on( '
|
44
|
+
opts.on( '-c', '--cloud CLOUD', "Filter by Cloud" ) do |val|
|
45
|
+
options[:cloud] = val
|
46
|
+
end
|
47
|
+
opts.on( '--network NETWORK', '--network NETWORK', "Filter by Network" ) do |val|
|
45
48
|
options[:network] = val
|
46
49
|
end
|
47
50
|
opts.footer = "List subnets."
|
@@ -61,8 +64,17 @@ class Morpheus::Cli::SubnetsCommand
|
|
61
64
|
else
|
62
65
|
return 1, "Network not found"
|
63
66
|
end
|
64
|
-
# params['networksId'] = params.delete('networkId')
|
65
67
|
end
|
68
|
+
cloud = nil
|
69
|
+
if options[:cloud]
|
70
|
+
cloud = find_cloud_by_name_or_id(options[:cloud])
|
71
|
+
if cloud
|
72
|
+
params['zoneId'] = cloud['id']
|
73
|
+
else
|
74
|
+
return 1, "Cloud not found"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
66
78
|
|
67
79
|
exit_code, err = 0, nil
|
68
80
|
|
@@ -82,6 +94,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
82
94
|
if network
|
83
95
|
subtitles << "Network: #{network['name']}"
|
84
96
|
end
|
97
|
+
if cloud
|
98
|
+
subtitles << "Cloud: #{cloud['name']}"
|
99
|
+
end
|
85
100
|
subtitles += parse_list_subtitles(options)
|
86
101
|
print_h1 title, subtitles
|
87
102
|
|
@@ -97,8 +112,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
97
112
|
"Cloud" => lambda {|it| it['zone']['name'] rescue it['zone'] },
|
98
113
|
"CIDR" => lambda {|it| it['cidr'] },
|
99
114
|
"DHCP" => lambda {|it| format_boolean(it['dhcpServer']) },
|
115
|
+
"Active" => lambda {|it| format_boolean(it['active']) },
|
100
116
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
101
|
-
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' }
|
117
|
+
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
102
118
|
}
|
103
119
|
print cyan
|
104
120
|
print as_pretty_table(subnets, subnet_columns)
|
@@ -113,7 +129,7 @@ class Morpheus::Cli::SubnetsCommand
|
|
113
129
|
def get(args)
|
114
130
|
options = {}
|
115
131
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
116
|
-
opts.banner = subcommand_usage("[
|
132
|
+
opts.banner = subcommand_usage("[subnet]")
|
117
133
|
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
118
134
|
opts.footer = "Get details about a subnet." + "\n" +
|
119
135
|
"[subnet] is required. This is the name or id of a subnet."
|
@@ -123,6 +139,7 @@ class Morpheus::Cli::SubnetsCommand
|
|
123
139
|
raise_command_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args}\n#{optparse}"
|
124
140
|
end
|
125
141
|
connect(options)
|
142
|
+
exit_code, err = 0, nil
|
126
143
|
begin
|
127
144
|
subnet_id = nil
|
128
145
|
if args[0].to_s =~ /\A\d{1,}\Z/
|
@@ -170,9 +187,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
170
187
|
"Pool" => lambda {|it| it['pool'] ? it['pool']['name'] : '' },
|
171
188
|
"DHCP" => lambda {|it| format_boolean it['dhcpServer'] },
|
172
189
|
#"Allow IP Override" => lambda {|it| it['allowStaticOverride'] ? 'Yes' : 'No' },
|
190
|
+
"Active" => lambda {|it| format_boolean(it['active']) },
|
173
191
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
174
192
|
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
175
|
-
# "Owner" => lambda {|it| it['owner'] ? it['owner']['name'] : '' },
|
176
193
|
}
|
177
194
|
print_description_list(description_cols, subnet)
|
178
195
|
|
@@ -265,9 +282,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
265
282
|
opts.on('--visibility [private|public]', String, "Visibility") do |val|
|
266
283
|
options['visibility'] = val
|
267
284
|
end
|
268
|
-
|
269
|
-
|
270
|
-
|
285
|
+
opts.on('--active [on|off]', String, "Can be used to disable a subnet") do |val|
|
286
|
+
options['active'] = val.to_s == 'on' || val.to_s == 'true'
|
287
|
+
end
|
271
288
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
272
289
|
opts.footer = "Create a new subnet." + "\n" +
|
273
290
|
"--network is required. This is the name or id of a network." #+ "\n" +
|
@@ -278,8 +295,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
278
295
|
if args.count > 1
|
279
296
|
raise_command_error "wrong number of arguments, expected 0-1 and got (#{args.count}) #{args}\n#{optparse}"
|
280
297
|
end
|
281
|
-
if args[
|
298
|
+
if args[0]
|
282
299
|
options[:options]['name'] = args[1]
|
300
|
+
options[:options].deep_merge!({'config' => {'subnetName' => args[0]}})
|
283
301
|
end
|
284
302
|
connect(options)
|
285
303
|
begin
|
@@ -312,6 +330,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
312
330
|
end
|
313
331
|
subnet_type = find_subnet_type_by_name_or_id(subnet_type_id)
|
314
332
|
return 1 if subnet_type.nil?
|
333
|
+
if subnet_type['creatable'] == false
|
334
|
+
raise_command_error "Subnet Type cannot be created: #{subnet_type['name']}"
|
335
|
+
end
|
315
336
|
payload['subnet']['type'] = {'id' => subnet_type['id'] }
|
316
337
|
#payload['subnet']['type'] = {'code' => subnet_type['code'] }
|
317
338
|
|
@@ -385,7 +406,7 @@ class Morpheus::Cli::SubnetsCommand
|
|
385
406
|
elsif !options[:quiet]
|
386
407
|
subnet = json_response['subnet']
|
387
408
|
print_green_success "Added subnet #{subnet['name']}"
|
388
|
-
get_args = [
|
409
|
+
get_args = [subnet['id']] + (options[:remote] ? ["-r",options[:remote]] : [])
|
389
410
|
get(get_args)
|
390
411
|
end
|
391
412
|
return 0
|
@@ -438,9 +459,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
438
459
|
opts.on('--visibility [private|public]', String, "Visibility") do |val|
|
439
460
|
options['visibility'] = val
|
440
461
|
end
|
441
|
-
|
442
|
-
|
443
|
-
|
462
|
+
opts.on('--active [on|off]', String, "Can be used to disable a subnet") do |val|
|
463
|
+
options['active'] = val.to_s == 'on' || val.to_s == 'true'
|
464
|
+
end
|
444
465
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
445
466
|
opts.footer = "Update a subnet." + "\n" +
|
446
467
|
"[subnet] is required. This is the name or id of a subnet."
|
@@ -451,10 +472,10 @@ class Morpheus::Cli::SubnetsCommand
|
|
451
472
|
end
|
452
473
|
connect(options)
|
453
474
|
begin
|
454
|
-
network = find_network_by_name_or_id(args[0])
|
455
|
-
return 1 if network.nil?
|
475
|
+
# network = find_network_by_name_or_id(args[0])
|
476
|
+
# return 1 if network.nil?
|
456
477
|
|
457
|
-
subnet = find_subnet_by_name_or_id(
|
478
|
+
subnet = find_subnet_by_name_or_id(args[0])
|
458
479
|
return 1 if subnet.nil?
|
459
480
|
|
460
481
|
# merge -O options into normally parsed options
|
@@ -510,16 +531,16 @@ class Morpheus::Cli::SubnetsCommand
|
|
510
531
|
|
511
532
|
@subnets_interface.setopts(options)
|
512
533
|
if options[:dry_run]
|
513
|
-
print_dry_run @subnets_interface.dry.update(
|
534
|
+
print_dry_run @subnets_interface.dry.update(subnet['id'], payload)
|
514
535
|
return
|
515
536
|
end
|
516
|
-
json_response = @subnets_interface.update(
|
537
|
+
json_response = @subnets_interface.update(subnet['id'], payload)
|
517
538
|
if options[:json]
|
518
539
|
puts as_json(json_response, options)
|
519
540
|
elsif !options[:quiet]
|
520
541
|
subnet = json_response['subnet']
|
521
542
|
print_green_success "Updated subnet #{subnet['name']}"
|
522
|
-
get_args = [
|
543
|
+
get_args = [subnet['id']] + (options[:remote] ? ["-r",options[:remote]] : [])
|
523
544
|
get(get_args)
|
524
545
|
end
|
525
546
|
return 0
|
@@ -546,6 +567,12 @@ class Morpheus::Cli::SubnetsCommand
|
|
546
567
|
subnet = find_subnet_by_name_or_id(args[0])
|
547
568
|
return 1 if subnet.nil?
|
548
569
|
|
570
|
+
subnet_type = find_subnet_type_by_name_or_id(subnet['type']['id'])
|
571
|
+
return 1 if subnet_type.nil?
|
572
|
+
if subnet_type['deletable'] == false
|
573
|
+
raise_command_error "Subnet Type cannot be deleted: #{subnet_type['name']}"
|
574
|
+
end
|
575
|
+
|
549
576
|
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the subnet: #{subnet['name']}?")
|
550
577
|
return 9, "aborted command"
|
551
578
|
end
|