ibm_power_hmc 0.15.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ibm_power_hmc/connection.rb +34 -36
- data/lib/ibm_power_hmc/parser.rb +26 -6
- data/lib/ibm_power_hmc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28ceda6d2c9095912e1bcf9b7a24bcb0153bc34a5c437a41966be9036fffb858
|
4
|
+
data.tar.gz: 94d8d1706954d560303e96f8c793fde5e9b0a181a7e2657a75d5f37fb5977fa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c001400d781dbadea9f68df8dc4eb5266ac6c3e74a9d8035ed7c112b404ec7553c8b97eab297dd72ce22919b024d8eaa3cfb30bf133514df1eae266ce198252b
|
7
|
+
data.tar.gz: 62dd1000797804b87a22528c711e777c07071d80df40621f6007d88e5b68ed90da6413888eee5e185379a15a9da522cfb0cbaa9c693640ccedecad23b2af9bd9
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ puts hmc.version
|
|
45
45
|
Retrieving managed systems that are powered on:
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
hc.managed_systems("State
|
48
|
+
hc.managed_systems("State==operating")
|
49
49
|
```
|
50
50
|
|
51
51
|
Listing the logical partitions and virtual I/O servers of each managed system:
|
@@ -10,7 +10,7 @@ module IbmPowerHmc
|
|
10
10
|
# HMC REST Client connection.
|
11
11
|
class Connection
|
12
12
|
##
|
13
|
-
# @!method initialize(host:, password:, username: "hscroot", port: 12_443, validate_ssl: true)
|
13
|
+
# @!method initialize(host:, password:, username: "hscroot", port: 12_443, validate_ssl: true, timeout: 60)
|
14
14
|
# Create a new HMC connection.
|
15
15
|
#
|
16
16
|
# @param host [String] Hostname of the HMC.
|
@@ -18,6 +18,7 @@ module IbmPowerHmc
|
|
18
18
|
# @param username [String] User name.
|
19
19
|
# @param port [Integer] TCP port number.
|
20
20
|
# @param validate_ssl [Boolean] Verify SSL certificates.
|
21
|
+
# @param timeout [Integer] The default HTTP timeout in seconds.
|
21
22
|
def initialize(host:, password:, username: "hscroot", port: 12_443, validate_ssl: true, timeout: 60)
|
22
23
|
@hostname = "#{host}:#{port}"
|
23
24
|
@username = username
|
@@ -104,7 +105,7 @@ module IbmPowerHmc
|
|
104
105
|
# @!method managed_system_quick(sys_uuid, property = nil)
|
105
106
|
# Retrieve information about a managed system (using Quick API).
|
106
107
|
# @param sys_uuid [String] The UUID of the managed system.
|
107
|
-
# @param
|
108
|
+
# @param property [String] The quick property name (optional).
|
108
109
|
# @return [Hash] The managed system.
|
109
110
|
def managed_system_quick(sys_uuid, property = nil)
|
110
111
|
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/quick"
|
@@ -182,8 +183,9 @@ module IbmPowerHmc
|
|
182
183
|
# @param lpar_uuid [String] The UUID of the logical partition.
|
183
184
|
# @param new_name [String] The new name of the logical partition.
|
184
185
|
def rename_lpar(lpar_uuid, new_name)
|
185
|
-
|
186
|
-
|
186
|
+
modify_object do
|
187
|
+
lpar(lpar_uuid).tap { |lpar| lpar.name = new_name }
|
188
|
+
end
|
187
189
|
end
|
188
190
|
|
189
191
|
##
|
@@ -636,14 +638,21 @@ module IbmPowerHmc
|
|
636
638
|
end
|
637
639
|
|
638
640
|
##
|
639
|
-
# @!method
|
640
|
-
#
|
641
|
+
# @!method template_modify(template_uuid, changes)
|
642
|
+
# Modify a template.
|
641
643
|
# @param template_uuid [String] UUID of the partition template to modify.
|
642
644
|
# @param changes [Hash] Hash of changes to make.
|
643
|
-
# @return [IbmPowerHmc::PartitionTemplate] The partition template.
|
644
645
|
def template_modify(template_uuid, changes)
|
645
646
|
method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}"
|
646
|
-
|
647
|
+
|
648
|
+
# Templates have no href so need to use modify_object_url.
|
649
|
+
modify_object_url(method_url) do
|
650
|
+
template(template_uuid).tap do |obj|
|
651
|
+
changes.each do |key, value|
|
652
|
+
obj.send("#{key}=", value)
|
653
|
+
end
|
654
|
+
end
|
655
|
+
end
|
647
656
|
end
|
648
657
|
|
649
658
|
##
|
@@ -792,7 +801,10 @@ module IbmPowerHmc
|
|
792
801
|
response = nil
|
793
802
|
loop do
|
794
803
|
response = request(:get, method_url)
|
795
|
-
#
|
804
|
+
# The HMC waits 10 seconds before returning 204 if there is no event.
|
805
|
+
# There is a hidden "?timeout=X" option but it does not always work.
|
806
|
+
# It will return "REST026C Maximum number of event requests exceeded"
|
807
|
+
# after a while.
|
796
808
|
break if response.code != 204 || !wait
|
797
809
|
end
|
798
810
|
FeedParser.new(response.body).objects(:Event).map do |e|
|
@@ -899,26 +911,26 @@ module IbmPowerHmc
|
|
899
911
|
end
|
900
912
|
end
|
901
913
|
|
902
|
-
|
903
|
-
|
904
|
-
# @!method modify_object(method_url, headers = {}, attempts = 5)
|
905
|
-
# Modify an object at a specified URI.
|
906
|
-
# @param method_url [String] The URL of the object to modify.
|
914
|
+
# @!method modify_object(headers = {}, attempts = 5)
|
915
|
+
# Post an IbmPowerHmc::AbstractRest object iteratively using ETag.
|
907
916
|
# @param headers [Hash] HTTP headers.
|
908
917
|
# @param attempts [Integer] Maximum number of retries.
|
909
|
-
# @
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
response = request(:get, method_url)
|
914
|
-
obj = Parser.new(response.body).object
|
918
|
+
# @yieldreturn [IbmPowerHmc::AbstractRest] The object to modify.
|
919
|
+
def modify_object(headers = {}, attempts = 5, &block)
|
920
|
+
modify_object_url(nil, headers, attempts, &block)
|
921
|
+
end
|
915
922
|
|
916
|
-
|
923
|
+
private
|
924
|
+
|
925
|
+
def modify_object_url(method_url = nil, headers = {}, attempts = 5)
|
926
|
+
while attempts > 0
|
927
|
+
obj = yield
|
928
|
+
raise "object has no href" if method_url.nil? && (!obj.kind_of?(AbstractRest) || obj.href.nil?)
|
917
929
|
|
918
930
|
# Use ETag to ensure object has not changed.
|
919
931
|
headers = headers.merge("If-Match" => obj.etag, :content_type => obj.content_type)
|
920
932
|
begin
|
921
|
-
request(:post, method_url, headers, obj.xml.to_s)
|
933
|
+
request(:post, method_url.nil? ? obj.href.path : method_url, headers, obj.xml.to_s)
|
922
934
|
break
|
923
935
|
rescue HttpError => e
|
924
936
|
attempts -= 1
|
@@ -928,20 +940,6 @@ module IbmPowerHmc
|
|
928
940
|
end
|
929
941
|
end
|
930
942
|
|
931
|
-
# @!method modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
|
932
|
-
# Modify an object at a specified URI.
|
933
|
-
# @param method_url [String] The URL of the object to modify.
|
934
|
-
# @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.
|
935
|
-
# @param headers [Hash] HTTP headers.
|
936
|
-
# @param attempts [Integer] Maximum number of retries.
|
937
|
-
def modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
|
938
|
-
modify_object(method_url, headers, attempts) do |obj|
|
939
|
-
changes.each do |key, value|
|
940
|
-
obj.send("#{key}=", value)
|
941
|
-
end
|
942
|
-
end
|
943
|
-
end
|
944
|
-
|
945
943
|
##
|
946
944
|
# @!method network_adapter(vm_type, lpar_uuid, netadap_uuid)
|
947
945
|
# Retrieve one or all virtual ethernet network adapters attached to a Logical Partition or a Virtual I/O Server.
|
data/lib/ibm_power_hmc/parser.rb
CHANGED
@@ -159,12 +159,11 @@ module IbmPowerHmc
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def collection_of(name, type)
|
162
|
-
objtype = Module.const_get("IbmPowerHmc::#{type}")
|
163
162
|
xml.get_elements([name, type].compact.join("/")).map do |elem|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
163
|
+
Module.const_get("IbmPowerHmc::#{elem.name}").new(elem)
|
164
|
+
rescue NameError
|
165
|
+
nil
|
166
|
+
end.compact
|
168
167
|
end
|
169
168
|
end
|
170
169
|
|
@@ -221,11 +220,23 @@ module IbmPowerHmc
|
|
221
220
|
ATTRS = {
|
222
221
|
:name => "ManagementConsoleName",
|
223
222
|
:build_level => "VersionInfo/BuildLevel",
|
223
|
+
:maint_level => "VersionInfo/Maintenance",
|
224
|
+
:sp_name => "VersionInfo/ServicePackName",
|
224
225
|
:version => "BaseVersion",
|
225
226
|
:ssh_pubkey => "PublicSSHKeyValue",
|
226
227
|
:uvmid => "UVMID",
|
227
228
|
:tz => "CurrentTimezone",
|
228
|
-
:uptime => "ManagementConsoleUpTime"
|
229
|
+
:uptime => "ManagementConsoleUpTime",
|
230
|
+
:uom_version => "UserObjectModelVersion/MinorVersion",
|
231
|
+
:uom_schema => "UserObjectModelVersion/SchemaNamespace",
|
232
|
+
:templates_version => "TemplateObjectModelVersion/MinorVersion",
|
233
|
+
:templates_schema => "TemplateObjectModelVersion/SchemaNamespace",
|
234
|
+
:web_version => "WebObjectModelVersion/MinorVersion",
|
235
|
+
:web_schema => "WebObjectModelVersion/SchemaNamespace",
|
236
|
+
:session_timeout => "SessionTimeout",
|
237
|
+
:web_access => "RemoteWebAccess",
|
238
|
+
:ssh_access => "RemoteCommandAccess",
|
239
|
+
:vterm_access => "RemoteVirtualTerminalAccess"
|
229
240
|
}.freeze
|
230
241
|
|
231
242
|
def time
|
@@ -320,6 +331,10 @@ module IbmPowerHmc
|
|
320
331
|
}.freeze
|
321
332
|
end
|
322
333
|
|
334
|
+
class HostChannelAdapter < IOAdapter; end
|
335
|
+
class PhysicalFibreChannelAdapter < IOAdapter; end
|
336
|
+
class SRIOVAdapter < IOAdapter; end
|
337
|
+
|
323
338
|
# Common class for LPAR and VIOS
|
324
339
|
class BasePartition < AbstractRest
|
325
340
|
ATTRS = {
|
@@ -360,6 +375,10 @@ module IbmPowerHmc
|
|
360
375
|
def sriov_elp_uuids
|
361
376
|
uuids_from_links("SRIOVEthernetLogicalPorts")
|
362
377
|
end
|
378
|
+
|
379
|
+
def io_adapters
|
380
|
+
collection_of("PartitionIOConfiguration/ProfileIOSlots/ProfileIOSlot/AssociatedIOSlot/RelatedIOAdapter", "*[1]")
|
381
|
+
end
|
363
382
|
end
|
364
383
|
|
365
384
|
# Logical Partition information
|
@@ -927,6 +946,7 @@ module IbmPowerHmc
|
|
927
946
|
:name => "partitionTemplateName",
|
928
947
|
:description => "description",
|
929
948
|
:lpar_name => "logicalPartitionConfig/partitionName",
|
949
|
+
:lpar_type => "logicalPartitionConfig/partitionType",
|
930
950
|
:lpar_id => "logicalPartitionConfig/partitionId",
|
931
951
|
:os => "logicalPartitionConfig/osVersion",
|
932
952
|
:memory => "logicalPartitionConfig/memoryConfiguration/currMemory",
|
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.16.1
|
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-10-
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|