morpheus-cli 4.2.8 → 4.2.10
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/Dockerfile +1 -1
- data/lib/morpheus/api.rb +1 -1
- data/lib/morpheus/api/activity_interface.rb +9 -0
- data/lib/morpheus/api/api_client.rb +83 -27
- data/lib/morpheus/api/apps_interface.rb +21 -0
- data/lib/morpheus/api/dashboard_interface.rb +5 -21
- data/lib/morpheus/api/instances_interface.rb +3 -10
- data/lib/morpheus/api/invoice_line_items_interface.rb +14 -0
- data/lib/morpheus/api/invoices_interface.rb +7 -12
- data/lib/morpheus/api/library_layouts_interface.rb +8 -0
- data/lib/morpheus/api/ping_interface.rb +20 -0
- data/lib/morpheus/api/projects_interface.rb +33 -0
- data/lib/morpheus/api/setup_interface.rb +19 -36
- data/lib/morpheus/api/user_settings_interface.rb +0 -6
- data/lib/morpheus/api/whoami_interface.rb +4 -8
- data/lib/morpheus/benchmarking.rb +16 -26
- data/lib/morpheus/cli.rb +10 -5
- data/lib/morpheus/cli/access_token_command.rb +5 -8
- data/lib/morpheus/cli/activity_command.rb +146 -0
- data/lib/morpheus/cli/apps.rb +312 -121
- data/lib/morpheus/cli/archives_command.rb +1 -1
- data/lib/morpheus/cli/auth_command.rb +4 -11
- data/lib/morpheus/cli/blueprints_command.rb +196 -137
- data/lib/morpheus/cli/change_password_command.rb +1 -1
- data/lib/morpheus/cli/cli_command.rb +225 -72
- data/lib/morpheus/cli/cli_registry.rb +2 -2
- data/lib/morpheus/cli/cloud_datastores_command.rb +1 -1
- data/lib/morpheus/cli/clouds.rb +5 -20
- data/lib/morpheus/cli/clusters.rb +4 -28
- data/lib/morpheus/cli/commands/standard/alias_command.rb +2 -9
- data/lib/morpheus/cli/commands/standard/benchmark_command.rb +2 -0
- data/lib/morpheus/cli/commands/standard/curl_command.rb +2 -3
- data/lib/morpheus/cli/commands/standard/history_command.rb +3 -6
- data/lib/morpheus/cli/commands/standard/man_command.rb +10 -7
- data/lib/morpheus/cli/commands/standard/ssl_verification_command.rb +10 -9
- data/lib/morpheus/cli/containers_command.rb +3 -3
- data/lib/morpheus/cli/credentials.rb +13 -16
- data/lib/morpheus/cli/error_handler.rb +18 -12
- data/lib/morpheus/cli/errors.rb +45 -0
- data/lib/morpheus/cli/execute_schedules_command.rb +1 -1
- data/lib/morpheus/cli/execution_request_command.rb +4 -4
- data/lib/morpheus/cli/groups.rb +84 -132
- data/lib/morpheus/cli/hosts.rb +6 -16
- data/lib/morpheus/cli/instances.rb +100 -183
- data/lib/morpheus/cli/invoices_command.rb +505 -71
- data/lib/morpheus/cli/library_layouts_command.rb +254 -166
- data/lib/morpheus/cli/library_option_lists_command.rb +0 -87
- data/lib/morpheus/cli/library_option_types_command.rb +0 -96
- data/lib/morpheus/cli/license.rb +3 -0
- data/lib/morpheus/cli/login.rb +17 -37
- data/lib/morpheus/cli/logout.rb +9 -5
- data/lib/morpheus/cli/mixins/accounts_helper.rb +83 -7
- data/lib/morpheus/cli/mixins/operations_helper.rb +41 -0
- data/lib/morpheus/cli/mixins/option_source_helper.rb +255 -0
- data/lib/morpheus/cli/mixins/print_helper.rb +18 -4
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +222 -13
- data/lib/morpheus/cli/mixins/remote_helper.rb +139 -0
- data/lib/morpheus/cli/monitoring_checks_command.rb +11 -3
- data/lib/morpheus/cli/network_groups_command.rb +8 -2
- data/lib/morpheus/cli/option_types.rb +1 -1
- data/lib/morpheus/cli/ping.rb +252 -0
- data/lib/morpheus/cli/price_sets_command.rb +16 -27
- data/lib/morpheus/cli/prices_command.rb +34 -27
- data/lib/morpheus/cli/processes_command.rb +81 -7
- data/lib/morpheus/cli/projects_command.rb +607 -0
- data/lib/morpheus/cli/recent_activity_command.rb +87 -65
- data/lib/morpheus/cli/remote.rb +965 -974
- data/lib/morpheus/cli/reports_command.rb +3 -15
- data/lib/morpheus/cli/roles.rb +8 -31
- data/lib/morpheus/cli/service_plans_command.rb +25 -31
- data/lib/morpheus/cli/setup.rb +392 -0
- data/lib/morpheus/cli/shell.rb +144 -56
- data/lib/morpheus/cli/subnets_command.rb +71 -11
- data/lib/morpheus/cli/tasks.rb +3 -3
- data/lib/morpheus/cli/user_sources_command.rb +4 -4
- data/lib/morpheus/cli/users.rb +135 -109
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +7 -7
- data/lib/morpheus/cli/whoami.rb +90 -129
- data/lib/morpheus/cli/wiki_command.rb +2 -14
- data/lib/morpheus/ext/rest_client.rb +36 -0
- data/lib/morpheus/formatters.rb +42 -5
- data/lib/morpheus/rest_client.rb +0 -10
- data/lib/morpheus/terminal.rb +41 -1
- data/lib/morpheus/util.rb +24 -0
- metadata +16 -3
- data/lib/morpheus/cli/command_error.rb +0 -22
data/lib/morpheus/cli/shell.rb
CHANGED
|
@@ -96,7 +96,8 @@ class Morpheus::Cli::Shell
|
|
|
96
96
|
@exploded_commands = []
|
|
97
97
|
Morpheus::Cli::CliRegistry.all.each do |cmd, klass|
|
|
98
98
|
@exploded_commands << cmd.to_s
|
|
99
|
-
subcommands = klass.subcommands rescue []
|
|
99
|
+
#subcommands = klass.subcommands rescue []
|
|
100
|
+
subcommands = klass.visible_subcommands rescue []
|
|
100
101
|
subcommands.keys.each do |sub_cmd|
|
|
101
102
|
@exploded_commands << "#{cmd} #{sub_cmd}"
|
|
102
103
|
end
|
|
@@ -118,7 +119,7 @@ class Morpheus::Cli::Shell
|
|
|
118
119
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
119
120
|
opts.banner = usage
|
|
120
121
|
# change to a temporary home directory, delete it afterwards.
|
|
121
|
-
opts.on('-e','--exec EXPRESSION', "Execute the command
|
|
122
|
+
opts.on('-e','--exec EXPRESSION', "Execute the command expression and exit. Expression can be a single morpheus command or several by using parenthesis and operators (, ), &&, ||, and ;") do |val|
|
|
122
123
|
@execute_mode = true
|
|
123
124
|
@execute_mode_command = val
|
|
124
125
|
end
|
|
@@ -129,43 +130,12 @@ class Morpheus::Cli::Shell
|
|
|
129
130
|
@@insecure = true
|
|
130
131
|
Morpheus::RestClient.enable_ssl_verification = false
|
|
131
132
|
end
|
|
132
|
-
|
|
133
|
-
@
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
end
|
|
139
|
-
@original_home_directory = my_terminal.home_directory
|
|
140
|
-
@temporary_home_directory = File.join(tmpdir, "morpheus-temp-shell-#{rand().to_s[2..7]}")
|
|
141
|
-
# change to a temporary home directory
|
|
142
|
-
Morpheus::Logging::DarkPrinter.puts "incognito mode" if Morpheus::Logging.debug?
|
|
143
|
-
Morpheus::Logging::DarkPrinter.puts "temporary home directory is #{@temporary_home_directory}" if Morpheus::Logging.debug?
|
|
144
|
-
my_terminal.set_home_directory(@temporary_home_directory)
|
|
145
|
-
# wow..this already has cached list of Remote.appliances
|
|
146
|
-
# this is kinda nice though..keep it for now,
|
|
147
|
-
#Morpheus::Cli::Remote.load_appliance_file
|
|
148
|
-
|
|
149
|
-
Morpheus::Cli::Remote.appliances.each do |app_name, app|
|
|
150
|
-
#app[:username] = "(anonymous)"
|
|
151
|
-
#app[:status] = "fresh"
|
|
152
|
-
app[:authenticated] = false
|
|
153
|
-
app.delete(:username)
|
|
154
|
-
app.delete(:last_login_at)
|
|
155
|
-
app.delete(:last_logout_at)
|
|
156
|
-
app.delete(:last_success_at)
|
|
157
|
-
app.delete(:last_check)
|
|
158
|
-
app.delete(:username)
|
|
159
|
-
app.delete(:error)
|
|
160
|
-
#app[:error] = "ho ho ho"
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
# Morpheus::Cli::Remote.save_appliances(new_remote_config)
|
|
164
|
-
|
|
165
|
-
# Morpheus::Cli::Remote.clear_active_appliance
|
|
166
|
-
# Morpheus::Cli::Credentials.clear_saved_credentials(@appliance_name)
|
|
167
|
-
# Morpheus::Cli::Credentials.load_saved_credentials
|
|
168
|
-
# Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).load_saved_credentials()
|
|
133
|
+
opts.on('-Z','--temporary', "Temporary shell. Use a temporary shell with the current remote configuration, credentials and history loaded. Temporary shells do not save changes to remote configuration changes and command history.") do
|
|
134
|
+
@temporary_shell_mode = true
|
|
135
|
+
end
|
|
136
|
+
opts.on('-z','--clean', "Clean shell. Use a temporary shell without any remote configuration, credentials or command history loaded.") do
|
|
137
|
+
@temporary_shell_mode = true
|
|
138
|
+
@clean_shell_mode = true
|
|
169
139
|
end
|
|
170
140
|
opts.on('-C','--nocolor', "Disable ANSI coloring") do
|
|
171
141
|
Term::ANSIColor::coloring = false
|
|
@@ -174,7 +144,7 @@ class Morpheus::Cli::Shell
|
|
|
174
144
|
Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::DEBUG)
|
|
175
145
|
::RestClient.log = Morpheus::Logging.debug? ? Morpheus::Logging::DarkPrinter.instance : nil
|
|
176
146
|
end
|
|
177
|
-
opts.on('-B','--benchmark', "Print benchmark time after each command is finished
|
|
147
|
+
opts.on('-B','--benchmark', "Print benchmark time after each command is finished" ) do
|
|
178
148
|
Morpheus::Benchmarking.enabled = true
|
|
179
149
|
my_terminal.benchmarking = Morpheus::Benchmarking.enabled
|
|
180
150
|
end
|
|
@@ -185,6 +155,107 @@ class Morpheus::Cli::Shell
|
|
|
185
155
|
end
|
|
186
156
|
optparse.parse!(args)
|
|
187
157
|
|
|
158
|
+
# is this a temporary/temporary_shell shell?
|
|
159
|
+
# this works just by changing the cli home directory and updating appliances
|
|
160
|
+
if @temporary_shell_mode
|
|
161
|
+
#Morpheus::Logging::DarkPrinter.puts "temporary shell started" if Morpheus::Logging.debug?
|
|
162
|
+
# for now, always use the original home directory
|
|
163
|
+
# or else this will just keep growing deeper and deeper.
|
|
164
|
+
@parent_shell_directories ||= []
|
|
165
|
+
@parent_shell_directories << my_terminal.home_directory
|
|
166
|
+
@previous_home_directory = @parent_shell_directories.last
|
|
167
|
+
if @original_home_directory.nil?
|
|
168
|
+
@original_home_directory = @previous_home_directory
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
#@norc = true # perhaps?
|
|
172
|
+
# instead of using TMPDIR, create tmp shell directory inside $MORPHEUS_CLI_HOME/tmp
|
|
173
|
+
# should chown these files too..
|
|
174
|
+
#tmpdir = ENV['MORPHEUS_CLI_TMPDIR'] || ENV['TMPDIR'] || ENV['TMP']
|
|
175
|
+
tmpdir = ENV['MORPHEUS_CLI_TMPDIR']
|
|
176
|
+
if !tmpdir
|
|
177
|
+
tmpdir = File.join(@original_home_directory, "tmp")
|
|
178
|
+
end
|
|
179
|
+
if !File.exists?(tmpdir)
|
|
180
|
+
# Morpheus::Logging::DarkPrinter.puts "creating tmpdir #{tmpdir}" if Morpheus::Logging.debug?
|
|
181
|
+
FileUtils.mkdir_p(tmpdir)
|
|
182
|
+
end
|
|
183
|
+
# this won't not happen since we mkdir above
|
|
184
|
+
if !File.exists?(tmpdir)
|
|
185
|
+
raise_command_error "Temporary directory not found. Use environment variable MORPHEUS_CLI_TMPDIR"
|
|
186
|
+
end
|
|
187
|
+
# change to a temporary home directory
|
|
188
|
+
@temporary_home_directory = File.join(tmpdir, "tmpshell-#{rand().to_s[2..7]}")
|
|
189
|
+
|
|
190
|
+
#if !File.exists?(@temporary_home_directory)
|
|
191
|
+
Morpheus::Logging::DarkPrinter.puts "starting temporary shell at #{@temporary_home_directory}" if Morpheus::Logging.debug?
|
|
192
|
+
FileUtils.mkdir_p(@temporary_home_directory)
|
|
193
|
+
# end
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
my_terminal.set_home_directory(@temporary_home_directory)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
# wow..this already has cached list of Remote.appliances
|
|
200
|
+
# this is kinda nice though..keep it for now,
|
|
201
|
+
#Morpheus::Cli::Remote.load_appliance_file
|
|
202
|
+
if @clean_shell_mode == true
|
|
203
|
+
# clean shell means no loading of remotes, aliases, history
|
|
204
|
+
# @norc = true
|
|
205
|
+
# todo: avoid writing files here and just work in memory for temporary shell
|
|
206
|
+
Morpheus::Cli::Remote.save_appliances({})
|
|
207
|
+
else
|
|
208
|
+
# keep remotes and credentials and activity or history
|
|
209
|
+
# this is done just by copying configuration files to the tmp home dir
|
|
210
|
+
#
|
|
211
|
+
# should use Morpheus::Cli::DotFile.morpheus_profile_filename
|
|
212
|
+
# and # should use Morpheus::Cli::DotFile.morpheus_profile_filename
|
|
213
|
+
# this already got run though.. this temporary mode should work for any terminal command,
|
|
214
|
+
# not just in shell
|
|
215
|
+
# .morpheus_profile has aliases
|
|
216
|
+
# this has already been loaded, probably should reload it...
|
|
217
|
+
if File.exists?(File.join(@previous_home_directory, ".morpheus_profile"))
|
|
218
|
+
FileUtils.cp(File.join(@previous_home_directory, ".morpheus_profile"), File.join(@temporary_home_directory, ".morpheus_profile"))
|
|
219
|
+
end
|
|
220
|
+
if @norc != true
|
|
221
|
+
if File.exists?(File.join(@previous_home_directory, ".morpheusrc"))
|
|
222
|
+
FileUtils.cp(File.join(@previous_home_directory, ".morpheusrc"), File.join(@temporary_home_directory, ".morpheusrc"))
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
if File.exists?(File.join(@previous_home_directory, "appliances"))
|
|
226
|
+
FileUtils.cp(File.join(@previous_home_directory, "appliances"), File.join(@temporary_home_directory, "appliances"))
|
|
227
|
+
end
|
|
228
|
+
if File.exists?(File.join(@previous_home_directory, "credentials"))
|
|
229
|
+
FileUtils.cp(File.join(@previous_home_directory, "credentials"), File.join(@temporary_home_directory, "credentials"))
|
|
230
|
+
end
|
|
231
|
+
if File.exists?(File.join(@previous_home_directory, "groups"))
|
|
232
|
+
FileUtils.cp(File.join(@previous_home_directory, "groups"), File.join(@temporary_home_directory, "groups"))
|
|
233
|
+
end
|
|
234
|
+
# stay logged in
|
|
235
|
+
# maybe have a different option for removing just credentials, and command history..
|
|
236
|
+
Morpheus::Cli::Remote.appliances.each do |app_name, app|
|
|
237
|
+
#app[:username] = "(anonymous)"
|
|
238
|
+
#app[:status] = "fresh"
|
|
239
|
+
#app[:authenticated] = false
|
|
240
|
+
# app.delete(:active) # keep remote active..
|
|
241
|
+
#app.delete(:username)
|
|
242
|
+
#app.delete(:last_login_at)
|
|
243
|
+
#app.delete(:last_logout_at)
|
|
244
|
+
# app[:last_logout_at] = Time.now.to_i
|
|
245
|
+
# keep last_success and last check
|
|
246
|
+
#app.delete(:last_success_at)
|
|
247
|
+
#app.delete(:last_check)
|
|
248
|
+
#app.delete(:username)
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Morpheus::Cli::Remote.save_appliances(new_remote_config)
|
|
252
|
+
# Morpheus::Cli::Remote.clear_active_appliance
|
|
253
|
+
# Morpheus::Cli::Credentials.clear_saved_credentials(@appliance_name)
|
|
254
|
+
# Morpheus::Cli::Credentials.load_saved_credentials
|
|
255
|
+
# Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).load_saved_credentials()
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
188
259
|
@history_logger ||= load_history_logger rescue nil
|
|
189
260
|
@history_logger.info "shell started" if @history_logger
|
|
190
261
|
load_history_from_log_file()
|
|
@@ -223,22 +294,33 @@ class Morpheus::Cli::Shell
|
|
|
223
294
|
end
|
|
224
295
|
end
|
|
225
296
|
|
|
226
|
-
#
|
|
297
|
+
# temporary_shell_mode, cover our tracks
|
|
227
298
|
if @temporary_home_directory
|
|
228
|
-
if @temporary_home_directory.include?("
|
|
299
|
+
if @temporary_home_directory.include?("tmpshell")
|
|
229
300
|
begin
|
|
230
301
|
FileUtils.remove_dir(@temporary_home_directory, true)
|
|
231
|
-
Morpheus::Logging::DarkPrinter.puts "cleaning up temporary
|
|
302
|
+
Morpheus::Logging::DarkPrinter.puts "cleaning up temporary shell at #{@temporary_home_directory}" if Morpheus::Logging.debug?
|
|
232
303
|
rescue
|
|
233
304
|
end
|
|
234
305
|
end
|
|
235
|
-
|
|
236
|
-
if
|
|
237
|
-
|
|
306
|
+
parent_shell_directory = @parent_shell_directories ? @parent_shell_directories.pop : nil
|
|
307
|
+
if parent_shell_directory
|
|
308
|
+
# switch terminal shell back to parent shell.
|
|
309
|
+
# should just be forking instead of all this...
|
|
310
|
+
my_terminal.set_home_directory(parent_shell_directory)
|
|
311
|
+
if @original_home_directory && @original_home_directory == parent_shell_directory
|
|
312
|
+
# back to original shell, not temporary, right?
|
|
313
|
+
# todo: probably need to reload shell here?
|
|
314
|
+
@temporary_home_directory = nil
|
|
315
|
+
else
|
|
316
|
+
# back to another temporary shell
|
|
317
|
+
# todo: probably need to reload shell here?
|
|
318
|
+
@temporary_home_directory = parent_shell_directory
|
|
319
|
+
end
|
|
320
|
+
else
|
|
321
|
+
# there was no parent, this would be weird since temporary_home_directory was true..
|
|
238
322
|
end
|
|
239
|
-
@original_home_directory = nil
|
|
240
323
|
end
|
|
241
|
-
|
|
242
324
|
return result
|
|
243
325
|
end
|
|
244
326
|
|
|
@@ -263,11 +345,13 @@ class Morpheus::Cli::Shell
|
|
|
263
345
|
return 0
|
|
264
346
|
#exit 0
|
|
265
347
|
elsif input == 'help'
|
|
266
|
-
|
|
267
|
-
|
|
348
|
+
if @temporary_shell_mode
|
|
349
|
+
puts "You are in a (temporary) morpheus shell"
|
|
350
|
+
else
|
|
351
|
+
puts "You are in a morpheus shell."
|
|
352
|
+
end
|
|
268
353
|
puts "See the available commands below."
|
|
269
354
|
|
|
270
|
-
|
|
271
355
|
puts "\nCommands:"
|
|
272
356
|
# commands = @morpheus_commands + @shell_commands
|
|
273
357
|
@morpheus_commands.sort.each {|cmd|
|
|
@@ -434,9 +518,11 @@ class Morpheus::Cli::Shell
|
|
|
434
518
|
print "#{input}, how may I #{cyan}help#{reset} you?\n"
|
|
435
519
|
end
|
|
436
520
|
return 0
|
|
437
|
-
elsif input
|
|
438
|
-
|
|
439
|
-
|
|
521
|
+
elsif input.strip =~ /^shell\s*/
|
|
522
|
+
# just allow shell to fall through
|
|
523
|
+
# we should reload the configs and history file after the sub shell process terminates though.
|
|
524
|
+
# actually, that looks like it is working just fine already...?
|
|
525
|
+
print cyan,"starting a subshell",reset,"\n"
|
|
440
526
|
elsif input =~ /^\.\s/
|
|
441
527
|
# dot alias for source <file>
|
|
442
528
|
log_history_command(input)
|
|
@@ -562,8 +648,10 @@ class Morpheus::Cli::Shell
|
|
|
562
648
|
cmd_number = matches[1].to_i
|
|
563
649
|
cmd = matches[2]
|
|
564
650
|
|
|
565
|
-
@last_command_number
|
|
566
|
-
|
|
651
|
+
if cmd_number > @last_command_number
|
|
652
|
+
@last_command_number = cmd_number
|
|
653
|
+
end
|
|
654
|
+
@history[cmd_number] = cmd
|
|
567
655
|
|
|
568
656
|
# for Ctrl+R history searching
|
|
569
657
|
Readline::HISTORY << cmd
|
|
@@ -24,6 +24,7 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
24
24
|
def connect(opts)
|
|
25
25
|
@api_client = establish_remote_appliance_connection(opts)
|
|
26
26
|
@networks_interface = @api_client.networks
|
|
27
|
+
@network_pools_interface = @api_client.network_pools
|
|
27
28
|
@network_types_interface = @api_client.network_types
|
|
28
29
|
@subnets_interface = @api_client.subnets
|
|
29
30
|
@subnet_types_interface = @api_client.subnet_types
|
|
@@ -125,7 +126,6 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
125
126
|
|
|
126
127
|
end
|
|
127
128
|
|
|
128
|
-
|
|
129
129
|
def get(args)
|
|
130
130
|
options = {}
|
|
131
131
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
@@ -186,7 +186,7 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
186
186
|
"Secondary DNS" => 'dnsSecondary',
|
|
187
187
|
"Pool" => lambda {|it| it['pool'] ? it['pool']['name'] : '' },
|
|
188
188
|
"DHCP" => lambda {|it| format_boolean it['dhcpServer'] },
|
|
189
|
-
|
|
189
|
+
"Allow IP Override" => lambda {|it| it['allowStaticOverride'] ? 'Yes' : 'No' },
|
|
190
190
|
"Active" => lambda {|it| format_boolean(it['active']) },
|
|
191
191
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
|
192
192
|
"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' },
|
|
@@ -285,6 +285,15 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
285
285
|
opts.on('--active [on|off]', String, "Can be used to disable a subnet") do |val|
|
|
286
286
|
options['active'] = val.to_s == 'on' || val.to_s == 'true'
|
|
287
287
|
end
|
|
288
|
+
opts.on('--pool ID', String, "Network Pool") do |val|
|
|
289
|
+
options['pool'] = val.to_i
|
|
290
|
+
end
|
|
291
|
+
opts.on('--dhcp-server [on|off]', String, "DHCP Server") do |val|
|
|
292
|
+
options['dhcpServer'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
|
|
293
|
+
end
|
|
294
|
+
opts.on('--can-assign-pool [on|off]', String, "DHCP Server") do |val|
|
|
295
|
+
options['canAssignPool'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
|
|
296
|
+
end
|
|
288
297
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
|
289
298
|
opts.footer = "Create a new subnet." + "\n" +
|
|
290
299
|
"--network is required. This is the name or id of a network." #+ "\n" +
|
|
@@ -303,6 +312,15 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
303
312
|
begin
|
|
304
313
|
passed_options = (options[:options] || {}).reject {|k,v| k.is_a?(Symbol) }
|
|
305
314
|
payload = nil
|
|
315
|
+
|
|
316
|
+
# Network
|
|
317
|
+
prompt_results = prompt_for_network(network_id, options)
|
|
318
|
+
if prompt_results[:success]
|
|
319
|
+
network = prompt_results[:network]
|
|
320
|
+
else
|
|
321
|
+
return 1, "Network prompt failed."
|
|
322
|
+
end
|
|
323
|
+
|
|
306
324
|
if options[:payload]
|
|
307
325
|
payload = options[:payload]
|
|
308
326
|
payload.deep_merge!({'subnet' => passed_options}) unless passed_options.empty?
|
|
@@ -310,14 +328,6 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
310
328
|
else
|
|
311
329
|
payload = {'subnet' => {}}
|
|
312
330
|
payload.deep_merge!({'subnet' => passed_options}) unless passed_options.empty?
|
|
313
|
-
|
|
314
|
-
# Network
|
|
315
|
-
prompt_results = prompt_for_network(network_id, options)
|
|
316
|
-
if prompt_results[:success]
|
|
317
|
-
network = prompt_results[:network]
|
|
318
|
-
else
|
|
319
|
-
return 1, "Network prompt failed."
|
|
320
|
-
end
|
|
321
331
|
|
|
322
332
|
# Name
|
|
323
333
|
# v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'description' => 'Name for this subnet.'}], options[:options])
|
|
@@ -355,6 +365,28 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
355
365
|
|
|
356
366
|
end
|
|
357
367
|
|
|
368
|
+
# DHCP
|
|
369
|
+
if options['dhcpServer']
|
|
370
|
+
payload['subnet']['dhcpServer'] = options['dhcpServer']
|
|
371
|
+
elsif subnet_type['dhcpServerEditable'] && payload['subnet']['dhcpServer'].nil? && !options[:no_prompt]
|
|
372
|
+
payload['subnet']['dhcpServer'] = Morpheus::Cli::OptionTypes.confirm("DHCP Server?", {:default=>false})
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
# Allow IP Override
|
|
376
|
+
if options['allowStaticOverride']
|
|
377
|
+
payload['subnet']['allowStaticOverride']
|
|
378
|
+
elsif !options[:no_prompt]
|
|
379
|
+
payload['subnet']['allowStaticOverride'] = Morpheus::Cli::OptionTypes.confirm("Allow IP Override?", {:default=>false})
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
# IP Pool
|
|
383
|
+
if options['pool']
|
|
384
|
+
payload['subnet']['pool'] = {'id' => options['pool']}
|
|
385
|
+
elsif subnet_type['canAssignPool'] && !options[:no_prompt]
|
|
386
|
+
network_pool_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => "pool", 'type' => 'select', 'fieldLabel' => "Network Pool", 'selectOptions' => list_network_pool_options(), 'required' => false, 'description' => 'Select Network Pool'}], options[:options], @api_client, {zoneId: network['zone']['id']}, options[:no_prompt])["pool"]
|
|
387
|
+
payload['subnet']['pool'] = {'id' => network_pool_id} if network_pool_id
|
|
388
|
+
end
|
|
389
|
+
|
|
358
390
|
# Group Access
|
|
359
391
|
# Group Access (default is All)
|
|
360
392
|
if group_access_all.nil?
|
|
@@ -416,7 +448,6 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
416
448
|
end
|
|
417
449
|
end
|
|
418
450
|
|
|
419
|
-
|
|
420
451
|
def update(args)
|
|
421
452
|
options = {}
|
|
422
453
|
tenants = nil
|
|
@@ -462,6 +493,15 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
462
493
|
opts.on('--active [on|off]', String, "Can be used to disable a subnet") do |val|
|
|
463
494
|
options['active'] = val.to_s == 'on' || val.to_s == 'true'
|
|
464
495
|
end
|
|
496
|
+
opts.on('--pool ID', String, "Network Pool") do |val|
|
|
497
|
+
options['pool'] = val.to_i
|
|
498
|
+
end
|
|
499
|
+
opts.on('--dhcp-server [on|off]', String, "DHCP Server") do |val|
|
|
500
|
+
options['dhcpServer'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
|
|
501
|
+
end
|
|
502
|
+
opts.on('--can-assign-pool [on|off]', String, "DHCP Server") do |val|
|
|
503
|
+
options['canAssignPool'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
|
|
504
|
+
end
|
|
465
505
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
|
466
506
|
opts.footer = "Update a subnet." + "\n" +
|
|
467
507
|
"[subnet] is required. This is the name or id of a subnet."
|
|
@@ -527,6 +567,21 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
527
567
|
payload['subnet']['visibility'] = options['visibility']
|
|
528
568
|
end
|
|
529
569
|
|
|
570
|
+
# DHCP
|
|
571
|
+
if options['dhcpServer'] != nil
|
|
572
|
+
payload['subnet']['dhcpServer'] = options['dhcpServer']
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
# Allow IP Override
|
|
576
|
+
if options['allowStaticOverride'] != nil
|
|
577
|
+
payload['subnet']['allowStaticOverride']
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
# IP Pool
|
|
581
|
+
if options['pool'] != nil
|
|
582
|
+
payload['subnet']['pool'] = {'id' => options['pool']}
|
|
583
|
+
end
|
|
584
|
+
|
|
530
585
|
end
|
|
531
586
|
|
|
532
587
|
@subnets_interface.setopts(options)
|
|
@@ -732,4 +787,9 @@ class Morpheus::Cli::SubnetsCommand
|
|
|
732
787
|
|
|
733
788
|
private
|
|
734
789
|
|
|
790
|
+
def list_network_pool_options()
|
|
791
|
+
@network_pools_interface.list['networkPools'].collect do |np|
|
|
792
|
+
{'name' => np['name'], 'value' => np['id']}
|
|
793
|
+
end
|
|
794
|
+
end
|
|
735
795
|
end
|
data/lib/morpheus/cli/tasks.rb
CHANGED
|
@@ -715,14 +715,14 @@ class Morpheus::Cli::Tasks
|
|
|
715
715
|
print_dry_run @tasks_interface.dry.update(task['id'], payload)
|
|
716
716
|
return 0
|
|
717
717
|
end
|
|
718
|
-
|
|
718
|
+
json_response = @tasks_interface.update(task['id'], payload)
|
|
719
719
|
if options[:json]
|
|
720
720
|
print JSON.pretty_generate(json_response)
|
|
721
|
-
if !
|
|
721
|
+
if !json_response['success']
|
|
722
722
|
return 1
|
|
723
723
|
end
|
|
724
724
|
else
|
|
725
|
-
print_green_success "Task #{
|
|
725
|
+
print_green_success "Task #{json_response['task']['name'] rescue ''} updated"
|
|
726
726
|
get([task['id']])
|
|
727
727
|
end
|
|
728
728
|
return 0
|
|
@@ -84,7 +84,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
|
84
84
|
title = "Morpheus User Sources"
|
|
85
85
|
subtitles = []
|
|
86
86
|
if account
|
|
87
|
-
subtitles << "
|
|
87
|
+
subtitles << "Tenant: #{account['name']}".strip
|
|
88
88
|
end
|
|
89
89
|
subtitles += parse_list_subtitles(options)
|
|
90
90
|
print_h1 title, subtitles
|
|
@@ -171,7 +171,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
|
171
171
|
"Name" => lambda {|it| it['name'] },
|
|
172
172
|
"Description" => lambda {|it| it['description'] },
|
|
173
173
|
"Type" => lambda {|it| it['type'] },
|
|
174
|
-
"
|
|
174
|
+
"Tenant" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
175
175
|
#"Subdomain" => lambda {|it| it['subdomain'] },
|
|
176
176
|
"Login URL" => lambda {|it| it['loginURL'] },
|
|
177
177
|
"Default Role" => lambda {|it| it['defaultAccountRole'] ? it['defaultAccountRole']['authority'] : '' },
|
|
@@ -223,7 +223,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
|
223
223
|
default_role_id = nil
|
|
224
224
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
225
225
|
opts.banner = subcommand_usage("[account] [name]")
|
|
226
|
-
opts.on('--account ID', String, "
|
|
226
|
+
opts.on('--account ID', String, "Tenant this user source belongs to") do |val|
|
|
227
227
|
account_id = val
|
|
228
228
|
end
|
|
229
229
|
opts.on('--type CODE', String, "User Source Type") do |val|
|
|
@@ -855,7 +855,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
|
855
855
|
{"ID" => lambda {|user_source| user_source['id'] } },
|
|
856
856
|
{"NAME" => lambda {|user_source| user_source['name'] } },
|
|
857
857
|
{"TYPE" => lambda {|user_source| user_source['type'] } },
|
|
858
|
-
{"
|
|
858
|
+
{"TENANT" => lambda {|user_source| user_source['account'] ? user_source['account']['name'] : '' } },
|
|
859
859
|
{"ACTIVE" => lambda {|user_source| format_boolean user_source['active'] } },
|
|
860
860
|
]
|
|
861
861
|
if opts[:include_fields]
|