ibm_power_hmc 0.11.0 → 0.12.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: 669594ada9babea18977e0e3870c6ea0e27305cd74660dbe2d3bbc70551ed4b4
4
- data.tar.gz: 76304c4b431924825adfc32dc14ff31c0951f0c6aae294010331c82a54ca384d
3
+ metadata.gz: e162db8e4002c4b1fbee71faceaa8c4a859f5e7e92e33e4cbbdb59862da9cde6
4
+ data.tar.gz: 97bc18d7e606bddd79f6ed83b9f2f5b562f5121c433d613085e7da5e695f71df
5
5
  SHA512:
6
- metadata.gz: 620c2c717f08248e38b1fec9ddec4dc4bea48537ba59a2ad5071cb16b04c93a35fdd05be492eb62de0c67b170881c3c0e7fe57bedfd7c91e92069ac51961bc06
7
- data.tar.gz: c79795ef430594a26709e8eb71f96ffca4689cf1e362ff7b8531e15e36d9e2fd73c396387a11634c6eea7f29d2bbc82267f952053a3fe40a0a909f36107a3451
6
+ metadata.gz: 3a36c85b010b6e67bd91e67fa380c4edb6cc27a34aee732237b5c95eaee2f6a983ee1c461bc6ab5830d4952743360f848a1228f85121f9ac8cf150b194440dac
7
+ data.tar.gz: 741c9dedab5f6bd5fd7af0038e8bdab555c6b71274f3cecded7aaf4cabb21371b744e3fd355140e61bc9c7a36128a473a81fffd6983662d2def0c0e22ac1fcc5
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
@@ -161,15 +161,17 @@ module IbmPowerHmc
161
161
  end
162
162
 
163
163
  ##
164
- # @!method vioses(sys_uuid = nil, search = {})
164
+ # @!method vioses(sys_uuid = nil, search = {}, permissive = true)
165
165
  # Retrieve the list of virtual I/O servers managed by the HMC.
166
166
  # @param sys_uuid [String] The UUID of the managed system.
167
167
  # @param search [Hash] The optional property name and value to match.
168
+ # @param permissive [Boolean] Skip virtual I/O servers that have error conditions.
168
169
  # @return [Array<IbmPowerHmc::VirtualIOServer>] The list of virtual I/O servers.
169
- def vioses(sys_uuid = nil, search = {})
170
+ def vioses(sys_uuid = nil, search = {}, permissive = true)
170
171
  if sys_uuid.nil?
171
172
  method_url = "/rest/api/uom/VirtualIOServer"
172
173
  search.each { |key, value| method_url += "/search/(#{key}==#{value})" }
174
+ method_url += "?ignoreError=true" if permissive
173
175
  else
174
176
  method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualIOServer"
175
177
  end
@@ -386,7 +388,7 @@ module IbmPowerHmc
386
388
  end
387
389
 
388
390
  ##
389
- # @!method templates_summary
391
+ # @!method templates_summary(draft = false)
390
392
  # Retrieve the list of partition template summaries.
391
393
  # @param draft [Boolean] Retrieve draft templates as well
392
394
  # @return [Array<IbmPowerHmc::PartitionTemplateSummary>] The list of partition template summaries.
@@ -397,7 +399,7 @@ module IbmPowerHmc
397
399
  end
398
400
 
399
401
  ##
400
- # @!method templates
402
+ # @!method templates(draft = false)
401
403
  # Retrieve the list of partition templates.
402
404
  # @param draft [Boolean] Retrieve draft templates as well
403
405
  # @return [Array<IbmPowerHmc::PartitionTemplate>] The list of partition templates.
@@ -510,8 +512,6 @@ module IbmPowerHmc
510
512
  # @param changes [Hash] Modifications to apply to the Template before deploying Logical Partition.
511
513
  # @return [String] The UUID of the deployed Logical Partition.
512
514
  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
515
  draft_uuid = template_check(template_uuid, target_sys_uuid).results["TEMPLATE_UUID"]
516
516
  template_transform(draft_uuid, target_sys_uuid)
517
517
  template_modify(draft_uuid, changes)
@@ -529,6 +529,23 @@ module IbmPowerHmc
529
529
  modify_object_attributes(method_url, changes)
530
530
  end
531
531
 
532
+ ##
533
+ # @!method template_copy(template_uuid, new_name)
534
+ # Copy existing template to a new one.
535
+ # @param template_uuid [String] UUID of the partition template to copy.
536
+ # @param new_name [String] Name of the new template.
537
+ # @return [IbmPowerHmc::PartitionTemplate] The new partition template.
538
+ def template_copy(template_uuid, new_name)
539
+ method_url = "/rest/api/templates/PartitionTemplate"
540
+ headers = {
541
+ :content_type => "application/vnd.ibm.powervm.templates+xml;type=PartitionTemplate"
542
+ }
543
+ original = template(template_uuid)
544
+ original.name = new_name
545
+ response = request(:put, method_url, headers, original.xml.to_s)
546
+ Parser.new(response.body).object(:PartitionTemplate)
547
+ end
548
+
532
549
  ##
533
550
  # @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
534
551
  # Power on a logical partition.
@@ -712,13 +729,15 @@ module IbmPowerHmc
712
729
  @status = err.http_code
713
730
  @message = err.message
714
731
 
715
- # Try to parse body as an HttpErrorResponse
732
+ # Try to parse body as an HttpErrorResponse.
716
733
  unless err.response.nil?
717
- resp = Parser.new(err.response.body).object(:HttpErrorResponse) rescue nil
718
- unless resp.nil?
734
+ begin
735
+ resp = Parser.new(err.response.body).object(:HttpErrorResponse)
719
736
  @uri = resp.uri
720
737
  @reason = resp.reason
721
738
  @message = resp.message
739
+ rescue
740
+ # not an XML body
722
741
  end
723
742
  end
724
743
  end
@@ -751,9 +770,9 @@ module IbmPowerHmc
751
770
  :headers => headers
752
771
  )
753
772
  rescue RestClient::Exception => e
754
- # Do not retry on failed logon attempts
773
+ # Do not retry on failed logon attempts.
755
774
  if e.http_code == 401 && @api_session_token != "" && !reauth
756
- # Try to reauth
775
+ # Try to reauth.
757
776
  reauth = true
758
777
  logon
759
778
  retry
@@ -785,20 +804,18 @@ module IbmPowerHmc
785
804
  break
786
805
  rescue HttpError => e
787
806
  attempts -= 1
788
- # Will get 412 ("Precondition Failed") if ETag mismatches
807
+ # Will get 412 ("Precondition Failed") if ETag mismatches.
789
808
  raise if e.status != 412 || attempts == 0
790
809
  end
791
810
  end
792
811
  end
793
812
 
794
- # @!method modify_object_attributes(method_url, headers = {}, attempts = 5)
813
+ # @!method modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
795
814
  # Modify an object at a specified URI.
796
815
  # @param method_url [String] The URL of the object to modify.
797
816
  # @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
817
  # @param headers [Hash] HTTP headers.
799
818
  # @param attempts [Integer] Maximum number of retries.
800
- # @yield [obj] The object to modify.
801
- # @yieldparam obj [IbmPowerHmc::AbstractRest] The object to modify.
802
819
  def modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
803
820
  modify_object(method_url, headers, attempts) do |obj|
804
821
  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.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.11.0
4
+ version: 0.12.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-07-01 00:00:00.000000000 Z
11
+ date: 2022-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client