ibm_power_hmc 0.19.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +8 -0
- data/lib/ibm_power_hmc/apis/connection.rb +6 -3
- data/lib/ibm_power_hmc/apis/job.rb +5 -16
- data/lib/ibm_power_hmc/apis/uom.rb +119 -10
- data/lib/ibm_power_hmc/schema/job.rb +83 -0
- data/lib/ibm_power_hmc/schema/parser.rb +17 -0
- data/lib/ibm_power_hmc/schema/uom.rb +109 -23
- data/lib/ibm_power_hmc/version.rb +1 -1
- data/lib/ibm_power_hmc.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a66a6b3ab2a70a1c398c51dae01828b936b6f859d34bc957ad22101e9314e11
|
4
|
+
data.tar.gz: 0f92d6cafc9348975d179b17e6451d31edae23d96a3314f6c4b3d9bc76d97cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 996802e21a82bfaf391a84fb1872998ecd662b19f0a600315c0445ad817d3220b723879a99272ff79ff15f7add22d12bef6be275ff8106816fe3289e2113ad61
|
7
|
+
data.tar.gz: a4dd65ac732a8e4cda2377df1d87b575c9947e1c5a7a41bff19a4eda333ed49c0f92a754a4e864e2d00d93f55a4e47e6862ab5a701c5f0f2091a6e5cbcf05522
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## v0.21.0
|
2
|
+
* Add methods to create/delete LPAR client network adapters
|
3
|
+
* Add methods and schema definitions for volume groups
|
4
|
+
* Add label and page83 schema definitions for PVs
|
5
|
+
* Add schema definitions for capabilities of lpars and vioses
|
6
|
+
## v0.20.0
|
7
|
+
* Add permissive option (`ignoreError=true`) for cluster APIs
|
8
|
+
* Fix `modify_object` method when URI has a query part
|
9
|
+
* Add `chcomgmt` method
|
10
|
+
* Add `grow_lu` method
|
11
|
+
* Add `shared_memory_pool` method
|
12
|
+
* Improve schema definitions for CPU and memory
|
13
|
+
* Add schema definition for shared memory pool
|
1
14
|
## v0.19.0
|
2
15
|
* Major code refactoring
|
3
16
|
* Add `serviceable_events` method
|
data/README.md
CHANGED
@@ -70,6 +70,14 @@ Shutting down a logical partition:
|
|
70
70
|
hc.poweroff_lpar(lpar_uuid, { "operation" => "shutdown" })
|
71
71
|
```
|
72
72
|
|
73
|
+
Setting the memory of a logical partition to 32GB:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
hc.modify_object do
|
77
|
+
hc.lpar(lpar_uuid).tap { |lpar| lpar.desired_memory = 32_768 }
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
73
81
|
Listing serviceable events:
|
74
82
|
|
75
83
|
```ruby
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
# Module for IBM HMC Rest API Client
|
4
4
|
module IbmPowerHmc
|
5
|
+
WEB_XMLNS = "http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
|
6
|
+
UOM_XMLNS = "http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/"
|
7
|
+
|
5
8
|
class Error < StandardError; end
|
6
9
|
|
7
10
|
##
|
@@ -37,7 +40,7 @@ module IbmPowerHmc
|
|
37
40
|
}
|
38
41
|
doc = REXML::Document.new("")
|
39
42
|
doc.add_element("LogonRequest", "schemaVersion" => "V1_1_0")
|
40
|
-
doc.root.add_namespace(
|
43
|
+
doc.root.add_namespace(WEB_XMLNS)
|
41
44
|
doc.root.add_element("UserID").text = @username
|
42
45
|
doc.root.add_element("Password").text = @password
|
43
46
|
|
@@ -122,7 +125,7 @@ module IbmPowerHmc
|
|
122
125
|
end
|
123
126
|
|
124
127
|
def to_s
|
125
|
-
|
128
|
+
%(msg="#{@message}" status="#{@status}" reason="#{@reason}" uri=#{@uri})
|
126
129
|
end
|
127
130
|
end
|
128
131
|
|
@@ -184,7 +187,7 @@ module IbmPowerHmc
|
|
184
187
|
# Use ETag to ensure object has not changed.
|
185
188
|
headers = headers.merge("If-Match" => obj.etag, :content_type => obj.content_type)
|
186
189
|
begin
|
187
|
-
request(:post, method_url.nil? ? obj.href.
|
190
|
+
request(:post, method_url.nil? ? obj.href.to_s : method_url, headers, obj.xml.to_s)
|
188
191
|
break
|
189
192
|
rescue HttpError => e
|
190
193
|
attempts -= 1
|
@@ -7,13 +7,15 @@ module IbmPowerHmc
|
|
7
7
|
class JobNotStarted < StandardError; end
|
8
8
|
|
9
9
|
class JobFailed < StandardError
|
10
|
+
attr_reader :job
|
11
|
+
|
10
12
|
def initialize(job)
|
11
13
|
super
|
12
14
|
@job = job
|
13
15
|
end
|
14
16
|
|
15
17
|
def to_s
|
16
|
-
|
18
|
+
%(#{job.status} err="#{job.results["result"]}" rc=#{job.results["returnCode"]} msg="#{job.message}" exception="#{job.results["ExceptionText"]}" url=#{job.url} id=#{job.id})
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
@@ -42,21 +44,8 @@ module IbmPowerHmc
|
|
42
44
|
headers = {
|
43
45
|
:content_type => "application/vnd.ibm.powervm.web+xml; type=JobRequest"
|
44
46
|
}
|
45
|
-
|
46
|
-
|
47
|
-
doc.root.add_namespace("http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/")
|
48
|
-
doc.root.add_namespace("JobRequest", "http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/")
|
49
|
-
op = doc.root.add_element("RequestedOperation", "schemaVersion" => "V1_1_0")
|
50
|
-
op.add_element("OperationName").text = @operation
|
51
|
-
op.add_element("GroupName").text = @group
|
52
|
-
|
53
|
-
jobparams = doc.root.add_element("JobParameters", "schemaVersion" => "V1_1_0")
|
54
|
-
@params.each do |key, value|
|
55
|
-
jobparam = jobparams.add_element("JobParameter", "schemaVersion" => "V1_1_0")
|
56
|
-
jobparam.add_element("ParameterName").text = key
|
57
|
-
jobparam.add_element("ParameterValue").text = value
|
58
|
-
end
|
59
|
-
response = @conn.request(:put, @method_url, headers, doc.to_s)
|
47
|
+
jobreq = JobRequest.marshal({:operation => @operation, :group => @group, :params => @params}, WEB_XMLNS)
|
48
|
+
response = @conn.request(:put, @method_url, headers, jobreq.xml.to_s)
|
60
49
|
jobresp = Parser.new(response.body).object(:JobResponse)
|
61
50
|
# Save the URL of the job (JobID is not sufficient as not all jobs are in uom).
|
62
51
|
@href = jobresp.href.path
|
@@ -193,8 +193,8 @@ module IbmPowerHmc
|
|
193
193
|
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualIOServer"
|
194
194
|
end
|
195
195
|
query = {}
|
196
|
-
query["ignoreError"] = "true" if permissive
|
197
196
|
query["group"] = group_name unless group_name.nil?
|
197
|
+
query["ignoreError"] = "true" if permissive
|
198
198
|
method_url += "?" + query.map { |h| h.join("=") }.join("&") unless query.empty?
|
199
199
|
|
200
200
|
response = request(:get, method_url)
|
@@ -234,6 +234,29 @@ module IbmPowerHmc
|
|
234
234
|
JSON.parse(response.body)
|
235
235
|
end
|
236
236
|
|
237
|
+
##
|
238
|
+
# @!method volume_groups(vios_uuid)
|
239
|
+
# Retrieve the list of volume groups available on a virtual I/O server.
|
240
|
+
# @param vios_uuid [String] The UUID of the virtual I/O server.
|
241
|
+
# @return [Array<IbmPowerHmc::VolumeGroup>] The list of volume groups.
|
242
|
+
def volume_groups(vios_uuid)
|
243
|
+
method_url = "/rest/api/uom/VirtualIOServer/#{vios_uuid}/VolumeGroup"
|
244
|
+
response = request(:get, method_url)
|
245
|
+
FeedParser.new(response.body).objects(:VolumeGroup)
|
246
|
+
end
|
247
|
+
|
248
|
+
##
|
249
|
+
# @!method volume_group(vios_uuid, vg_uuid)
|
250
|
+
# Retrieve information about a volume group on a virtual I/O server.
|
251
|
+
# @param vios_uuid [String] The UUID of the virtual I/O server.
|
252
|
+
# @param vg_uuid [String] The UUID of the volume group.
|
253
|
+
# @return [IbmPowerHmc::VolumeGroup] The volume groups.
|
254
|
+
def volume_group(vios_uuid, vg_uuid)
|
255
|
+
method_url = "/rest/api/uom/VirtualIOServer/#{vios_uuid}/VolumeGroup/#{vg_uuid}"
|
256
|
+
response = request(:get, method_url)
|
257
|
+
Parser.new(response.body).object(:VolumeGroup)
|
258
|
+
end
|
259
|
+
|
237
260
|
##
|
238
261
|
# @!method groups
|
239
262
|
# Retrieve the list of groups defined on the HMC.
|
@@ -325,6 +348,36 @@ module IbmPowerHmc
|
|
325
348
|
end
|
326
349
|
private :network_adapter
|
327
350
|
|
351
|
+
##
|
352
|
+
# @!method network_adapter_lpar_create(lpar_uuid, sys_uuid, vswitch_uuid, **args)
|
353
|
+
# Create a virtual ethernet network adapter attached to a logical partition.
|
354
|
+
# @param lpar_uuid [String] UUID of the logical partition.
|
355
|
+
# @param sys_uuid [String] UUID of the managed system of the virtual switch.
|
356
|
+
# @param vswitch_uuid [String] UUID of the virtual switch.
|
357
|
+
# @param args [Hash] The network adapter properties.
|
358
|
+
# @return [IbmPowerHmc::ClientNetworkAdapter] The created network adapter.
|
359
|
+
def network_adapter_lpar_create(lpar_uuid, sys_uuid, vswitch_uuid, **args)
|
360
|
+
method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/ClientNetworkAdapter"
|
361
|
+
headers = {
|
362
|
+
:content_type => "application/vnd.ibm.powervm.uom+xml; type=ClientNetworkAdapter"
|
363
|
+
}
|
364
|
+
args[:vswitch_href] = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch/#{vswitch_uuid}"
|
365
|
+
netadap = ClientNetworkAdapter.marshal(args)
|
366
|
+
response = request(:put, method_url, headers, netadap.xml.to_s)
|
367
|
+
Parser.new(response.body).object(:ClientNetworkAdapter)
|
368
|
+
end
|
369
|
+
|
370
|
+
##
|
371
|
+
# @!method network_adapter_lpar_delete(lpar_uuid, netadap_uuid)
|
372
|
+
# Delete a virtual ethernet network adapter attached to a logical partition.
|
373
|
+
# @param lpar_uuid [String] UUID of the logical partition.
|
374
|
+
# @param netadap_uuid [String] UUID of the adapter to delete.
|
375
|
+
def network_adapter_lpar_delete(lpar_uuid, netadap_uuid)
|
376
|
+
method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/ClientNetworkAdapter/#{netadap_uuid}"
|
377
|
+
request(:delete, method_url)
|
378
|
+
# Returns HTTP 204 if ok
|
379
|
+
end
|
380
|
+
|
328
381
|
##
|
329
382
|
# @!method sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil)
|
330
383
|
# Retrieve one or all SR-IOV ethernet logical ports attached to a logical partition.
|
@@ -413,11 +466,12 @@ module IbmPowerHmc
|
|
413
466
|
end
|
414
467
|
|
415
468
|
##
|
416
|
-
# @!method clusters
|
469
|
+
# @!method clusters(permissive = true)
|
417
470
|
# Retrieve the list of clusters managed by the HMC.
|
471
|
+
# @param permissive [Boolean] Ignore errors generated from bad clusters.
|
418
472
|
# @return [Array<IbmPowerHmc::Cluster>] The list of clusters.
|
419
|
-
def clusters
|
420
|
-
method_url = "/rest/api/uom/Cluster"
|
473
|
+
def clusters(permissive = true)
|
474
|
+
method_url = "/rest/api/uom/Cluster#{'?ignoreError=true' if permissive}"
|
421
475
|
response = request(:get, method_url)
|
422
476
|
FeedParser.new(response.body).objects(:Cluster)
|
423
477
|
end
|
@@ -434,11 +488,12 @@ module IbmPowerHmc
|
|
434
488
|
end
|
435
489
|
|
436
490
|
##
|
437
|
-
# @!method ssps
|
491
|
+
# @!method ssps(permissive = true)
|
438
492
|
# Retrieve the list of shared storage pools managed by the HMC.
|
493
|
+
# @param permissive [Boolean] Ignore errors generated from bad clusters.
|
439
494
|
# @return [Array<IbmPowerHmc::SharedStoragePool>] The list of shared storage pools.
|
440
|
-
def ssps
|
441
|
-
method_url = "/rest/api/uom/SharedStoragePool"
|
495
|
+
def ssps(permissive = true)
|
496
|
+
method_url = "/rest/api/uom/SharedStoragePool#{'?ignoreError=true' if permissive}"
|
442
497
|
response = request(:get, method_url)
|
443
498
|
FeedParser.new(response.body).objects(:SharedStoragePool)
|
444
499
|
end
|
@@ -455,13 +510,17 @@ module IbmPowerHmc
|
|
455
510
|
end
|
456
511
|
|
457
512
|
##
|
458
|
-
# @!method tiers(group_name = nil)
|
513
|
+
# @!method tiers(group_name = nil, permissive = true)
|
459
514
|
# Retrieve the list of tiers that are part of shared storage pools managed by the HMC.
|
460
515
|
# @param group_name [String] The extended group attributes.
|
516
|
+
# @param permissive [Boolean] Ignore errors generated from bad clusters.
|
461
517
|
# @return [Array<IbmPowerHmc::Tier>] The list of tiers.
|
462
|
-
def tiers(group_name = nil)
|
518
|
+
def tiers(group_name = nil, permissive = true)
|
463
519
|
method_url = "/rest/api/uom/Tier"
|
464
|
-
|
520
|
+
query = {}
|
521
|
+
query["group"] = group_name unless group_name.nil?
|
522
|
+
query["ignoreError"] = "true" if permissive
|
523
|
+
method_url += "?" + query.map { |h| h.join("=") }.join("&") unless query.empty?
|
465
524
|
response = request(:get, method_url)
|
466
525
|
FeedParser.new(response.body).objects(:Tier)
|
467
526
|
end
|
@@ -503,6 +562,24 @@ module IbmPowerHmc
|
|
503
562
|
end
|
504
563
|
end
|
505
564
|
|
565
|
+
##
|
566
|
+
# @!method shared_memory_pool(sys_uuid, pool_uuid = nil)
|
567
|
+
# Retrieve information about Shared Memory Pools.
|
568
|
+
# @param sys_uuid [String] The UUID of the managed system.
|
569
|
+
# @param pool_uuid [String] The UUID of the shared memory pool (return all pools if omitted)
|
570
|
+
# @return [Array<IbmPowerHmc::SharedMemoryPool>, IbmPowerHmc::SharedMemoryPool] The list of shared memory pools.
|
571
|
+
def shared_memory_pool(sys_uuid, pool_uuid = nil)
|
572
|
+
if pool_uuid.nil?
|
573
|
+
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedMemoryPool"
|
574
|
+
response = request(:get, method_url)
|
575
|
+
FeedParser.new(response.body).objects(:SharedMemoryPool)
|
576
|
+
else
|
577
|
+
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedMemoryPool/#{pool_uuid}"
|
578
|
+
response = request(:get, method_url)
|
579
|
+
Parser.new(response.body).object(:SharedMemoryPool)
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
506
583
|
##
|
507
584
|
# @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
|
508
585
|
# Power on a logical partition.
|
@@ -602,6 +679,21 @@ module IbmPowerHmc
|
|
602
679
|
job
|
603
680
|
end
|
604
681
|
|
682
|
+
##
|
683
|
+
# @!method chcomgmt(sys_uuid, status)
|
684
|
+
# Change the co-management settings for a managed system.
|
685
|
+
# @param sys_uuid [String] The UUID of the managed system.
|
686
|
+
# @param status [String] The new co-management status ("rel", "norm", "keep").
|
687
|
+
# @return [IbmPowerHmc::HmcJob] The HMC job.
|
688
|
+
def chcomgmt(sys_uuid, status)
|
689
|
+
operation = status == "rel" ? "ReleaseController" : "RequestController"
|
690
|
+
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/do/#{operation}"
|
691
|
+
|
692
|
+
params = {}
|
693
|
+
params["coManagementControllerStatus"] = status unless status == "rel"
|
694
|
+
HmcJob.new(self, method_url, operation, "ManagedSystem", params).tap(&:run)
|
695
|
+
end
|
696
|
+
|
605
697
|
##
|
606
698
|
# @!method cli_run(hmc_uuid, cmd, sync = true)
|
607
699
|
# Run a CLI command on the HMC as a job.
|
@@ -621,6 +713,23 @@ module IbmPowerHmc
|
|
621
713
|
job
|
622
714
|
end
|
623
715
|
|
716
|
+
##
|
717
|
+
# @!method grow_lu(cl_uuid, lu_uuid, capacity)
|
718
|
+
# Increase the size of a logical unit in a cluster.
|
719
|
+
# @param cl_uuid [String] The UUID of the cluster.
|
720
|
+
# @param lu_uuid [String] The UUID of the logical unit.
|
721
|
+
# @param capacity [Float] The new logical unit size (in GB).
|
722
|
+
# @return [IbmPowerHmc::HmcJob] The HMC job.
|
723
|
+
def grow_lu(cl_uuid, lu_uuid, capacity)
|
724
|
+
method_url = "/rest/api/uom/Cluster/#{cl_uuid}/do/GrowLogicalUnit"
|
725
|
+
|
726
|
+
params = {
|
727
|
+
"LogicalUnitUDID" => lu_uuid,
|
728
|
+
"Capacity" => capacity
|
729
|
+
}
|
730
|
+
HmcJob.new(self, method_url, "GrowLogicalUnit", "Cluster", params).tap(&:run)
|
731
|
+
end
|
732
|
+
|
624
733
|
##
|
625
734
|
# @!method next_events(wait = true)
|
626
735
|
# Retrieve a list of events that occured since last call.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IbmPowerHmc
|
4
|
+
# Job Request
|
5
|
+
class JobRequest < AbstractRest
|
6
|
+
def operation
|
7
|
+
singleton("RequestedOperation/OperationName")
|
8
|
+
end
|
9
|
+
|
10
|
+
def operation=(operation)
|
11
|
+
elem = xml.elements["RequestedOperation"]
|
12
|
+
elem = xml.add_element("RequestedOperation", "schemaVersion" => "V1_1_0") if elem.nil?
|
13
|
+
elem.add_element("OperationName").text = operation
|
14
|
+
end
|
15
|
+
|
16
|
+
def group
|
17
|
+
singleton("RequestedOperation/GroupName")
|
18
|
+
end
|
19
|
+
|
20
|
+
def group=(group)
|
21
|
+
elem = xml.elements["RequestedOperation"]
|
22
|
+
elem = xml.add_element("RequestedOperation", "schemaVersion" => "V1_1_0") if elem.nil?
|
23
|
+
elem.add_element("GroupName").text = group
|
24
|
+
end
|
25
|
+
|
26
|
+
def params
|
27
|
+
params = {}
|
28
|
+
xml.each_element("JobParameters/JobParameter") do |jobparam|
|
29
|
+
name = jobparam.elements["ParameterName"]&.text&.strip
|
30
|
+
value = jobparam.elements["ParameterValue"]&.text&.strip
|
31
|
+
params[name] = value unless name.nil?
|
32
|
+
end
|
33
|
+
params
|
34
|
+
end
|
35
|
+
|
36
|
+
def params=(params)
|
37
|
+
jobparams = xml.add_element("JobParameters", "schemaVersion" => "V1_1_0")
|
38
|
+
params.each do |key, value|
|
39
|
+
jobparam = jobparams.add_element("JobParameter", "schemaVersion" => "V1_1_0")
|
40
|
+
jobparam.add_element("ParameterName").text = key
|
41
|
+
jobparam.add_element("ParameterValue").text = value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Job Response
|
47
|
+
class JobResponse < AbstractRest
|
48
|
+
ATTRS = {
|
49
|
+
:id => "JobID",
|
50
|
+
:status => "Status",
|
51
|
+
:message => "ResponseException/Message",
|
52
|
+
:target_uuid => "TargetUuid",
|
53
|
+
:linear_progress => "Progress/LinearProgress"
|
54
|
+
}.freeze
|
55
|
+
|
56
|
+
def url
|
57
|
+
singleton("RequestURL", "href")
|
58
|
+
end
|
59
|
+
|
60
|
+
def request
|
61
|
+
elem = xml.elements["JobRequestInstance"]
|
62
|
+
JobRequest.new(elem) unless elem.nil?
|
63
|
+
end
|
64
|
+
|
65
|
+
def started_at
|
66
|
+
timestamp("TimeStarted")
|
67
|
+
end
|
68
|
+
|
69
|
+
def completed_at
|
70
|
+
timestamp("TimeCompleted")
|
71
|
+
end
|
72
|
+
|
73
|
+
def results
|
74
|
+
results = {}
|
75
|
+
xml.each_element("Results/JobParameter") do |jobparam|
|
76
|
+
name = jobparam.elements["ParameterName"]&.text&.strip
|
77
|
+
value = jobparam.elements["ParameterValue"]&.text&.strip
|
78
|
+
results[name] = value unless name.nil?
|
79
|
+
end
|
80
|
+
results
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -87,6 +87,23 @@ module IbmPowerHmc
|
|
87
87
|
self.class::ATTRS.each { |varname, xpath| define_attr(varname, xpath) }
|
88
88
|
end
|
89
89
|
|
90
|
+
##
|
91
|
+
# @!method marshal(attrs = {}, namespace = UOM_XMLNS, version = "V1_1_0")
|
92
|
+
# XML marshaling of object.
|
93
|
+
# @param attrs [Hash] The initial properties of the object.
|
94
|
+
# @param namespace [String] The XML namespace to use.
|
95
|
+
# @param version [String] The XML schema version to use.
|
96
|
+
def self.marshal(attrs = {}, namespace = UOM_XMLNS, version = "V1_1_0")
|
97
|
+
doc = REXML::Document.new("")
|
98
|
+
doc.add_element(name.split("::").last, "schemaVersion" => version)
|
99
|
+
doc.root.add_namespace(namespace)
|
100
|
+
obj = new(doc.root)
|
101
|
+
attrs.each do |varname, value|
|
102
|
+
obj.send("#{varname}=", value)
|
103
|
+
end
|
104
|
+
obj
|
105
|
+
end
|
106
|
+
|
90
107
|
##
|
91
108
|
# @!method define_attr(varname, xpath)
|
92
109
|
# Define an instance variable using the text of an XML element as value.
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'base64'
|
4
|
+
|
3
5
|
module IbmPowerHmc
|
4
6
|
# HMC information
|
5
7
|
class ManagementConsole < AbstractRest
|
@@ -74,7 +76,7 @@ module IbmPowerHmc
|
|
74
76
|
|
75
77
|
def capabilities
|
76
78
|
xml.get_elements("AssociatedSystemCapabilities/*").map do |elem|
|
77
|
-
elem.name
|
79
|
+
elem.name if elem.text&.strip == "true"
|
78
80
|
end.compact
|
79
81
|
end
|
80
82
|
|
@@ -129,8 +131,13 @@ module IbmPowerHmc
|
|
129
131
|
:state => "PartitionState",
|
130
132
|
:type => "PartitionType",
|
131
133
|
:memory => "PartitionMemoryConfiguration/CurrentMemory",
|
134
|
+
:desired_memory => "PartitionMemoryConfiguration/DesiredMemory",
|
135
|
+
:min_memory => "PartitionMemoryConfiguration/MinimumMemory",
|
136
|
+
:max_memory => "PartitionMemoryConfiguration/MaximumMemory",
|
132
137
|
:dedicated => "PartitionProcessorConfiguration/CurrentHasDedicatedProcessors",
|
133
138
|
:sharing_mode => "PartitionProcessorConfiguration/CurrentSharingMode",
|
139
|
+
:uncapped_weight => "PartitionProcessorConfiguration/CurrentSharedProcessorConfiguration/CurrentUncappedWeight",
|
140
|
+
:desired_uncapped_weight => "PartitionProcessorConfiguration/SharedProcessorConfiguration/UncappedWeight",
|
134
141
|
:rmc_state => "ResourceMonitoringControlState",
|
135
142
|
:rmc_ipaddr => "ResourceMonitoringIPAddress",
|
136
143
|
:os => "OperatingSystemVersion",
|
@@ -138,6 +145,12 @@ module IbmPowerHmc
|
|
138
145
|
:procs => "PartitionProcessorConfiguration/CurrentDedicatedProcessorConfiguration/CurrentProcessors",
|
139
146
|
:proc_units => "PartitionProcessorConfiguration/CurrentSharedProcessorConfiguration/CurrentProcessingUnits",
|
140
147
|
:vprocs => "PartitionProcessorConfiguration/CurrentSharedProcessorConfiguration/AllocatedVirtualProcessors",
|
148
|
+
:desired_proc_units => "PartitionProcessorConfiguration/SharedProcessorConfiguration/DesiredProcessingUnits",
|
149
|
+
:desired_vprocs => "PartitionProcessorConfiguration/SharedProcessorConfiguration/DesiredVirtualProcessors",
|
150
|
+
:minimum_proc_units => "PartitionProcessorConfiguration/SharedProcessorConfiguration/MinimumProcessingUnits",
|
151
|
+
:minimum_vprocs => "PartitionProcessorConfiguration/SharedProcessorConfiguration/MinimumVirtualProcessors",
|
152
|
+
:maximum_proc_units => "PartitionProcessorConfiguration/SharedProcessorConfiguration/MaximumProcessingUnits",
|
153
|
+
:maximum_vprocs => "PartitionProcessorConfiguration/SharedProcessorConfiguration/MaximumVirtualProcessors",
|
141
154
|
:cpu_compat_mode => "CurrentProcessorCompatibilityMode",
|
142
155
|
:description => "Description"
|
143
156
|
}.freeze
|
@@ -163,6 +176,12 @@ module IbmPowerHmc
|
|
163
176
|
uuids_from_links("SRIOVEthernetLogicalPorts")
|
164
177
|
end
|
165
178
|
|
179
|
+
def capabilities
|
180
|
+
xml.get_elements("PartitionCapabilities/*").map do |elem|
|
181
|
+
elem.name if elem.text&.strip == "true"
|
182
|
+
end.compact
|
183
|
+
end
|
184
|
+
|
166
185
|
def io_adapters
|
167
186
|
collection_of("PartitionIOConfiguration/ProfileIOSlots/ProfileIOSlot/AssociatedIOSlot/RelatedIOAdapter", "*[1]")
|
168
187
|
end
|
@@ -190,10 +209,20 @@ module IbmPowerHmc
|
|
190
209
|
|
191
210
|
# VIOS information
|
192
211
|
class VirtualIOServer < BasePartition
|
212
|
+
def capabilities
|
213
|
+
xml.get_elements("VirtualIOServerCapabilities/*").map do |elem|
|
214
|
+
elem.name if elem.text&.strip == "true"
|
215
|
+
end.compact.concat(super)
|
216
|
+
end
|
217
|
+
|
193
218
|
def pvs
|
194
219
|
collection_of("PhysicalVolumes", "PhysicalVolume")
|
195
220
|
end
|
196
221
|
|
222
|
+
def vg_uuids
|
223
|
+
uuids_from_links("StoragePools")
|
224
|
+
end
|
225
|
+
|
197
226
|
def rep
|
198
227
|
elem = xml.elements["MediaRepositories/VirtualMediaRepository"]
|
199
228
|
VirtualMediaRepository.new(elem) unless elem.nil?
|
@@ -284,6 +313,33 @@ module IbmPowerHmc
|
|
284
313
|
}.freeze
|
285
314
|
end
|
286
315
|
|
316
|
+
# Volume Group information
|
317
|
+
class VolumeGroup < AbstractRest
|
318
|
+
ATTRS = {
|
319
|
+
:udid => "UniqueDeviceID",
|
320
|
+
:size => "AvailableSize", # in GiB
|
321
|
+
:dev_count => "BackingDeviceCount",
|
322
|
+
:free_space => "FreeSpace", # in GiB
|
323
|
+
:capacity => "GroupCapacity",
|
324
|
+
:name => "GroupName",
|
325
|
+
:serial => "GroupSerialID",
|
326
|
+
:state => "GroupState",
|
327
|
+
:max_lvs => "MaximumLogicalVolumes"
|
328
|
+
}.freeze
|
329
|
+
|
330
|
+
def reps
|
331
|
+
collection_of("MediaRepositories", "VirtualMediaRepository")
|
332
|
+
end
|
333
|
+
|
334
|
+
def pvs
|
335
|
+
collection_of("PhysicalVolumes", "PhysicalVolume")
|
336
|
+
end
|
337
|
+
|
338
|
+
def lvs
|
339
|
+
collection_of("VirtualDisks", "VirtualDisk")
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
287
343
|
# Empty parent class to match K2 schema definition
|
288
344
|
class VirtualSCSIStorage < AbstractNonRest; end
|
289
345
|
|
@@ -296,8 +352,19 @@ module IbmPowerHmc
|
|
296
352
|
:capacity => "VolumeCapacity", # in MiB
|
297
353
|
:name => "VolumeName",
|
298
354
|
:is_fc => "IsFibreChannelBacked",
|
355
|
+
:is_iscsi => "IsISCSIBacked",
|
299
356
|
:udid => "VolumeUniqueID"
|
300
357
|
}.freeze
|
358
|
+
|
359
|
+
def label
|
360
|
+
str = singleton("StorageLabel")
|
361
|
+
Base64.decode64(str) unless str.nil?
|
362
|
+
end
|
363
|
+
|
364
|
+
def page83
|
365
|
+
str = singleton("DescriptorPage83")
|
366
|
+
Base64.decode64(str) unless str.nil?
|
367
|
+
end
|
301
368
|
end
|
302
369
|
|
303
370
|
# Logical Volume information
|
@@ -307,9 +374,13 @@ module IbmPowerHmc
|
|
307
374
|
:label => "DiskLabel",
|
308
375
|
:capacity => "DiskCapacity", # in GiB
|
309
376
|
:psize => "PartitionSize",
|
310
|
-
:vg => "VolumeGroup",
|
311
377
|
:udid => "UniqueDeviceID"
|
312
378
|
}.freeze
|
379
|
+
|
380
|
+
def vg_uuid
|
381
|
+
href = singleton("VolumeGroup", "href")
|
382
|
+
uuid_from_href(href) unless href.nil?
|
383
|
+
end
|
313
384
|
end
|
314
385
|
|
315
386
|
# Virtual CD-ROM information
|
@@ -404,6 +475,10 @@ module IbmPowerHmc
|
|
404
475
|
def vswitch_uuid
|
405
476
|
uuids_from_links("AssociatedVirtualSwitch").first
|
406
477
|
end
|
478
|
+
|
479
|
+
def vswitch_href=(href)
|
480
|
+
xml.add_element("AssociatedVirtualSwitch").add_element("link", "href" => href, "rel" => "related")
|
481
|
+
end
|
407
482
|
end
|
408
483
|
|
409
484
|
# Client Network Adapter information
|
@@ -795,6 +870,38 @@ module IbmPowerHmc
|
|
795
870
|
end
|
796
871
|
end
|
797
872
|
|
873
|
+
# Shared Memory Pool
|
874
|
+
class SharedMemoryPool < AbstractRest
|
875
|
+
ATTRS = {
|
876
|
+
:pool_mb => "CurrentPoolMemory",
|
877
|
+
:available_mb => "CurrentAvailablePoolMemory",
|
878
|
+
:max_mb => "CurrentMaximumPoolMemory",
|
879
|
+
:sys_mb =>"SystemFirmwarePoolMemory",
|
880
|
+
:pool_id => "PoolID",
|
881
|
+
:dedup => "MemoryDeduplicationEnabled"
|
882
|
+
}.freeze
|
883
|
+
|
884
|
+
def paging_vios_uuids
|
885
|
+
["PagingServicePartitionOne", "PagingServicePartitionTwo"].map do |attr|
|
886
|
+
if (vios_href = singleton(attr, "href"))
|
887
|
+
uuid_from_href(vios_href)
|
888
|
+
end
|
889
|
+
end
|
890
|
+
end
|
891
|
+
|
892
|
+
def lpar_uuids
|
893
|
+
REXML::XPath.match(xml, "PagingDevices/ReservedStorageDevice").map do |dev|
|
894
|
+
if (lpar = dev.elements["AssociatedLogicalPartition"])
|
895
|
+
uuid_from_href(lpar.attributes["href"])
|
896
|
+
end
|
897
|
+
end.compact
|
898
|
+
end
|
899
|
+
|
900
|
+
def sys_uuid
|
901
|
+
uuid_from_href(href, -3)
|
902
|
+
end
|
903
|
+
end
|
904
|
+
|
798
905
|
# HMC Event
|
799
906
|
class Event < AbstractRest
|
800
907
|
attr_accessor :usertask
|
@@ -806,25 +913,4 @@ module IbmPowerHmc
|
|
806
913
|
:detail => "EventDetail"
|
807
914
|
}.freeze
|
808
915
|
end
|
809
|
-
|
810
|
-
# Job Response
|
811
|
-
class JobResponse < AbstractRest
|
812
|
-
ATTRS = {
|
813
|
-
:id => "JobID",
|
814
|
-
:status => "Status",
|
815
|
-
:operation => "JobRequestInstance/RequestedOperation/OperationName",
|
816
|
-
:group => "JobRequestInstance/RequestedOperation/GroupName",
|
817
|
-
:message => "ResponseException/Message"
|
818
|
-
}.freeze
|
819
|
-
|
820
|
-
def results
|
821
|
-
results = {}
|
822
|
-
xml.each_element("Results/JobParameter") do |jobparam|
|
823
|
-
name = jobparam.elements["ParameterName"]&.text&.strip
|
824
|
-
value = jobparam.elements["ParameterValue"]&.text&.strip
|
825
|
-
results[name] = value unless name.nil?
|
826
|
-
end
|
827
|
-
results
|
828
|
-
end
|
829
|
-
end
|
830
916
|
end
|
data/lib/ibm_power_hmc.rb
CHANGED
@@ -14,6 +14,7 @@ module IbmPowerHmc
|
|
14
14
|
require_relative "./ibm_power_hmc/apis/templates"
|
15
15
|
require_relative "./ibm_power_hmc/apis/uom"
|
16
16
|
require_relative "./ibm_power_hmc/schema/parser"
|
17
|
+
require_relative "./ibm_power_hmc/schema/job"
|
17
18
|
require_relative "./ibm_power_hmc/schema/pcm"
|
18
19
|
require_relative "./ibm_power_hmc/schema/sem"
|
19
20
|
require_relative "./ibm_power_hmc/schema/templates"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibm_power_hmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IBM Power
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/ibm_power_hmc/apis/sem.rb
|
63
63
|
- lib/ibm_power_hmc/apis/templates.rb
|
64
64
|
- lib/ibm_power_hmc/apis/uom.rb
|
65
|
+
- lib/ibm_power_hmc/schema/job.rb
|
65
66
|
- lib/ibm_power_hmc/schema/parser.rb
|
66
67
|
- lib/ibm_power_hmc/schema/pcm.rb
|
67
68
|
- lib/ibm_power_hmc/schema/sem.rb
|