ibm_power_hmc 0.6.0 → 0.8.2

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: 288ed57579492fd505491fe8e56f9dbd371cb6aaae118f98c14202fd20e8bf85
4
- data.tar.gz: b21286ee62bfa69e14d609ad001b72f012ccbe3fdebc59f090320d03877e6d20
3
+ metadata.gz: c623fd45cb85f923d0790b547880961e484577caf9e04b2a12faf31d89b6d73b
4
+ data.tar.gz: 644e6b64a701b460a42af2cc9b1eae2975166ed34e9656ae8f7279f7738f5f3d
5
5
  SHA512:
6
- metadata.gz: 7d5010709dd4a423ca131c99d3891ef78c4de8a479e87afe402eb554db660f03f2d85b24728d22773ff1681263f4346ff303e08078c4e9b91519e5ad6398a40a
7
- data.tar.gz: fd6e00f6bb1039b0320d7fb7959f6a3a2206047fe6ebcb1cc795a6f0f37e92e8740cbe8d980d4fa496bfa6c00d3de6efeafba6f4136b7974630b5d187e4bbc7d
6
+ metadata.gz: 33f6075119a6babfc364dd5aff3fb3bf892ce76a27aae925d387807d46e554193cd71262c050d91128935d4b8e61e77183f6a4492dcfd7ecb4015ec6d3c128f0
7
+ data.tar.gz: 7548dbcefd537dd37bdcdde5b7d95184e06374972a46a88b108a576e85c34da9dce71e5daa09b0fae2c2f4808fd63688f6aca9a3fc07aa7ef79e65b1c523c72b
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
@@ -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
  ```
data/Rakefile CHANGED
File without changes
File without changes
@@ -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,133 @@ 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 templates
388
+ # Retrieve the list of partition templates.
389
+ # @return [Array<IbmPowerHmc::PartitionTemplate>] The list of partition templates.
390
+ def templates
391
+ method_url = "/rest/api/templates/PartitionTemplate?detail=full"
392
+ response = request(:get, method_url)
393
+ FeedParser.new(response.body).objects(:PartitionTemplate)
394
+ end
395
+
396
+ ##
397
+ # @!method template(template_uuid)
398
+ # Retrieve details for a particular partition template.
399
+ # @param template_uuid [String] UUID of the partition template.
400
+ # @return [IbmPowerHmc::PartitionTemplate] The partition template.
401
+ def template(template_uuid)
402
+ method_url = "/rest/api/templates/PartitionTemplate/#{template_uuid}"
403
+ response = request(:get, method_url)
404
+ Parser.new(response.body).object(:PartitionTemplate)
405
+ end
406
+
407
+ ##
408
+ # @!method capture_lpar(lpar_uuid, sys_uuid, template_name, sync = true)
409
+ # Capture partition configuration as template.
410
+ # @param lpar_uuid [String] The UUID of the logical partition.
411
+ # @param sys_uuid [String] The UUID of the managed system.
412
+ # @param template_name [String] The name to be given for the new template.
413
+ # @param sync [Boolean] Start the job and wait for its completion.
414
+ # @return [IbmPowerHmc::HmcJob] The HMC job.
415
+ def capture_lpar(lpar_uuid, sys_uuid, template_name, sync = true)
416
+ # Need to include session token in payload so make sure we are logged in
417
+ logon if @api_session_token.nil?
418
+ method_url = "/rest/api/templates/PartitionTemplate/do/capture"
419
+ params = {
420
+ "TargetUuid" => lpar_uuid,
421
+ "NewTemplateName" => template_name,
422
+ "ManagedSystemUuid" => sys_uuid,
423
+ "K_X_API_SESSION_MEMENTO" => @api_session_token
424
+ }
425
+ job = HmcJob.new(self, method_url, "Capture", "PartitionTemplate", params)
426
+ job.run if sync
427
+ job
428
+ end
429
+
303
430
  ##
304
431
  # @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
305
432
  # Power on a logical partition.
@@ -432,7 +559,31 @@ module IbmPowerHmc
432
559
  # No need to sleep as the HMC already waits a bit before returning 204
433
560
  break if response.code != 204 || !wait
434
561
  end
435
- FeedParser.new(response.body).objects(:Event)
562
+ FeedParser.new(response.body).objects(:Event).map do |e|
563
+ data = e.data.split("/") unless e.data.nil?
564
+ if !data.nil? && data.length >= 2 && data[-2].eql?("UserTask")
565
+ e.usertask = usertask(data.last)
566
+ end
567
+ e
568
+ end.compact
569
+ end
570
+
571
+ ##
572
+ # @!method usertask(uuid = true)
573
+ # Retrieve details of an event of type "user task".
574
+ # @param uuid [String] UUID of user task.
575
+ # @return [Hash] Hash of user task attributes.
576
+ def usertask(uuid)
577
+ method_url = "/rest/api/ui/UserTask/#{uuid}"
578
+ response = request(:get, method_url)
579
+ j = JSON.parse(response.body)
580
+ if j['status'].eql?("Completed")
581
+ case j['key']
582
+ when "TEMPLATE_PARTITION_SAVE", "TEMPLATE_PARTITION_SAVE_AS", "TEMPLATE_PARTITION_CAPTURE"
583
+ j['template_uuid'] = templates_summary.find { |t| t.name.eql?(j['labelParams'].first) }&.uuid
584
+ end
585
+ end
586
+ j
436
587
  end
437
588
 
438
589
  ##
@@ -562,8 +713,8 @@ module IbmPowerHmc
562
713
  # Retrieve one or all SR-IOV Ethernet loical ports attached to a Logical Partition or a Virtual I/O Server.
563
714
  # @param vm_type [String] "LogicalPartition" or "VirtualIOServer".
564
715
  # @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.
716
+ # @param sriov_elp_uuid [String] UUID of the port to match (returns all ports if nil).
717
+ # @return [Array<IbmPowerHmc::SRIOVEthernetLogicalPort>, IbmPowerHmc::SRIOVEthernetLogicalPort] The list of ports.
567
718
  def sriov_ethernet_port(vm_type, lpar_uuid, sriov_elp_uuid)
568
719
  if sriov_elp_uuid.nil?
569
720
  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
@@ -74,9 +74,6 @@ module IbmPowerHmc
74
74
  end
75
75
  end
76
76
 
77
- private_constant :Parser
78
- private_constant :FeedParser
79
-
80
77
  ##
81
78
  # HMC generic K2 non-REST object.
82
79
  # @abstract
@@ -116,15 +113,34 @@ module IbmPowerHmc
116
113
  attr.nil? ? elem.text&.strip : elem.attributes[attr]
117
114
  end
118
115
 
119
- def extract_uuid_from_href(href, index = -1)
116
+ def to_s
117
+ str = +"#{self.class.name}:\n"
118
+ self.class::ATTRS.each do |varname, _|
119
+ value = instance_variable_get("@#{varname}")
120
+ value = value.nil? ? "null" : "'#{value}'"
121
+ str << " #{varname}: #{value}\n"
122
+ end
123
+ str
124
+ end
125
+
126
+ def uuid_from_href(href, index = -1)
120
127
  URI(href).path.split('/')[index]
121
128
  end
122
129
 
123
130
  def uuids_from_links(elem, index = -1)
124
131
  xml.get_elements("#{elem}/link[@href]").map do |link|
125
- extract_uuid_from_href(link.attributes["href"], index)
132
+ uuid_from_href(link.attributes["href"], index)
126
133
  end.compact
127
134
  end
135
+
136
+ def collection_of(name, type)
137
+ objtype = Module.const_get("IbmPowerHmc::#{type}")
138
+ xml.get_elements("#{name}/#{type}").map do |elem|
139
+ objtype.new(elem)
140
+ end
141
+ rescue
142
+ []
143
+ end
128
144
  end
129
145
 
130
146
  ##
@@ -151,6 +167,12 @@ module IbmPowerHmc
151
167
  attr_reader :uuid, :published, :href, :etag, :content_type
152
168
 
153
169
  def initialize(entry)
170
+ if entry.name != "entry"
171
+ # We are inlined.
172
+ super(entry)
173
+ return
174
+ end
175
+
154
176
  @uuid = entry.elements["id"]&.text
155
177
  @published = Time.xmlschema(entry.elements["published"]&.text)
156
178
  link = entry.elements["link[@rel='SELF']"]
@@ -160,6 +182,13 @@ module IbmPowerHmc
160
182
  @content_type = content.attributes["type"]
161
183
  super(content.elements.first)
162
184
  end
185
+
186
+ def to_s
187
+ str = super
188
+ str << " uuid: '#{uuid}'\n" if defined?(@uuid)
189
+ str << " published: '#{published}'\n" if defined?(@published)
190
+ str
191
+ end
163
192
  end
164
193
 
165
194
  # HMC information
@@ -167,12 +196,19 @@ module IbmPowerHmc
167
196
  ATTRS = {
168
197
  :name => "ManagementConsoleName",
169
198
  :build_level => "VersionInfo/BuildLevel",
170
- :version => "BaseVersion"
199
+ :version => "BaseVersion",
200
+ :ssh_pubkey => "PublicSSHKeyValue"
171
201
  }.freeze
172
202
 
173
203
  def managed_systems_uuids
174
204
  uuids_from_links("ManagedSystems")
175
205
  end
206
+
207
+ def ssh_authkeys
208
+ xml.get_elements("AuthorizedKeysValue/AuthorizedKey").map do |elem|
209
+ elem.text&.strip
210
+ end.compact
211
+ end
176
212
  end
177
213
 
178
214
  # Managed System information
@@ -189,9 +225,17 @@ module IbmPowerHmc
189
225
  :avail_cpus => "AssociatedSystemProcessorConfiguration/CurrentAvailableSystemProcessorUnits",
190
226
  :mtype => "MachineTypeModelAndSerialNumber/MachineType",
191
227
  :model => "MachineTypeModelAndSerialNumber/Model",
192
- :serial => "MachineTypeModelAndSerialNumber/SerialNumber"
228
+ :serial => "MachineTypeModelAndSerialNumber/SerialNumber",
229
+ :vtpm_version => "AssociatedSystemSecurity/VirtualTrustedPlatformModuleVersion",
230
+ :vtpm_lpars => "AssociatedSystemSecurity/AvailableVirtualTrustedPlatformModulePartitions"
193
231
  }.freeze
194
232
 
233
+ def cpu_compat_modes
234
+ xml.get_elements("AssociatedSystemProcessorConfiguration/SupportedPartitionProcessorCompatibilityModes").map do |elem|
235
+ elem.text&.strip
236
+ end.compact
237
+ end
238
+
195
239
  def lpars_uuids
196
240
  uuids_from_links("AssociatedLogicalPartitions")
197
241
  end
@@ -200,6 +244,10 @@ module IbmPowerHmc
200
244
  uuids_from_links("AssociatedVirtualIOServers")
201
245
  end
202
246
 
247
+ def io_adapters
248
+ collection_of("AssociatedSystemIOConfiguration/IOSlots/IOSlot/RelatedIOAdapter", "IOAdapter")
249
+ end
250
+
203
251
  def vswitches_uuids
204
252
  uuids_from_links("AssociatedSystemIOConfiguration/AssociatedSystemVirtualNetwork/VirtualSwitches")
205
253
  end
@@ -209,6 +257,18 @@ module IbmPowerHmc
209
257
  end
210
258
  end
211
259
 
260
+ # I/O Adapter information
261
+ class IOAdapter < AbstractNonRest
262
+ ATTRS = {
263
+ :id => "AdapterID",
264
+ :description => "Description",
265
+ :name => "DeviceName",
266
+ :type => "DeviceType",
267
+ :dr_name => "DynamicReconfigurationConnectorName",
268
+ :udid => "UniqueDeviceID"
269
+ }.freeze
270
+ end
271
+
212
272
  # Common class for LPAR and VIOS
213
273
  class BasePartition < AbstractRest
214
274
  ATTRS = {
@@ -217,7 +277,8 @@ module IbmPowerHmc
217
277
  :state => "PartitionState",
218
278
  :type => "PartitionType",
219
279
  :memory => "PartitionMemoryConfiguration/CurrentMemory",
220
- :dedicated => "PartitionProcessorConfiguration/HasDedicatedProcessors",
280
+ :dedicated => "PartitionProcessorConfiguration/CurrentHasDedicatedProcessors",
281
+ :sharing_mode => "PartitionProcessorConfiguration/CurrentSharingMode",
221
282
  :rmc_state => "ResourceMonitoringControlState",
222
283
  :rmc_ipaddr => "ResourceMonitoringIPAddress",
223
284
  :os => "OperatingSystemVersion",
@@ -228,18 +289,24 @@ module IbmPowerHmc
228
289
  }.freeze
229
290
 
230
291
  def sys_uuid
231
- sys_href = singleton("AssociatedManagedSystem", "href")
232
- extract_uuid_from_href(sys_href)
292
+ href = singleton("AssociatedManagedSystem", "href")
293
+ uuid_from_href(href) unless href.nil?
233
294
  end
234
295
 
235
296
  def net_adap_uuids
236
297
  uuids_from_links("ClientNetworkAdapters")
237
298
  end
238
299
 
300
+ def lhea_ports
301
+ collection_of("HostEthernetAdapterLogicalPorts", "HostEthernetAdapterLogicalPort")
302
+ end
303
+
239
304
  def sriov_elp_uuids
240
305
  uuids_from_links("SRIOVEthernetLogicalPorts")
241
306
  end
242
307
 
308
+ # Setters
309
+
243
310
  def name=(name)
244
311
  xml.elements[ATTRS[:name]].text = name
245
312
  @name = name
@@ -251,17 +318,91 @@ module IbmPowerHmc
251
318
  def vnic_dedicated_uuids
252
319
  uuids_from_links("DedicatedVirtualNICs")
253
320
  end
321
+
322
+ def vscsi_client_uuids
323
+ uuids_from_links("VirtualSCSIClientAdapters")
324
+ end
325
+
326
+ def vfc_client_uuids
327
+ uuids_from_links("VirtualFibreChannelClientAdapters")
328
+ end
254
329
  end
255
330
 
256
331
  # VIOS information
257
332
  class VirtualIOServer < BasePartition
333
+ def pvs
334
+ collection_of("PhysicalVolumes", "PhysicalVolume")
335
+ end
336
+
337
+ def rep
338
+ elem = xml.elements["MediaRepositories/VirtualMediaRepository"]
339
+ VirtualMediaRepository.new(elem) unless elem.nil?
340
+ end
341
+
342
+ def vscsi_mappings
343
+ collection_of("VirtualSCSIMappings", "VirtualSCSIMapping")
344
+ end
345
+
346
+ def vfc_mappings
347
+ collection_of("VirtualFibreChannelMappings", "VirtualFibreChannelMapping")
348
+ end
349
+ end
350
+
351
+ # Empty parent class to match K2 schema definition
352
+ class VirtualSCSIStorage < AbstractNonRest; end
353
+
354
+ # Physical Volume information
355
+ class PhysicalVolume < VirtualSCSIStorage
356
+ ATTRS = {
357
+ :location => "LocationCode",
358
+ :description => "Description",
359
+ :is_available => "AvailableForUsage",
360
+ :capacity => "VolumeCapacity",
361
+ :name => "VolumeName",
362
+ :is_fc => "IsFibreChannelBacked",
363
+ :udid => "VolumeUniqueID"
364
+ }.freeze
365
+ end
366
+
367
+ # Logical Volume information
368
+ class VirtualDisk < VirtualSCSIStorage
369
+ ATTRS = {
370
+ :name => "DiskName",
371
+ :label => "DiskLabel",
372
+ :capacity => "DiskCapacity", # In GiB
373
+ :psize => "PartitionSize",
374
+ :vg => "VolumeGroup",
375
+ :udid => "UniqueDeviceID"
376
+ }.freeze
377
+ end
378
+
379
+ # Virtual CD-ROM information
380
+ class VirtualOpticalMedia < VirtualSCSIStorage
381
+ ATTRS = {
382
+ :name => "MediaName",
383
+ :udid => "MediaUDID",
384
+ :mount_opts => "MountType",
385
+ :size => "Size" # in GiB
386
+ }.freeze
387
+ end
388
+
389
+ # Virtual Media Repository information
390
+ class VirtualMediaRepository < AbstractNonRest
391
+ ATTRS = {
392
+ :name => "RepositoryName",
393
+ :size => "RepositorySize" # in GiB
394
+ }.freeze
395
+
396
+ def vopts
397
+ collection_of("OpticalMedia", "VirtualOpticalMedia")
398
+ end
258
399
  end
259
400
 
260
401
  # Virtual Switch information
261
402
  class VirtualSwitch < AbstractRest
262
403
  ATTRS = {
263
404
  :id => "SwitchID",
264
- :mode => "SwitchMode",
405
+ :mode => "SwitchMode", # "VEB", "VEPA"
265
406
  :name => "SwitchName"
266
407
  }.freeze
267
408
 
@@ -285,7 +426,7 @@ module IbmPowerHmc
285
426
 
286
427
  def vswitch_uuid
287
428
  href = singleton("AssociatedSwitch", "href")
288
- extract_uuid_from_href(href)
429
+ uuid_from_href(href) unless href.nil?
289
430
  end
290
431
 
291
432
  def lpars_uuids
@@ -324,23 +465,364 @@ module IbmPowerHmc
324
465
  end
325
466
  end
326
467
 
327
- class SRIOVEthernetLogicalPort < AbstractRest
328
- ATTRS = {
468
+ # LP-HEA information
469
+ class EthernetBackingDevice < IOAdapter; end
470
+ class HostEthernetAdapterLogicalPort < EthernetBackingDevice
471
+ ATTRS = ATTRS.merge({
329
472
  :macaddr => "MACAddress",
330
- :location => "LocationCode"
473
+ :port_id => "LogicalPortID",
474
+ :state => "PortState",
475
+ :location => "HEALogicalPortPhysicalLocation"
476
+ }.freeze)
477
+ end
478
+
479
+ # Virtual NIC dedicated information
480
+ class VirtualNICDedicated < VirtualIOAdapter
481
+ ATTRS = ATTRS.merge({
482
+ :location => "DynamicReconfigurationConnectorName", # overrides VirtualIOAdapter
483
+ :macaddr => "Details/MACAddress",
484
+ :os_devname => "Details/OSDeviceName",
485
+ :port_vlan_id => "Details/PortVLANID"
486
+ }.freeze)
487
+ end
488
+
489
+ # SR-IOV Configured Logical Port information
490
+ class SRIOVConfiguredLogicalPort < AbstractRest
491
+ ATTRS = {
492
+ :port_id => "LogicalPortID",
493
+ :port_vlan_id => "PortVLANID",
494
+ :location => "LocationCode",
495
+ :dr_name => "DynamicReconfigurationConnectorName",
496
+ :devname => "DeviceName",
497
+ :capacity => "ConfiguredCapacity"
498
+ }.freeze
499
+
500
+ def lpars_uuids
501
+ uuids_from_links("AssociatedLogicalPartitions")
502
+ end
503
+ end
504
+
505
+ # SR-IOV Ethernet Logical Port information
506
+ class SRIOVEthernetLogicalPort < SRIOVConfiguredLogicalPort
507
+ ATTRS = ATTRS.merge({
508
+ :macaddr => "MACAddress"
509
+ }.freeze)
510
+ end
511
+
512
+ # Virtual SCSI mapping information
513
+ class VirtualSCSIMapping < AbstractNonRest
514
+ def lpar_uuid
515
+ href = singleton("AssociatedLogicalPartition", "href")
516
+ uuid_from_href(href) unless href.nil?
517
+ end
518
+
519
+ def client
520
+ elem = xml.elements["ClientAdapter"]
521
+ VirtualSCSIClientAdapter.new(elem) unless elem.nil?
522
+ end
523
+
524
+ def server
525
+ elem = xml.elements["ServerAdapter"]
526
+ VirtualSCSIServerAdapter.new(elem) unless elem.nil?
527
+ end
528
+
529
+ def storage
530
+ # Possible storage types are:
531
+ # LogicalUnit, PhysicalVolume, VirtualDisk, VirtualOpticalMedia
532
+ elem = xml.elements["Storage/*[1]"]
533
+ Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
534
+ end
535
+
536
+ def device
537
+ # Possible backing device types are:
538
+ # LogicalVolumeVirtualTargetDevice, PhysicalVolumeVirtualTargetDevice,
539
+ # SharedStoragePoolLogicalUnitVirtualTargetDevice, VirtualOpticalTargetDevice
540
+ elem = xml.elements["TargetDevice/*[1]"]
541
+ Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
542
+ end
543
+ end
544
+
545
+ # Virtual SCSI adapter (common class for Client and Server)
546
+ class VirtualSCSIAdapter < VirtualIOAdapter
547
+ ATTRS = ATTRS.merge({
548
+ :name => "AdapterName",
549
+ :backdev => "BackingDeviceName",
550
+ :remote_backdev => "RemoteBackingDeviceName",
551
+ :remote_lpar_id => "RemoteLogicalPartitionID",
552
+ :remote_slot => "RemoteSlotNumber",
553
+ :server_location => "ServerLocationCode",
554
+ :udid => "UniqueDeviceID"
555
+ }.freeze)
556
+ end
557
+
558
+ # Virtual SCSI client adapter information
559
+ class VirtualSCSIClientAdapter < VirtualSCSIAdapter
560
+ def server
561
+ elem = xml.elements["ServerAdapter"]
562
+ VirtualSCSIServerAdapter.new(elem) unless elem.nil?
563
+ end
564
+
565
+ def vios_uuid
566
+ href = singleton("ConnectingPartition", "href")
567
+ uuid_from_href(href) unless href.nil?
568
+ end
569
+ end
570
+
571
+ # Virtual SCSI server adapter information
572
+ class VirtualSCSIServerAdapter < VirtualSCSIAdapter; end
573
+
574
+ # Virtual target device information
575
+ class VirtualTargetDevice < AbstractNonRest
576
+ ATTRS = {
577
+ :lun => "LogicalUnitAddress",
578
+ :parent => "ParentName",
579
+ :target => "TargetName",
580
+ :udid => "UniqueDeviceID"
581
+ }.freeze
582
+ end
583
+
584
+ # LV backing device information
585
+ class LogicalVolumeVirtualTargetDevice < VirtualTargetDevice; end
586
+
587
+ # PV backing device information
588
+ class PhysicalVolumeVirtualTargetDevice < VirtualTargetDevice; end
589
+
590
+ # LU backing device information
591
+ class SharedStoragePoolLogicalUnitVirtualTargetDevice < VirtualTargetDevice
592
+ ATTRS = ATTRS.merge({
593
+ :cluster_id => "ClusterID",
594
+ :path => "PathName",
595
+ :raid_level => "RAIDLevel"
596
+ }.freeze)
597
+ end
598
+
599
+ # Virtual CD backing device information
600
+ class VirtualOpticalTargetDevice < VirtualTargetDevice
601
+ def media
602
+ elem = xml.elements["VirtualOpticalMedia"]
603
+ VirtualOpticalMedia.new(elem) unless elem.nil?
604
+ end
605
+ end
606
+
607
+ # VFC mapping information
608
+ class VirtualFibreChannelMapping < AbstractNonRest
609
+ def lpar_uuid
610
+ href = singleton("AssociatedLogicalPartition", "href")
611
+ uuid_from_href(href) unless href.nil?
612
+ end
613
+
614
+ def client
615
+ elem = xml.elements["ClientAdapter"]
616
+ VirtualFibreChannelClientAdapter.new(elem) unless elem.nil?
617
+ end
618
+
619
+ def server
620
+ elem = xml.elements["ServerAdapter"]
621
+ VirtualFibreChannelServerAdapter.new(elem) unless elem.nil?
622
+ end
623
+
624
+ def port
625
+ elem = xml.elements["Port"]
626
+ PhysicalFibreChannelPort.new(elem) unless elem.nil?
627
+ end
628
+ end
629
+
630
+ # VFC adapter information
631
+ class VirtualFibreChannelAdapter < VirtualIOAdapter
632
+ ATTRS = ATTRS.merge({
633
+ :name => "AdapterName",
634
+ :lpar_id => "ConnectingPartitionID",
635
+ :slot => "ConnectingVirtualSlotNumber",
636
+ :udid => "UniqueDeviceID"
637
+ }.freeze)
638
+
639
+ def lpar_uuid
640
+ href = singleton("ConnectingPartition", "href")
641
+ uuid_from_href(href) unless href.nil?
642
+ end
643
+ end
644
+
645
+ # VFC client information
646
+ class VirtualFibreChannelClientAdapter < VirtualFibreChannelAdapter
647
+ def nport_loggedin
648
+ collection_of("NportLoggedInStatus", "VirtualFibreChannelNPortLoginStatus")
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
+ collection_of("PhysicalVolumes", "PhysicalVolume")
703
+ end
704
+ end
705
+
706
+ # Cluster information
707
+ class Cluster < AbstractRest
708
+ ATTRS = {
709
+ :name => "ClusterName",
710
+ :id => "ClusterID",
711
+ :tier_capable => "ClusterCapabilities/IsTierCapable"
712
+ }.freeze
713
+
714
+ def repopvs
715
+ collection_of("RepositoryDisk", "PhysicalVolume")
716
+ end
717
+
718
+ def ssp_uuid
719
+ href = singleton("ClusterSharedStoragePool", "href")
720
+ uuid_from_href(href) unless href.nil?
721
+ end
722
+
723
+ def nodes
724
+ collection_of("Node", "Node")
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) unless href.nil?
740
+ end
741
+ end
742
+
743
+ # SSP information
744
+ class SharedStoragePool < AbstractRest
745
+ ATTRS = {
746
+ :id => "SharedStoragePoolID",
747
+ :name => "StoragePoolName",
748
+ :udid => "UniqueDeviceID",
749
+ :capacity => "Capacity",
750
+ :free_space => "FreeSpace",
751
+ :overcommit => "OverCommitSpace",
752
+ :total_lu_size => "TotalLogicalUnitSize",
753
+ :alert_threshold => "AlertThreshold"
754
+ }.freeze
755
+
756
+ def cluster_uuid
757
+ href = singleton("AssociatedCluster", "href")
758
+ uuid_from_href(href) unless href.nil?
759
+ end
760
+
761
+ def pvs
762
+ collection_of("PhysicalVolumes", "PhysicalVolume")
763
+ end
764
+
765
+ def tiers_uuids
766
+ uuids_from_links("AssociatedTiers")
767
+ end
768
+
769
+ def lus
770
+ collection_of("LogicalUnits", "LogicalUnit")
771
+ end
772
+ end
773
+
774
+ # SSP tier information
775
+ class Tier < AbstractRest
776
+ ATTRS = {
777
+ :name => "Name",
778
+ :udid => "UniqueDeviceID",
779
+ :type => "Type",
780
+ :capacity => "Capacity",
781
+ :total_lu_size => "TotalLogicalUnitSize",
782
+ :is_default => "IsDefault",
783
+ :free_space => "FreeSpace"
784
+ }.freeze
785
+
786
+ def ssp_uuid
787
+ href = singleton("AssociatedSharedStoragePool", "href")
788
+ uuid_from_href(href) unless href.nil?
789
+ end
790
+
791
+ def lus_uuids
792
+ uuids_from_links("AssociatedLogicalUnits")
793
+ end
794
+ end
795
+
796
+ # SSP LU information
797
+ class LogicalUnit < VirtualSCSIStorage
798
+ ATTRS = {
799
+ :name => "UnitName",
800
+ :capacity => "UnitCapacity",
801
+ :udid => "UniqueDeviceID",
802
+ :thin => "ThinDevice",
803
+ :type => "LogicalUnitType",
804
+ :in_use => "InUse"
805
+ }.freeze
806
+ end
807
+
808
+ class PartitionTemplateSummary < AbstractRest
809
+ ATTRS = {
810
+ :name => "partitionTemplateName"
331
811
  }.freeze
332
812
  end
333
813
 
334
- class VirtualNICDedicated < AbstractRest
814
+ class PartitionTemplate < AbstractRest
335
815
  ATTRS = {
336
- :macaddr => "Details/MACAddress",
337
- :slot => "VirtualSlotNumber",
338
- :location => "DynamicReconfigurationConnectorName"
816
+ :name => "partitionTemplateName",
817
+ :description => "description",
818
+ :os => "logicalPartitionConfig/osVersion",
819
+ :memory => "logicalPartitionConfig/memoryConfiguration/currMemory"
339
820
  }.freeze
340
821
  end
341
822
 
342
823
  # HMC Event
343
824
  class Event < AbstractRest
825
+ attr_accessor :usertask
344
826
  ATTRS = {
345
827
  :id => "EventID",
346
828
  :type => "EventType",
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IbmPowerHmc
4
- VERSION = "0.6.0"
4
+ VERSION = "0.8.2"
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.6.0
4
+ version: 0.8.2
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: 2021-11-12 00:00:00.000000000 Z
11
+ date: 2022-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
27
  description: A Ruby gem for interacting with the IBM Hardware Management Console (HMC).
28
- email:
28
+ email:
29
29
  executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
@@ -55,7 +55,7 @@ metadata:
55
55
  homepage_uri: http://github.com/IBM/ibm_power_hmc_sdk_ruby
56
56
  source_code_uri: http://github.com/IBM/ibm_power_hmc_sdk_ruby
57
57
  changelog_uri: http://github.com/IBM/ibm_power_hmc_sdk_ruby/blob/master/CHANGELOG.md
58
- post_install_message:
58
+ post_install_message:
59
59
  rdoc_options: []
60
60
  require_paths:
61
61
  - lib
@@ -70,8 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.1.4
74
- signing_key:
73
+ rubygems_version: 3.1.2
74
+ signing_key:
75
75
  specification_version: 4
76
76
  summary: IBM Power HMC Ruby gem.
77
77
  test_files: []