ibm_power_hmc 0.11.0 → 0.12.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 669594ada9babea18977e0e3870c6ea0e27305cd74660dbe2d3bbc70551ed4b4
4
- data.tar.gz: 76304c4b431924825adfc32dc14ff31c0951f0c6aae294010331c82a54ca384d
3
+ metadata.gz: af80f7c29ca2a209985e3b7f62604fc9ba962f2b0c2da10041fad1eb881f7d32
4
+ data.tar.gz: 006f79fee2ae35c82ba612639662e85ed743753f74142b1054d7166a71e877f9
5
5
  SHA512:
6
- metadata.gz: 620c2c717f08248e38b1fec9ddec4dc4bea48537ba59a2ad5071cb16b04c93a35fdd05be492eb62de0c67b170881c3c0e7fe57bedfd7c91e92069ac51961bc06
7
- data.tar.gz: c79795ef430594a26709e8eb71f96ffca4689cf1e362ff7b8531e15e36d9e2fd73c396387a11634c6eea7f29d2bbc82267f952053a3fe40a0a909f36107a3451
6
+ metadata.gz: 0ae3f9052998b99880aa096c0cdd13fca6c8112b6c80b93b51b64f2c9f22e07070b2cf100c61a06011086bd0a459f9ec843103c6c8568c02083dd18fbfd5ebd8
7
+ data.tar.gz: a9ca88412d5554c3d3d5376c72447b90da0f940553fa83d4f5396a402413af3a411b0f51a105418c77a886260d16aff954029bd73e13ff5c2ce56cfa0e30375e
data/.rubocop_local.yml CHANGED
@@ -9,5 +9,3 @@ Style/OptionalBooleanParameter:
9
9
  Enabled: false
10
10
  Style/StringConcatenation:
11
11
  Enabled: false
12
- Style/RescueModifier:
13
- Enabled: false
@@ -16,12 +16,13 @@ module IbmPowerHmc
16
16
  # @param username [String] User name.
17
17
  # @param port [Integer] TCP port number.
18
18
  # @param validate_ssl [Boolean] Verify SSL certificates.
19
- def initialize(host:, password:, username: "hscroot", port: 12_443, validate_ssl: true)
19
+ def initialize(host:, password:, username: "hscroot", port: 12_443, validate_ssl: true, timeout: 60)
20
20
  @hostname = "#{host}:#{port}"
21
21
  @username = username
22
22
  @password = password
23
23
  @verify_ssl = validate_ssl
24
24
  @api_session_token = nil
25
+ @timeout = timeout
25
26
  end
26
27
 
27
28
  ##
@@ -161,15 +162,17 @@ module IbmPowerHmc
161
162
  end
162
163
 
163
164
  ##
164
- # @!method vioses(sys_uuid = nil, search = {})
165
+ # @!method vioses(sys_uuid = nil, search = {}, permissive = true)
165
166
  # Retrieve the list of virtual I/O servers managed by the HMC.
166
167
  # @param sys_uuid [String] The UUID of the managed system.
167
168
  # @param search [Hash] The optional property name and value to match.
169
+ # @param permissive [Boolean] Skip virtual I/O servers that have error conditions.
168
170
  # @return [Array<IbmPowerHmc::VirtualIOServer>] The list of virtual I/O servers.
169
- def vioses(sys_uuid = nil, search = {})
171
+ def vioses(sys_uuid = nil, search = {}, permissive = true)
170
172
  if sys_uuid.nil?
171
173
  method_url = "/rest/api/uom/VirtualIOServer"
172
174
  search.each { |key, value| method_url += "/search/(#{key}==#{value})" }
175
+ method_url += "?ignoreError=true" if permissive
173
176
  else
174
177
  method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualIOServer"
175
178
  end
@@ -386,7 +389,7 @@ module IbmPowerHmc
386
389
  end
387
390
 
388
391
  ##
389
- # @!method templates_summary
392
+ # @!method templates_summary(draft = false)
390
393
  # Retrieve the list of partition template summaries.
391
394
  # @param draft [Boolean] Retrieve draft templates as well
392
395
  # @return [Array<IbmPowerHmc::PartitionTemplateSummary>] The list of partition template summaries.
@@ -397,7 +400,7 @@ module IbmPowerHmc
397
400
  end
398
401
 
399
402
  ##
400
- # @!method templates
403
+ # @!method templates(draft = false)
401
404
  # Retrieve the list of partition templates.
402
405
  # @param draft [Boolean] Retrieve draft templates as well
403
406
  # @return [Array<IbmPowerHmc::PartitionTemplate>] The list of partition templates.
@@ -510,8 +513,6 @@ module IbmPowerHmc
510
513
  # @param changes [Hash] Modifications to apply to the Template before deploying Logical Partition.
511
514
  # @return [String] The UUID of the deployed Logical Partition.
512
515
  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
516
  draft_uuid = template_check(template_uuid, target_sys_uuid).results["TEMPLATE_UUID"]
516
517
  template_transform(draft_uuid, target_sys_uuid)
517
518
  template_modify(draft_uuid, changes)
@@ -529,6 +530,23 @@ module IbmPowerHmc
529
530
  modify_object_attributes(method_url, changes)
530
531
  end
531
532
 
533
+ ##
534
+ # @!method template_copy(template_uuid, new_name)
535
+ # Copy existing template to a new one.
536
+ # @param template_uuid [String] UUID of the partition template to copy.
537
+ # @param new_name [String] Name of the new template.
538
+ # @return [IbmPowerHmc::PartitionTemplate] The new partition template.
539
+ def template_copy(template_uuid, new_name)
540
+ method_url = "/rest/api/templates/PartitionTemplate"
541
+ headers = {
542
+ :content_type => "application/vnd.ibm.powervm.templates+xml;type=PartitionTemplate"
543
+ }
544
+ original = template(template_uuid)
545
+ original.name = new_name
546
+ response = request(:put, method_url, headers, original.xml.to_s)
547
+ Parser.new(response.body).object(:PartitionTemplate)
548
+ end
549
+
532
550
  ##
533
551
  # @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
534
552
  # Power on a logical partition.
@@ -712,13 +730,15 @@ module IbmPowerHmc
712
730
  @status = err.http_code
713
731
  @message = err.message
714
732
 
715
- # Try to parse body as an HttpErrorResponse
733
+ # Try to parse body as an HttpErrorResponse.
716
734
  unless err.response.nil?
717
- resp = Parser.new(err.response.body).object(:HttpErrorResponse) rescue nil
718
- unless resp.nil?
735
+ begin
736
+ resp = Parser.new(err.response.body).object(:HttpErrorResponse)
719
737
  @uri = resp.uri
720
738
  @reason = resp.reason
721
739
  @message = resp.message
740
+ rescue
741
+ # not an XML body
722
742
  end
723
743
  end
724
744
  end
@@ -748,12 +768,13 @@ module IbmPowerHmc
748
768
  :url => url,
749
769
  :verify_ssl => @verify_ssl,
750
770
  :payload => payload,
751
- :headers => headers
771
+ :headers => headers,
772
+ :timeout => @timeout
752
773
  )
753
774
  rescue RestClient::Exception => e
754
- # Do not retry on failed logon attempts
775
+ # Do not retry on failed logon attempts.
755
776
  if e.http_code == 401 && @api_session_token != "" && !reauth
756
- # Try to reauth
777
+ # Try to reauth.
757
778
  reauth = true
758
779
  logon
759
780
  retry
@@ -785,20 +806,18 @@ module IbmPowerHmc
785
806
  break
786
807
  rescue HttpError => e
787
808
  attempts -= 1
788
- # Will get 412 ("Precondition Failed") if ETag mismatches
809
+ # Will get 412 ("Precondition Failed") if ETag mismatches.
789
810
  raise if e.status != 412 || attempts == 0
790
811
  end
791
812
  end
792
813
  end
793
814
 
794
- # @!method modify_object_attributes(method_url, headers = {}, attempts = 5)
815
+ # @!method modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
795
816
  # Modify an object at a specified URI.
796
817
  # @param method_url [String] The URL of the object to modify.
797
818
  # @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
819
  # @param headers [Hash] HTTP headers.
799
820
  # @param attempts [Integer] Maximum number of retries.
800
- # @yield [obj] The object to modify.
801
- # @yieldparam obj [IbmPowerHmc::AbstractRest] The object to modify.
802
821
  def modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
803
822
  modify_object(method_url, headers, attempts) do |obj|
804
823
  changes.each do |key, value|
@@ -5,6 +5,7 @@ module IbmPowerHmc
5
5
  # HMC Job for long running operations.
6
6
  class HmcJob
7
7
  class JobNotStarted < StandardError; end
8
+
8
9
  class JobFailed < StandardError
9
10
  def initialize(job)
10
11
  super
@@ -109,7 +110,7 @@ module IbmPowerHmc
109
110
  def run(timeout = 120, poll_interval = 0)
110
111
  start
111
112
  wait(timeout, poll_interval)
112
- raise JobFailed.new(@last_status) unless @last_status.status.eql?("COMPLETED_OK")
113
+ raise JobFailed.new(@last_status), "Job failed" unless @last_status.status.eql?("COMPLETED_OK")
113
114
  ensure
114
115
  delete if defined?(@href)
115
116
  end
@@ -223,9 +223,15 @@ module IbmPowerHmc
223
223
  :build_level => "VersionInfo/BuildLevel",
224
224
  :version => "BaseVersion",
225
225
  :ssh_pubkey => "PublicSSHKeyValue",
226
- :uvmid => "UVMID"
226
+ :uvmid => "UVMID",
227
+ :tz => "CurrentTimezone",
228
+ :uptime => "ManagementConsoleUpTime"
227
229
  }.freeze
228
230
 
231
+ def time
232
+ Time.at(0, singleton("ManagementConsoleTime").to_i, :millisecond).utc
233
+ end
234
+
229
235
  def managed_systems_uuids
230
236
  uuids_from_links("ManagedSystems")
231
237
  end
@@ -419,7 +425,7 @@ module IbmPowerHmc
419
425
  :location => "LocationCode",
420
426
  :description => "Description",
421
427
  :is_available => "AvailableForUsage",
422
- :capacity => "VolumeCapacity",
428
+ :capacity => "VolumeCapacity", # in MiB
423
429
  :name => "VolumeName",
424
430
  :is_fc => "IsFibreChannelBacked",
425
431
  :udid => "VolumeUniqueID"
@@ -431,7 +437,7 @@ module IbmPowerHmc
431
437
  ATTRS = {
432
438
  :name => "DiskName",
433
439
  :label => "DiskLabel",
434
- :capacity => "DiskCapacity", # In GiB
440
+ :capacity => "DiskCapacity", # in GiB
435
441
  :psize => "PartitionSize",
436
442
  :vg => "VolumeGroup",
437
443
  :udid => "UniqueDeviceID"
@@ -923,13 +929,13 @@ module IbmPowerHmc
923
929
  def vscsi=(list = [])
924
930
  adaps = REXML::Element.new('virtualSCSIClientAdapters')
925
931
  adaps.add_attribute('schemaVersion', 'V1_5_0')
926
- list.each do |vlan|
932
+ list.each do |vscsi|
927
933
  adaps.add_element('VirtualSCSIClientAdapter', {'schemaVersion' => 'V1_5_0'}).tap do |v|
928
934
  v.add_element('associatedLogicalUnits', {'schemaVersion' => 'V1_5_0'})
929
935
  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]
936
+ e.add_element('PhysicalVolume', {'schemaVersion' => 'V1_5_0'}).add_element('name').text = vscsi[:physvol] if vscsi[:physvol]
931
937
  end
932
- v.add_element('connectingPartitionName').text = vlan[:vios]
938
+ v.add_element('connectingPartitionName').text = vscsi[:vios]
933
939
  v.add_element('AssociatedTargetDevices', {'schemaVersion' => 'V1_5_0'})
934
940
  v.add_element('associatedVirtualOpticalMedia', {'schemaVersion' => 'V1_5_0'})
935
941
  end
@@ -953,10 +959,10 @@ module IbmPowerHmc
953
959
  def vfc=(list = [])
954
960
  adaps = REXML::Element.new('virtualFibreChannelClientAdapters')
955
961
  adaps.add_attribute('schemaVersion', 'V1_5_0')
956
- list.each do |vlan|
962
+ list.each do |vfc|
957
963
  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]
964
+ v.add_element('connectingPartitionName').text = vfc[:vios]
965
+ v.add_element('portName').text = vfc[:port]
960
966
  end
961
967
  end
962
968
  if xml.elements['logicalPartitionConfig/virtualFibreChannelClientAdapters']
@@ -980,10 +986,10 @@ module IbmPowerHmc
980
986
  adaps = REXML::Element.new('clientNetworkAdapters')
981
987
  adaps.add_attribute('schemaVersion', 'V1_5_0')
982
988
  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|
989
+ adaps.add_element('ClientNetworkAdapter', {'schemaVersion' => 'V1_5_0'})
990
+ .add_element('clientVirtualNetworks', {'schemaVersion' => 'V1_5_0'})
991
+ .add_element('ClientVirtualNetwork', {'schemaVersion' => 'V1_5_0'})
992
+ .tap do |v|
987
993
  v.add_element('name').text = vlan[:name]
988
994
  v.add_element('vlanId').text = vlan[:vlan_id]
989
995
  v.add_element('associatedSwitchName').text = vlan[:switch]
@@ -1036,6 +1042,7 @@ module IbmPowerHmc
1036
1042
  end
1037
1043
  end
1038
1044
 
1045
+ # Performance and Capacity Monitoring preferences
1039
1046
  class ManagementConsolePcmPreference < AbstractRest
1040
1047
  ATTRS = {
1041
1048
  :max_ltm => "MaximumManagedSystemsForLongTermMonitor",
@@ -17,7 +17,7 @@ module IbmPowerHmc
17
17
  end
18
18
 
19
19
  ##
20
- # @!method managed_system_pcm_preferences
20
+ # @!method managed_system_pcm_preferences(sys_uuid)
21
21
  # Return Performance and Capacity Monitor preferences for a Managed System.
22
22
  # @param sys_uuid [String] The managed system UUID.
23
23
  # @return [IbmPowerHmc::ManagedSystemPcmPreference] The PCM preferences for the Managed System.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IbmPowerHmc
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.2"
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.11.0
4
+ version: 0.12.2
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-07-01 00:00:00.000000000 Z
11
+ date: 2022-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client