ibm_power_hmc 0.8.8 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_local.yml +2 -0
- data/lib/ibm_power_hmc/connection.rb +111 -5
- data/lib/ibm_power_hmc/job.rb +15 -4
- data/lib/ibm_power_hmc/parser.rb +164 -16
- data/lib/ibm_power_hmc/pcm.rb +14 -1
- data/lib/ibm_power_hmc/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669594ada9babea18977e0e3870c6ea0e27305cd74660dbe2d3bbc70551ed4b4
|
4
|
+
data.tar.gz: 76304c4b431924825adfc32dc14ff31c0951f0c6aae294010331c82a54ca384d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 620c2c717f08248e38b1fec9ddec4dc4bea48537ba59a2ad5071cb16b04c93a35fdd05be492eb62de0c67b170881c3c0e7fe57bedfd7c91e92069ac51961bc06
|
7
|
+
data.tar.gz: c79795ef430594a26709e8eb71f96ffca4689cf1e362ff7b8531e15e36d9e2fd73c396387a11634c6eea7f29d2bbc82267f952053a3fe40a0a909f36107a3451
|
data/.rubocop_local.yml
CHANGED
@@ -157,7 +157,7 @@ module IbmPowerHmc
|
|
157
157
|
# @param new_name [String] The new name of the logical partition.
|
158
158
|
def rename_lpar(lpar_uuid, new_name)
|
159
159
|
method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}"
|
160
|
-
|
160
|
+
modify_object_attributes(method_url, {:name => new_name})
|
161
161
|
end
|
162
162
|
|
163
163
|
##
|
@@ -388,9 +388,10 @@ module IbmPowerHmc
|
|
388
388
|
##
|
389
389
|
# @!method templates_summary
|
390
390
|
# Retrieve the list of partition template summaries.
|
391
|
+
# @param draft [Boolean] Retrieve draft templates as well
|
391
392
|
# @return [Array<IbmPowerHmc::PartitionTemplateSummary>] The list of partition template summaries.
|
392
|
-
def templates_summary
|
393
|
-
method_url = "/rest/api/templates/PartitionTemplate"
|
393
|
+
def templates_summary(draft = false)
|
394
|
+
method_url = "/rest/api/templates/PartitionTemplate#{'?draft=false' unless draft}"
|
394
395
|
response = request(:get, method_url)
|
395
396
|
FeedParser.new(response.body).objects(:PartitionTemplateSummary)
|
396
397
|
end
|
@@ -398,9 +399,10 @@ module IbmPowerHmc
|
|
398
399
|
##
|
399
400
|
# @!method templates
|
400
401
|
# Retrieve the list of partition templates.
|
402
|
+
# @param draft [Boolean] Retrieve draft templates as well
|
401
403
|
# @return [Array<IbmPowerHmc::PartitionTemplate>] The list of partition templates.
|
402
|
-
def templates
|
403
|
-
method_url = "/rest/api/templates/PartitionTemplate?detail=full"
|
404
|
+
def templates(draft = false)
|
405
|
+
method_url = "/rest/api/templates/PartitionTemplate?detail=full#{'&draft=false' unless draft}"
|
404
406
|
response = request(:get, method_url)
|
405
407
|
FeedParser.new(response.body).objects(:PartitionTemplate)
|
406
408
|
end
|
@@ -439,6 +441,94 @@ module IbmPowerHmc
|
|
439
441
|
job
|
440
442
|
end
|
441
443
|
|
444
|
+
##
|
445
|
+
# @!method template_check(template_uuid, target_sys_uuid, sync = true)
|
446
|
+
# Start Template Check job (first of three steps to deploy an LPAR from a Template).
|
447
|
+
# @param template_uuid [String] The UUID of the Template to deploy an LPAR from.
|
448
|
+
# @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
|
449
|
+
# @param sync [Boolean] Start the job and wait for its completion.
|
450
|
+
# @return [IbmPowerHmc::HmcJob] The HMC job.
|
451
|
+
def template_check(template_uuid, target_sys_uuid, sync = true)
|
452
|
+
# Need to include session token in payload so make sure we are logged in
|
453
|
+
logon if @api_session_token.nil?
|
454
|
+
method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}/do/check"
|
455
|
+
params = {
|
456
|
+
"TargetUuid" => target_sys_uuid,
|
457
|
+
"K_X_API_SESSION_MEMENTO" => @api_session_token
|
458
|
+
}
|
459
|
+
job = HmcJob.new(self, method_url, "Check", "PartitionTemplate", params)
|
460
|
+
job.run if sync
|
461
|
+
job
|
462
|
+
end
|
463
|
+
|
464
|
+
##
|
465
|
+
# @!method template_transform(draft_template_uuid, target_sys_uuid, sync = true)
|
466
|
+
# Start Template Transform job (second of three steps to deploy an LPAR from a Template).
|
467
|
+
# @param draft_template_uuid [String] The UUID of the Draft Template created by the Template Check job.
|
468
|
+
# @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
|
469
|
+
# @param sync [Boolean] Start the job and wait for its completion.
|
470
|
+
# @return [IbmPowerHmc::HmcJob] The HMC job.
|
471
|
+
def template_transform(draft_template_uuid, target_sys_uuid, sync = true)
|
472
|
+
# Need to include session token in payload so make sure we are logged in
|
473
|
+
logon if @api_session_token.nil?
|
474
|
+
method_url = "/rest/api/templates/PartitionTemplate/#{draft_template_uuid}/do/transform"
|
475
|
+
params = {
|
476
|
+
"TargetUuid" => target_sys_uuid,
|
477
|
+
"K_X_API_SESSION_MEMENTO" => @api_session_token
|
478
|
+
}
|
479
|
+
job = HmcJob.new(self, method_url, "Transform", "PartitionTemplate", params)
|
480
|
+
job.run if sync
|
481
|
+
job
|
482
|
+
end
|
483
|
+
|
484
|
+
##
|
485
|
+
# @!method template_deploy(draft_template_uuid, target_sys_uuid, sync = true)
|
486
|
+
# Start Template Deploy job (last of three steps to deploy an LPAR from a Template).
|
487
|
+
# @param draft_template_uuid [String] The UUID of the Draft Template created by the Template Check job.
|
488
|
+
# @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
|
489
|
+
# @param sync [Boolean] Start the job and wait for its completion.
|
490
|
+
# @return [IbmPowerHmc::HmcJob] The HMC job.
|
491
|
+
def template_deploy(draft_template_uuid, target_sys_uuid, sync = true)
|
492
|
+
# Need to include session token in payload so make sure we are logged in
|
493
|
+
logon if @api_session_token.nil?
|
494
|
+
method_url = "/rest/api/templates/PartitionTemplate/#{draft_template_uuid}/do/deploy"
|
495
|
+
params = {
|
496
|
+
"TargetUuid" => target_sys_uuid,
|
497
|
+
"TemplateUuid" => draft_template_uuid,
|
498
|
+
"K_X_API_SESSION_MEMENTO" => @api_session_token
|
499
|
+
}
|
500
|
+
job = HmcJob.new(self, method_url, "Deploy", "PartitionTemplate", params)
|
501
|
+
job.run if sync
|
502
|
+
job
|
503
|
+
end
|
504
|
+
|
505
|
+
##
|
506
|
+
# @!method template_provision(template_uuid, target_sys_uuid, changes)
|
507
|
+
# Deploy Logical Partition from a Template (performs Check, Transform and Deploy steps in a single method).
|
508
|
+
# @param template_uuid [String] The UUID of the Template to deploy an LPAR from.
|
509
|
+
# @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
|
510
|
+
# @param changes [Hash] Modifications to apply to the Template before deploying Logical Partition.
|
511
|
+
# @return [String] The UUID of the deployed Logical Partition.
|
512
|
+
def template_provision(template_uuid, target_sys_uuid, changes)
|
513
|
+
# Need to include session token in payload so make sure we are logged in
|
514
|
+
logon if @api_session_token.nil?
|
515
|
+
draft_uuid = template_check(template_uuid, target_sys_uuid).results["TEMPLATE_UUID"]
|
516
|
+
template_transform(draft_uuid, target_sys_uuid)
|
517
|
+
template_modify(draft_uuid, changes)
|
518
|
+
template_deploy(draft_uuid, target_sys_uuid).results["PartitionUuid"]
|
519
|
+
end
|
520
|
+
|
521
|
+
##
|
522
|
+
# @!method template(template_uuid, changes)
|
523
|
+
# modify_object_attributes wrapper for templates.
|
524
|
+
# @param template_uuid [String] UUID of the partition template to modify.
|
525
|
+
# @param changes [Hash] Hash of changes to make.
|
526
|
+
# @return [IbmPowerHmc::PartitionTemplate] The partition template.
|
527
|
+
def template_modify(template_uuid, changes)
|
528
|
+
method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}"
|
529
|
+
modify_object_attributes(method_url, changes)
|
530
|
+
end
|
531
|
+
|
442
532
|
##
|
443
533
|
# @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
|
444
534
|
# Power on a logical partition.
|
@@ -701,6 +791,22 @@ module IbmPowerHmc
|
|
701
791
|
end
|
702
792
|
end
|
703
793
|
|
794
|
+
# @!method modify_object_attributes(method_url, headers = {}, attempts = 5)
|
795
|
+
# Modify an object at a specified URI.
|
796
|
+
# @param method_url [String] The URL of the object to modify.
|
797
|
+
# @param changes [Hash] Hash of changes to make. Key is the attribute modify/create (as defined in the AbstractNonRest subclass). A value of nil removes the attribute.
|
798
|
+
# @param headers [Hash] HTTP headers.
|
799
|
+
# @param attempts [Integer] Maximum number of retries.
|
800
|
+
# @yield [obj] The object to modify.
|
801
|
+
# @yieldparam obj [IbmPowerHmc::AbstractRest] The object to modify.
|
802
|
+
def modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
|
803
|
+
modify_object(method_url, headers, attempts) do |obj|
|
804
|
+
changes.each do |key, value|
|
805
|
+
obj.send("#{key}=", value)
|
806
|
+
end
|
807
|
+
end
|
808
|
+
end
|
809
|
+
|
704
810
|
##
|
705
811
|
# @!method network_adapter(vm_type, lpar_uuid, netadap_uuid)
|
706
812
|
# Retrieve one or all virtual ethernet network adapters attached to a Logical Partition or a Virtual I/O Server.
|
data/lib/ibm_power_hmc/job.rb
CHANGED
@@ -5,6 +5,16 @@ module IbmPowerHmc
|
|
5
5
|
# HMC Job for long running operations.
|
6
6
|
class HmcJob
|
7
7
|
class JobNotStarted < StandardError; end
|
8
|
+
class JobFailed < StandardError
|
9
|
+
def initialize(job)
|
10
|
+
super
|
11
|
+
@job = job
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
"id=\"#{@job.id}\" operation=\"#{@job.group}/#{@job.operation}\" status=\"#{@job.status}\" message=\"#{@job.message}\" exception_text=\"#{@job.results['ExceptionText']}\""
|
16
|
+
end
|
17
|
+
end
|
8
18
|
|
9
19
|
##
|
10
20
|
# @!method initialize(conn, method_url, operation, group, params = {})
|
@@ -52,7 +62,7 @@ module IbmPowerHmc
|
|
52
62
|
end
|
53
63
|
|
54
64
|
# @return [Hash] The job results returned by the HMC.
|
55
|
-
attr_reader :results
|
65
|
+
attr_reader :results, :last_status
|
56
66
|
|
57
67
|
##
|
58
68
|
# @!method status
|
@@ -65,9 +75,9 @@ module IbmPowerHmc
|
|
65
75
|
:content_type => "application/vnd.ibm.powervm.web+xml; type=JobRequest"
|
66
76
|
}
|
67
77
|
response = @conn.request(:get, @href, headers)
|
68
|
-
|
69
|
-
@results =
|
70
|
-
|
78
|
+
@last_status = Parser.new(response.body).object(:JobResponse)
|
79
|
+
@results = @last_status.results
|
80
|
+
@last_status.status
|
71
81
|
end
|
72
82
|
|
73
83
|
##
|
@@ -99,6 +109,7 @@ module IbmPowerHmc
|
|
99
109
|
def run(timeout = 120, poll_interval = 0)
|
100
110
|
start
|
101
111
|
wait(timeout, poll_interval)
|
112
|
+
raise JobFailed.new(@last_status) unless @last_status.status.eql?("COMPLETED_OK")
|
102
113
|
ensure
|
103
114
|
delete if defined?(@href)
|
104
115
|
end
|
data/lib/ibm_power_hmc/parser.rb
CHANGED
@@ -34,7 +34,7 @@ module IbmPowerHmc
|
|
34
34
|
content = entry.elements["content[@type]"]
|
35
35
|
return if content.nil?
|
36
36
|
|
37
|
-
type = content.attributes["type"].split("=").
|
37
|
+
type = content.attributes["type"].split("=")[1] || filter_type.to_s
|
38
38
|
return unless filter_type.nil? || filter_type.to_s == type
|
39
39
|
|
40
40
|
Module.const_get("IbmPowerHmc::#{type}").new(entry)
|
@@ -95,10 +95,35 @@ module IbmPowerHmc
|
|
95
95
|
def define_attr(varname, xpath)
|
96
96
|
value = singleton(xpath)
|
97
97
|
self.class.__send__(:attr_reader, varname)
|
98
|
+
self.class.__send__(:define_method, "#{varname}=") do |v|
|
99
|
+
if v.nil?
|
100
|
+
xml.elements.delete(xpath)
|
101
|
+
else
|
102
|
+
create_element(xpath) if xml.elements[xpath].nil?
|
103
|
+
xml.elements[xpath].text = v
|
104
|
+
end
|
105
|
+
instance_variable_set("@#{varname}", v)
|
106
|
+
end
|
98
107
|
instance_variable_set("@#{varname}", value)
|
99
108
|
end
|
100
109
|
private :define_attr
|
101
110
|
|
111
|
+
##
|
112
|
+
# @!method create_element(xpath)
|
113
|
+
# Create a new XML element.
|
114
|
+
# @param xpath [String] The XPath of the XML element to create.
|
115
|
+
def create_element(xpath)
|
116
|
+
cur = xml
|
117
|
+
xpath.split("/").each do |el|
|
118
|
+
p = cur.elements[el]
|
119
|
+
if p.nil?
|
120
|
+
cur = cur.add_element(el)
|
121
|
+
else
|
122
|
+
cur = p
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
102
127
|
##
|
103
128
|
# @!method singleton(xpath, attr = nil)
|
104
129
|
# Get the text (or the value of a specified attribute) of an XML element.
|
@@ -135,7 +160,7 @@ module IbmPowerHmc
|
|
135
160
|
|
136
161
|
def collection_of(name, type)
|
137
162
|
objtype = Module.const_get("IbmPowerHmc::#{type}")
|
138
|
-
xml.get_elements(
|
163
|
+
xml.get_elements([name, type].compact.join("/")).map do |elem|
|
139
164
|
objtype.new(elem)
|
140
165
|
end
|
141
166
|
rescue
|
@@ -327,13 +352,6 @@ module IbmPowerHmc
|
|
327
352
|
def sriov_elp_uuids
|
328
353
|
uuids_from_links("SRIOVEthernetLogicalPorts")
|
329
354
|
end
|
330
|
-
|
331
|
-
# Setters
|
332
|
-
|
333
|
-
def name=(name)
|
334
|
-
xml.elements[ATTRS[:name]].text = name
|
335
|
-
@name = name
|
336
|
-
end
|
337
355
|
end
|
338
356
|
|
339
357
|
# Logical Partition information
|
@@ -430,6 +448,15 @@ module IbmPowerHmc
|
|
430
448
|
}.freeze
|
431
449
|
end
|
432
450
|
|
451
|
+
# SharedFileSystemFile information
|
452
|
+
class SharedFileSystemFile < VirtualSCSIStorage
|
453
|
+
ATTRS = {
|
454
|
+
:name => "SharedFileSystemFileName",
|
455
|
+
:path => "SharedFileSystemFilePath",
|
456
|
+
:udid => "UniqueDeviceID"
|
457
|
+
}.freeze
|
458
|
+
end
|
459
|
+
|
433
460
|
# Virtual Media Repository information
|
434
461
|
class VirtualMediaRepository < AbstractNonRest
|
435
462
|
ATTRS = {
|
@@ -573,11 +600,12 @@ module IbmPowerHmc
|
|
573
600
|
|
574
601
|
def storage
|
575
602
|
# Possible storage types are:
|
576
|
-
# LogicalUnit, PhysicalVolume, VirtualDisk, VirtualOpticalMedia
|
603
|
+
# LogicalUnit, PhysicalVolume, VirtualDisk, VirtualOpticalMedia,
|
604
|
+
# SharedFileSystemFile
|
577
605
|
elem = xml.elements["Storage/*[1]"]
|
578
606
|
begin
|
579
607
|
Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
|
580
|
-
rescue
|
608
|
+
rescue NameError
|
581
609
|
nil
|
582
610
|
end
|
583
611
|
end
|
@@ -585,9 +613,14 @@ module IbmPowerHmc
|
|
585
613
|
def device
|
586
614
|
# Possible backing device types are:
|
587
615
|
# LogicalVolumeVirtualTargetDevice, PhysicalVolumeVirtualTargetDevice,
|
588
|
-
# SharedStoragePoolLogicalUnitVirtualTargetDevice, VirtualOpticalTargetDevice
|
616
|
+
# SharedStoragePoolLogicalUnitVirtualTargetDevice, VirtualOpticalTargetDevice,
|
617
|
+
# SharedFileSystemFileVirtualTargetDevice
|
589
618
|
elem = xml.elements["TargetDevice/*[1]"]
|
590
|
-
|
619
|
+
begin
|
620
|
+
Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
|
621
|
+
rescue NameError
|
622
|
+
nil
|
623
|
+
end
|
591
624
|
end
|
592
625
|
end
|
593
626
|
|
@@ -653,6 +686,9 @@ module IbmPowerHmc
|
|
653
686
|
end
|
654
687
|
end
|
655
688
|
|
689
|
+
# SharedFileSystemFile backing device information
|
690
|
+
class SharedFileSystemFileVirtualTargetDevice < VirtualTargetDevice; end
|
691
|
+
|
656
692
|
# VFC mapping information
|
657
693
|
class VirtualFibreChannelMapping < AbstractNonRest
|
658
694
|
def lpar_uuid
|
@@ -864,6 +900,8 @@ module IbmPowerHmc
|
|
864
900
|
ATTRS = {
|
865
901
|
:name => "partitionTemplateName",
|
866
902
|
:description => "description",
|
903
|
+
:lpar_name => "logicalPartitionConfig/partitionName",
|
904
|
+
:lpar_id => "logicalPartitionConfig/partitionId",
|
867
905
|
:os => "logicalPartitionConfig/osVersion",
|
868
906
|
:memory => "logicalPartitionConfig/memoryConfiguration/currMemory",
|
869
907
|
:dedicated => "logicalPartitionConfig/processorConfiguration/hasDedicatedProcessors",
|
@@ -872,6 +910,87 @@ module IbmPowerHmc
|
|
872
910
|
:proc_units => "logicalPartitionConfig/processorConfiguration/sharedProcessorConfiguration/desiredProcessingUnits",
|
873
911
|
:procs => "logicalPartitionConfig/processorConfiguration/dedicatedProcessorConfiguration/desiredProcessors"
|
874
912
|
}.freeze
|
913
|
+
|
914
|
+
def vscsi
|
915
|
+
REXML::XPath.match(xml, 'logicalPartitionConfig/virtualSCSIClientAdapters/VirtualSCSIClientAdapter').map do |adap|
|
916
|
+
{
|
917
|
+
:vios => adap.elements['connectingPartitionName']&.text,
|
918
|
+
:physvol => adap.elements['associatedPhysicalVolume/PhysicalVolume/name']&.text,
|
919
|
+
}
|
920
|
+
end
|
921
|
+
end
|
922
|
+
|
923
|
+
def vscsi=(list = [])
|
924
|
+
adaps = REXML::Element.new('virtualSCSIClientAdapters')
|
925
|
+
adaps.add_attribute('schemaVersion', 'V1_5_0')
|
926
|
+
list.each do |vlan|
|
927
|
+
adaps.add_element('VirtualSCSIClientAdapter', {'schemaVersion' => 'V1_5_0'}).tap do |v|
|
928
|
+
v.add_element('associatedLogicalUnits', {'schemaVersion' => 'V1_5_0'})
|
929
|
+
v.add_element('associatedPhysicalVolume', {'schemaVersion' => 'V1_5_0'}).tap do |e|
|
930
|
+
e.add_element('PhysicalVolume', {'schemaVersion' => 'V1_5_0'}).add_element('name').text = vlan[:physvol] if vlan[:physvol]
|
931
|
+
end
|
932
|
+
v.add_element('connectingPartitionName').text = vlan[:vios]
|
933
|
+
v.add_element('AssociatedTargetDevices', {'schemaVersion' => 'V1_5_0'})
|
934
|
+
v.add_element('associatedVirtualOpticalMedia', {'schemaVersion' => 'V1_5_0'})
|
935
|
+
end
|
936
|
+
end
|
937
|
+
if xml.elements['logicalPartitionConfig/virtualSCSIClientAdapters']
|
938
|
+
xml.elements['logicalPartitionConfig/virtualSCSIClientAdapters'] = adaps
|
939
|
+
else
|
940
|
+
xml.elements['logicalPartitionConfig'].add_element(adaps)
|
941
|
+
end
|
942
|
+
end
|
943
|
+
|
944
|
+
def vfc
|
945
|
+
REXML::XPath.match(xml, 'logicalPartitionConfig/virtualFibreChannelClientAdapters/VirtualFibreChannelClientAdapter').map do |adap|
|
946
|
+
{
|
947
|
+
:vios => adap.elements['connectingPartitionName']&.text,
|
948
|
+
:port => adap.elements['portName']&.text
|
949
|
+
}
|
950
|
+
end
|
951
|
+
end
|
952
|
+
|
953
|
+
def vfc=(list = [])
|
954
|
+
adaps = REXML::Element.new('virtualFibreChannelClientAdapters')
|
955
|
+
adaps.add_attribute('schemaVersion', 'V1_5_0')
|
956
|
+
list.each do |vlan|
|
957
|
+
adaps.add_element('VirtualFibreChannelClientAdapter', {'schemaVersion' => 'V1_5_0'}).tap do |v|
|
958
|
+
v.add_element('connectingPartitionName').text = vlan[:vios]
|
959
|
+
v.add_element('portName').text = vlan[:port]
|
960
|
+
end
|
961
|
+
end
|
962
|
+
if xml.elements['logicalPartitionConfig/virtualFibreChannelClientAdapters']
|
963
|
+
xml.elements['logicalPartitionConfig/virtualFibreChannelClientAdapters'] = adaps
|
964
|
+
else
|
965
|
+
xml.elements['logicalPartitionConfig'].add_element(adaps)
|
966
|
+
end
|
967
|
+
end
|
968
|
+
|
969
|
+
def vlans
|
970
|
+
REXML::XPath.match(xml, 'logicalPartitionConfig/clientNetworkAdapters/ClientNetworkAdapter/clientVirtualNetworks/ClientVirtualNetwork').map do |vlan|
|
971
|
+
{
|
972
|
+
:name => vlan.elements['name']&.text,
|
973
|
+
:vlan_id => vlan.elements['vlanId']&.text,
|
974
|
+
:switch => vlan.elements['associatedSwitchName']&.text
|
975
|
+
}
|
976
|
+
end
|
977
|
+
end
|
978
|
+
|
979
|
+
def vlans=(list = [])
|
980
|
+
adaps = REXML::Element.new('clientNetworkAdapters')
|
981
|
+
adaps.add_attribute('schemaVersion', 'V1_5_0')
|
982
|
+
list.each do |vlan|
|
983
|
+
adaps.add_element('ClientNetworkAdapter', {'schemaVersion' => 'V1_5_0'}).
|
984
|
+
add_element('clientVirtualNetworks', {'schemaVersion' => 'V1_5_0'}).
|
985
|
+
add_element('ClientVirtualNetwork', {'schemaVersion' => 'V1_5_0'}).
|
986
|
+
tap do |v|
|
987
|
+
v.add_element('name').text = vlan[:name]
|
988
|
+
v.add_element('vlanId').text = vlan[:vlan_id]
|
989
|
+
v.add_element('associatedSwitchName').text = vlan[:switch]
|
990
|
+
end
|
991
|
+
end
|
992
|
+
xml.elements['logicalPartitionConfig/clientNetworkAdapters'] = adaps
|
993
|
+
end
|
875
994
|
end
|
876
995
|
|
877
996
|
# HMC Event
|
@@ -899,9 +1018,11 @@ module IbmPowerHmc
|
|
899
1018
|
# Job Response
|
900
1019
|
class JobResponse < AbstractRest
|
901
1020
|
ATTRS = {
|
902
|
-
:id
|
903
|
-
:status
|
904
|
-
:
|
1021
|
+
:id => "JobID",
|
1022
|
+
:status => "Status",
|
1023
|
+
:operation => "JobRequestInstance/RequestedOperation/OperationName",
|
1024
|
+
:group => "JobRequestInstance/RequestedOperation/GroupName",
|
1025
|
+
:message => "ResponseException/Message"
|
905
1026
|
}.freeze
|
906
1027
|
|
907
1028
|
def results
|
@@ -914,4 +1035,31 @@ module IbmPowerHmc
|
|
914
1035
|
results
|
915
1036
|
end
|
916
1037
|
end
|
1038
|
+
|
1039
|
+
class ManagementConsolePcmPreference < AbstractRest
|
1040
|
+
ATTRS = {
|
1041
|
+
:max_ltm => "MaximumManagedSystemsForLongTermMonitor",
|
1042
|
+
:max_compute_ltm => "MaximumManagedSystemsForComputeLTM",
|
1043
|
+
:max_aggregation => "MaximumManagedSystemsForAggregation",
|
1044
|
+
:max_stm => "MaximumManagedSystemsForShortTermMonitor",
|
1045
|
+
:max_em => "MaximumManagedSystemsForEnergyMonitor",
|
1046
|
+
:aggregated_storage_duration => "AggregatedMetricsStorageDuration"
|
1047
|
+
}.freeze
|
1048
|
+
|
1049
|
+
def managed_system_preferences
|
1050
|
+
collection_of(nil, "ManagedSystemPcmPreference")
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
class ManagedSystemPcmPreference < AbstractNonRest
|
1055
|
+
ATTRS = {
|
1056
|
+
:id => "Metadata/Atom/AtomID",
|
1057
|
+
:name => "SystemName",
|
1058
|
+
:long_term_monitor => "LongTermMonitorEnabled",
|
1059
|
+
:aggregation => "AggregationEnabled",
|
1060
|
+
:short_term_monitor => "ShortTermMonitorEnabled",
|
1061
|
+
:compute_ltm => "ComputeLTMEnabled",
|
1062
|
+
:energy_monitor => "EnergyMonitorEnabled"
|
1063
|
+
}.freeze
|
1064
|
+
end
|
917
1065
|
end
|
data/lib/ibm_power_hmc/pcm.rb
CHANGED
@@ -5,11 +5,24 @@ require 'uri'
|
|
5
5
|
|
6
6
|
module IbmPowerHmc
|
7
7
|
class Connection
|
8
|
+
##
|
9
|
+
# @!method pcm_preferences
|
10
|
+
# Retrieve global Performance and Capacity Monitor preferences for the HMC.
|
11
|
+
# @return [Array<IbmPowerHmc::ManagementConsolePcmPreference>] The PCM preferences for the HMC.
|
8
12
|
def pcm_preferences
|
9
13
|
method_url = "/rest/api/pcm/preferences"
|
10
14
|
|
11
15
|
response = request(:get, method_url)
|
12
|
-
|
16
|
+
FeedParser.new(response.body).objects(:ManagementConsolePcmPreference)
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# @!method managed_system_pcm_preferences
|
21
|
+
# Return Performance and Capacity Monitor preferences for a Managed System.
|
22
|
+
# @param sys_uuid [String] The managed system UUID.
|
23
|
+
# @return [IbmPowerHmc::ManagedSystemPcmPreference] The PCM preferences for the Managed System.
|
24
|
+
def managed_system_pcm_preferences(sys_uuid)
|
25
|
+
pcm_preferences.first.managed_system_preferences.find { |p| p.id.eql?(sys_uuid) }
|
13
26
|
end
|
14
27
|
|
15
28
|
##
|
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.11.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-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
87
|
+
rubygems_version: 3.1.4
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: IBM Power HMC Ruby gem.
|