morpheus-cli 5.3.3 → 5.3.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 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +10 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +4 -4
- data/lib/morpheus/api/network_routers_interface.rb +21 -0
- data/lib/morpheus/api/network_servers_interface.rb +42 -0
- data/lib/morpheus/api/rest_interface.rb +2 -1
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +2 -1
- data/lib/morpheus/cli/cloud_resource_pools_command.rb +1 -1
- data/lib/morpheus/cli/clouds.rb +22 -40
- data/lib/morpheus/cli/hosts.rb +0 -1
- data/lib/morpheus/cli/instances.rb +111 -7
- data/lib/morpheus/cli/invoices_command.rb +42 -38
- data/lib/morpheus/cli/library_option_lists_command.rb +3 -3
- data/lib/morpheus/cli/load_balancer_pools.rb +111 -0
- data/lib/morpheus/cli/load_balancer_virtual_servers.rb +136 -0
- data/lib/morpheus/cli/load_balancers.rb +0 -155
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +32 -11
- data/lib/morpheus/cli/mixins/rest_command.rb +53 -37
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +488 -0
- data/lib/morpheus/cli/network_routers_command.rb +291 -7
- data/lib/morpheus/cli/network_scopes_command.rb +442 -0
- data/lib/morpheus/cli/networks_command.rb +2 -2
- data/lib/morpheus/cli/option_types.rb +20 -0
- data/lib/morpheus/cli/subnets_command.rb +7 -2
- data/lib/morpheus/cli/tasks.rb +25 -2
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +2 -0
- data/lib/morpheus/cli.rb +9 -1
- metadata +9 -2
@@ -584,7 +584,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
584
584
|
if options[:description]
|
585
585
|
options[:options]['description'] = options[:description]
|
586
586
|
end
|
587
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false}], options[:options])
|
587
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false, 'defaultValue' => options[:default_description]}], options[:options])
|
588
588
|
payload['instance']['description'] = v_prompt['description'] if !v_prompt['description'].empty?
|
589
589
|
|
590
590
|
# Environment
|
@@ -593,14 +593,14 @@ module Morpheus::Cli::ProvisioningHelper
|
|
593
593
|
elsif options[:options]['instanceContext'] && !options[:options]['environment']
|
594
594
|
options[:options]['environment'] = options[:options]['instanceContext']
|
595
595
|
end
|
596
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'environment', 'fieldLabel' => 'Environment', 'type' => 'select', 'required' => false, 'selectOptions' => get_available_environments()}], options[:options])
|
596
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'environment', 'fieldLabel' => 'Environment', 'type' => 'select', 'required' => false, 'selectOptions' => get_available_environments(), 'defaultValue' => options[:default_environment]}], options[:options])
|
597
597
|
payload['instance']['instanceContext'] = v_prompt['environment'] if !v_prompt['environment'].empty?
|
598
598
|
|
599
599
|
# Labels (used to be called tags)
|
600
600
|
if options[:labels]
|
601
601
|
payload['instance']['labels'] = options[:labels].is_a?(Array) ? options[:labels] : options[:labels].to_s.split(',').collect {|it| it.to_s.strip }.compact.uniq
|
602
602
|
else
|
603
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'labels', 'fieldLabel' => 'Labels', 'type' => 'text', 'required' => false}], options[:options])
|
603
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'labels', 'fieldLabel' => 'Labels', 'type' => 'text', 'required' => false, 'defaultValue' => options[:default_labels]}], options[:options])
|
604
604
|
payload['instance']['labels'] = v_prompt['labels'].split(',').collect {|it| it.to_s.strip }.compact.uniq if !v_prompt['labels'].empty?
|
605
605
|
end
|
606
606
|
|
@@ -986,20 +986,28 @@ module Morpheus::Cli::ProvisioningHelper
|
|
986
986
|
end
|
987
987
|
|
988
988
|
# metadata tags
|
989
|
-
|
990
|
-
|
989
|
+
# metadata_tag_key = 'metadata'
|
990
|
+
metadata_tag_key = 'tags'
|
991
|
+
if !options[:metadata]
|
992
|
+
if options[:options]['metadata'].is_a?(Array)
|
993
|
+
options[:metadata] = options[:options]['metadata']
|
994
|
+
end
|
995
|
+
if options[:options]['tags'].is_a?(Array)
|
996
|
+
options[:metadata] = options[:options]['tags']
|
997
|
+
end
|
991
998
|
end
|
992
999
|
if options[:metadata]
|
1000
|
+
metadata = []
|
993
1001
|
if options[:metadata] == "[]" || options[:metadata] == "null"
|
994
|
-
|
1002
|
+
metadata = []
|
995
1003
|
elsif options[:metadata].is_a?(Array)
|
996
|
-
|
1004
|
+
metadata = options[:metadata]
|
997
1005
|
else
|
998
1006
|
# parse string into format name:value, name:value
|
999
1007
|
# merge IDs from current metadata
|
1000
1008
|
# todo: should allow quoted semicolons..
|
1001
|
-
|
1002
|
-
|
1009
|
+
metadata = options[:metadata].split(",").select {|it| !it.to_s.empty? }
|
1010
|
+
metadata = metadata.collect do |it|
|
1003
1011
|
metadata_pair = it.split(":")
|
1004
1012
|
if metadata_pair.size < 2 && it.include?("=")
|
1005
1013
|
metadata_pair = it.split("=")
|
@@ -1009,13 +1017,13 @@ module Morpheus::Cli::ProvisioningHelper
|
|
1009
1017
|
row['value'] = metadata_pair[1].to_s.strip
|
1010
1018
|
row
|
1011
1019
|
end
|
1012
|
-
payload['metadata'] = metadata_list
|
1013
1020
|
end
|
1021
|
+
payload[metadata_tag_key] = metadata
|
1014
1022
|
else
|
1015
1023
|
# prompt for metadata tags
|
1016
1024
|
metadata = prompt_metadata(options)
|
1017
1025
|
if !metadata.empty?
|
1018
|
-
payload[
|
1026
|
+
payload[metadata_tag_key] = metadata
|
1019
1027
|
end
|
1020
1028
|
end
|
1021
1029
|
|
@@ -1737,6 +1745,19 @@ module Morpheus::Cli::ProvisioningHelper
|
|
1737
1745
|
no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))
|
1738
1746
|
metadata_array = []
|
1739
1747
|
metadata_index = 0
|
1748
|
+
# Keep Current Tags (foo:bar,hello:world)
|
1749
|
+
# this is used by clone()
|
1750
|
+
if options[:current_tags] && !options[:current_tags].empty?
|
1751
|
+
current_tags_string = options[:current_tags].collect { |tag| tag['name'].to_s + '=' + tag['value'].to_s }.join(', ')
|
1752
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'keepExistingTags', 'type' => 'checkbox', 'fieldLabel' => "Keep existing metadata tags (#{current_tags_string}) ?", 'required' => true, 'description' => 'Whether or not to keep existing metadata tags', 'defaultValue' => true}], options[:options])
|
1753
|
+
if ['on','true','1',''].include?(v_prompt['keepExistingTags'].to_s.downcase)
|
1754
|
+
options[:current_tags].each do |tag|
|
1755
|
+
current_tag = tag.clone
|
1756
|
+
current_tag.delete('id')
|
1757
|
+
metadata_array << current_tag
|
1758
|
+
end
|
1759
|
+
end
|
1760
|
+
end
|
1740
1761
|
has_another_metadata = options[:options] && options[:options]["metadata#{metadata_index}"]
|
1741
1762
|
add_another_metadata = has_another_metadata || (!no_prompt && Morpheus::Cli::OptionTypes.confirm("Add a metadata tag?", {default: false}))
|
1742
1763
|
while add_another_metadata do
|
@@ -10,7 +10,8 @@
|
|
10
10
|
# * load_balancer_column_definitions() - Column definitions for the "get" command display output.
|
11
11
|
# * load_balancer_list_column_definitions() - Column definitions for the "list" command display output.
|
12
12
|
#
|
13
|
-
#
|
13
|
+
# Example of a RestCommand for `morpheus load-balancers`.
|
14
|
+
#
|
14
15
|
# class Morpheus::Cli::LoadBalancers
|
15
16
|
#
|
16
17
|
# include Morpheus::Cli::CliCommand
|
@@ -21,7 +22,7 @@
|
|
21
22
|
# # and would be the default values if not set.
|
22
23
|
# set_rest_name :load_balancers
|
23
24
|
# set_rest_label "Load Balancer"
|
24
|
-
#
|
25
|
+
# set_rest_label_plural "Load Balancers"
|
25
26
|
# set_rest_object_key "load_balancer"
|
26
27
|
# set_rest_has_type true
|
27
28
|
# set_rest_type "load_balancer_types"
|
@@ -50,7 +51,7 @@ module Morpheus::Cli::RestCommand
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def rest_name=(v)
|
53
|
-
@rest_name = v
|
54
|
+
@rest_name = v.to_s
|
54
55
|
end
|
55
56
|
|
56
57
|
alias :set_rest_name :rest_name=
|
@@ -61,11 +62,11 @@ module Morpheus::Cli::RestCommand
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def default_rest_key
|
64
|
-
rest_name.chomp("s")
|
65
|
+
rest_name.to_s.chomp("s")
|
65
66
|
end
|
66
67
|
|
67
68
|
def rest_key=(v)
|
68
|
-
@rest_key = v
|
69
|
+
@rest_key = v.to_s
|
69
70
|
end
|
70
71
|
|
71
72
|
alias :set_rest_key :rest_key=
|
@@ -80,7 +81,7 @@ module Morpheus::Cli::RestCommand
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def rest_arg=(v)
|
83
|
-
@rest_arg = v
|
84
|
+
@rest_arg = v.to_s
|
84
85
|
end
|
85
86
|
|
86
87
|
alias :set_rest_arg :rest_arg=
|
@@ -95,26 +96,26 @@ module Morpheus::Cli::RestCommand
|
|
95
96
|
end
|
96
97
|
|
97
98
|
def rest_label=(v)
|
98
|
-
@rest_label = v
|
99
|
+
@rest_label = v.to_s
|
99
100
|
end
|
100
101
|
|
101
102
|
alias :set_rest_label :rest_label=
|
102
103
|
|
103
104
|
# the plural version of the label eg. "Neat Things"
|
104
|
-
def
|
105
|
-
@
|
105
|
+
def rest_label_plural
|
106
|
+
@rest_label_plural || default_rest_label_plural
|
106
107
|
end
|
107
108
|
|
108
|
-
def
|
109
|
+
def default_rest_label_plural
|
109
110
|
#rest_name.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ")
|
110
111
|
rest_label.to_s.pluralize
|
111
112
|
end
|
112
113
|
|
113
|
-
def
|
114
|
-
@
|
114
|
+
def rest_label_plural=(v)
|
115
|
+
@rest_label_plural = v.to_s
|
115
116
|
end
|
116
117
|
|
117
|
-
alias :
|
118
|
+
alias :set_rest_label_plural :rest_label_plural=
|
118
119
|
|
119
120
|
# rest_interface_name is the interface name for the resource. eg. "neat_things"
|
120
121
|
def rest_interface_name
|
@@ -126,7 +127,7 @@ module Morpheus::Cli::RestCommand
|
|
126
127
|
end
|
127
128
|
|
128
129
|
def rest_interface_name=(v)
|
129
|
-
@rest_interface_name = v
|
130
|
+
@rest_interface_name = v.to_s
|
130
131
|
end
|
131
132
|
|
132
133
|
alias :set_rest_interface_name :rest_interface_name=
|
@@ -158,7 +159,7 @@ module Morpheus::Cli::RestCommand
|
|
158
159
|
end
|
159
160
|
|
160
161
|
def rest_type_name=(v)
|
161
|
-
@rest_type_name = v
|
162
|
+
@rest_type_name = v.to_s
|
162
163
|
end
|
163
164
|
|
164
165
|
alias :set_rest_type_name :rest_type_name=
|
@@ -175,7 +176,7 @@ module Morpheus::Cli::RestCommand
|
|
175
176
|
end
|
176
177
|
|
177
178
|
def rest_type_key=(v)
|
178
|
-
@rest_type_key = v
|
179
|
+
@rest_type_key = v.to_s
|
179
180
|
end
|
180
181
|
|
181
182
|
alias :set_rest_type_key :rest_type_key=
|
@@ -190,7 +191,7 @@ module Morpheus::Cli::RestCommand
|
|
190
191
|
end
|
191
192
|
|
192
193
|
def rest_type_arg=(v)
|
193
|
-
@rest_type_arg = v
|
194
|
+
@rest_type_arg = v.to_s
|
194
195
|
end
|
195
196
|
|
196
197
|
alias :set_rest_type_arg :rest_type_arg=
|
@@ -205,26 +206,26 @@ module Morpheus::Cli::RestCommand
|
|
205
206
|
end
|
206
207
|
|
207
208
|
def rest_type_label=(v)
|
208
|
-
@rest_type_label = v
|
209
|
+
@rest_type_label = v.to_s
|
209
210
|
end
|
210
211
|
|
211
212
|
alias :set_rest_type_label :rest_type_label=
|
212
213
|
|
213
214
|
# the plural version of the label eg. "Neat Things"
|
214
|
-
def
|
215
|
-
@
|
215
|
+
def rest_type_label_plural
|
216
|
+
@rest_type_label_plural || default_rest_type_label_plural
|
216
217
|
end
|
217
218
|
|
218
|
-
def
|
219
|
+
def default_rest_type_label_plural
|
219
220
|
#rest_type_name.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ")
|
220
221
|
rest_type_label.to_s.pluralize
|
221
222
|
end
|
222
223
|
|
223
|
-
def
|
224
|
-
@
|
224
|
+
def rest_type_label_plural=(v)
|
225
|
+
@rest_type_label_plural = v.to_s
|
225
226
|
end
|
226
227
|
|
227
|
-
alias :
|
228
|
+
alias :set_rest_type_label_plural :rest_type_label_plural=
|
228
229
|
|
229
230
|
# the name of the default interface, matches the rest name eg. "neat_things"
|
230
231
|
def rest_type_interface_name
|
@@ -236,7 +237,7 @@ module Morpheus::Cli::RestCommand
|
|
236
237
|
end
|
237
238
|
|
238
239
|
def rest_type_interface_name=(v)
|
239
|
-
@rest_type_interface_name = v
|
240
|
+
@rest_type_interface_name = v.to_s
|
240
241
|
end
|
241
242
|
|
242
243
|
alias :set_rest_type_interface_name :rest_type_interface_name=
|
@@ -247,7 +248,7 @@ module Morpheus::Cli::RestCommand
|
|
247
248
|
def register_interfaces(*interfaces)
|
248
249
|
@registered_interfaces ||= []
|
249
250
|
interfaces.flatten.each do |it|
|
250
|
-
@registered_interfaces << it.
|
251
|
+
@registered_interfaces << it.to_s
|
251
252
|
end
|
252
253
|
# put the default rest_interface first
|
253
254
|
if rest_interface_name && !@registered_interfaces.include?(rest_interface_name)
|
@@ -300,8 +301,8 @@ module Morpheus::Cli::RestCommand
|
|
300
301
|
self.class.rest_label
|
301
302
|
end
|
302
303
|
|
303
|
-
def
|
304
|
-
self.class.
|
304
|
+
def rest_label_plural
|
305
|
+
self.class.rest_label_plural
|
305
306
|
end
|
306
307
|
|
307
308
|
def rest_interface_name
|
@@ -356,8 +357,8 @@ module Morpheus::Cli::RestCommand
|
|
356
357
|
self.class.rest_type_label
|
357
358
|
end
|
358
359
|
|
359
|
-
def
|
360
|
-
self.class.
|
360
|
+
def rest_type_label_plural
|
361
|
+
self.class.rest_type_label_plural
|
361
362
|
end
|
362
363
|
|
363
364
|
def rest_type_interface_name
|
@@ -415,9 +416,12 @@ module Morpheus::Cli::RestCommand
|
|
415
416
|
params = {}
|
416
417
|
options = {}
|
417
418
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
418
|
-
opts.banner = subcommand_usage()
|
419
|
+
opts.banner = subcommand_usage("[search]")
|
419
420
|
build_standard_list_options(opts, options)
|
420
|
-
|
421
|
+
opts.footer = <<-EOT
|
422
|
+
List #{rest_label_plural.downcase}.
|
423
|
+
[search] is optional. This is a search phrase to filter the results.
|
424
|
+
EOT
|
421
425
|
end
|
422
426
|
optparse.parse!(args)
|
423
427
|
connect(options)
|
@@ -433,9 +437,9 @@ module Morpheus::Cli::RestCommand
|
|
433
437
|
json_response = rest_interface.list(params)
|
434
438
|
render_response(json_response, options, rest_list_key) do
|
435
439
|
records = json_response[rest_list_key]
|
436
|
-
print_h1 "Morpheus #{
|
440
|
+
print_h1 "Morpheus #{rest_label_plural}"
|
437
441
|
if records.nil? || records.empty?
|
438
|
-
print cyan,"No #{
|
442
|
+
print cyan,"No #{rest_label_plural.downcase} found.",reset,"\n"
|
439
443
|
else
|
440
444
|
print as_pretty_table(records, rest_list_column_definitions.upcase_keys!, options)
|
441
445
|
print_results_pagination(json_response) if json_response['meta']
|
@@ -449,7 +453,7 @@ module Morpheus::Cli::RestCommand
|
|
449
453
|
params = {}
|
450
454
|
options = {}
|
451
455
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
452
|
-
opts.banner = subcommand_usage("[
|
456
|
+
opts.banner = subcommand_usage("[#{rest_arg}]")
|
453
457
|
build_standard_get_options(opts, options)
|
454
458
|
opts.footer = <<-EOT
|
455
459
|
Get details about #{a_or_an(rest_label)} #{rest_label.downcase}.
|
@@ -504,17 +508,21 @@ EOT
|
|
504
508
|
options = {}
|
505
509
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
506
510
|
if rest_has_type
|
507
|
-
opts.banner = subcommand_usage("[
|
511
|
+
opts.banner = subcommand_usage("[#{rest_arg}] -t TYPE")
|
508
512
|
opts.on( '-t', "--#{rest_type_arg} TYPE", "#{rest_type_label}" ) do |val|
|
509
513
|
record_type_id = val
|
510
514
|
end
|
511
515
|
else
|
512
|
-
opts.banner = subcommand_usage("[
|
516
|
+
opts.banner = subcommand_usage("[#{rest_arg}]")
|
513
517
|
end
|
514
518
|
# if defined?(add_#{rest_key}_option_types)
|
515
519
|
# build_option_type_options(opts, options, add_#{rest_key}_option_types)
|
516
520
|
# end
|
517
521
|
build_standard_add_options(opts, options)
|
522
|
+
opts.footer = <<-EOT
|
523
|
+
Create a new #{rest_label.downcase}.
|
524
|
+
[#{rest_arg}] is required. This is the name of the new #{rest_label.downcase}.
|
525
|
+
EOT
|
518
526
|
end
|
519
527
|
optparse.parse!(args)
|
520
528
|
# todo: make supporting args[0] optional and more flexible
|
@@ -592,6 +600,10 @@ EOT
|
|
592
600
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
593
601
|
opts.banner = subcommand_usage("[#{rest_arg}] [options]")
|
594
602
|
build_standard_update_options(opts, options)
|
603
|
+
opts.footer = <<-EOT
|
604
|
+
Update an existing #{rest_label.downcase}.
|
605
|
+
[#{rest_arg}] is required. This is the name or id of #{a_or_an(rest_label)} #{rest_label.downcase}.
|
606
|
+
EOT
|
595
607
|
end
|
596
608
|
optparse.parse!(args)
|
597
609
|
verify_args!(args:args, optparse:optparse, count:1)
|
@@ -629,6 +641,10 @@ EOT
|
|
629
641
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
630
642
|
opts.banner = subcommand_usage("[#{rest_arg}]")
|
631
643
|
build_standard_remove_options(opts, options)
|
644
|
+
opts.footer = <<-EOT
|
645
|
+
Delete an existing #{rest_label.downcase}.
|
646
|
+
[#{rest_arg}] is required. This is the name or id of #{a_or_an(rest_label)} #{rest_label.downcase}.
|
647
|
+
EOT
|
632
648
|
end
|
633
649
|
optparse.parse!(args)
|
634
650
|
verify_args!(args:args, optparse:optparse, count:1)
|