morpheus-cli 9.0.2 → 9.1.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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/affinity_groups_interface.rb +46 -0
  4. data/lib/morpheus/api/api_client.rb +13 -0
  5. data/lib/morpheus/api/clouds_interface.rb +42 -0
  6. data/lib/morpheus/api/clusters_interface.rb +7 -1
  7. data/lib/morpheus/api/distributed_workers_interface.rb +41 -0
  8. data/lib/morpheus/api/host_vm_groups_interface.rb +37 -0
  9. data/lib/morpheus/cli/commands/affinity_groups_command.rb +554 -0
  10. data/lib/morpheus/cli/commands/backups_command.rb +1 -1
  11. data/lib/morpheus/cli/commands/clouds.rb +421 -29
  12. data/lib/morpheus/cli/commands/clusters.rb +37 -39
  13. data/lib/morpheus/cli/commands/distributed_workers_command.rb +282 -0
  14. data/lib/morpheus/cli/commands/host_vm_groups_command.rb +423 -0
  15. data/lib/morpheus/cli/mixins/affinity_helper.rb +118 -0
  16. data/lib/morpheus/cli/mixins/infrastructure_helper.rb +137 -0
  17. data/lib/morpheus/cli/option_types.rb +36 -1
  18. data/lib/morpheus/cli/version.rb +1 -1
  19. data/test/api/affinity_groups_interface_test.rb +43 -0
  20. data/test/api/clouds_interface_test.rb +67 -0
  21. data/test/api/host_vm_groups_interface_test.rb +35 -0
  22. data/test/cli/affinity_groups_cloud_cluster_scope_test.rb +270 -0
  23. data/test/cli/affinity_groups_cluster_scope_test.rb +171 -0
  24. data/test/cli/affinity_groups_test.rb +57 -0
  25. data/test/cli/affinity_groups_violations_scope_test.rb +141 -0
  26. data/test/cli/affinity_helper_test.rb +367 -0
  27. data/test/cli/backups_test.rb +212 -0
  28. data/test/cli/clusters_uuid_test.rb +131 -0
  29. data/test/cli/distributed_workers_test.rb +68 -0
  30. data/test/cli/host_vm_groups_cluster_scope_test.rb +187 -0
  31. data/test/cli/host_vm_groups_test.rb +63 -0
  32. data/test/cli/infrastructure_helper_cluster_resolver_test.rb +250 -0
  33. metadata +37 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1c28da8f1406a4119d87de9b4f0defe5e98ad69d347625c8c8018bcf02f196b
4
- data.tar.gz: 65164bb33eb05de4d1627de11a43297316e8bb5a82849a6010d91cfdcb2d5236
3
+ metadata.gz: 1ee4533b64e10012a262a86fe83ba4fdf2b72d86df2dc77553b74ad49767c8bd
4
+ data.tar.gz: 286e246f4d627e019a8b84d9ed40d7b06982b156a3dcc43a736defe59b0daaa3
5
5
  SHA512:
6
- metadata.gz: a265975de9ea8d79e23679f035536d6d201929c4133cd3cd4a410ae626597b4931019fed1c354e4ff0e67d8a83506719f10b921580522656aab858ddea23c69e
7
- data.tar.gz: 142b6cd4634d72f4636e0d251d0cfd905050ba9cceed13e75acd6091f4ca4f263e03043d30f10b40158ab15962e0a22307e2acdcfae75cfe18a059e8279b0049
6
+ metadata.gz: 81ce2b9bdea02474b34285ba487cab42b87ffc09e7742e64b13f5d82b3f70bdb387e48405508ba14ceafc5305bf6a595fdc6f2ef5be0b0799dc7a8bf25733747
7
+ data.tar.gz: 17bbc3726d741a8308cdf4104edb49d2bd77ac83767d5da4367ac81bb42beb3dc6dfe04b7e58a67eb67a1ebf9d7e2fff955234cafaacf9b2b1147b1b05b4ef5c
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.7.5
2
2
 
3
- RUN gem install morpheus-cli -v 9.0.2
3
+ RUN gem install morpheus-cli -v 9.1.0
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -0,0 +1,46 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ # Top-level flat-by-ID affinity group endpoints (MORPH-14136).
4
+ #
5
+ # Only show/update/delete are exposed at this path. Per
6
+ # morpheus-ui ApiV1UrlMappings (rc-9.1.0):
7
+ # "Flat-by-ID endpoints for morpheus-cli -- list/create stay scoped under
8
+ # /clusters/{id}/... and /zones/{id}/...."
9
+ # For list/create/form-options use Morpheus::ClustersInterface or
10
+ # Morpheus::CloudsInterface. Violations is flat, with scope in the query string.
11
+ class Morpheus::AffinityGroupsInterface < Morpheus::APIClient
12
+
13
+ def base_path
14
+ "/api/affinity-groups"
15
+ end
16
+
17
+ def get(id, params={})
18
+ validate_id!(id)
19
+ url = "#{base_path}/#{id}"
20
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
21
+ execute(method: :get, url: url, headers: headers)
22
+ end
23
+
24
+ def update(id, payload)
25
+ validate_id!(id)
26
+ url = "#{base_path}/#{id}"
27
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
28
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
29
+ end
30
+
31
+ def destroy(id, params={})
32
+ validate_id!(id)
33
+ url = "#{base_path}/#{id}"
34
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
35
+ execute(method: :delete, url: url, headers: headers)
36
+ end
37
+
38
+ alias :delete :destroy
39
+
40
+ def violations(params={})
41
+ url = "#{base_path}/violations"
42
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
43
+ execute(method: :get, url: url, headers: headers)
44
+ end
45
+
46
+ end
@@ -556,6 +556,15 @@ class Morpheus::APIClient
556
556
  Morpheus::ClustersInterface.new(common_interface_options).setopts(@options)
557
557
  end
558
558
 
559
+ def affinity_groups
560
+ Morpheus::AffinityGroupsInterface.new(common_interface_options).setopts(@options)
561
+ end
562
+
563
+ def host_vm_groups
564
+ Morpheus::HostVmGroupsInterface.new(common_interface_options).setopts(@options)
565
+ end
566
+
567
+
559
568
  def accounts
560
569
  Morpheus::AccountsInterface.new(common_interface_options).setopts(@options)
561
570
  end
@@ -592,6 +601,10 @@ class Morpheus::APIClient
592
601
  Morpheus::KeyPairsInterface.new(common_interface_options).setopts(@options)
593
602
  end
594
603
 
604
+ def distributed_workers
605
+ Morpheus::DistributedWorkersInterface.new(common_interface_options).setopts(@options)
606
+ end
607
+
595
608
  def certificates
596
609
  Morpheus::CertificatesInterface.new(common_interface_options).setopts(@options)
597
610
  end
@@ -172,4 +172,46 @@ class Morpheus::CloudsInterface < Morpheus::APIClient
172
172
  execute(method: :delete, url: url, headers: headers)
173
173
  end
174
174
 
175
+ def affinity_group_form_options(id, params={})
176
+ url = "#{base_path}/#{id}/affinity-groups/form-options"
177
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
178
+ execute(method: :get, url: url, headers: headers)
179
+ end
180
+
181
+ def list_host_vm_groups(id, params={})
182
+ url = "#{base_path}/#{id}/host-vm-groups"
183
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
184
+ execute(method: :get, url: url, headers: headers)
185
+ end
186
+
187
+ def get_host_vm_group(id, host_vm_group_id, params={})
188
+ url = "#{base_path}/#{id}/host-vm-groups/#{host_vm_group_id}"
189
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
190
+ execute(method: :get, url: url, headers: headers)
191
+ end
192
+
193
+ def create_host_vm_group(id, payload)
194
+ url = "#{base_path}/#{id}/host-vm-groups"
195
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
196
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
197
+ end
198
+
199
+ def update_host_vm_group(id, host_vm_group_id, payload)
200
+ url = "#{base_path}/#{id}/host-vm-groups/#{host_vm_group_id}"
201
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
202
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
203
+ end
204
+
205
+ def destroy_host_vm_group(id, host_vm_group_id, params={})
206
+ url = "#{base_path}/#{id}/host-vm-groups/#{host_vm_group_id}"
207
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
208
+ execute(method: :delete, url: url, headers: headers)
209
+ end
210
+
211
+ def host_vm_group_form_options(id, params={})
212
+ url = "#{base_path}/#{id}/host-vm-groups/form-options"
213
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
214
+ execute(method: :get, url: url, headers: headers)
215
+ end
216
+
175
217
  end
@@ -21,7 +21,13 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
21
21
  elsif params.is_a?(Numeric)
22
22
  url = "#{base_path}/#{params}"
23
23
  elsif params.is_a?(String)
24
- headers[:params]['name'] = params
24
+ # A uuid-shaped string resolves via the path endpoint (/api/clusters/{uuid});
25
+ # any other string is treated as a name filter for backward compatibility.
26
+ if params =~ /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/i
27
+ url = "#{base_path}/#{params}"
28
+ else
29
+ headers[:params]['name'] = params
30
+ end
25
31
  end
26
32
  execute(method: :get, url: url, headers: headers)
27
33
  end
@@ -0,0 +1,41 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::DistributedWorkersInterface < Morpheus::APIClient
4
+
5
+ def get(id, params={})
6
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
7
+ url = "#{@base_url}/api/distributed-workers/#{id}"
8
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
9
+ opts = {method: :get, url: url, headers: headers}
10
+ execute(opts)
11
+ end
12
+
13
+ def list(params={})
14
+ url = "#{@base_url}/api/distributed-workers"
15
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
16
+ opts = {method: :get, url: url, headers: headers}
17
+ execute(opts)
18
+ end
19
+
20
+ def create(payload)
21
+ url = "#{@base_url}/api/distributed-workers"
22
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
23
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
24
+ execute(opts)
25
+ end
26
+
27
+ def update(id, payload)
28
+ url = "#{@base_url}/api/distributed-workers/#{id}"
29
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
30
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
31
+ execute(opts)
32
+ end
33
+
34
+ def destroy(id, params={})
35
+ url = "#{@base_url}/api/distributed-workers/#{id}"
36
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
37
+ opts = {method: :delete, url: url, headers: headers}
38
+ execute(opts)
39
+ end
40
+
41
+ end
@@ -0,0 +1,37 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ # Top-level flat-by-ID host/VM group endpoints (MORPH-14136).
4
+ #
5
+ # Only show/update/delete are exposed at this path; list/create/form-options
6
+ # stay scoped under /clusters/{id}/host-vm-groups and /zones/{id}/host-vm-groups.
7
+ # See morpheus-ui ApiV1UrlMappings (rc-9.1.0).
8
+ class Morpheus::HostVmGroupsInterface < Morpheus::APIClient
9
+
10
+ def base_path
11
+ "/api/host-vm-groups"
12
+ end
13
+
14
+ def get(id, params={})
15
+ validate_id!(id)
16
+ url = "#{base_path}/#{id}"
17
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
18
+ execute(method: :get, url: url, headers: headers)
19
+ end
20
+
21
+ def update(id, payload)
22
+ validate_id!(id)
23
+ url = "#{base_path}/#{id}"
24
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
25
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
26
+ end
27
+
28
+ def destroy(id, params={})
29
+ validate_id!(id)
30
+ url = "#{base_path}/#{id}"
31
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
32
+ execute(method: :delete, url: url, headers: headers)
33
+ end
34
+
35
+ alias :delete :destroy
36
+
37
+ end