ibm_power_hmc 0.6.0 → 0.7.0

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: 288ed57579492fd505491fe8e56f9dbd371cb6aaae118f98c14202fd20e8bf85
4
- data.tar.gz: b21286ee62bfa69e14d609ad001b72f012ccbe3fdebc59f090320d03877e6d20
3
+ metadata.gz: 128d1d4297c8885e438de247ccf25a143c856a3cdff5e2894f49c0541b475a6e
4
+ data.tar.gz: ee5304a78bf10231755750641b3ea5fc11064bea52753db4c8c42456461bbd3f
5
5
  SHA512:
6
- metadata.gz: 7d5010709dd4a423ca131c99d3891ef78c4de8a479e87afe402eb554db660f03f2d85b24728d22773ff1681263f4346ff303e08078c4e9b91519e5ad6398a40a
7
- data.tar.gz: fd6e00f6bb1039b0320d7fb7959f6a3a2206047fe6ebcb1cc795a6f0f37e92e8740cbe8d980d4fa496bfa6c00d3de6efeafba6f4136b7974630b5d187e4bbc7d
6
+ metadata.gz: 7924966345897965a3789b26ef307ae3df5e5dccbdf316e0d59ed665d57a2ceaaf51128f225cd08a2544b6c77d54ae634b5f75d25bfa766c3672480f01fc72da
7
+ data.tar.gz: '078600454867693aaf410ca0a898eb5464f24b4dd40db56c61caa5145fbc54685f0819f576862f6065649f4a2d46dab2d5f838938b207fc376e563cfc724c56f'
data/README.md CHANGED
@@ -52,9 +52,9 @@ Listing the logical partitions and virtual I/O servers of each managed system:
52
52
 
53
53
  ```ruby
54
54
  hc.managed_systems.each do |sys|
55
- puts sys
56
- puts hc.lpars(sys.uuid)
57
- puts hc.vioses(sys.uuid)
55
+ puts sys.name
56
+ hc.lpars(sys.uuid).each { |lpar| puts lpar.name }
57
+ hc.vioses(sys.uuid).each { |vios| puts vios.name }
58
58
  end
59
59
  ```
60
60
 
@@ -73,9 +73,9 @@ hc.poweroff_lpar(lpar_uuid, { "operation" => "shutdown" })
73
73
  Processing events:
74
74
 
75
75
  ```ruby
76
- loop
76
+ loop do
77
77
  hc.next_events.each do |event|
78
- puts event
78
+ puts event.type
79
79
  end
80
80
  end
81
81
  ```
@@ -266,18 +266,18 @@ module IbmPowerHmc
266
266
  # @!method sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil)
267
267
  # Retrieve one or all SR-IOV ethernet logical ports attached to a logical partition.
268
268
  # @param lpar_uuid [String] UUID of the logical partition.
269
- # @param netadap_uuid [String] UUID of the port to match (returns all ports if omitted).
270
- # @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of ports.
269
+ # @param sriov_elp_uuid [String] UUID of the port to match (returns all ports if omitted).
270
+ # @return [Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort] The list of ports.
271
271
  def sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil)
272
272
  sriov_ethernet_port("LogicalPartition", lpar_uuid, sriov_elp_uuid)
273
273
  end
274
274
 
275
275
  ##
276
- # @!method network_adapter_vios(vios_uuid, netadap_uuid = nil)
276
+ # @!method network_adapter_vios(vios_uuid, sriov_elp_uuid = nil)
277
277
  # Retrieve one or all SR-IOV ethernet logical ports attached to a Virtual I/O Server.
278
278
  # @param vios_uuid [String] UUID of the Virtual I/O Server.
279
- # @param netadap_uuid [String] UUID of the port to match (returns all ports if omitted).
280
- # @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of ports.
279
+ # @param sriov_elp_uuid [String] UUID of the port to match (returns all ports if omitted).
280
+ # @return [Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort] The list of ports.
281
281
  def sriov_elp_vios(vios_uuid, sriov_elp_uuid = nil)
282
282
  sriov_ethernet_port("VirtualIOServer", vios_uuid, sriov_elp_uuid)
283
283
  end
@@ -286,8 +286,8 @@ module IbmPowerHmc
286
286
  # @!method vnic_dedicated(lpar_uuid, vnic_uuid = nil)
287
287
  # Retrieve one or all dedicated virtual network interface controller (vNIC) attached to a logical partition.
288
288
  # @param lpar_uuid [String] UUID of the logical partition.
289
- # @param netadap_uuid [String] UUID of the vNIC to match (returns all vNICs if omitted).
290
- # @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of vNICs.
289
+ # @param vnic_uuid [String] UUID of the vNIC to match (returns all vNICs if omitted).
290
+ # @return [Array<IbmPowerHmc::VirtualNICDedicated>, IbmPowerHmc::VirtualNICDedicated] The list of vNICs.
291
291
  def vnic_dedicated(lpar_uuid, vnic_uuid = nil)
292
292
  if vnic_uuid.nil?
293
293
  method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualNICDedicated"
@@ -300,6 +300,123 @@ module IbmPowerHmc
300
300
  end
301
301
  end
302
302
 
303
+ ##
304
+ # @!method clusters
305
+ # Retrieve the list of clusters managed by the HMC.
306
+ # @return [Array<IbmPowerHmc::Cluster>] The list of clusters.
307
+ def clusters
308
+ method_url = "/rest/api/uom/Cluster"
309
+ response = request(:get, method_url)
310
+ FeedParser.new(response.body).objects(:Cluster)
311
+ end
312
+
313
+ ##
314
+ # @!method cluster(cl_uuid)
315
+ # Retrieve information about a cluster.
316
+ # @param cl_uuid [String] The UUID of the cluster.
317
+ # @return [IbmPowerHmc::Cluster] The cluster.
318
+ def cluster(cl_uuid)
319
+ method_url = "/rest/api/uom/Cluster/#{cl_uuid}"
320
+ response = request(:get, method_url)
321
+ Parser.new(response.body).object(:Cluster)
322
+ end
323
+
324
+ ##
325
+ # @!method ssps
326
+ # Retrieve the list of shared storage pools managed by the HMC.
327
+ # @return [Array<IbmPowerHmc::SharedStoragePool>] The list of shared storage pools.
328
+ def ssps
329
+ method_url = "/rest/api/uom/SharedStoragePool"
330
+ response = request(:get, method_url)
331
+ FeedParser.new(response.body).objects(:SharedStoragePool)
332
+ end
333
+
334
+ ##
335
+ # @!method ssp(ssp_uuid)
336
+ # Retrieve information about a shared storage pool.
337
+ # @param ssp_uuid [String] The UUID of the shared storage pool.
338
+ # @return [IbmPowerHmc::SharedStoragePool] The shared storage pool.
339
+ def ssp(ssp_uuid)
340
+ method_url = "/rest/api/uom/SharedStoragePool/#{ssp_uuid}"
341
+ response = request(:get, method_url)
342
+ Parser.new(response.body).object(:SharedStoragePool)
343
+ end
344
+
345
+ ##
346
+ # @!method tiers(group_name = nil)
347
+ # Retrieve the list of tiers that are part of shared storage pools managed by the HMC.
348
+ # @param group_name [String] The extended group attributes.
349
+ # @return [Array<IbmPowerHmc::Tier>] The list of tiers.
350
+ def tiers(group_name = nil)
351
+ method_url = "/rest/api/uom/Tier"
352
+ method_url += "?group=#{group_name}" unless group_name.nil?
353
+ response = request(:get, method_url)
354
+ FeedParser.new(response.body).objects(:Tier)
355
+ end
356
+
357
+ ##
358
+ # @!method tier(tier_uuid, ssp_uuid = nil, group_name = nil)
359
+ # Retrieve information about a tier.
360
+ # @param tier_uuid [String] The UUID of the tier.
361
+ # @param ssp_uuid [String] The UUID of the shared storage pool.
362
+ # @param group_name [String] The extended group attributes.
363
+ # @return [IbmPowerHmc::Tier] The tier.
364
+ def tier(tier_uuid, ssp_uuid = nil, group_name = nil)
365
+ if ssp_uuid.nil?
366
+ method_url = "/rest/api/uom/Tier/#{tier_uuid}"
367
+ else
368
+ method_url = "/rest/api/uom/SharedStoragePool/#{ssp_uuid}/Tier/#{tier_uuid}"
369
+ end
370
+ method_url += "?group=#{group_name}" unless group_name.nil?
371
+
372
+ response = request(:get, method_url)
373
+ Parser.new(response.body).object(:Tier)
374
+ end
375
+
376
+ ##
377
+ # @!method templates_summary
378
+ # Retrieve the list of partition template summaries.
379
+ # @return [Array<IbmPowerHmc::PartitionTemplateSummary>] The list of partition template summaries.
380
+ def templates_summary
381
+ method_url = "/rest/api/templates/PartitionTemplate"
382
+ response = request(:get, method_url)
383
+ FeedParser.new(response.body).objects(:PartitionTemplateSummary)
384
+ end
385
+
386
+ ##
387
+ # @!method template(template_uuid)
388
+ # Retrieve details for a particular partition template.
389
+ # @param template_uuid [String] UUID of the partition template.
390
+ # @return [IbmPowerHmc::PartitionTemplate] The partition template.
391
+ def template(template_uuid)
392
+ method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}"
393
+ response = request(:get, method_url)
394
+ Parser.new(response.body).object(:PartitionTemplate)
395
+ end
396
+
397
+ ##
398
+ # @!method capture_lpar(lpar_uuid, sys_uuid, template_name, sync = true)
399
+ # Capture partition configuration as template.
400
+ # @param lpar_uuid [String] The UUID of the logical partition.
401
+ # @param sys_uuid [String] The UUID of the managed system.
402
+ # @param template_name [String] The name to be given for the new template.
403
+ # @param sync [Boolean] Start the job and wait for its completion.
404
+ # @return [IbmPowerHmc::HmcJob] The HMC job.
405
+ def capture_lpar(lpar_uuid, sys_uuid, template_name, sync = true)
406
+ # Need to include session token in payload so make sure we are logged in
407
+ logon if @api_session_token.nil?
408
+ method_url = "/rest/api/templates/PartitionTemplate/do/capture"
409
+ params = {
410
+ "TargetUuid" => lpar_uuid,
411
+ "NewTemplateName" => template_name,
412
+ "ManagedSystemUuid" => sys_uuid,
413
+ "K_X_API_SESSION_MEMENTO" => @api_session_token
414
+ }
415
+ job = HmcJob.new(self, method_url, "Capture", "PartitionTemplate", params)
416
+ job.run if sync
417
+ job
418
+ end
419
+
303
420
  ##
304
421
  # @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
305
422
  # Power on a logical partition.
@@ -432,7 +549,24 @@ module IbmPowerHmc
432
549
  # No need to sleep as the HMC already waits a bit before returning 204
433
550
  break if response.code != 204 || !wait
434
551
  end
435
- FeedParser.new(response.body).objects(:Event)
552
+ FeedParser.new(response.body).objects(:Event).map do |e|
553
+ data = e.data.split("/")
554
+ if data[-2].eql?("UserTask")
555
+ e.usertask = usertask(data.last)
556
+ end
557
+ e
558
+ end.compact
559
+ end
560
+
561
+ ##
562
+ # @!method usertask(uuid = true)
563
+ # Retrieve details of an event of type "user task".
564
+ # @param uuid [String] UUID of user task.
565
+ # @return [Hash] Hash of user task attributes.
566
+ def usertask(uuid)
567
+ method_url = "/rest/api/ui/UserTask/#{uuid}"
568
+ response = request(:get, method_url)
569
+ JSON.parse(response.body)
436
570
  end
437
571
 
438
572
  ##
@@ -562,8 +696,8 @@ module IbmPowerHmc
562
696
  # Retrieve one or all SR-IOV Ethernet loical ports attached to a Logical Partition or a Virtual I/O Server.
563
697
  # @param vm_type [String] "LogicalPartition" or "VirtualIOServer".
564
698
  # @param lpar_uuid [String] UUID of the Logical Partition or the Virtual I/O Server.
565
- # @param netadap_uuid [String] UUID of the port to match (returns all ports if nil).
566
- # @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of ports.
699
+ # @param sriov_elp_uuid [String] UUID of the port to match (returns all ports if nil).
700
+ # @return [Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort] The list of ports.
567
701
  def sriov_ethernet_port(vm_type, lpar_uuid, sriov_elp_uuid)
568
702
  if sriov_elp_uuid.nil?
569
703
  method_url = "/rest/api/uom/#{vm_type}/#{lpar_uuid}/SRIOVEthernetLogicalPort"
@@ -26,7 +26,7 @@ module IbmPowerHmc
26
26
  ##
27
27
  # @!method start
28
28
  # Start the job asynchronously.
29
- # @return [String] The ID of the job.
29
+ # @return [String] The URL of the job.
30
30
  def start
31
31
  headers = {
32
32
  :content_type => "application/vnd.ibm.powervm.web+xml; type=JobRequest"
@@ -47,7 +47,8 @@ module IbmPowerHmc
47
47
  end
48
48
  response = @conn.request(:put, @method_url, headers, doc.to_s)
49
49
  jobresp = Parser.new(response.body).object(:JobResponse)
50
- @id = jobresp.id
50
+ # Save the URL of the job (JobID is not sufficient as not all jobs are in uom).
51
+ @href = jobresp.href.path
51
52
  end
52
53
 
53
54
  # @return [Hash] The job results returned by the HMC.
@@ -58,13 +59,12 @@ module IbmPowerHmc
58
59
  # Return the status of the job.
59
60
  # @return [String] The status of the job.
60
61
  def status
61
- raise JobNotStarted unless defined?(@id)
62
+ raise JobNotStarted unless defined?(@href)
62
63
 
63
- method_url = "/rest/api/uom/jobs/#{@id}"
64
64
  headers = {
65
65
  :content_type => "application/vnd.ibm.powervm.web+xml; type=JobRequest"
66
66
  }
67
- response = @conn.request(:get, method_url, headers)
67
+ response = @conn.request(:get, @href, headers)
68
68
  jobresp = Parser.new(response.body).object(:JobResponse)
69
69
  @results = jobresp.results
70
70
  jobresp.status
@@ -100,17 +100,16 @@ module IbmPowerHmc
100
100
  start
101
101
  wait(timeout, poll_interval)
102
102
  ensure
103
- delete if defined?(@id)
103
+ delete if defined?(@href)
104
104
  end
105
105
 
106
106
  ##
107
107
  # @!method delete
108
108
  # Delete the job from the HMC.
109
109
  def delete
110
- raise JobNotStarted unless defined?(@id)
110
+ raise JobNotStarted unless defined?(@href)
111
111
 
112
- method_url = "/rest/api/uom/jobs/#{@id}"
113
- @conn.request(:delete, method_url)
112
+ @conn.request(:delete, @href)
114
113
  # Returns HTTP 204 if ok
115
114
  end
116
115
  end
@@ -116,13 +116,23 @@ module IbmPowerHmc
116
116
  attr.nil? ? elem.text&.strip : elem.attributes[attr]
117
117
  end
118
118
 
119
- def extract_uuid_from_href(href, index = -1)
119
+ def to_s
120
+ str = +"#{self.class.name}:\n"
121
+ self.class::ATTRS.each do |varname, _|
122
+ value = instance_variable_get("@#{varname}")
123
+ value = value.nil? ? "null" : "'#{value}'"
124
+ str << " #{varname}: #{value}\n"
125
+ end
126
+ str
127
+ end
128
+
129
+ def uuid_from_href(href, index = -1)
120
130
  URI(href).path.split('/')[index]
121
131
  end
122
132
 
123
133
  def uuids_from_links(elem, index = -1)
124
134
  xml.get_elements("#{elem}/link[@href]").map do |link|
125
- extract_uuid_from_href(link.attributes["href"], index)
135
+ uuid_from_href(link.attributes["href"], index)
126
136
  end.compact
127
137
  end
128
138
  end
@@ -151,6 +161,12 @@ module IbmPowerHmc
151
161
  attr_reader :uuid, :published, :href, :etag, :content_type
152
162
 
153
163
  def initialize(entry)
164
+ if entry.name != "entry"
165
+ # We are inlined.
166
+ super(entry)
167
+ return
168
+ end
169
+
154
170
  @uuid = entry.elements["id"]&.text
155
171
  @published = Time.xmlschema(entry.elements["published"]&.text)
156
172
  link = entry.elements["link[@rel='SELF']"]
@@ -160,6 +176,13 @@ module IbmPowerHmc
160
176
  @content_type = content.attributes["type"]
161
177
  super(content.elements.first)
162
178
  end
179
+
180
+ def to_s
181
+ str = super
182
+ str << " uuid: '#{uuid}'\n" if defined?(@uuid)
183
+ str << " published: '#{published}'\n" if defined?(@published)
184
+ str
185
+ end
163
186
  end
164
187
 
165
188
  # HMC information
@@ -189,9 +212,17 @@ module IbmPowerHmc
189
212
  :avail_cpus => "AssociatedSystemProcessorConfiguration/CurrentAvailableSystemProcessorUnits",
190
213
  :mtype => "MachineTypeModelAndSerialNumber/MachineType",
191
214
  :model => "MachineTypeModelAndSerialNumber/Model",
192
- :serial => "MachineTypeModelAndSerialNumber/SerialNumber"
215
+ :serial => "MachineTypeModelAndSerialNumber/SerialNumber",
216
+ :vtpm_version => "AssociatedSystemSecurity/VirtualTrustedPlatformModuleVersion",
217
+ :vtpm_lpars => "AssociatedSystemSecurity/AvailableVirtualTrustedPlatformModulePartitions"
193
218
  }.freeze
194
219
 
220
+ def cpu_compat_modes
221
+ xml.get_elements("AssociatedSystemProcessorConfiguration/SupportedPartitionProcessorCompatibilityModes").map do |elem|
222
+ elem.text&.strip
223
+ end.compact
224
+ end
225
+
195
226
  def lpars_uuids
196
227
  uuids_from_links("AssociatedLogicalPartitions")
197
228
  end
@@ -200,6 +231,12 @@ module IbmPowerHmc
200
231
  uuids_from_links("AssociatedVirtualIOServers")
201
232
  end
202
233
 
234
+ def io_adapters
235
+ xml.get_elements("AssociatedSystemIOConfiguration/IOSlots/IOSlot/RelatedIOAdapter/IOAdapter").map do |elem|
236
+ IOAdapter.new(elem)
237
+ end
238
+ end
239
+
203
240
  def vswitches_uuids
204
241
  uuids_from_links("AssociatedSystemIOConfiguration/AssociatedSystemVirtualNetwork/VirtualSwitches")
205
242
  end
@@ -209,6 +246,18 @@ module IbmPowerHmc
209
246
  end
210
247
  end
211
248
 
249
+ # I/O Adapter information
250
+ class IOAdapter < AbstractNonRest
251
+ ATTRS = {
252
+ :id => "AdapterID",
253
+ :description => "Description",
254
+ :name => "DeviceName",
255
+ :type => "DeviceType",
256
+ :dr_name => "DynamicReconfigurationConnectorName",
257
+ :udid => "UniqueDeviceID"
258
+ }.freeze
259
+ end
260
+
212
261
  # Common class for LPAR and VIOS
213
262
  class BasePartition < AbstractRest
214
263
  ATTRS = {
@@ -229,17 +278,25 @@ module IbmPowerHmc
229
278
 
230
279
  def sys_uuid
231
280
  sys_href = singleton("AssociatedManagedSystem", "href")
232
- extract_uuid_from_href(sys_href)
281
+ uuid_from_href(sys_href)
233
282
  end
234
283
 
235
284
  def net_adap_uuids
236
285
  uuids_from_links("ClientNetworkAdapters")
237
286
  end
238
287
 
288
+ def lhea_ports
289
+ xml.get_elements("HostEthernetAdapterLogicalPorts/HostEthernetAdapterLogicalPort").map do |elem|
290
+ HostEthernetAdapterLogicalPort.new(elem)
291
+ end
292
+ end
293
+
239
294
  def sriov_elp_uuids
240
295
  uuids_from_links("SRIOVEthernetLogicalPorts")
241
296
  end
242
297
 
298
+ # Setters
299
+
243
300
  def name=(name)
244
301
  xml.elements[ATTRS[:name]].text = name
245
302
  @name = name
@@ -251,17 +308,99 @@ module IbmPowerHmc
251
308
  def vnic_dedicated_uuids
252
309
  uuids_from_links("DedicatedVirtualNICs")
253
310
  end
311
+
312
+ def vscsi_client_uuids
313
+ uuids_from_links("VirtualSCSIClientAdapters")
314
+ end
315
+
316
+ def vfc_client_uuids
317
+ uuids_from_links("VirtualFibreChannelClientAdapters")
318
+ end
254
319
  end
255
320
 
256
321
  # VIOS information
257
322
  class VirtualIOServer < BasePartition
323
+ def pvs
324
+ xml.get_elements("PhysicalVolumes/PhysicalVolume").map do |elem|
325
+ PhysicalVolume.new(elem)
326
+ end
327
+ end
328
+
329
+ def rep
330
+ elem = xml.elements["MediaRepositories/VirtualMediaRepository"]
331
+ VirtualMediaRepository.new(elem) unless elem.nil?
332
+ end
333
+
334
+ def vscsi_mappings
335
+ xml.get_elements("VirtualSCSIMappings/VirtualSCSIMapping").map do |elem|
336
+ VirtualSCSIMapping.new(elem)
337
+ end
338
+ end
339
+
340
+ def vfc_mappings
341
+ xml.get_elements("VirtualFibreChannelMappings/VirtualFibreChannelMapping").map do |elem|
342
+ VirtualFibreChannelMapping.new(elem)
343
+ end
344
+ end
345
+ end
346
+
347
+ # Empty parent class to match K2 schema definition
348
+ class VirtualSCSIStorage < AbstractNonRest; end
349
+
350
+ # Physical Volume information
351
+ class PhysicalVolume < VirtualSCSIStorage
352
+ ATTRS = {
353
+ :location => "LocationCode",
354
+ :description => "Description",
355
+ :is_available => "AvailableForUsage",
356
+ :capacity => "VolumeCapacity",
357
+ :name => "VolumeName",
358
+ :is_fc => "IsFibreChannelBacked",
359
+ :udid => "VolumeUniqueID"
360
+ }.freeze
361
+ end
362
+
363
+ # Logical Volume information
364
+ class VirtualDisk < VirtualSCSIStorage
365
+ ATTRS = {
366
+ :name => "DiskName",
367
+ :label => "DiskLabel",
368
+ :capacity => "DiskCapacity", # In GiB
369
+ :psize => "PartitionSize",
370
+ :vg => "VolumeGroup",
371
+ :udid => "UniqueDeviceID"
372
+ }.freeze
373
+ end
374
+
375
+ # Virtual CD-ROM information
376
+ class VirtualOpticalMedia < VirtualSCSIStorage
377
+ ATTRS = {
378
+ :name => "MediaName",
379
+ :udid => "MediaUDID",
380
+ :mount_opts => "MountType",
381
+ :size => "Size" # in GiB
382
+ }.freeze
383
+ end
384
+
385
+ # Virtual Media Repository information
386
+ class VirtualMediaRepository < AbstractNonRest
387
+ ATTRS = {
388
+ :name => "RepositoryName",
389
+ :size => "RepositorySize" # in GiB
390
+ }.freeze
391
+
392
+ def vopts
393
+ xml.get_elements("OpticalMedia/VirtualOpticalMedia").map do |elem|
394
+ VirtualOpticalMedia.new(elem)
395
+ end
396
+ end
258
397
  end
259
398
 
260
399
  # Virtual Switch information
261
400
  class VirtualSwitch < AbstractRest
262
401
  ATTRS = {
263
402
  :id => "SwitchID",
264
- :mode => "SwitchMode",
403
+ :mode => "SwitchMode", # "VEB", "VEPA"
265
404
  :name => "SwitchName"
266
405
  }.freeze
267
406
 
@@ -285,7 +424,7 @@ module IbmPowerHmc
285
424
 
286
425
  def vswitch_uuid
287
426
  href = singleton("AssociatedSwitch", "href")
288
- extract_uuid_from_href(href)
427
+ uuid_from_href(href)
289
428
  end
290
429
 
291
430
  def lpars_uuids
@@ -324,23 +463,369 @@ module IbmPowerHmc
324
463
  end
325
464
  end
326
465
 
327
- class SRIOVEthernetLogicalPort < AbstractRest
328
- ATTRS = {
466
+ # LP-HEA information
467
+ class EthernetBackingDevice < IOAdapter; end
468
+ class HostEthernetAdapterLogicalPort < EthernetBackingDevice
469
+ ATTRS = ATTRS.merge({
329
470
  :macaddr => "MACAddress",
330
- :location => "LocationCode"
471
+ :port_id => "LogicalPortID",
472
+ :state => "PortState",
473
+ :location => "HEALogicalPortPhysicalLocation"
474
+ }.freeze)
475
+ end
476
+
477
+ # Virtual NIC dedicated information
478
+ class VirtualNICDedicated < VirtualIOAdapter
479
+ ATTRS = ATTRS.merge({
480
+ :location => "DynamicReconfigurationConnectorName", # overrides VirtualIOAdapter
481
+ :macaddr => "Details/MACAddress",
482
+ :os_devname => "Details/OSDeviceName",
483
+ :port_vlan_id => "Details/PortVLANID"
484
+ }.freeze)
485
+ end
486
+
487
+ # SR-IOV Configured Logical Port information
488
+ class SRIOVConfiguredLogicalPort < AbstractRest
489
+ ATTRS = {
490
+ :port_id => "LogicalPortID",
491
+ :port_vlan_id => "PortVLANID",
492
+ :location => "LocationCode",
493
+ :dr_name => "DynamicReconfigurationConnectorName",
494
+ :devname => "DeviceName",
495
+ :capacity => "ConfiguredCapacity"
496
+ }.freeze
497
+
498
+ def lpars_uuids
499
+ uuids_from_links("AssociatedLogicalPartitions")
500
+ end
501
+ end
502
+
503
+ # SR-IOV Ethernet Logical Port information
504
+ class SRIOVEthernetLogicalPort < SRIOVConfiguredLogicalPort
505
+ ATTRS = ATTRS.merge({
506
+ :macaddr => "MACAddress"
507
+ }.freeze)
508
+ end
509
+
510
+ # Virtual SCSI mapping information
511
+ class VirtualSCSIMapping < AbstractNonRest
512
+ def lpar_uuid
513
+ href = singleton("AssociatedLogicalPartition", "href")
514
+ uuid_from_href(href)
515
+ end
516
+
517
+ def client
518
+ elem = xml.elements["ClientAdapter"]
519
+ VirtualSCSIClientAdapter.new(elem) unless elem.nil?
520
+ end
521
+
522
+ def server
523
+ elem = xml.elements["ServerAdapter"]
524
+ VirtualSCSIServerAdapter.new(elem) unless elem.nil?
525
+ end
526
+
527
+ def storage
528
+ # Possible storage types are:
529
+ # LogicalUnit, PhysicalVolume, VirtualDisk, VirtualOpticalMedia
530
+ elem = xml.elements["Storage/*[1]"]
531
+ Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
532
+ end
533
+
534
+ def device
535
+ # Possible backing device types are:
536
+ # LogicalVolumeVirtualTargetDevice, PhysicalVolumeVirtualTargetDevice,
537
+ # SharedStoragePoolLogicalUnitVirtualTargetDevice, VirtualOpticalTargetDevice
538
+ elem = xml.elements["TargetDevice/*[1]"]
539
+ Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
540
+ end
541
+ end
542
+
543
+ # Virtual SCSI adapter (common class for Client and Server)
544
+ class VirtualSCSIAdapter < VirtualIOAdapter
545
+ ATTRS = ATTRS.merge({
546
+ :name => "AdapterName",
547
+ :backdev => "BackingDeviceName",
548
+ :remote_backdev => "RemoteBackingDeviceName",
549
+ :remote_lpar_id => "RemoteLogicalPartitionID",
550
+ :remote_slot => "RemoteSlotNumber",
551
+ :server_location => "ServerLocationCode",
552
+ :udid => "UniqueDeviceID"
553
+ }.freeze)
554
+ end
555
+
556
+ # Virtual SCSI client adapter information
557
+ class VirtualSCSIClientAdapter < VirtualSCSIAdapter
558
+ def server
559
+ elem = xml.elements["ServerAdapter"]
560
+ VirtualSCSIServerAdapter.new(elem) unless elem.nil?
561
+ end
562
+
563
+ def vios_uuid
564
+ href = singleton("ConnectingPartition", "href")
565
+ uuid_from_href(href)
566
+ end
567
+ end
568
+
569
+ # Virtual SCSI server adapter information
570
+ class VirtualSCSIServerAdapter < VirtualSCSIAdapter; end
571
+
572
+ # Virtual target device information
573
+ class VirtualTargetDevice < AbstractNonRest
574
+ ATTRS = {
575
+ :lun => "LogicalUnitAddress",
576
+ :parent => "ParentName",
577
+ :target => "TargetName",
578
+ :udid => "UniqueDeviceID"
579
+ }.freeze
580
+ end
581
+
582
+ # LV backing device information
583
+ class LogicalVolumeVirtualTargetDevice < VirtualTargetDevice; end
584
+
585
+ # PV backing device information
586
+ class PhysicalVolumeVirtualTargetDevice < VirtualTargetDevice; end
587
+
588
+ # LU backing device information
589
+ class SharedStoragePoolLogicalUnitVirtualTargetDevice < VirtualTargetDevice
590
+ ATTRS = ATTRS.merge({
591
+ :cluster_id => "ClusterID",
592
+ :path => "PathName",
593
+ :raid_level => "RAIDLevel"
594
+ }.freeze)
595
+ end
596
+
597
+ # Virtual CD backing device information
598
+ class VirtualOpticalTargetDevice < VirtualTargetDevice
599
+ def media
600
+ elem = xml.elements["VirtualOpticalMedia"]
601
+ VirtualOpticalMedia.new(elem) unless elem.nil?
602
+ end
603
+ end
604
+
605
+ # VFC mapping information
606
+ class VirtualFibreChannelMapping < AbstractNonRest
607
+ def lpar_uuid
608
+ href = singleton("AssociatedLogicalPartition", "href")
609
+ uuid_from_href(href)
610
+ end
611
+
612
+ def client
613
+ elem = xml.elements["ClientAdapter"]
614
+ VirtualFibreChannelClientAdapter.new(elem) unless elem.nil?
615
+ end
616
+
617
+ def server
618
+ elem = xml.elements["ServerAdapter"]
619
+ VirtualFibreChannelServerAdapter.new(elem) unless elem.nil?
620
+ end
621
+
622
+ def port
623
+ elem = xml.elements["Port"]
624
+ PhysicalFibreChannelPort.new(elem) unless elem.nil?
625
+ end
626
+ end
627
+
628
+ # VFC adapter information
629
+ class VirtualFibreChannelAdapter < VirtualIOAdapter
630
+ ATTRS = ATTRS.merge({
631
+ :name => "AdapterName",
632
+ :lpar_id => "ConnectingPartitionID",
633
+ :slot => "ConnectingVirtualSlotNumber",
634
+ :udid => "UniqueDeviceID"
635
+ }.freeze)
636
+
637
+ def lpar_uuid
638
+ href = singleton("ConnectingPartition", "href")
639
+ uuid_from_href(href)
640
+ end
641
+ end
642
+
643
+ # VFC client information
644
+ class VirtualFibreChannelClientAdapter < VirtualFibreChannelAdapter
645
+ def nport_loggedin
646
+ xml.get_elements("NportLoggedInStatus/VirtualFibreChannelNPortLoginStatus").map do |elem|
647
+ VirtualFibreChannelNPortLoginStatus.new(elem)
648
+ end
649
+ end
650
+
651
+ def server
652
+ elem = xml.elements["ServerAdapter"]
653
+ VirtualFibreChannelServerAdapter.new(elem) unless elem.nil?
654
+ end
655
+
656
+ def wwpns
657
+ singleton("WWPNs")&.split
658
+ end
659
+
660
+ def os_disks
661
+ xml.get_elements("OperatingSystemDisks/OperatingSystemDisk/Name").map do |elem|
662
+ elem.text&.strip
663
+ end.compact
664
+ end
665
+ end
666
+
667
+ # VFC port status
668
+ class VirtualFibreChannelNPortLoginStatus < AbstractNonRest
669
+ ATTRS = {
670
+ :wwpn => "WWPN",
671
+ :wwpn_status => "WWPNStatus",
672
+ :loggedin_by => "LoggedInBy",
673
+ :reason => "StatusReason"
674
+ }.freeze
675
+ end
676
+
677
+ # VFC server information
678
+ class VirtualFibreChannelServerAdapter < VirtualFibreChannelAdapter
679
+ ATTRS = ATTRS.merge({
680
+ :map_port => "MapPort"
681
+ }.freeze)
682
+
683
+ def port
684
+ elem = xml.elements["PhysicalPort"]
685
+ PhysicalFibreChannelPort.new(elem) unless elem.nil?
686
+ end
687
+ end
688
+
689
+ # FC port information
690
+ class PhysicalFibreChannelPort < AbstractNonRest
691
+ ATTRS = {
692
+ :location => "LocationCode",
693
+ :name => "PortName",
694
+ :udid => "UniqueDeviceID",
695
+ :wwpn => "WWPN",
696
+ :wwnn => "WWNN",
697
+ :avail_ports => "AvailablePorts",
698
+ :total_ports => "TotalPorts"
699
+ }.freeze
700
+
701
+ def pvs
702
+ xml.get_elements("PhysicalVolumes/PhysicalVolume").map do |elem|
703
+ PhysicalVolume.new(elem)
704
+ end
705
+ end
706
+ end
707
+
708
+ # Cluster information
709
+ class Cluster < AbstractRest
710
+ ATTRS = {
711
+ :name => "ClusterName",
712
+ :id => "ClusterID",
713
+ :tier_capable => "ClusterCapabilities/IsTierCapable"
714
+ }.freeze
715
+
716
+ def ssp_uuid
717
+ href = singleton("ClusterSharedStoragePool", "href")
718
+ uuid_from_href(href)
719
+ end
720
+
721
+ def nodes
722
+ xml.get_elements("Node/Node").map do |elem|
723
+ Node.new(elem)
724
+ end
725
+ end
726
+ end
727
+
728
+ # Cluster node information
729
+ class Node < AbstractNonRest
730
+ ATTRS = {
731
+ :hostname => "HostName",
732
+ :lpar_id => "PartitionID",
733
+ :state => "State",
734
+ :ioslevel => "VirtualIOServerLevel"
735
+ }.freeze
736
+
737
+ def vios_uuid
738
+ href = singleton("VirtualIOServer", "href")
739
+ uuid_from_href(href)
740
+ end
741
+ end
742
+
743
+ # SSP information
744
+ class SharedStoragePool < AbstractRest
745
+ ATTRS = {
746
+ :name => "StoragePoolName",
747
+ :udid => "UniqueDeviceID",
748
+ :capacity => "Capacity",
749
+ :free_space => "FreeSpace",
750
+ :overcommit => "OverCommitSpace",
751
+ :total_lu_size => "TotalLogicalUnitSize",
752
+ :alert_threshold => "AlertThreshold"
753
+ }.freeze
754
+
755
+ def cluster_uuid
756
+ href = singleton("AssociatedCluster", "href")
757
+ uuid_from_href(href)
758
+ end
759
+
760
+ def pvs
761
+ xml.get_elements("PhysicalVolumes/PhysicalVolume").map do |elem|
762
+ PhysicalVolume.new(elem)
763
+ end
764
+ end
765
+
766
+ def tiers_uuids
767
+ uuids_from_links("AssociatedTiers")
768
+ end
769
+
770
+ def lus
771
+ xml.get_elements("LogicalUnits/LogicalUnit").map do |elem|
772
+ LogicalUnit.new(elem)
773
+ end
774
+ end
775
+ end
776
+
777
+ # SSP tier information
778
+ class Tier < AbstractRest
779
+ ATTRS = {
780
+ :name => "Name",
781
+ :udid => "UniqueDeviceID",
782
+ :type => "Type",
783
+ :capacity => "Capacity",
784
+ :total_lu_size => "TotalLogicalUnitSize",
785
+ :is_default => "IsDefault",
786
+ :free_space => "FreeSpace"
787
+ }.freeze
788
+
789
+ def ssp_uuid
790
+ href = singleton("AssociatedSharedStoragePool", "href")
791
+ uuid_from_href(href)
792
+ end
793
+
794
+ def lus_uuids
795
+ uuids_from_links("AssociatedLogicalUnits")
796
+ end
797
+ end
798
+
799
+ # SSP LU information
800
+ class LogicalUnit < VirtualSCSIStorage
801
+ ATTRS = {
802
+ :name => "UnitName",
803
+ :capacity => "UnitCapacity",
804
+ :udid => "UniqueDeviceID",
805
+ :thin => "ThinDevice",
806
+ :type => "LogicalUnitType",
807
+ :in_use => "InUse"
808
+ }.freeze
809
+ end
810
+
811
+ class PartitionTemplateSummary < AbstractRest
812
+ ATTRS = {
813
+ :name => "partitionTemplateName"
331
814
  }.freeze
332
815
  end
333
816
 
334
- class VirtualNICDedicated < AbstractRest
817
+ class PartitionTemplate < AbstractRest
335
818
  ATTRS = {
336
- :macaddr => "Details/MACAddress",
337
- :slot => "VirtualSlotNumber",
338
- :location => "DynamicReconfigurationConnectorName"
819
+ :name => "partitionTemplateName",
820
+ :description => "description",
821
+ :os => "logicalPartitionConfig/osVersion",
822
+ :memory => "logicalPartitionConfig/memoryConfiguration/currMemory"
339
823
  }.freeze
340
824
  end
341
825
 
342
826
  # HMC Event
343
827
  class Event < AbstractRest
828
+ attr_accessor :usertask
344
829
  ATTRS = {
345
830
  :id => "EventID",
346
831
  :type => "EventType",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IbmPowerHmc
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.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.6.0
4
+ version: 0.7.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: 2021-11-12 00:00:00.000000000 Z
11
+ date: 2021-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client