ibm_power_hmc 0.10.0 → 0.13.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: ebd50ae53571c98987372d364410261fa5a5440cf23e009c9cf8219eb2e052de
4
- data.tar.gz: 7514545bd7a9be7e958597b7fdebc161f9ea253b20550165a798765930b09eec
3
+ metadata.gz: 3e96072a9ae18c79163e6f52a904e3b4f696f9b5d56729fc92d234a385929269
4
+ data.tar.gz: 69738a546bff4977e35c4732894a0b1916ec8e0dd49601c7e41d95e793f83ae8
5
5
  SHA512:
6
- metadata.gz: 41c1fd98ca6750bad69416b3c29986c432c77d8168d72ae485a90a6199b53716dd214c70f74b4c5971e03845d359f847c15a3958a616debd097effcfc0a5567b
7
- data.tar.gz: 44f761a7d986716fe2338bceee413785add2fbfdece042022fec02edadcf60d02ea9deb49bad75d0752ea05b64fbe37b36a554d15f7a6e52bb09c62966ab3e9b
6
+ metadata.gz: cbe96ad163dc152b885638579ca712a47e07716d98485cd3585de86d8b01e8ba961211cc27a0d0d8b0e4273f610b94eab46e114fc98f1049b480ab73a266f0fa
7
+ data.tar.gz: 94dafbe96f39811e3b1e70eae35fcc22442c05bbe0eae3fbca3e1e5577c35dffeb575bef5ecc87babdd08939904882391f811b5ddd980983ce30679e7f6c7f18
data/.gitignore CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.rubocop_local.yml CHANGED
File without changes
data/CHANGELOG.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
File without changes
@@ -157,22 +157,61 @@ 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
- modify_object(method_url) { |lpar| lpar.name = new_name }
160
+ modify_object_attributes(method_url, {:name => new_name})
161
161
  end
162
162
 
163
163
  ##
164
- # @!method vioses(sys_uuid = nil, search = {})
164
+ # @!method lpar_migrate_validate(lpar_uuid, target_sys_name, sync = true)
165
+ # Validate if a logical partition can be migrated to another managed system.
166
+ # @raise [IbmPowerHmc::JobFailed] if validation fails
167
+ # @param lpar_uuid [String] The UUID of the logical partition to migrate.
168
+ # @param target_sys_name [String] The managed system to migrate partition to.
169
+ # @param sync [Boolean] Start the job and wait for its completion.
170
+ def lpar_migrate_validate(lpar_uuid, target_sys_name, sync = true)
171
+ # Need to include session token in payload so make sure we are logged in
172
+ logon if @api_session_token.nil?
173
+ method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/do/MigrateValidate"
174
+ params = {
175
+ "TargetManagedSystemName" => target_sys_name
176
+ }
177
+ HmcJob.new(self, method_url, "MigrateValidate", "LogicalPartition", params).tap do |job|
178
+ job.run if sync
179
+ end
180
+ end
181
+
182
+ ##
183
+ # @!method lpar_migrate(lpar_uuid, target_sys_name, sync = true)
184
+ # Migrate a logical partition to another managed system.
185
+ # @param lpar_uuid [String] The UUID of the logical partition to migrate.
186
+ # @param target_sys_name [String] The managed system to migrate partition to.
187
+ # @param sync [Boolean] Start the job and wait for its completion.
188
+ def lpar_migrate(lpar_uuid, target_sys_name, sync = true)
189
+ # Need to include session token in payload so make sure we are logged in
190
+ logon if @api_session_token.nil?
191
+ method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/do/Migrate"
192
+ params = {
193
+ "TargetManagedSystemName" => target_sys_name
194
+ }
195
+ HmcJob.new(self, method_url, "Migrate", "LogicalPartition", params).tap do |job|
196
+ job.run if sync
197
+ end
198
+ end
199
+
200
+ ##
201
+ # @!method vioses(sys_uuid = nil, search = {}, permissive = true)
165
202
  # Retrieve the list of virtual I/O servers managed by the HMC.
166
203
  # @param sys_uuid [String] The UUID of the managed system.
167
204
  # @param search [Hash] The optional property name and value to match.
205
+ # @param permissive [Boolean] Skip virtual I/O servers that have error conditions.
168
206
  # @return [Array<IbmPowerHmc::VirtualIOServer>] The list of virtual I/O servers.
169
- def vioses(sys_uuid = nil, search = {})
207
+ def vioses(sys_uuid = nil, search = {}, permissive = true)
170
208
  if sys_uuid.nil?
171
209
  method_url = "/rest/api/uom/VirtualIOServer"
172
210
  search.each { |key, value| method_url += "/search/(#{key}==#{value})" }
173
211
  else
174
212
  method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualIOServer"
175
213
  end
214
+ method_url += "?ignoreError=true" if permissive
176
215
  response = request(:get, method_url)
177
216
  FeedParser.new(response.body).objects(:VirtualIOServer)
178
217
  end
@@ -312,6 +351,42 @@ module IbmPowerHmc
312
351
  end
313
352
  end
314
353
 
354
+ ##
355
+ # @!method vscsi_client_adapter(lpar_uuid, adap_uuid = nil)
356
+ # Retrieve one or all virtual SCSI storage client adapters attached to a logical partition.
357
+ # @param lpar_uuid [String] UUID of the logical partition.
358
+ # @param adap_uuid [String] UUID of the adapter to match (returns all adapters if omitted).
359
+ # @return [Array<IbmPowerHmc::VirtualSCSIClientAdapter>, IbmPowerHmc::VirtualSCSIClientAdapter] The list of storage adapters.
360
+ def vscsi_client_adapter(lpar_uuid, adap_uuid = nil)
361
+ if adap_uuid.nil?
362
+ method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualSCSIClientAdapter"
363
+ response = request(:get, method_url)
364
+ FeedParser.new(response.body).objects(:VirtualSCSIClientAdapter)
365
+ else
366
+ method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualSCSIClientAdapter/#{adap_uuid}"
367
+ response = request(:get, method_url)
368
+ Parser.new(response.body).object(:VirtualSCSIClientAdapter)
369
+ end
370
+ end
371
+
372
+ ##
373
+ # @!method vfc_client_adapter(lpar_uuid, adap_uuid = nil)
374
+ # Retrieve one or all virtual Fibre Channel storage client adapters attached to a logical partition.
375
+ # @param lpar_uuid [String] UUID of the logical partition.
376
+ # @param adap_uuid [String] UUID of the adapter to match (returns all adapters if omitted).
377
+ # @return [Array<IbmPowerHmc::VirtualFibreChannelClientAdapter>, IbmPowerHmc::VirtualFibreChannelClientAdapter] The list of storage adapters.
378
+ def vfc_client_adapter(lpar_uuid, adap_uuid = nil)
379
+ if adap_uuid.nil?
380
+ method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualFibreChannelClientAdapter"
381
+ response = request(:get, method_url)
382
+ FeedParser.new(response.body).objects(:VirtualFibreChannelClientAdapter)
383
+ else
384
+ method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualFibreChannelClientAdapter/#{adap_uuid}"
385
+ response = request(:get, method_url)
386
+ Parser.new(response.body).object(:VirtualFibreChannelClientAdapter)
387
+ end
388
+ end
389
+
315
390
  ##
316
391
  # @!method clusters
317
392
  # Retrieve the list of clusters managed by the HMC.
@@ -386,21 +461,41 @@ module IbmPowerHmc
386
461
  end
387
462
 
388
463
  ##
389
- # @!method templates_summary
464
+ # @!method shared_processor_pool(sys_uuid, pool_uuid = nil)
465
+ # Retrieve information about Shared Processor Pools.
466
+ # @param sys_uuid [String] The UUID of the managed system.
467
+ # @param pool_uuid [String] The UUID of the shared storage pool (return all pools if omitted)
468
+ # @return [Array<IbmPowerHmc::SharedProcessorPool>, IbmPowerHmc::SharedProcessorPool] The list of shared processor pools.
469
+ def shared_processor_pool(sys_uuid, pool_uuid = nil)
470
+ if pool_uuid.nil?
471
+ method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedProcessorPool"
472
+ response = request(:get, method_url)
473
+ FeedParser.new(response.body).objects(:SharedProcessorPool)
474
+ else
475
+ method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/SharedProcessorPool/#{pool_uuid}"
476
+ response = request(:get, method_url)
477
+ Parser.new(response.body).object(:SharedProcessorPool)
478
+ end
479
+ end
480
+
481
+ ##
482
+ # @!method templates_summary(draft = false)
390
483
  # Retrieve the list of partition template summaries.
484
+ # @param draft [Boolean] Retrieve draft templates as well
391
485
  # @return [Array<IbmPowerHmc::PartitionTemplateSummary>] The list of partition template summaries.
392
- def templates_summary
393
- method_url = "/rest/api/templates/PartitionTemplate"
486
+ def templates_summary(draft = false)
487
+ method_url = "/rest/api/templates/PartitionTemplate#{'?draft=false' unless draft}"
394
488
  response = request(:get, method_url)
395
489
  FeedParser.new(response.body).objects(:PartitionTemplateSummary)
396
490
  end
397
491
 
398
492
  ##
399
- # @!method templates
493
+ # @!method templates(draft = false)
400
494
  # Retrieve the list of partition templates.
495
+ # @param draft [Boolean] Retrieve draft templates as well
401
496
  # @return [Array<IbmPowerHmc::PartitionTemplate>] The list of partition templates.
402
- def templates
403
- method_url = "/rest/api/templates/PartitionTemplate?detail=full"
497
+ def templates(draft = false)
498
+ method_url = "/rest/api/templates/PartitionTemplate?detail=full#{'&draft=false' unless draft}"
404
499
  response = request(:get, method_url)
405
500
  FeedParser.new(response.body).objects(:PartitionTemplate)
406
501
  end
@@ -439,6 +534,109 @@ module IbmPowerHmc
439
534
  job
440
535
  end
441
536
 
537
+ ##
538
+ # @!method template_check(template_uuid, target_sys_uuid, sync = true)
539
+ # Start Template Check job (first of three steps to deploy an LPAR from a Template).
540
+ # @param template_uuid [String] The UUID of the Template to deploy an LPAR from.
541
+ # @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
542
+ # @param sync [Boolean] Start the job and wait for its completion.
543
+ # @return [IbmPowerHmc::HmcJob] The HMC job.
544
+ def template_check(template_uuid, target_sys_uuid, sync = true)
545
+ # Need to include session token in payload so make sure we are logged in
546
+ logon if @api_session_token.nil?
547
+ method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}/do/check"
548
+ params = {
549
+ "TargetUuid" => target_sys_uuid,
550
+ "K_X_API_SESSION_MEMENTO" => @api_session_token
551
+ }
552
+ job = HmcJob.new(self, method_url, "Check", "PartitionTemplate", params)
553
+ job.run if sync
554
+ job
555
+ end
556
+
557
+ ##
558
+ # @!method template_transform(draft_template_uuid, target_sys_uuid, sync = true)
559
+ # Start Template Transform job (second of three steps to deploy an LPAR from a Template).
560
+ # @param draft_template_uuid [String] The UUID of the Draft Template created by the Template Check job.
561
+ # @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
562
+ # @param sync [Boolean] Start the job and wait for its completion.
563
+ # @return [IbmPowerHmc::HmcJob] The HMC job.
564
+ def template_transform(draft_template_uuid, target_sys_uuid, sync = true)
565
+ # Need to include session token in payload so make sure we are logged in
566
+ logon if @api_session_token.nil?
567
+ method_url = "/rest/api/templates/PartitionTemplate/#{draft_template_uuid}/do/transform"
568
+ params = {
569
+ "TargetUuid" => target_sys_uuid,
570
+ "K_X_API_SESSION_MEMENTO" => @api_session_token
571
+ }
572
+ job = HmcJob.new(self, method_url, "Transform", "PartitionTemplate", params)
573
+ job.run if sync
574
+ job
575
+ end
576
+
577
+ ##
578
+ # @!method template_deploy(draft_template_uuid, target_sys_uuid, sync = true)
579
+ # Start Template Deploy job (last of three steps to deploy an LPAR from a Template).
580
+ # @param draft_template_uuid [String] The UUID of the Draft Template created by the Template Check job.
581
+ # @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
582
+ # @param sync [Boolean] Start the job and wait for its completion.
583
+ # @return [IbmPowerHmc::HmcJob] The HMC job.
584
+ def template_deploy(draft_template_uuid, target_sys_uuid, sync = true)
585
+ # Need to include session token in payload so make sure we are logged in
586
+ logon if @api_session_token.nil?
587
+ method_url = "/rest/api/templates/PartitionTemplate/#{draft_template_uuid}/do/deploy"
588
+ params = {
589
+ "TargetUuid" => target_sys_uuid,
590
+ "TemplateUuid" => draft_template_uuid,
591
+ "K_X_API_SESSION_MEMENTO" => @api_session_token
592
+ }
593
+ job = HmcJob.new(self, method_url, "Deploy", "PartitionTemplate", params)
594
+ job.run if sync
595
+ job
596
+ end
597
+
598
+ ##
599
+ # @!method template_provision(template_uuid, target_sys_uuid, changes)
600
+ # Deploy Logical Partition from a Template (performs Check, Transform and Deploy steps in a single method).
601
+ # @param template_uuid [String] The UUID of the Template to deploy an LPAR from.
602
+ # @param target_sys_uuid [String] The UUID of the Managed System to deploy the LPAR on.
603
+ # @param changes [Hash] Modifications to apply to the Template before deploying Logical Partition.
604
+ # @return [String] The UUID of the deployed Logical Partition.
605
+ def template_provision(template_uuid, target_sys_uuid, changes)
606
+ draft_uuid = template_check(template_uuid, target_sys_uuid).results["TEMPLATE_UUID"]
607
+ template_transform(draft_uuid, target_sys_uuid)
608
+ template_modify(draft_uuid, changes)
609
+ template_deploy(draft_uuid, target_sys_uuid).results["PartitionUuid"]
610
+ end
611
+
612
+ ##
613
+ # @!method template(template_uuid, changes)
614
+ # modify_object_attributes wrapper for templates.
615
+ # @param template_uuid [String] UUID of the partition template to modify.
616
+ # @param changes [Hash] Hash of changes to make.
617
+ # @return [IbmPowerHmc::PartitionTemplate] The partition template.
618
+ def template_modify(template_uuid, changes)
619
+ method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}"
620
+ modify_object_attributes(method_url, changes)
621
+ end
622
+
623
+ ##
624
+ # @!method template_copy(template_uuid, new_name)
625
+ # Copy existing template to a new one.
626
+ # @param template_uuid [String] UUID of the partition template to copy.
627
+ # @param new_name [String] Name of the new template.
628
+ # @return [IbmPowerHmc::PartitionTemplate] The new partition template.
629
+ def template_copy(template_uuid, new_name)
630
+ method_url = "/rest/api/templates/PartitionTemplate"
631
+ headers = {
632
+ :content_type => "application/vnd.ibm.powervm.templates+xml;type=PartitionTemplate"
633
+ }
634
+ original = template(template_uuid)
635
+ original.name = new_name
636
+ response = request(:put, method_url, headers, original.xml.to_s)
637
+ Parser.new(response.body).object(:PartitionTemplate)
638
+ end
639
+
442
640
  ##
443
641
  # @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
444
642
  # Power on a logical partition.
@@ -622,13 +820,15 @@ module IbmPowerHmc
622
820
  @status = err.http_code
623
821
  @message = err.message
624
822
 
625
- # Try to parse body as an HttpErrorResponse
823
+ # Try to parse body as an HttpErrorResponse.
626
824
  unless err.response.nil?
627
- resp = Parser.new(err.response.body).object(:HttpErrorResponse) rescue nil
628
- unless resp.nil?
825
+ begin
826
+ resp = Parser.new(err.response.body).object(:HttpErrorResponse)
629
827
  @uri = resp.uri
630
828
  @reason = resp.reason
631
829
  @message = resp.message
830
+ rescue
831
+ # not an XML body
632
832
  end
633
833
  end
634
834
  end
@@ -661,9 +861,9 @@ module IbmPowerHmc
661
861
  :headers => headers
662
862
  )
663
863
  rescue RestClient::Exception => e
664
- # Do not retry on failed logon attempts
864
+ # Do not retry on failed logon attempts.
665
865
  if e.http_code == 401 && @api_session_token != "" && !reauth
666
- # Try to reauth
866
+ # Try to reauth.
667
867
  reauth = true
668
868
  logon
669
869
  retry
@@ -695,12 +895,26 @@ module IbmPowerHmc
695
895
  break
696
896
  rescue HttpError => e
697
897
  attempts -= 1
698
- # Will get 412 ("Precondition Failed") if ETag mismatches
898
+ # Will get 412 ("Precondition Failed") if ETag mismatches.
699
899
  raise if e.status != 412 || attempts == 0
700
900
  end
701
901
  end
702
902
  end
703
903
 
904
+ # @!method modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
905
+ # Modify an object at a specified URI.
906
+ # @param method_url [String] The URL of the object to modify.
907
+ # @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.
908
+ # @param headers [Hash] HTTP headers.
909
+ # @param attempts [Integer] Maximum number of retries.
910
+ def modify_object_attributes(method_url, changes, headers = {}, attempts = 5)
911
+ modify_object(method_url, headers, attempts) do |obj|
912
+ changes.each do |key, value|
913
+ obj.send("#{key}=", value)
914
+ end
915
+ end
916
+ end
917
+
704
918
  ##
705
919
  # @!method network_adapter(vm_type, lpar_uuid, netadap_uuid)
706
920
  # Retrieve one or all virtual ethernet network adapters attached to a Logical Partition or a Virtual I/O Server.
@@ -6,6 +6,17 @@ module IbmPowerHmc
6
6
  class HmcJob
7
7
  class JobNotStarted < StandardError; end
8
8
 
9
+ class JobFailed < StandardError
10
+ def initialize(job)
11
+ super
12
+ @job = job
13
+ end
14
+
15
+ def to_s
16
+ "id=\"#{@job.id}\" operation=\"#{@job.group}/#{@job.operation}\" status=\"#{@job.status}\" message=\"#{@job.message}\" exception_text=\"#{@job.results['ExceptionText']}\""
17
+ end
18
+ end
19
+
9
20
  ##
10
21
  # @!method initialize(conn, method_url, operation, group, params = {})
11
22
  # Construct a new HMC Job.
@@ -52,7 +63,7 @@ module IbmPowerHmc
52
63
  end
53
64
 
54
65
  # @return [Hash] The job results returned by the HMC.
55
- attr_reader :results
66
+ attr_reader :results, :last_status
56
67
 
57
68
  ##
58
69
  # @!method status
@@ -65,9 +76,9 @@ module IbmPowerHmc
65
76
  :content_type => "application/vnd.ibm.powervm.web+xml; type=JobRequest"
66
77
  }
67
78
  response = @conn.request(:get, @href, headers)
68
- jobresp = Parser.new(response.body).object(:JobResponse)
69
- @results = jobresp.results
70
- jobresp.status
79
+ @last_status = Parser.new(response.body).object(:JobResponse)
80
+ @results = @last_status.results
81
+ @last_status.status
71
82
  end
72
83
 
73
84
  ##
@@ -99,6 +110,7 @@ module IbmPowerHmc
99
110
  def run(timeout = 120, poll_interval = 0)
100
111
  start
101
112
  wait(timeout, poll_interval)
113
+ raise JobFailed.new(@last_status), "Job failed" unless @last_status.status.eql?("COMPLETED_OK")
102
114
  ensure
103
115
  delete if defined?(@href)
104
116
  end
@@ -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.
@@ -198,9 +223,15 @@ module IbmPowerHmc
198
223
  :build_level => "VersionInfo/BuildLevel",
199
224
  :version => "BaseVersion",
200
225
  :ssh_pubkey => "PublicSSHKeyValue",
201
- :uvmid => "UVMID"
226
+ :uvmid => "UVMID",
227
+ :tz => "CurrentTimezone",
228
+ :uptime => "ManagementConsoleUpTime"
202
229
  }.freeze
203
230
 
231
+ def time
232
+ Time.at(0, singleton("ManagementConsoleTime").to_i, :millisecond).utc
233
+ end
234
+
204
235
  def managed_systems_uuids
205
236
  uuids_from_links("ManagedSystems")
206
237
  end
@@ -327,13 +358,6 @@ module IbmPowerHmc
327
358
  def sriov_elp_uuids
328
359
  uuids_from_links("SRIOVEthernetLogicalPorts")
329
360
  end
330
-
331
- # Setters
332
-
333
- def name=(name)
334
- xml.elements[ATTRS[:name]].text = name
335
- @name = name
336
- end
337
361
  end
338
362
 
339
363
  # Logical Partition information
@@ -401,7 +425,7 @@ module IbmPowerHmc
401
425
  :location => "LocationCode",
402
426
  :description => "Description",
403
427
  :is_available => "AvailableForUsage",
404
- :capacity => "VolumeCapacity",
428
+ :capacity => "VolumeCapacity", # in MiB
405
429
  :name => "VolumeName",
406
430
  :is_fc => "IsFibreChannelBacked",
407
431
  :udid => "VolumeUniqueID"
@@ -413,7 +437,7 @@ module IbmPowerHmc
413
437
  ATTRS = {
414
438
  :name => "DiskName",
415
439
  :label => "DiskLabel",
416
- :capacity => "DiskCapacity", # In GiB
440
+ :capacity => "DiskCapacity", # in GiB
417
441
  :psize => "PartitionSize",
418
442
  :vg => "VolumeGroup",
419
443
  :udid => "UniqueDeviceID"
@@ -872,6 +896,22 @@ module IbmPowerHmc
872
896
  }.freeze
873
897
  end
874
898
 
899
+ # Shared Processor Pool
900
+ class SharedProcessorPool < AbstractRest
901
+ ATTRS = {
902
+ :name => "PoolName",
903
+ :available => "AvailableProcUnits",
904
+ :max => "MaximumProcessingUnits",
905
+ :reserved => "CurrentReservedProcessingUnits",
906
+ :pending_reserved => "PendingReservedProcessingUnits",
907
+ :pool_id => "PoolID"
908
+ }.freeze
909
+
910
+ def lpar_uuids
911
+ uuids_from_links("AssignedPartitions")
912
+ end
913
+ end
914
+
875
915
  class PartitionTemplateSummary < AbstractRest
876
916
  ATTRS = {
877
917
  :name => "partitionTemplateName"
@@ -882,6 +922,8 @@ module IbmPowerHmc
882
922
  ATTRS = {
883
923
  :name => "partitionTemplateName",
884
924
  :description => "description",
925
+ :lpar_name => "logicalPartitionConfig/partitionName",
926
+ :lpar_id => "logicalPartitionConfig/partitionId",
885
927
  :os => "logicalPartitionConfig/osVersion",
886
928
  :memory => "logicalPartitionConfig/memoryConfiguration/currMemory",
887
929
  :dedicated => "logicalPartitionConfig/processorConfiguration/hasDedicatedProcessors",
@@ -890,6 +932,87 @@ module IbmPowerHmc
890
932
  :proc_units => "logicalPartitionConfig/processorConfiguration/sharedProcessorConfiguration/desiredProcessingUnits",
891
933
  :procs => "logicalPartitionConfig/processorConfiguration/dedicatedProcessorConfiguration/desiredProcessors"
892
934
  }.freeze
935
+
936
+ def vscsi
937
+ REXML::XPath.match(xml, 'logicalPartitionConfig/virtualSCSIClientAdapters/VirtualSCSIClientAdapter').map do |adap|
938
+ {
939
+ :vios => adap.elements['connectingPartitionName']&.text,
940
+ :physvol => adap.elements['associatedPhysicalVolume/PhysicalVolume/name']&.text,
941
+ }
942
+ end
943
+ end
944
+
945
+ def vscsi=(list = [])
946
+ adaps = REXML::Element.new('virtualSCSIClientAdapters')
947
+ adaps.add_attribute('schemaVersion', 'V1_5_0')
948
+ list.each do |vscsi|
949
+ adaps.add_element('VirtualSCSIClientAdapter', {'schemaVersion' => 'V1_5_0'}).tap do |v|
950
+ v.add_element('associatedLogicalUnits', {'schemaVersion' => 'V1_5_0'})
951
+ v.add_element('associatedPhysicalVolume', {'schemaVersion' => 'V1_5_0'}).tap do |e|
952
+ e.add_element('PhysicalVolume', {'schemaVersion' => 'V1_5_0'}).add_element('name').text = vscsi[:physvol] if vscsi[:physvol]
953
+ end
954
+ v.add_element('connectingPartitionName').text = vscsi[:vios]
955
+ v.add_element('AssociatedTargetDevices', {'schemaVersion' => 'V1_5_0'})
956
+ v.add_element('associatedVirtualOpticalMedia', {'schemaVersion' => 'V1_5_0'})
957
+ end
958
+ end
959
+ if xml.elements['logicalPartitionConfig/virtualSCSIClientAdapters']
960
+ xml.elements['logicalPartitionConfig/virtualSCSIClientAdapters'] = adaps
961
+ else
962
+ xml.elements['logicalPartitionConfig'].add_element(adaps)
963
+ end
964
+ end
965
+
966
+ def vfc
967
+ REXML::XPath.match(xml, 'logicalPartitionConfig/virtualFibreChannelClientAdapters/VirtualFibreChannelClientAdapter').map do |adap|
968
+ {
969
+ :vios => adap.elements['connectingPartitionName']&.text,
970
+ :port => adap.elements['portName']&.text
971
+ }
972
+ end
973
+ end
974
+
975
+ def vfc=(list = [])
976
+ adaps = REXML::Element.new('virtualFibreChannelClientAdapters')
977
+ adaps.add_attribute('schemaVersion', 'V1_5_0')
978
+ list.each do |vfc|
979
+ adaps.add_element('VirtualFibreChannelClientAdapter', {'schemaVersion' => 'V1_5_0'}).tap do |v|
980
+ v.add_element('connectingPartitionName').text = vfc[:vios]
981
+ v.add_element('portName').text = vfc[:port]
982
+ end
983
+ end
984
+ if xml.elements['logicalPartitionConfig/virtualFibreChannelClientAdapters']
985
+ xml.elements['logicalPartitionConfig/virtualFibreChannelClientAdapters'] = adaps
986
+ else
987
+ xml.elements['logicalPartitionConfig'].add_element(adaps)
988
+ end
989
+ end
990
+
991
+ def vlans
992
+ REXML::XPath.match(xml, 'logicalPartitionConfig/clientNetworkAdapters/ClientNetworkAdapter/clientVirtualNetworks/ClientVirtualNetwork').map do |vlan|
993
+ {
994
+ :name => vlan.elements['name']&.text,
995
+ :vlan_id => vlan.elements['vlanId']&.text,
996
+ :switch => vlan.elements['associatedSwitchName']&.text
997
+ }
998
+ end
999
+ end
1000
+
1001
+ def vlans=(list = [])
1002
+ adaps = REXML::Element.new('clientNetworkAdapters')
1003
+ adaps.add_attribute('schemaVersion', 'V1_5_0')
1004
+ list.each do |vlan|
1005
+ adaps.add_element('ClientNetworkAdapter', {'schemaVersion' => 'V1_5_0'})
1006
+ .add_element('clientVirtualNetworks', {'schemaVersion' => 'V1_5_0'})
1007
+ .add_element('ClientVirtualNetwork', {'schemaVersion' => 'V1_5_0'})
1008
+ .tap do |v|
1009
+ v.add_element('name').text = vlan[:name]
1010
+ v.add_element('vlanId').text = vlan[:vlan_id]
1011
+ v.add_element('associatedSwitchName').text = vlan[:switch]
1012
+ end
1013
+ end
1014
+ xml.elements['logicalPartitionConfig/clientNetworkAdapters'] = adaps
1015
+ end
893
1016
  end
894
1017
 
895
1018
  # HMC Event
@@ -917,9 +1040,11 @@ module IbmPowerHmc
917
1040
  # Job Response
918
1041
  class JobResponse < AbstractRest
919
1042
  ATTRS = {
920
- :id => "JobID",
921
- :status => "Status",
922
- :message => "ResponseException/Message"
1043
+ :id => "JobID",
1044
+ :status => "Status",
1045
+ :operation => "JobRequestInstance/RequestedOperation/OperationName",
1046
+ :group => "JobRequestInstance/RequestedOperation/GroupName",
1047
+ :message => "ResponseException/Message"
923
1048
  }.freeze
924
1049
 
925
1050
  def results
@@ -933,6 +1058,7 @@ module IbmPowerHmc
933
1058
  end
934
1059
  end
935
1060
 
1061
+ # Performance and Capacity Monitoring preferences
936
1062
  class ManagementConsolePcmPreference < AbstractRest
937
1063
  ATTRS = {
938
1064
  :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.10.0"
4
+ VERSION = "0.13.0"
5
5
  end
data/lib/ibm_power_hmc.rb CHANGED
File without changes
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.10.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - IBM Power
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  description: A Ruby gem for interacting with the IBM Hardware Management Console (HMC).
42
- email:
42
+ email:
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
@@ -69,7 +69,7 @@ metadata:
69
69
  homepage_uri: http://github.com/IBM/ibm_power_hmc_sdk_ruby
70
70
  source_code_uri: http://github.com/IBM/ibm_power_hmc_sdk_ruby
71
71
  changelog_uri: http://github.com/IBM/ibm_power_hmc_sdk_ruby/blob/master/CHANGELOG.md
72
- post_install_message:
72
+ post_install_message:
73
73
  rdoc_options: []
74
74
  require_paths:
75
75
  - lib
@@ -84,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.1.2
88
- signing_key:
87
+ rubygems_version: 3.1.4
88
+ signing_key:
89
89
  specification_version: 4
90
90
  summary: IBM Power HMC Ruby gem.
91
91
  test_files: []