ibm_power_hmc 0.4.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/ibm_power_hmc/connection.rb +263 -32
- data/lib/ibm_power_hmc/job.rb +8 -9
- data/lib/ibm_power_hmc/parser.rb +629 -66
- data/lib/ibm_power_hmc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caf9b3a9dcb79bb47bbe628afda5c77ecf94ec6627dc469b8e1a2f564196c8a3
|
4
|
+
data.tar.gz: 031cf0f7f98a8800203281e6d7b27b83adce11651363ac3ce01d06d8c9a69865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 305a5f34bb64be2962d639b38df77fed119de4bb4800db6c0c3d0343af5ac04b336020d3ad0c58a91176ed8601d45a06ab0c6e439592accb5759a7e6924739d2
|
7
|
+
data.tar.gz: 40e6fa63028817a280c26d75a7e0777cb3da60a801ec9dc742fa99405da1fb23343bc79e4b2d81ea145047a6ed1ad06ce72dd681bdc544a685b672a3b92b1805
|
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
|
-
|
57
|
-
|
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
|
```
|
@@ -157,7 +157,6 @@ 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
|
-
|
161
160
|
modify_object(method_url) { |lpar| lpar.name = new_name }
|
162
161
|
end
|
163
162
|
|
@@ -197,12 +196,58 @@ module IbmPowerHmc
|
|
197
196
|
Parser.new(response.body).object(:VirtualIOServer)
|
198
197
|
end
|
199
198
|
|
199
|
+
##
|
200
|
+
# @!method virtual_switches(sys_uuid)
|
201
|
+
# Retrieve the list of virtual switches from a specified managed system.
|
202
|
+
# @param sys_uuid [String] The UUID of the managed system.
|
203
|
+
# @return [Array<IbmPowerHmc::VirtualSwitch>] The list of virtual switches.
|
204
|
+
def virtual_switches(sys_uuid)
|
205
|
+
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch"
|
206
|
+
response = request(:get, method_url)
|
207
|
+
FeedParser.new(response.body).objects(:VirtualSwitch)
|
208
|
+
end
|
209
|
+
|
210
|
+
##
|
211
|
+
# @!method virtual_switch(vswitch_uuid, sys_uuid)
|
212
|
+
# Retrieve information about a virtual switch.
|
213
|
+
# @param vswitch_uuid [String] The UUID of the virtual switch.
|
214
|
+
# @param sys_uuid [String] The UUID of the managed system.
|
215
|
+
# @return [IbmPowerHmc::VirtualSwitch] The virtual switch.
|
216
|
+
def virtual_switch(vswitch_uuid, sys_uuid)
|
217
|
+
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch/#{vswitch_uuid}"
|
218
|
+
response = request(:get, method_url)
|
219
|
+
Parser.new(response.body).object(:VirtualSwitch)
|
220
|
+
end
|
221
|
+
|
222
|
+
##
|
223
|
+
# @!method virtual_networks(sys_uuid)
|
224
|
+
# Retrieve the list of virtual networks from a specified managed system.
|
225
|
+
# @param sys_uuid [String] The UUID of the managed system.
|
226
|
+
# @return [Array<IbmPowerHmc::VirtualNetwork>] The list of virtual networks.
|
227
|
+
def virtual_networks(sys_uuid)
|
228
|
+
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualNetwork"
|
229
|
+
response = request(:get, method_url)
|
230
|
+
FeedParser.new(response.body).objects(:VirtualNetwork)
|
231
|
+
end
|
232
|
+
|
233
|
+
##
|
234
|
+
# @!method virtual_network(vnet_uuid, sys_uuid)
|
235
|
+
# Retrieve information about a virtual network.
|
236
|
+
# @param vnet_uuid [String] The UUID of the virtual network.
|
237
|
+
# @param sys_uuid [String] The UUID of the managed system.
|
238
|
+
# @return [IbmPowerHmc::VirtualNetwork] The virtual network.
|
239
|
+
def virtual_network(vnet_uuid, sys_uuid)
|
240
|
+
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualNetwork/#{vnet_uuid}"
|
241
|
+
response = request(:get, method_url)
|
242
|
+
Parser.new(response.body).object(:VirtualNetwork)
|
243
|
+
end
|
244
|
+
|
200
245
|
##
|
201
246
|
# @!method network_adapter_lpar(lpar_uuid, netadap_uuid = nil)
|
202
247
|
# Retrieve one or all virtual ethernet network adapters attached to a logical partition.
|
203
248
|
# @param lpar_uuid [String] UUID of the logical partition.
|
204
249
|
# @param netadap_uuid [String] UUID of the adapter to match (returns all adapters if omitted).
|
205
|
-
# @return [Array<IbmPowerHmc::ClientNetworkAdapter
|
250
|
+
# @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of network adapters.
|
206
251
|
def network_adapter_lpar(lpar_uuid, netadap_uuid = nil)
|
207
252
|
network_adapter("LogicalPartition", lpar_uuid, netadap_uuid)
|
208
253
|
end
|
@@ -212,11 +257,176 @@ module IbmPowerHmc
|
|
212
257
|
# Retrieve one or all virtual ethernet network adapters attached to a Virtual I/O Server.
|
213
258
|
# @param vios_uuid [String] UUID of the Virtual I/O Server.
|
214
259
|
# @param netadap_uuid [String] UUID of the adapter to match (returns all adapters if omitted).
|
215
|
-
# @return [Array<IbmPowerHmc::ClientNetworkAdapter
|
260
|
+
# @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of network adapters.
|
216
261
|
def network_adapter_vios(vios_uuid, netadap_uuid = nil)
|
217
262
|
network_adapter("VirtualIOServer", vios_uuid, netadap_uuid)
|
218
263
|
end
|
219
264
|
|
265
|
+
##
|
266
|
+
# @!method sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil)
|
267
|
+
# Retrieve one or all SR-IOV ethernet logical ports attached to a logical partition.
|
268
|
+
# @param lpar_uuid [String] UUID of the logical partition.
|
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
|
+
def sriov_elp_lpar(lpar_uuid, sriov_elp_uuid = nil)
|
272
|
+
sriov_ethernet_port("LogicalPartition", lpar_uuid, sriov_elp_uuid)
|
273
|
+
end
|
274
|
+
|
275
|
+
##
|
276
|
+
# @!method network_adapter_vios(vios_uuid, sriov_elp_uuid = nil)
|
277
|
+
# Retrieve one or all SR-IOV ethernet logical ports attached to a Virtual I/O Server.
|
278
|
+
# @param vios_uuid [String] UUID of the Virtual I/O Server.
|
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
|
+
def sriov_elp_vios(vios_uuid, sriov_elp_uuid = nil)
|
282
|
+
sriov_ethernet_port("VirtualIOServer", vios_uuid, sriov_elp_uuid)
|
283
|
+
end
|
284
|
+
|
285
|
+
##
|
286
|
+
# @!method vnic_dedicated(lpar_uuid, vnic_uuid = nil)
|
287
|
+
# Retrieve one or all dedicated virtual network interface controller (vNIC) attached to a logical partition.
|
288
|
+
# @param lpar_uuid [String] UUID of the logical partition.
|
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
|
+
def vnic_dedicated(lpar_uuid, vnic_uuid = nil)
|
292
|
+
if vnic_uuid.nil?
|
293
|
+
method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualNICDedicated"
|
294
|
+
response = request(:get, method_url)
|
295
|
+
FeedParser.new(response.body).objects(:VirtualNICDedicated)
|
296
|
+
else
|
297
|
+
method_url = "/rest/api/uom/LogicalPartition/#{lpar_uuid}/VirtualNICDedicated/#{vnic_uuid}"
|
298
|
+
response = request(:get, method_url)
|
299
|
+
Parser.new(response.body).object(:VirtualNICDedicated)
|
300
|
+
end
|
301
|
+
end
|
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
|
+
|
220
430
|
##
|
221
431
|
# @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
|
222
432
|
# Power on a logical partition.
|
@@ -335,29 +545,6 @@ module IbmPowerHmc
|
|
335
545
|
job
|
336
546
|
end
|
337
547
|
|
338
|
-
##
|
339
|
-
# @!method virtual_switches(sys_uuid)
|
340
|
-
# Retrieve the list of virtual switches from a specified managed system.
|
341
|
-
# @param sys_uuid [String] The UUID of the managed system.
|
342
|
-
# @return [Array<IbmPowerHmc::VirtualSwitch>] The list of virtual switches.
|
343
|
-
def virtual_switches(sys_uuid)
|
344
|
-
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch"
|
345
|
-
response = request(:get, method_url)
|
346
|
-
FeedParser.new(response.body).objects(:VirtualSwitch)
|
347
|
-
end
|
348
|
-
|
349
|
-
##
|
350
|
-
# @!method virtual_switch(vswitch_uuid, sys_uuid)
|
351
|
-
# Retrieve information about a virtual switch.
|
352
|
-
# @param vswitch_uuid [String] The UUID of the virtual switch.
|
353
|
-
# @param sys_uuid [String] The UUID of the managed system.
|
354
|
-
# @return [IbmPowerHmc::VirtualSwitch] The virtual switch.
|
355
|
-
def virtual_switch(vswitch_uuid, sys_uuid)
|
356
|
-
method_url = "/rest/api/uom/ManagedSystem/#{sys_uuid}/VirtualSwitch/#{vswitch_uuid}"
|
357
|
-
response = request(:get, method_url)
|
358
|
-
Parser.new(response.body).object(:VirtualSwitch)
|
359
|
-
end
|
360
|
-
|
361
548
|
##
|
362
549
|
# @!method next_events(wait = true)
|
363
550
|
# Retrieve a list of events that occured since last call.
|
@@ -372,7 +559,31 @@ module IbmPowerHmc
|
|
372
559
|
# No need to sleep as the HMC already waits a bit before returning 204
|
373
560
|
break if response.code != 204 || !wait
|
374
561
|
end
|
375
|
-
FeedParser.new(response.body).objects(:Event)
|
562
|
+
FeedParser.new(response.body).objects(:Event).map do |e|
|
563
|
+
data = e.data.split("/")
|
564
|
+
if 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.select { |t| t.name.eql?(j['labelParams'].first) }.first&.uuid
|
584
|
+
end
|
585
|
+
end
|
586
|
+
j
|
376
587
|
end
|
377
588
|
|
378
589
|
##
|
@@ -479,21 +690,41 @@ module IbmPowerHmc
|
|
479
690
|
end
|
480
691
|
|
481
692
|
##
|
482
|
-
# @!method
|
693
|
+
# @!method network_adapter(vm_type, lpar_uuid, netadap_uuid)
|
483
694
|
# Retrieve one or all virtual ethernet network adapters attached to a Logical Partition or a Virtual I/O Server.
|
484
|
-
# @param vm_type [String] "
|
695
|
+
# @param vm_type [String] "LogicalPartition" or "VirtualIOServer".
|
485
696
|
# @param lpar_uuid [String] UUID of the Logical Partition or the Virtual I/O Server.
|
486
697
|
# @param netadap_uuid [String] UUID of the adapter to match (returns all adapters if nil).
|
487
|
-
# @return [Array<IbmPowerHmc::ClientNetworkAdapter
|
698
|
+
# @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of network adapters.
|
488
699
|
def network_adapter(vm_type, lpar_uuid, netadap_uuid)
|
489
700
|
if netadap_uuid.nil?
|
490
701
|
method_url = "/rest/api/uom/#{vm_type}/#{lpar_uuid}/ClientNetworkAdapter"
|
702
|
+
response = request(:get, method_url)
|
703
|
+
FeedParser.new(response.body).objects(:ClientNetworkAdapter)
|
491
704
|
else
|
492
705
|
method_url = "/rest/api/uom/#{vm_type}/#{lpar_uuid}/ClientNetworkAdapter/#{netadap_uuid}"
|
706
|
+
response = request(:get, method_url)
|
707
|
+
Parser.new(response.body).object(:ClientNetworkAdapter)
|
493
708
|
end
|
709
|
+
end
|
494
710
|
|
495
|
-
|
496
|
-
|
711
|
+
##
|
712
|
+
# @!method sriov_ethernet_port(vm_type, lpar_uuid, sriov_elp_uuid)
|
713
|
+
# Retrieve one or all SR-IOV Ethernet loical ports attached to a Logical Partition or a Virtual I/O Server.
|
714
|
+
# @param vm_type [String] "LogicalPartition" or "VirtualIOServer".
|
715
|
+
# @param lpar_uuid [String] UUID of the Logical Partition or the Virtual I/O Server.
|
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.
|
718
|
+
def sriov_ethernet_port(vm_type, lpar_uuid, sriov_elp_uuid)
|
719
|
+
if sriov_elp_uuid.nil?
|
720
|
+
method_url = "/rest/api/uom/#{vm_type}/#{lpar_uuid}/SRIOVEthernetLogicalPort"
|
721
|
+
response = request(:get, method_url)
|
722
|
+
FeedParser.new(response.body).objects(:SRIOVEthernetLogicalPort)
|
723
|
+
else
|
724
|
+
method_url = "/rest/api/uom/#{vm_type}/#{lpar_uuid}/SRIOVEthernetLogicalPort/#{sriov_elp_uuid}"
|
725
|
+
response = request(:get, method_url)
|
726
|
+
Parser.new(response.body).object(:SRIOVEthernetLogicalPort)
|
727
|
+
end
|
497
728
|
end
|
498
729
|
end
|
499
730
|
end
|
data/lib/ibm_power_hmc/job.rb
CHANGED
@@ -26,7 +26,7 @@ module IbmPowerHmc
|
|
26
26
|
##
|
27
27
|
# @!method start
|
28
28
|
# Start the job asynchronously.
|
29
|
-
# @return [String] The
|
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
|
-
|
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?(@
|
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,
|
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?(@
|
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?(@
|
110
|
+
raise JobNotStarted unless defined?(@href)
|
111
111
|
|
112
|
-
|
113
|
-
@conn.request(:delete, method_url)
|
112
|
+
@conn.request(:delete, @href)
|
114
113
|
# Returns HTTP 204 if ok
|
115
114
|
end
|
116
115
|
end
|
data/lib/ibm_power_hmc/parser.rb
CHANGED
@@ -78,39 +78,16 @@ module IbmPowerHmc
|
|
78
78
|
private_constant :FeedParser
|
79
79
|
|
80
80
|
##
|
81
|
-
# HMC generic K2
|
82
|
-
# Encapsulate data for a single object.
|
83
|
-
# The XML looks like this:
|
84
|
-
# <entry>
|
85
|
-
# <id>uuid</id>
|
86
|
-
# <published>timestamp</published>
|
87
|
-
# <etag:etag>ETag</etag:etag>
|
88
|
-
# <content type="type">
|
89
|
-
# <!-- actual content here -->
|
90
|
-
# </content>
|
91
|
-
# </entry>
|
92
|
-
#
|
81
|
+
# HMC generic K2 non-REST object.
|
93
82
|
# @abstract
|
94
|
-
# @attr_reader [String] uuid The UUID of the object contained in the entry.
|
95
|
-
# @attr_reader [URI::HTTPS] href The URL of the object itself.
|
96
|
-
# @attr_reader [Time] published The time at which the entry was published.
|
97
|
-
# @attr_reader [String] etag The entity tag of the entry.
|
98
|
-
# @attr_reader [String] content_type The content type of the object contained in the entry.
|
99
83
|
# @attr_reader [REXML::Document] xml The XML document representing this object.
|
100
|
-
class
|
84
|
+
class AbstractNonRest
|
101
85
|
ATTRS = {}.freeze
|
102
|
-
attr_reader :
|
86
|
+
attr_reader :xml
|
103
87
|
|
104
|
-
def initialize(
|
105
|
-
@
|
106
|
-
|
107
|
-
@href = URI(link.attributes["href"]) unless link.nil?
|
108
|
-
@published = Time.xmlschema(doc.elements["published"]&.text)
|
109
|
-
@etag = doc.elements["etag:etag"]&.text&.strip
|
110
|
-
content = doc.elements["content"]
|
111
|
-
@content_type = content.attributes["type"]
|
112
|
-
@xml = content.elements.first
|
113
|
-
define_attrs(self.class::ATTRS)
|
88
|
+
def initialize(xml)
|
89
|
+
@xml = xml
|
90
|
+
self.class::ATTRS.each { |varname, xpath| define_attr(varname, xpath) }
|
114
91
|
end
|
115
92
|
|
116
93
|
##
|
@@ -123,17 +100,7 @@ module IbmPowerHmc
|
|
123
100
|
self.class.__send__(:attr_reader, varname)
|
124
101
|
instance_variable_set("@#{varname}", value)
|
125
102
|
end
|
126
|
-
|
127
|
-
##
|
128
|
-
# @!method define_attrs(hash)
|
129
|
-
# Define instance variables using the texts of XML elements as values.
|
130
|
-
# @param hash [Hash] The name of the instance variables and the XPaths
|
131
|
-
# of the XML elements containing the values.
|
132
|
-
def define_attrs(hash)
|
133
|
-
hash.each do |key, value|
|
134
|
-
define_attr(key, value)
|
135
|
-
end
|
136
|
-
end
|
103
|
+
private :define_attr
|
137
104
|
|
138
105
|
##
|
139
106
|
# @!method singleton(xpath, attr = nil)
|
@@ -149,8 +116,72 @@ module IbmPowerHmc
|
|
149
116
|
attr.nil? ? elem.text&.strip : elem.attributes[attr]
|
150
117
|
end
|
151
118
|
|
152
|
-
def
|
153
|
-
|
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)
|
130
|
+
URI(href).path.split('/')[index]
|
131
|
+
end
|
132
|
+
|
133
|
+
def uuids_from_links(elem, index = -1)
|
134
|
+
xml.get_elements("#{elem}/link[@href]").map do |link|
|
135
|
+
uuid_from_href(link.attributes["href"], index)
|
136
|
+
end.compact
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# HMC generic K2 REST object.
|
142
|
+
# Encapsulate data for a single REST object.
|
143
|
+
# The XML looks like this:
|
144
|
+
# <entry>
|
145
|
+
# <id>uuid</id>
|
146
|
+
# <published>timestamp</published>
|
147
|
+
# <link rel="SELF" href="https://..."/>
|
148
|
+
# <etag:etag>ETag</etag:etag>
|
149
|
+
# <content type="type">
|
150
|
+
# <!-- actual content here -->
|
151
|
+
# </content>
|
152
|
+
# </entry>
|
153
|
+
#
|
154
|
+
# @abstract
|
155
|
+
# @attr_reader [String] uuid The UUID of the object contained in the entry.
|
156
|
+
# @attr_reader [Time] published The time at which the entry was published.
|
157
|
+
# @attr_reader [URI::HTTPS] href The URL of the object itself.
|
158
|
+
# @attr_reader [String] etag The entity tag of the entry.
|
159
|
+
# @attr_reader [String] content_type The content type of the object contained in the entry.
|
160
|
+
class AbstractRest < AbstractNonRest
|
161
|
+
attr_reader :uuid, :published, :href, :etag, :content_type
|
162
|
+
|
163
|
+
def initialize(entry)
|
164
|
+
if entry.name != "entry"
|
165
|
+
# We are inlined.
|
166
|
+
super(entry)
|
167
|
+
return
|
168
|
+
end
|
169
|
+
|
170
|
+
@uuid = entry.elements["id"]&.text
|
171
|
+
@published = Time.xmlschema(entry.elements["published"]&.text)
|
172
|
+
link = entry.elements["link[@rel='SELF']"]
|
173
|
+
@href = URI(link.attributes["href"]) unless link.nil?
|
174
|
+
@etag = entry.elements["etag:etag"]&.text&.strip
|
175
|
+
content = entry.elements["content"]
|
176
|
+
@content_type = content.attributes["type"]
|
177
|
+
super(content.elements.first)
|
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
|
154
185
|
end
|
155
186
|
end
|
156
187
|
|
@@ -163,9 +194,7 @@ module IbmPowerHmc
|
|
163
194
|
}.freeze
|
164
195
|
|
165
196
|
def managed_systems_uuids
|
166
|
-
|
167
|
-
extract_uuid_from_href(link.attributes["href"])
|
168
|
-
end.compact
|
197
|
+
uuids_from_links("ManagedSystems")
|
169
198
|
end
|
170
199
|
end
|
171
200
|
|
@@ -183,22 +212,52 @@ module IbmPowerHmc
|
|
183
212
|
:avail_cpus => "AssociatedSystemProcessorConfiguration/CurrentAvailableSystemProcessorUnits",
|
184
213
|
:mtype => "MachineTypeModelAndSerialNumber/MachineType",
|
185
214
|
:model => "MachineTypeModelAndSerialNumber/Model",
|
186
|
-
:serial => "MachineTypeModelAndSerialNumber/SerialNumber"
|
215
|
+
:serial => "MachineTypeModelAndSerialNumber/SerialNumber",
|
216
|
+
:vtpm_version => "AssociatedSystemSecurity/VirtualTrustedPlatformModuleVersion",
|
217
|
+
:vtpm_lpars => "AssociatedSystemSecurity/AvailableVirtualTrustedPlatformModulePartitions"
|
187
218
|
}.freeze
|
188
219
|
|
189
|
-
def
|
190
|
-
xml.get_elements("
|
191
|
-
|
220
|
+
def cpu_compat_modes
|
221
|
+
xml.get_elements("AssociatedSystemProcessorConfiguration/SupportedPartitionProcessorCompatibilityModes").map do |elem|
|
222
|
+
elem.text&.strip
|
192
223
|
end.compact
|
193
224
|
end
|
194
225
|
|
226
|
+
def lpars_uuids
|
227
|
+
uuids_from_links("AssociatedLogicalPartitions")
|
228
|
+
end
|
229
|
+
|
195
230
|
def vioses_uuids
|
196
|
-
|
197
|
-
|
198
|
-
|
231
|
+
uuids_from_links("AssociatedVirtualIOServers")
|
232
|
+
end
|
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
|
+
|
240
|
+
def vswitches_uuids
|
241
|
+
uuids_from_links("AssociatedSystemIOConfiguration/AssociatedSystemVirtualNetwork/VirtualSwitches")
|
242
|
+
end
|
243
|
+
|
244
|
+
def networks_uuids
|
245
|
+
uuids_from_links("AssociatedSystemIOConfiguration/AssociatedSystemVirtualNetwork/VirtualNetworks")
|
199
246
|
end
|
200
247
|
end
|
201
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
|
+
|
202
261
|
# Common class for LPAR and VIOS
|
203
262
|
class BasePartition < AbstractRest
|
204
263
|
ATTRS = {
|
@@ -211,20 +270,33 @@ module IbmPowerHmc
|
|
211
270
|
:rmc_state => "ResourceMonitoringControlState",
|
212
271
|
:rmc_ipaddr => "ResourceMonitoringIPAddress",
|
213
272
|
:os => "OperatingSystemVersion",
|
214
|
-
:ref_code => "ReferenceCode"
|
273
|
+
:ref_code => "ReferenceCode",
|
274
|
+
:procs => "PartitionProcessorConfiguration/CurrentDedicatedProcessorConfiguration/CurrentProcessors",
|
275
|
+
:proc_units => "PartitionProcessorConfiguration/CurrentSharedProcessorConfiguration/CurrentProcessingUnits",
|
276
|
+
:vprocs => "PartitionProcessorConfiguration/CurrentSharedProcessorConfiguration/AllocatedVirtualProcessors"
|
215
277
|
}.freeze
|
216
278
|
|
217
279
|
def sys_uuid
|
218
280
|
sys_href = singleton("AssociatedManagedSystem", "href")
|
219
|
-
|
281
|
+
uuid_from_href(sys_href)
|
220
282
|
end
|
221
283
|
|
222
284
|
def net_adap_uuids
|
223
|
-
|
224
|
-
|
285
|
+
uuids_from_links("ClientNetworkAdapters")
|
286
|
+
end
|
287
|
+
|
288
|
+
def lhea_ports
|
289
|
+
xml.get_elements("HostEthernetAdapterLogicalPorts/HostEthernetAdapterLogicalPort").map do |elem|
|
290
|
+
HostEthernetAdapterLogicalPort.new(elem)
|
225
291
|
end
|
226
292
|
end
|
227
293
|
|
294
|
+
def sriov_elp_uuids
|
295
|
+
uuids_from_links("SRIOVEthernetLogicalPorts")
|
296
|
+
end
|
297
|
+
|
298
|
+
# Setters
|
299
|
+
|
228
300
|
def name=(name)
|
229
301
|
xml.elements[ATTRS[:name]].text = name
|
230
302
|
@name = name
|
@@ -233,27 +305,527 @@ module IbmPowerHmc
|
|
233
305
|
|
234
306
|
# Logical Partition information
|
235
307
|
class LogicalPartition < BasePartition
|
308
|
+
def vnic_dedicated_uuids
|
309
|
+
uuids_from_links("DedicatedVirtualNICs")
|
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
|
236
319
|
end
|
237
320
|
|
238
321
|
# VIOS information
|
239
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
|
240
397
|
end
|
241
398
|
|
242
399
|
# Virtual Switch information
|
243
400
|
class VirtualSwitch < AbstractRest
|
244
401
|
ATTRS = {
|
245
402
|
:id => "SwitchID",
|
246
|
-
:mode => "SwitchMode",
|
403
|
+
:mode => "SwitchMode", # "VEB", "VEPA"
|
247
404
|
:name => "SwitchName"
|
248
405
|
}.freeze
|
249
406
|
|
250
407
|
def sys_uuid
|
251
408
|
href.path.split('/')[-3]
|
252
409
|
end
|
410
|
+
|
411
|
+
def networks_uuids
|
412
|
+
uuids_from_links("VirtualNetworks")
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
# Virtual Network information
|
417
|
+
class VirtualNetwork < AbstractRest
|
418
|
+
ATTRS = {
|
419
|
+
:name => "NetworkName",
|
420
|
+
:vlan_id => "NetworkVLANID",
|
421
|
+
:vswitch_id => "VswitchID",
|
422
|
+
:tagged => "TaggedNetwork"
|
423
|
+
}.freeze
|
424
|
+
|
425
|
+
def vswitch_uuid
|
426
|
+
href = singleton("AssociatedSwitch", "href")
|
427
|
+
uuid_from_href(href)
|
428
|
+
end
|
429
|
+
|
430
|
+
def lpars_uuids
|
431
|
+
uuids_from_links("ConnectedPartitions")
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
# Virtual I/O Adapter information
|
436
|
+
class VirtualIOAdapter < AbstractRest
|
437
|
+
ATTRS = {
|
438
|
+
:type => "AdapterType", # "Server", "Client", "Unknown"
|
439
|
+
:location => "LocationCode",
|
440
|
+
:slot => "VirtualSlotNumber",
|
441
|
+
:required => "RequiredAdapter"
|
442
|
+
}.freeze
|
443
|
+
end
|
444
|
+
|
445
|
+
# Virtual Ethernet Adapter information
|
446
|
+
class VirtualEthernetAdapter < VirtualIOAdapter
|
447
|
+
ATTRS = ATTRS.merge({
|
448
|
+
:macaddr => "MACAddress",
|
449
|
+
:vswitch_id => "VirtualSwitchID",
|
450
|
+
:vlan_id => "PortVLANID",
|
451
|
+
:location => "LocationCode"
|
452
|
+
}.freeze)
|
453
|
+
|
454
|
+
def vswitch_uuid
|
455
|
+
uuids_from_links("AssociatedVirtualSwitch").first
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
# Client Network Adapter information
|
460
|
+
class ClientNetworkAdapter < VirtualEthernetAdapter
|
461
|
+
def networks_uuids
|
462
|
+
uuids_from_links("VirtualNetworks")
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
# LP-HEA information
|
467
|
+
class EthernetBackingDevice < IOAdapter; end
|
468
|
+
class HostEthernetAdapterLogicalPort < EthernetBackingDevice
|
469
|
+
ATTRS = ATTRS.merge({
|
470
|
+
:macaddr => "MACAddress",
|
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"
|
814
|
+
}.freeze
|
815
|
+
end
|
816
|
+
|
817
|
+
class PartitionTemplate < AbstractRest
|
818
|
+
ATTRS = {
|
819
|
+
:name => "partitionTemplateName",
|
820
|
+
:description => "description",
|
821
|
+
:os => "logicalPartitionConfig/osVersion",
|
822
|
+
:memory => "logicalPartitionConfig/memoryConfiguration/currMemory"
|
823
|
+
}.freeze
|
253
824
|
end
|
254
825
|
|
255
826
|
# HMC Event
|
256
827
|
class Event < AbstractRest
|
828
|
+
attr_accessor :usertask
|
257
829
|
ATTRS = {
|
258
830
|
:id => "EventID",
|
259
831
|
:type => "EventType",
|
@@ -262,15 +834,6 @@ module IbmPowerHmc
|
|
262
834
|
}.freeze
|
263
835
|
end
|
264
836
|
|
265
|
-
# Network adapter information
|
266
|
-
class ClientNetworkAdapter < AbstractRest
|
267
|
-
ATTRS = {
|
268
|
-
:macaddr => "MACAddress",
|
269
|
-
:vswitch_id => "VirtualSwitchID",
|
270
|
-
:vlan_id => "PortVLANID"
|
271
|
-
}.freeze
|
272
|
-
end
|
273
|
-
|
274
837
|
# Error response from HMC
|
275
838
|
class HttpErrorResponse < AbstractRest
|
276
839
|
ATTRS = {
|
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.
|
4
|
+
version: 0.8.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
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|