morpheus-cli 8.1.2 → 9.0.0
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 +2 -2
- data/lib/morpheus/api/api_client.rb +8 -0
- data/lib/morpheus/api/groups_interface.rb +2 -1
- data/lib/morpheus/api/servers_interface.rb +0 -1
- data/lib/morpheus/api/support_bundles_interface.rb +46 -0
- data/lib/morpheus/api/systems_interface.rb +32 -0
- data/lib/morpheus/api/tokens_interface.rb +39 -0
- data/lib/morpheus/cli/cli_command.rb +6 -1
- data/lib/morpheus/cli/commands/clients_command.rb +60 -74
- data/lib/morpheus/cli/commands/clouds.rb +30 -2
- data/lib/morpheus/cli/commands/clusters.rb +5 -0
- data/lib/morpheus/cli/commands/execution_request_command.rb +6 -2
- data/lib/morpheus/cli/commands/groups.rb +46 -23
- data/lib/morpheus/cli/commands/hosts.rb +21 -14
- data/lib/morpheus/cli/commands/instances.rb +32 -6
- data/lib/morpheus/cli/commands/storage_volumes.rb +1 -1
- data/lib/morpheus/cli/commands/support_bundles_command.rb +606 -0
- data/lib/morpheus/cli/commands/systems.rb +606 -2
- data/lib/morpheus/cli/commands/tokens_command.rb +391 -0
- data/lib/morpheus/cli/commands/workflows.rb +16 -3
- data/lib/morpheus/cli/mixins/infrastructure_helper.rb +30 -14
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +21 -7
- data/lib/morpheus/cli/version.rb +1 -1
- data/test/api/systems_interface_test.rb +26 -0
- data/test/cli/systems_test.rb +206 -0
- metadata +10 -2
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __dir__))
|
|
3
|
+
require 'morpheus'
|
|
4
|
+
require 'morpheus/cli/commands/systems'
|
|
5
|
+
|
|
6
|
+
class SystemsCommandTest < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def test_systems_registers_network_update_subcommands
|
|
9
|
+
command_names = Morpheus::Cli::Systems.subcommands.keys.collect(&:to_s)
|
|
10
|
+
assert command_names.include?('list-available-network-updates')
|
|
11
|
+
assert command_names.include?('apply-network-update')
|
|
12
|
+
assert command_names.include?('list-available-network-server-updates')
|
|
13
|
+
assert command_names.include?('apply-network-server-update')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_list_available_network_server_updates_dry_run
|
|
17
|
+
command = Morpheus::Cli::Systems.new
|
|
18
|
+
captured_request = nil
|
|
19
|
+
command.define_singleton_method(:connect) do |options|
|
|
20
|
+
@systems_interface = Object.new
|
|
21
|
+
@systems_interface.define_singleton_method(:setopts) { |opts| }
|
|
22
|
+
@systems_interface.define_singleton_method(:dry) { self }
|
|
23
|
+
@systems_interface.define_singleton_method(:list_network_server_update_definitions) do |system_id, server_id, params|
|
|
24
|
+
{method: :get, system_id: system_id, server_id: server_id, params: params}
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
command.define_singleton_method(:find_by_name_or_id) do |type, value|
|
|
28
|
+
{'id' => (type == :systems ? 1 : 2), 'name' => value.to_s}
|
|
29
|
+
end
|
|
30
|
+
command.define_singleton_method(:print_dry_run) do |request|
|
|
31
|
+
captured_request = request
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
result = command.send(:list_available_network_server_updates, ['--dry-run', 'system-1', 'network-1'])
|
|
35
|
+
|
|
36
|
+
assert_nil result
|
|
37
|
+
assert_equal :get, captured_request[:method]
|
|
38
|
+
assert_equal 1, captured_request[:system_id]
|
|
39
|
+
assert_equal 2, captured_request[:server_id]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_apply_network_server_update_dry_run
|
|
43
|
+
command = Morpheus::Cli::Systems.new
|
|
44
|
+
captured_request = nil
|
|
45
|
+
command.define_singleton_method(:connect) do |options|
|
|
46
|
+
@systems_interface = Object.new
|
|
47
|
+
@systems_interface.define_singleton_method(:setopts) { |opts| }
|
|
48
|
+
@systems_interface.define_singleton_method(:dry) { self }
|
|
49
|
+
@systems_interface.define_singleton_method(:apply_network_server_update_definition) do |system_id, server_id, update_definition_id, payload, params|
|
|
50
|
+
{method: :post, system_id: system_id, server_id: server_id, update_definition_id: update_definition_id, payload: payload, params: params}
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
command.define_singleton_method(:find_by_name_or_id) do |type, value|
|
|
54
|
+
{'id' => (type == :systems ? 1 : 2), 'name' => value.to_s}
|
|
55
|
+
end
|
|
56
|
+
command.define_singleton_method(:print_dry_run) do |request|
|
|
57
|
+
captured_request = request
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
result = command.send(:apply_network_server_update, ['--dry-run', 'system-1', 'network-1', '3'])
|
|
61
|
+
|
|
62
|
+
assert_nil result
|
|
63
|
+
assert_equal :post, captured_request[:method]
|
|
64
|
+
assert_equal 1, captured_request[:system_id]
|
|
65
|
+
assert_equal 2, captured_request[:server_id]
|
|
66
|
+
assert_equal '3', captured_request[:update_definition_id]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_update_dry_run_with_components_payload
|
|
70
|
+
command = Morpheus::Cli::Systems.new
|
|
71
|
+
captured_request = nil
|
|
72
|
+
interface = Object.new
|
|
73
|
+
interface.define_singleton_method(:get) do |id|
|
|
74
|
+
{'system' => {'id' => id, 'name' => "system-#{id}"}}
|
|
75
|
+
end
|
|
76
|
+
interface.define_singleton_method(:dry) { self }
|
|
77
|
+
interface.define_singleton_method(:update) do |id, payload|
|
|
78
|
+
{method: :put, id: id, payload: payload}
|
|
79
|
+
end
|
|
80
|
+
command.define_singleton_method(:connect) do |options|
|
|
81
|
+
end
|
|
82
|
+
command.define_singleton_method(:rest_interface) do
|
|
83
|
+
interface
|
|
84
|
+
end
|
|
85
|
+
command.define_singleton_method(:print_dry_run) do |request|
|
|
86
|
+
captured_request = request
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
result = command.send(:update, ['--dry-run', '1', '--description', 'updated', '--component', '{"id":17,"name":"CN-CLI-1"}', '--component', '{"typeCode":"dummy-storage-controller","name":"SC-CLI-1"}'])
|
|
90
|
+
|
|
91
|
+
assert_nil result
|
|
92
|
+
assert_equal :put, captured_request[:method]
|
|
93
|
+
assert_equal 1, captured_request[:id]
|
|
94
|
+
assert_equal 'updated', captured_request[:payload]['system']['description']
|
|
95
|
+
assert_equal 2, captured_request[:payload]['system']['components'].size
|
|
96
|
+
assert_equal 17, captured_request[:payload]['system']['components'][0]['id']
|
|
97
|
+
assert_equal 'dummy-storage-controller', captured_request[:payload]['system']['components'][1]['typeCode']
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_update_dry_run_allows_empty_components_array
|
|
101
|
+
command = Morpheus::Cli::Systems.new
|
|
102
|
+
captured_request = nil
|
|
103
|
+
interface = Object.new
|
|
104
|
+
interface.define_singleton_method(:get) do |id|
|
|
105
|
+
{'system' => {'id' => id, 'name' => "system-#{id}"}}
|
|
106
|
+
end
|
|
107
|
+
interface.define_singleton_method(:dry) { self }
|
|
108
|
+
interface.define_singleton_method(:update) do |id, payload|
|
|
109
|
+
{method: :put, id: id, payload: payload}
|
|
110
|
+
end
|
|
111
|
+
command.define_singleton_method(:connect) do |options|
|
|
112
|
+
end
|
|
113
|
+
command.define_singleton_method(:rest_interface) do
|
|
114
|
+
interface
|
|
115
|
+
end
|
|
116
|
+
command.define_singleton_method(:print_dry_run) do |request|
|
|
117
|
+
captured_request = request
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
result = command.send(:update, ['--dry-run', '1', '--components', '[]'])
|
|
121
|
+
|
|
122
|
+
assert_nil result
|
|
123
|
+
assert_equal :put, captured_request[:method]
|
|
124
|
+
assert_equal [], captured_request[:payload]['system']['components']
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_render_response_for_get_includes_components_table
|
|
128
|
+
command = Morpheus::Cli::Systems.new
|
|
129
|
+
captured_rows = nil
|
|
130
|
+
command.define_singleton_method(:render_response) do |json_response, options, key, &block|
|
|
131
|
+
block.call if block
|
|
132
|
+
end
|
|
133
|
+
command.define_singleton_method(:print_h1) do |*args|
|
|
134
|
+
end
|
|
135
|
+
command.define_singleton_method(:print_h2) do |*args|
|
|
136
|
+
end
|
|
137
|
+
command.define_singleton_method(:print_description_list) do |*args|
|
|
138
|
+
end
|
|
139
|
+
command.define_singleton_method(:print) do |*args|
|
|
140
|
+
end
|
|
141
|
+
command.define_singleton_method(:as_pretty_table) do |rows, columns, options|
|
|
142
|
+
captured_rows = rows
|
|
143
|
+
"TABLE"
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
command.send(:render_response_for_get, {
|
|
147
|
+
'system' => {
|
|
148
|
+
'id' => 1,
|
|
149
|
+
'name' => 'system-1',
|
|
150
|
+
'components' => [
|
|
151
|
+
{'id' => 17, 'name' => 'CN-CLI-1', 'externalId' => 'ext-17', 'type' => {'code' => 'dummy-compute-node', 'name' => 'Compute Node'}}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
}, {})
|
|
155
|
+
|
|
156
|
+
assert_equal 1, captured_rows.size
|
|
157
|
+
assert_equal 17, captured_rows[0][:id]
|
|
158
|
+
assert_equal 'dummy-compute-node', captured_rows[0][:type_code]
|
|
159
|
+
assert_equal 'ext-17', captured_rows[0][:external_id]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Integration tests for Systems CLI commands against a live Morpheus instance.
|
|
165
|
+
# Requires a configured remote and login (uses MorpheusTest::TestCase).
|
|
166
|
+
# Tests that return no records are skipped with a message rather than failing.
|
|
167
|
+
if defined?(MorpheusTest::TestCase)
|
|
168
|
+
class SystemsLiveTest < MorpheusTest::TestCase
|
|
169
|
+
|
|
170
|
+
def test_systems_list_types
|
|
171
|
+
assert_execute %(systems list-types)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def test_systems_list_layouts
|
|
175
|
+
system_type = client.system_types.list({})['systemTypes']&.first
|
|
176
|
+
if system_type
|
|
177
|
+
assert_execute %(systems list-layouts "#{system_type['id']}")
|
|
178
|
+
else
|
|
179
|
+
puts "No system types found, skipping test `#{__method__}`"
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_systems_list_layouts_with_components
|
|
184
|
+
system_types = client.system_types.list({})['systemTypes'] || []
|
|
185
|
+
type_with_components = system_types.find do |st|
|
|
186
|
+
layouts = client.system_types.list_layouts(st['id'], {})['systemTypeLayouts'] || []
|
|
187
|
+
layouts.any? { |l| l['componentTypes']&.any? }
|
|
188
|
+
end
|
|
189
|
+
if type_with_components
|
|
190
|
+
assert_execute %(systems list-layouts "#{type_with_components['id']}")
|
|
191
|
+
else
|
|
192
|
+
puts "No layouts with componentTypes found on this instance, skipping test `#{__method__}`"
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def test_systems_list_layouts_json
|
|
197
|
+
system_type = client.system_types.list({})['systemTypes']&.first
|
|
198
|
+
if system_type
|
|
199
|
+
assert_execute %(systems list-layouts "#{system_type['id']}" --json)
|
|
200
|
+
else
|
|
201
|
+
puts "No system types found, skipping test `#{__method__}`"
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
end
|
|
206
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: morpheus-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 9.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Estes
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2026-
|
|
14
|
+
date: 2026-06-15 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: tins
|
|
@@ -381,10 +381,12 @@ files:
|
|
|
381
381
|
- lib/morpheus/api/storage_volumes_interface.rb
|
|
382
382
|
- lib/morpheus/api/subnet_types_interface.rb
|
|
383
383
|
- lib/morpheus/api/subnets_interface.rb
|
|
384
|
+
- lib/morpheus/api/support_bundles_interface.rb
|
|
384
385
|
- lib/morpheus/api/system_types_interface.rb
|
|
385
386
|
- lib/morpheus/api/systems_interface.rb
|
|
386
387
|
- lib/morpheus/api/task_sets_interface.rb
|
|
387
388
|
- lib/morpheus/api/tasks_interface.rb
|
|
389
|
+
- lib/morpheus/api/tokens_interface.rb
|
|
388
390
|
- lib/morpheus/api/usage_interface.rb
|
|
389
391
|
- lib/morpheus/api/user_groups_interface.rb
|
|
390
392
|
- lib/morpheus/api/user_settings_interface.rb
|
|
@@ -572,10 +574,12 @@ files:
|
|
|
572
574
|
- lib/morpheus/cli/commands/storage_volume_types.rb
|
|
573
575
|
- lib/morpheus/cli/commands/storage_volumes.rb
|
|
574
576
|
- lib/morpheus/cli/commands/subnets_command.rb
|
|
577
|
+
- lib/morpheus/cli/commands/support_bundles_command.rb
|
|
575
578
|
- lib/morpheus/cli/commands/systems.rb
|
|
576
579
|
- lib/morpheus/cli/commands/tasks.rb
|
|
577
580
|
- lib/morpheus/cli/commands/tee_command.rb
|
|
578
581
|
- lib/morpheus/cli/commands/tenants_command.rb
|
|
582
|
+
- lib/morpheus/cli/commands/tokens_command.rb
|
|
579
583
|
- lib/morpheus/cli/commands/update_command.rb
|
|
580
584
|
- lib/morpheus/cli/commands/usage_command.rb
|
|
581
585
|
- lib/morpheus/cli/commands/user_groups_command.rb
|
|
@@ -643,6 +647,7 @@ files:
|
|
|
643
647
|
- test/api/containers_interface_test.rb
|
|
644
648
|
- test/api/instances_interface_test.rb
|
|
645
649
|
- test/api/network_routers_interface_test.rb
|
|
650
|
+
- test/api/systems_interface_test.rb
|
|
646
651
|
- test/api/whoami_interface_test.rb
|
|
647
652
|
- test/cli/access_token_test.rb
|
|
648
653
|
- test/cli/auth_test.rb
|
|
@@ -657,6 +662,7 @@ files:
|
|
|
657
662
|
- test/cli/remote_test.rb
|
|
658
663
|
- test/cli/roles_test.rb
|
|
659
664
|
- test/cli/shell_test.rb
|
|
665
|
+
- test/cli/systems_test.rb
|
|
660
666
|
- test/cli/version_test.rb
|
|
661
667
|
- test/cli/view_test.rb
|
|
662
668
|
- test/cli/whoami_test.rb
|
|
@@ -692,6 +698,7 @@ test_files:
|
|
|
692
698
|
- test/api/containers_interface_test.rb
|
|
693
699
|
- test/api/instances_interface_test.rb
|
|
694
700
|
- test/api/network_routers_interface_test.rb
|
|
701
|
+
- test/api/systems_interface_test.rb
|
|
695
702
|
- test/api/whoami_interface_test.rb
|
|
696
703
|
- test/cli/access_token_test.rb
|
|
697
704
|
- test/cli/auth_test.rb
|
|
@@ -706,6 +713,7 @@ test_files:
|
|
|
706
713
|
- test/cli/remote_test.rb
|
|
707
714
|
- test/cli/roles_test.rb
|
|
708
715
|
- test/cli/shell_test.rb
|
|
716
|
+
- test/cli/systems_test.rb
|
|
709
717
|
- test/cli/version_test.rb
|
|
710
718
|
- test/cli/view_test.rb
|
|
711
719
|
- test/cli/whoami_test.rb
|