ibm_power_hmc 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 795c24c54a66370ed07b6d1fdac7f156e2802f2e3ddcc874a3e63704cea8c1f9
4
- data.tar.gz: 0cb32bfa4740e020d444e1d4b520cee210c50e14c13c7caacf3c79edc9529121
3
+ metadata.gz: faeaaee474f96b0beb9747a2d346110a1321e9060b2b196770598f1bccfd85a8
4
+ data.tar.gz: 3af51fcdb06f722a95e44bcea28f8ed4f4fef9cdfd9e1332063c3bf288a00c61
5
5
  SHA512:
6
- metadata.gz: c980bfb6bea2bcf632903a5cda0dccfafc49f4115fa94d80823d6ba836cd9c385a37faa7e3951bb1c7675e8d928d92250890920689d8b07c870b8043196d532e
7
- data.tar.gz: 7af86636d815da7b63587e459bbd4601045c55f4485cb22eb503b6875e00c43cd94f83d412882fe995e3846171547979f0fd5f93ab4e6804013e01fb9bd9d38d
6
+ metadata.gz: 1756c8a220a30ba88da0cd0d518a681657f9d08a231c11715e461d0fe5be1c171b17e98bb290fd29f9cdb551da48cdfc699707147abded7cfa204dcde26067be
7
+ data.tar.gz: 8906b25b90865262000331f4c371b546cac852eeb14714e8c75b0e7ae937422d441a1c920687d4e8913dad088a9eadbbbb7a5d740fceccd57f9733e9112ce2bc
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" => "operating")
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 property_name [String] The quick property name (optional).
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
- method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}"
186
- modify_object_attributes(method_url, {:name => new_name})
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 template(template_uuid, changes)
640
- # modify_object_attributes wrapper for templates.
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
- modify_object_attributes(method_url, changes)
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
  ##
@@ -782,18 +791,20 @@ module IbmPowerHmc
782
791
  end
783
792
 
784
793
  ##
785
- # @!method next_events(wait = true)
794
+ # @!method next_events(timeout = -1)
786
795
  # Retrieve a list of events that occured since last call.
787
- # @param wait [Boolean] If no event is available, block until new events occur.
796
+ # @param timeout [Integer] The number of seconds to wait if no event is available.
797
+ # Specify -1 to wait indefinitely.
788
798
  # @return [Array<IbmPowerHmc::Event>] The list of events.
789
- def next_events(wait = true)
799
+ def next_events(timeout = -1)
790
800
  method_url = "/rest/api/uom/Event"
801
+ method_url += "?timeout=#{timeout}" if timeout >= 0
791
802
 
792
803
  response = nil
793
804
  loop do
794
805
  response = request(:get, method_url)
795
- # No need to sleep as the HMC already waits a bit before returning 204
796
- break if response.code != 204 || !wait
806
+ # The HMC waits "timeout" seconds (10 if not specified) before returning 204.
807
+ break if response.code != 204 || timeout >= 0
797
808
  end
798
809
  FeedParser.new(response.body).objects(:Event).map do |e|
799
810
  data = e.data.split("/") unless e.data.nil?
@@ -899,26 +910,26 @@ module IbmPowerHmc
899
910
  end
900
911
  end
901
912
 
902
- private
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.
913
+ # @!method modify_object(headers = {}, attempts = 5)
914
+ # Post an IbmPowerHmc::AbstractRest object iteratively using ETag.
907
915
  # @param headers [Hash] HTTP headers.
908
916
  # @param attempts [Integer] Maximum number of retries.
909
- # @yield [obj] The object to modify.
910
- # @yieldparam obj [IbmPowerHmc::AbstractRest] The object to modify.
911
- def modify_object(method_url, headers = {}, attempts = 5)
912
- while attempts > 0
913
- response = request(:get, method_url)
914
- obj = Parser.new(response.body).object
917
+ # @yieldreturn [IbmPowerHmc::AbstractRest] The object to modify.
918
+ def modify_object(headers = {}, attempts = 5, &block)
919
+ modify_object_url(nil, headers, attempts, &block)
920
+ end
915
921
 
916
- yield obj
922
+ private
923
+
924
+ def modify_object_url(method_url = nil, headers = {}, attempts = 5)
925
+ while attempts > 0
926
+ obj = yield
927
+ raise "object has no href" if method_url.nil? && (!obj.kind_of?(AbstractRest) || obj.href.nil?)
917
928
 
918
929
  # Use ETag to ensure object has not changed.
919
930
  headers = headers.merge("If-Match" => obj.etag, :content_type => obj.content_type)
920
931
  begin
921
- request(:post, method_url, headers, obj.xml.to_s)
932
+ request(:post, method_url.nil? ? obj.href.path : method_url, headers, obj.xml.to_s)
922
933
  break
923
934
  rescue HttpError => e
924
935
  attempts -= 1
@@ -928,20 +939,6 @@ module IbmPowerHmc
928
939
  end
929
940
  end
930
941
 
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
942
  ##
946
943
  # @!method network_adapter(vm_type, lpar_uuid, netadap_uuid)
947
944
  # Retrieve one or all virtual ethernet network adapters attached to a Logical Partition or a Virtual I/O Server.
@@ -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
- objtype.new(elem)
165
- end
166
- rescue
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",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IbmPowerHmc
4
- VERSION = "0.15.0"
4
+ VERSION = "0.16.0"
5
5
  end
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.15.0
4
+ version: 0.16.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-10-04 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client