ibm_power_hmc 0.5.0 → 0.8.1

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: 2c866478ebd950e9570ce2983d62e90b15fdc27163ea77f3b3f5873138b57cf9
4
- data.tar.gz: c58488b78a699e4d0f1fc48c43d41db03f9df7c20f861d29e37d80375e8068a2
3
+ metadata.gz: af5d28dd76ae4e57514691d4ab40e023ca18a6a7e71c4691b15c564097920964
4
+ data.tar.gz: 68a2d511853792668bca5247da9c1910725367ff6fb65ec3f21674953b7be876
5
5
  SHA512:
6
- metadata.gz: 8201481418ec67876a0298d8785ca23a7f2e366a4765ddda8e98024fa71a97a79932661d920090b033da9958c3859460865bb56b7379058e02a9d4f688dab523
7
- data.tar.gz: cfee7c90c9c22149358b17cf861df4d31d757dde93cf5a30c1196f7957fe48d28bb636643bfbed99238b18215d2048d61c85067b66c8d481bc7678d3fe5ab112
6
+ metadata.gz: a77ff9b3db36ef774dd64b37d14b5bd57226cbfe31dece9e17c799089c94418d24bea27f2504fbd0ec84d9e3120023a11db1e4619f06e46f92f12c629398d1ff
7
+ data.tar.gz: 0feb113a298fb117d6ef5cbfaf1fbab3b6a7e72bb69a749c7a36bc0255147d1e0b640879acd1e233780eecb8ef96768efe35e43ea56e3c73ecd7914b63387f09
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
@@ -262,6 +262,171 @@ module IbmPowerHmc
262
262
  network_adapter("VirtualIOServer", vios_uuid, netadap_uuid)
263
263
  end
264
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
+
265
430
  ##
266
431
  # @!method poweron_lpar(lpar_uuid, params = {}, sync = true)
267
432
  # Power on a logical partition.
@@ -394,7 +559,31 @@ module IbmPowerHmc
394
559
  # No need to sleep as the HMC already waits a bit before returning 204
395
560
  break if response.code != 204 || !wait
396
561
  end
397
- 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
398
587
  end
399
588
 
400
589
  ##
@@ -518,5 +707,24 @@ module IbmPowerHmc
518
707
  Parser.new(response.body).object(:ClientNetworkAdapter)
519
708
  end
520
709
  end
710
+
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
728
+ end
521
729
  end
522
730
  end
@@ -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,8 +113,33 @@ module IbmPowerHmc
116
113
  attr.nil? ? elem.text&.strip : elem.attributes[attr]
117
114
  end
118
115
 
119
- def extract_uuid_from_href(href)
120
- URI(href).path.split('/').last
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)
127
+ URI(href).path.split('/')[index]
128
+ end
129
+
130
+ def uuids_from_links(elem, index = -1)
131
+ xml.get_elements("#{elem}/link[@href]").map do |link|
132
+ uuid_from_href(link.attributes["href"], index)
133
+ end.compact
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
+ []
121
143
  end
122
144
  end
123
145
 
@@ -145,6 +167,12 @@ module IbmPowerHmc
145
167
  attr_reader :uuid, :published, :href, :etag, :content_type
146
168
 
147
169
  def initialize(entry)
170
+ if entry.name != "entry"
171
+ # We are inlined.
172
+ super(entry)
173
+ return
174
+ end
175
+
148
176
  @uuid = entry.elements["id"]&.text
149
177
  @published = Time.xmlschema(entry.elements["published"]&.text)
150
178
  link = entry.elements["link[@rel='SELF']"]
@@ -154,6 +182,13 @@ module IbmPowerHmc
154
182
  @content_type = content.attributes["type"]
155
183
  super(content.elements.first)
156
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
157
192
  end
158
193
 
159
194
  # HMC information
@@ -161,12 +196,17 @@ module IbmPowerHmc
161
196
  ATTRS = {
162
197
  :name => "ManagementConsoleName",
163
198
  :build_level => "VersionInfo/BuildLevel",
164
- :version => "BaseVersion"
199
+ :version => "BaseVersion",
200
+ :ssh_pubkey => "PublicSSHKeyValue"
165
201
  }.freeze
166
202
 
167
203
  def managed_systems_uuids
168
- xml.get_elements("ManagedSystems/link").map do |link|
169
- extract_uuid_from_href(link.attributes["href"])
204
+ uuids_from_links("ManagedSystems")
205
+ end
206
+
207
+ def ssh_authkeys
208
+ xml.get_elements("AuthorizedKeysValue/AuthorizedKey").map do |elem|
209
+ elem.text&.strip
170
210
  end.compact
171
211
  end
172
212
  end
@@ -185,22 +225,50 @@ module IbmPowerHmc
185
225
  :avail_cpus => "AssociatedSystemProcessorConfiguration/CurrentAvailableSystemProcessorUnits",
186
226
  :mtype => "MachineTypeModelAndSerialNumber/MachineType",
187
227
  :model => "MachineTypeModelAndSerialNumber/Model",
188
- :serial => "MachineTypeModelAndSerialNumber/SerialNumber"
228
+ :serial => "MachineTypeModelAndSerialNumber/SerialNumber",
229
+ :vtpm_version => "AssociatedSystemSecurity/VirtualTrustedPlatformModuleVersion",
230
+ :vtpm_lpars => "AssociatedSystemSecurity/AvailableVirtualTrustedPlatformModulePartitions"
189
231
  }.freeze
190
232
 
191
- def lpars_uuids
192
- xml.get_elements("AssociatedLogicalPartitions/link").map do |link|
193
- extract_uuid_from_href(link.attributes["href"])
233
+ def cpu_compat_modes
234
+ xml.get_elements("AssociatedSystemProcessorConfiguration/SupportedPartitionProcessorCompatibilityModes").map do |elem|
235
+ elem.text&.strip
194
236
  end.compact
195
237
  end
196
238
 
239
+ def lpars_uuids
240
+ uuids_from_links("AssociatedLogicalPartitions")
241
+ end
242
+
197
243
  def vioses_uuids
198
- xml.get_elements("AssociatedVirtualIOServers/link").map do |link|
199
- extract_uuid_from_href(link.attributes["href"])
200
- end.compact
244
+ uuids_from_links("AssociatedVirtualIOServers")
245
+ end
246
+
247
+ def io_adapters
248
+ collection_of("AssociatedSystemIOConfiguration/IOSlots/IOSlot/RelatedIOAdapter", "IOAdapter")
249
+ end
250
+
251
+ def vswitches_uuids
252
+ uuids_from_links("AssociatedSystemIOConfiguration/AssociatedSystemVirtualNetwork/VirtualSwitches")
253
+ end
254
+
255
+ def networks_uuids
256
+ uuids_from_links("AssociatedSystemIOConfiguration/AssociatedSystemVirtualNetwork/VirtualNetworks")
201
257
  end
202
258
  end
203
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
+
204
272
  # Common class for LPAR and VIOS
205
273
  class BasePartition < AbstractRest
206
274
  ATTRS = {
@@ -220,16 +288,24 @@ module IbmPowerHmc
220
288
  }.freeze
221
289
 
222
290
  def sys_uuid
223
- sys_href = singleton("AssociatedManagedSystem", "href")
224
- extract_uuid_from_href(sys_href)
291
+ href = singleton("AssociatedManagedSystem", "href")
292
+ uuid_from_href(href) unless href.nil?
225
293
  end
226
294
 
227
295
  def net_adap_uuids
228
- xml.get_elements("ClientNetworkAdapters/link").map do |link|
229
- extract_uuid_from_href(link.attributes["href"])
230
- end.compact
296
+ uuids_from_links("ClientNetworkAdapters")
297
+ end
298
+
299
+ def lhea_ports
300
+ collection_of("HostEthernetAdapterLogicalPorts", "HostEthernetAdapterLogicalPort")
301
+ end
302
+
303
+ def sriov_elp_uuids
304
+ uuids_from_links("SRIOVEthernetLogicalPorts")
231
305
  end
232
306
 
307
+ # Setters
308
+
233
309
  def name=(name)
234
310
  xml.elements[ATTRS[:name]].text = name
235
311
  @name = name
@@ -238,17 +314,94 @@ module IbmPowerHmc
238
314
 
239
315
  # Logical Partition information
240
316
  class LogicalPartition < BasePartition
317
+ def vnic_dedicated_uuids
318
+ uuids_from_links("DedicatedVirtualNICs")
319
+ end
320
+
321
+ def vscsi_client_uuids
322
+ uuids_from_links("VirtualSCSIClientAdapters")
323
+ end
324
+
325
+ def vfc_client_uuids
326
+ uuids_from_links("VirtualFibreChannelClientAdapters")
327
+ end
241
328
  end
242
329
 
243
330
  # VIOS information
244
331
  class VirtualIOServer < BasePartition
332
+ def pvs
333
+ collection_of("PhysicalVolumes", "PhysicalVolume")
334
+ end
335
+
336
+ def rep
337
+ elem = xml.elements["MediaRepositories/VirtualMediaRepository"]
338
+ VirtualMediaRepository.new(elem) unless elem.nil?
339
+ end
340
+
341
+ def vscsi_mappings
342
+ collection_of("VirtualSCSIMappings", "VirtualSCSIMapping")
343
+ end
344
+
345
+ def vfc_mappings
346
+ collection_of("VirtualFibreChannelMappings", "VirtualFibreChannelMapping")
347
+ end
348
+ end
349
+
350
+ # Empty parent class to match K2 schema definition
351
+ class VirtualSCSIStorage < AbstractNonRest; end
352
+
353
+ # Physical Volume information
354
+ class PhysicalVolume < VirtualSCSIStorage
355
+ ATTRS = {
356
+ :location => "LocationCode",
357
+ :description => "Description",
358
+ :is_available => "AvailableForUsage",
359
+ :capacity => "VolumeCapacity",
360
+ :name => "VolumeName",
361
+ :is_fc => "IsFibreChannelBacked",
362
+ :udid => "VolumeUniqueID"
363
+ }.freeze
364
+ end
365
+
366
+ # Logical Volume information
367
+ class VirtualDisk < VirtualSCSIStorage
368
+ ATTRS = {
369
+ :name => "DiskName",
370
+ :label => "DiskLabel",
371
+ :capacity => "DiskCapacity", # In GiB
372
+ :psize => "PartitionSize",
373
+ :vg => "VolumeGroup",
374
+ :udid => "UniqueDeviceID"
375
+ }.freeze
376
+ end
377
+
378
+ # Virtual CD-ROM information
379
+ class VirtualOpticalMedia < VirtualSCSIStorage
380
+ ATTRS = {
381
+ :name => "MediaName",
382
+ :udid => "MediaUDID",
383
+ :mount_opts => "MountType",
384
+ :size => "Size" # in GiB
385
+ }.freeze
386
+ end
387
+
388
+ # Virtual Media Repository information
389
+ class VirtualMediaRepository < AbstractNonRest
390
+ ATTRS = {
391
+ :name => "RepositoryName",
392
+ :size => "RepositorySize" # in GiB
393
+ }.freeze
394
+
395
+ def vopts
396
+ collection_of("OpticalMedia", "VirtualOpticalMedia")
397
+ end
245
398
  end
246
399
 
247
400
  # Virtual Switch information
248
401
  class VirtualSwitch < AbstractRest
249
402
  ATTRS = {
250
403
  :id => "SwitchID",
251
- :mode => "SwitchMode",
404
+ :mode => "SwitchMode", # "VEB", "VEPA"
252
405
  :name => "SwitchName"
253
406
  }.freeze
254
407
 
@@ -257,9 +410,7 @@ module IbmPowerHmc
257
410
  end
258
411
 
259
412
  def networks_uuids
260
- xml.get_elements("VirtualNetworks/link").map do |link|
261
- extract_uuid_from_href(link.attributes["href"])
262
- end.compact
413
+ uuids_from_links("VirtualNetworks")
263
414
  end
264
415
  end
265
416
 
@@ -274,13 +425,11 @@ module IbmPowerHmc
274
425
 
275
426
  def vswitch_uuid
276
427
  href = singleton("AssociatedSwitch", "href")
277
- extract_uuid_from_href(href)
428
+ uuid_from_href(href) unless href.nil?
278
429
  end
279
430
 
280
431
  def lpars_uuids
281
- xml.get_elements("ConnectedPartitions/link").map do |link|
282
- extract_uuid_from_href(link.attributes["href"])
283
- end.compact
432
+ uuids_from_links("ConnectedPartitions")
284
433
  end
285
434
  end
286
435
 
@@ -299,26 +448,380 @@ module IbmPowerHmc
299
448
  ATTRS = ATTRS.merge({
300
449
  :macaddr => "MACAddress",
301
450
  :vswitch_id => "VirtualSwitchID",
302
- :vlan_id => "PortVLANID"
451
+ :vlan_id => "PortVLANID",
452
+ :location => "LocationCode"
303
453
  }.freeze)
304
454
 
305
455
  def vswitch_uuid
306
- href = singleton("AssociatedVirtualSwitch/link", "href")
307
- extract_uuid_from_href(href)
456
+ uuids_from_links("AssociatedVirtualSwitch").first
308
457
  end
309
458
  end
310
459
 
311
460
  # Client Network Adapter information
312
461
  class ClientNetworkAdapter < VirtualEthernetAdapter
313
462
  def networks_uuids
314
- xml.get_elements("VirtualNetworks/link").map do |link|
315
- extract_uuid_from_href(link.attributes["href"])
463
+ uuids_from_links("VirtualNetworks")
464
+ end
465
+ end
466
+
467
+ # LP-HEA information
468
+ class EthernetBackingDevice < IOAdapter; end
469
+ class HostEthernetAdapterLogicalPort < EthernetBackingDevice
470
+ ATTRS = ATTRS.merge({
471
+ :macaddr => "MACAddress",
472
+ :port_id => "LogicalPortID",
473
+ :state => "PortState",
474
+ :location => "HEALogicalPortPhysicalLocation"
475
+ }.freeze)
476
+ end
477
+
478
+ # Virtual NIC dedicated information
479
+ class VirtualNICDedicated < VirtualIOAdapter
480
+ ATTRS = ATTRS.merge({
481
+ :location => "DynamicReconfigurationConnectorName", # overrides VirtualIOAdapter
482
+ :macaddr => "Details/MACAddress",
483
+ :os_devname => "Details/OSDeviceName",
484
+ :port_vlan_id => "Details/PortVLANID"
485
+ }.freeze)
486
+ end
487
+
488
+ # SR-IOV Configured Logical Port information
489
+ class SRIOVConfiguredLogicalPort < AbstractRest
490
+ ATTRS = {
491
+ :port_id => "LogicalPortID",
492
+ :port_vlan_id => "PortVLANID",
493
+ :location => "LocationCode",
494
+ :dr_name => "DynamicReconfigurationConnectorName",
495
+ :devname => "DeviceName",
496
+ :capacity => "ConfiguredCapacity"
497
+ }.freeze
498
+
499
+ def lpars_uuids
500
+ uuids_from_links("AssociatedLogicalPartitions")
501
+ end
502
+ end
503
+
504
+ # SR-IOV Ethernet Logical Port information
505
+ class SRIOVEthernetLogicalPort < SRIOVConfiguredLogicalPort
506
+ ATTRS = ATTRS.merge({
507
+ :macaddr => "MACAddress"
508
+ }.freeze)
509
+ end
510
+
511
+ # Virtual SCSI mapping information
512
+ class VirtualSCSIMapping < AbstractNonRest
513
+ def lpar_uuid
514
+ href = singleton("AssociatedLogicalPartition", "href")
515
+ uuid_from_href(href) unless href.nil?
516
+ end
517
+
518
+ def client
519
+ elem = xml.elements["ClientAdapter"]
520
+ VirtualSCSIClientAdapter.new(elem) unless elem.nil?
521
+ end
522
+
523
+ def server
524
+ elem = xml.elements["ServerAdapter"]
525
+ VirtualSCSIServerAdapter.new(elem) unless elem.nil?
526
+ end
527
+
528
+ def storage
529
+ # Possible storage types are:
530
+ # LogicalUnit, PhysicalVolume, VirtualDisk, VirtualOpticalMedia
531
+ elem = xml.elements["Storage/*[1]"]
532
+ Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
533
+ end
534
+
535
+ def device
536
+ # Possible backing device types are:
537
+ # LogicalVolumeVirtualTargetDevice, PhysicalVolumeVirtualTargetDevice,
538
+ # SharedStoragePoolLogicalUnitVirtualTargetDevice, VirtualOpticalTargetDevice
539
+ elem = xml.elements["TargetDevice/*[1]"]
540
+ Module.const_get("IbmPowerHmc::#{elem.name}").new(elem) unless elem.nil?
541
+ end
542
+ end
543
+
544
+ # Virtual SCSI adapter (common class for Client and Server)
545
+ class VirtualSCSIAdapter < VirtualIOAdapter
546
+ ATTRS = ATTRS.merge({
547
+ :name => "AdapterName",
548
+ :backdev => "BackingDeviceName",
549
+ :remote_backdev => "RemoteBackingDeviceName",
550
+ :remote_lpar_id => "RemoteLogicalPartitionID",
551
+ :remote_slot => "RemoteSlotNumber",
552
+ :server_location => "ServerLocationCode",
553
+ :udid => "UniqueDeviceID"
554
+ }.freeze)
555
+ end
556
+
557
+ # Virtual SCSI client adapter information
558
+ class VirtualSCSIClientAdapter < VirtualSCSIAdapter
559
+ def server
560
+ elem = xml.elements["ServerAdapter"]
561
+ VirtualSCSIServerAdapter.new(elem) unless elem.nil?
562
+ end
563
+
564
+ def vios_uuid
565
+ href = singleton("ConnectingPartition", "href")
566
+ uuid_from_href(href) unless href.nil?
567
+ end
568
+ end
569
+
570
+ # Virtual SCSI server adapter information
571
+ class VirtualSCSIServerAdapter < VirtualSCSIAdapter; end
572
+
573
+ # Virtual target device information
574
+ class VirtualTargetDevice < AbstractNonRest
575
+ ATTRS = {
576
+ :lun => "LogicalUnitAddress",
577
+ :parent => "ParentName",
578
+ :target => "TargetName",
579
+ :udid => "UniqueDeviceID"
580
+ }.freeze
581
+ end
582
+
583
+ # LV backing device information
584
+ class LogicalVolumeVirtualTargetDevice < VirtualTargetDevice; end
585
+
586
+ # PV backing device information
587
+ class PhysicalVolumeVirtualTargetDevice < VirtualTargetDevice; end
588
+
589
+ # LU backing device information
590
+ class SharedStoragePoolLogicalUnitVirtualTargetDevice < VirtualTargetDevice
591
+ ATTRS = ATTRS.merge({
592
+ :cluster_id => "ClusterID",
593
+ :path => "PathName",
594
+ :raid_level => "RAIDLevel"
595
+ }.freeze)
596
+ end
597
+
598
+ # Virtual CD backing device information
599
+ class VirtualOpticalTargetDevice < VirtualTargetDevice
600
+ def media
601
+ elem = xml.elements["VirtualOpticalMedia"]
602
+ VirtualOpticalMedia.new(elem) unless elem.nil?
603
+ end
604
+ end
605
+
606
+ # VFC mapping information
607
+ class VirtualFibreChannelMapping < AbstractNonRest
608
+ def lpar_uuid
609
+ href = singleton("AssociatedLogicalPartition", "href")
610
+ uuid_from_href(href) unless href.nil?
611
+ end
612
+
613
+ def client
614
+ elem = xml.elements["ClientAdapter"]
615
+ VirtualFibreChannelClientAdapter.new(elem) unless elem.nil?
616
+ end
617
+
618
+ def server
619
+ elem = xml.elements["ServerAdapter"]
620
+ VirtualFibreChannelServerAdapter.new(elem) unless elem.nil?
621
+ end
622
+
623
+ def port
624
+ elem = xml.elements["Port"]
625
+ PhysicalFibreChannelPort.new(elem) unless elem.nil?
626
+ end
627
+ end
628
+
629
+ # VFC adapter information
630
+ class VirtualFibreChannelAdapter < VirtualIOAdapter
631
+ ATTRS = ATTRS.merge({
632
+ :name => "AdapterName",
633
+ :lpar_id => "ConnectingPartitionID",
634
+ :slot => "ConnectingVirtualSlotNumber",
635
+ :udid => "UniqueDeviceID"
636
+ }.freeze)
637
+
638
+ def lpar_uuid
639
+ href = singleton("ConnectingPartition", "href")
640
+ uuid_from_href(href) unless href.nil?
641
+ end
642
+ end
643
+
644
+ # VFC client information
645
+ class VirtualFibreChannelClientAdapter < VirtualFibreChannelAdapter
646
+ def nport_loggedin
647
+ collection_of("NportLoggedInStatus", "VirtualFibreChannelNPortLoginStatus")
648
+ end
649
+
650
+ def server
651
+ elem = xml.elements["ServerAdapter"]
652
+ VirtualFibreChannelServerAdapter.new(elem) unless elem.nil?
653
+ end
654
+
655
+ def wwpns
656
+ singleton("WWPNs")&.split
657
+ end
658
+
659
+ def os_disks
660
+ xml.get_elements("OperatingSystemDisks/OperatingSystemDisk/Name").map do |elem|
661
+ elem.text&.strip
316
662
  end.compact
317
663
  end
318
664
  end
319
665
 
666
+ # VFC port status
667
+ class VirtualFibreChannelNPortLoginStatus < AbstractNonRest
668
+ ATTRS = {
669
+ :wwpn => "WWPN",
670
+ :wwpn_status => "WWPNStatus",
671
+ :loggedin_by => "LoggedInBy",
672
+ :reason => "StatusReason"
673
+ }.freeze
674
+ end
675
+
676
+ # VFC server information
677
+ class VirtualFibreChannelServerAdapter < VirtualFibreChannelAdapter
678
+ ATTRS = ATTRS.merge({
679
+ :map_port => "MapPort"
680
+ }.freeze)
681
+
682
+ def port
683
+ elem = xml.elements["PhysicalPort"]
684
+ PhysicalFibreChannelPort.new(elem) unless elem.nil?
685
+ end
686
+ end
687
+
688
+ # FC port information
689
+ class PhysicalFibreChannelPort < AbstractNonRest
690
+ ATTRS = {
691
+ :location => "LocationCode",
692
+ :name => "PortName",
693
+ :udid => "UniqueDeviceID",
694
+ :wwpn => "WWPN",
695
+ :wwnn => "WWNN",
696
+ :avail_ports => "AvailablePorts",
697
+ :total_ports => "TotalPorts"
698
+ }.freeze
699
+
700
+ def pvs
701
+ collection_of("PhysicalVolumes", "PhysicalVolume")
702
+ end
703
+ end
704
+
705
+ # Cluster information
706
+ class Cluster < AbstractRest
707
+ ATTRS = {
708
+ :name => "ClusterName",
709
+ :id => "ClusterID",
710
+ :tier_capable => "ClusterCapabilities/IsTierCapable"
711
+ }.freeze
712
+
713
+ def repopvs
714
+ collection_of("RepositoryDisk", "PhysicalVolume")
715
+ end
716
+
717
+ def ssp_uuid
718
+ href = singleton("ClusterSharedStoragePool", "href")
719
+ uuid_from_href(href) unless href.nil?
720
+ end
721
+
722
+ def nodes
723
+ collection_of("Node", "Node")
724
+ end
725
+ end
726
+
727
+ # Cluster node information
728
+ class Node < AbstractNonRest
729
+ ATTRS = {
730
+ :hostname => "HostName",
731
+ :lpar_id => "PartitionID",
732
+ :state => "State",
733
+ :ioslevel => "VirtualIOServerLevel"
734
+ }.freeze
735
+
736
+ def vios_uuid
737
+ href = singleton("VirtualIOServer", "href")
738
+ uuid_from_href(href) unless href.nil?
739
+ end
740
+ end
741
+
742
+ # SSP information
743
+ class SharedStoragePool < AbstractRest
744
+ ATTRS = {
745
+ :id => "SharedStoragePoolID",
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) unless href.nil?
758
+ end
759
+
760
+ def pvs
761
+ collection_of("PhysicalVolumes", "PhysicalVolume")
762
+ end
763
+
764
+ def tiers_uuids
765
+ uuids_from_links("AssociatedTiers")
766
+ end
767
+
768
+ def lus
769
+ collection_of("LogicalUnits", "LogicalUnit")
770
+ end
771
+ end
772
+
773
+ # SSP tier information
774
+ class Tier < AbstractRest
775
+ ATTRS = {
776
+ :name => "Name",
777
+ :udid => "UniqueDeviceID",
778
+ :type => "Type",
779
+ :capacity => "Capacity",
780
+ :total_lu_size => "TotalLogicalUnitSize",
781
+ :is_default => "IsDefault",
782
+ :free_space => "FreeSpace"
783
+ }.freeze
784
+
785
+ def ssp_uuid
786
+ href = singleton("AssociatedSharedStoragePool", "href")
787
+ uuid_from_href(href) unless href.nil?
788
+ end
789
+
790
+ def lus_uuids
791
+ uuids_from_links("AssociatedLogicalUnits")
792
+ end
793
+ end
794
+
795
+ # SSP LU information
796
+ class LogicalUnit < VirtualSCSIStorage
797
+ ATTRS = {
798
+ :name => "UnitName",
799
+ :capacity => "UnitCapacity",
800
+ :udid => "UniqueDeviceID",
801
+ :thin => "ThinDevice",
802
+ :type => "LogicalUnitType",
803
+ :in_use => "InUse"
804
+ }.freeze
805
+ end
806
+
807
+ class PartitionTemplateSummary < AbstractRest
808
+ ATTRS = {
809
+ :name => "partitionTemplateName"
810
+ }.freeze
811
+ end
812
+
813
+ class PartitionTemplate < AbstractRest
814
+ ATTRS = {
815
+ :name => "partitionTemplateName",
816
+ :description => "description",
817
+ :os => "logicalPartitionConfig/osVersion",
818
+ :memory => "logicalPartitionConfig/memoryConfiguration/currMemory"
819
+ }.freeze
820
+ end
821
+
320
822
  # HMC Event
321
823
  class Event < AbstractRest
824
+ attr_accessor :usertask
322
825
  ATTRS = {
323
826
  :id => "EventID",
324
827
  :type => "EventType",
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IbmPowerHmc
4
- VERSION = "0.5.0"
4
+ VERSION = "0.8.1"
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.5.0
4
+ version: 0.8.1
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-08 00:00:00.000000000 Z
11
+ date: 2022-02-03 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: []