ibm_power_hmc 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ibm_power_hmc/connection.rb +55 -32
- data/lib/ibm_power_hmc/parser.rb +107 -51
- 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: 2c866478ebd950e9570ce2983d62e90b15fdc27163ea77f3b3f5873138b57cf9
|
4
|
+
data.tar.gz: c58488b78a699e4d0f1fc48c43d41db03f9df7c20f861d29e37d80375e8068a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8201481418ec67876a0298d8785ca23a7f2e366a4765ddda8e98024fa71a97a79932661d920090b033da9958c3859460865bb56b7379058e02a9d4f688dab523
|
7
|
+
data.tar.gz: cfee7c90c9c22149358b17cf861df4d31d757dde93cf5a30c1196f7957fe48d28bb636643bfbed99238b18215d2048d61c85067b66c8d481bc7678d3fe5ab112
|
@@ -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,7 +257,7 @@ 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
|
@@ -335,29 +380,6 @@ module IbmPowerHmc
|
|
335
380
|
job
|
336
381
|
end
|
337
382
|
|
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
383
|
##
|
362
384
|
# @!method next_events(wait = true)
|
363
385
|
# Retrieve a list of events that occured since last call.
|
@@ -479,21 +501,22 @@ module IbmPowerHmc
|
|
479
501
|
end
|
480
502
|
|
481
503
|
##
|
482
|
-
# @!method
|
504
|
+
# @!method network_adapter(vm_type, lpar_uuid, netadap_uuid)
|
483
505
|
# Retrieve one or all virtual ethernet network adapters attached to a Logical Partition or a Virtual I/O Server.
|
484
|
-
# @param vm_type [String] "
|
506
|
+
# @param vm_type [String] "LogicalPartition" or "VirtualIOServer".
|
485
507
|
# @param lpar_uuid [String] UUID of the Logical Partition or the Virtual I/O Server.
|
486
508
|
# @param netadap_uuid [String] UUID of the adapter to match (returns all adapters if nil).
|
487
|
-
# @return [Array<IbmPowerHmc::ClientNetworkAdapter
|
509
|
+
# @return [Array<IbmPowerHmc::ClientNetworkAdapter>, IbmPowerHmc::ClientNetworkAdapter] The list of network adapters.
|
488
510
|
def network_adapter(vm_type, lpar_uuid, netadap_uuid)
|
489
511
|
if netadap_uuid.nil?
|
490
512
|
method_url = "/rest/api/uom/#{vm_type}/#{lpar_uuid}/ClientNetworkAdapter"
|
513
|
+
response = request(:get, method_url)
|
514
|
+
FeedParser.new(response.body).objects(:ClientNetworkAdapter)
|
491
515
|
else
|
492
516
|
method_url = "/rest/api/uom/#{vm_type}/#{lpar_uuid}/ClientNetworkAdapter/#{netadap_uuid}"
|
517
|
+
response = request(:get, method_url)
|
518
|
+
Parser.new(response.body).object(:ClientNetworkAdapter)
|
493
519
|
end
|
494
|
-
|
495
|
-
response = request(:get, method_url)
|
496
|
-
Parser.new(response.body).object(:ClientNetworkAdapter)
|
497
520
|
end
|
498
521
|
end
|
499
522
|
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)
|
@@ -154,6 +121,41 @@ module IbmPowerHmc
|
|
154
121
|
end
|
155
122
|
end
|
156
123
|
|
124
|
+
##
|
125
|
+
# HMC generic K2 REST object.
|
126
|
+
# Encapsulate data for a single REST object.
|
127
|
+
# The XML looks like this:
|
128
|
+
# <entry>
|
129
|
+
# <id>uuid</id>
|
130
|
+
# <published>timestamp</published>
|
131
|
+
# <link rel="SELF" href="https://..."/>
|
132
|
+
# <etag:etag>ETag</etag:etag>
|
133
|
+
# <content type="type">
|
134
|
+
# <!-- actual content here -->
|
135
|
+
# </content>
|
136
|
+
# </entry>
|
137
|
+
#
|
138
|
+
# @abstract
|
139
|
+
# @attr_reader [String] uuid The UUID of the object contained in the entry.
|
140
|
+
# @attr_reader [Time] published The time at which the entry was published.
|
141
|
+
# @attr_reader [URI::HTTPS] href The URL of the object itself.
|
142
|
+
# @attr_reader [String] etag The entity tag of the entry.
|
143
|
+
# @attr_reader [String] content_type The content type of the object contained in the entry.
|
144
|
+
class AbstractRest < AbstractNonRest
|
145
|
+
attr_reader :uuid, :published, :href, :etag, :content_type
|
146
|
+
|
147
|
+
def initialize(entry)
|
148
|
+
@uuid = entry.elements["id"]&.text
|
149
|
+
@published = Time.xmlschema(entry.elements["published"]&.text)
|
150
|
+
link = entry.elements["link[@rel='SELF']"]
|
151
|
+
@href = URI(link.attributes["href"]) unless link.nil?
|
152
|
+
@etag = entry.elements["etag:etag"]&.text&.strip
|
153
|
+
content = entry.elements["content"]
|
154
|
+
@content_type = content.attributes["type"]
|
155
|
+
super(content.elements.first)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
157
159
|
# HMC information
|
158
160
|
class ManagementConsole < AbstractRest
|
159
161
|
ATTRS = {
|
@@ -211,7 +213,10 @@ module IbmPowerHmc
|
|
211
213
|
:rmc_state => "ResourceMonitoringControlState",
|
212
214
|
:rmc_ipaddr => "ResourceMonitoringIPAddress",
|
213
215
|
:os => "OperatingSystemVersion",
|
214
|
-
:ref_code => "ReferenceCode"
|
216
|
+
:ref_code => "ReferenceCode",
|
217
|
+
:procs => "PartitionProcessorConfiguration/CurrentDedicatedProcessorConfiguration/CurrentProcessors",
|
218
|
+
:proc_units => "PartitionProcessorConfiguration/CurrentSharedProcessorConfiguration/CurrentProcessingUnits",
|
219
|
+
:vprocs => "PartitionProcessorConfiguration/CurrentSharedProcessorConfiguration/AllocatedVirtualProcessors"
|
215
220
|
}.freeze
|
216
221
|
|
217
222
|
def sys_uuid
|
@@ -222,7 +227,7 @@ module IbmPowerHmc
|
|
222
227
|
def net_adap_uuids
|
223
228
|
xml.get_elements("ClientNetworkAdapters/link").map do |link|
|
224
229
|
extract_uuid_from_href(link.attributes["href"])
|
225
|
-
end
|
230
|
+
end.compact
|
226
231
|
end
|
227
232
|
|
228
233
|
def name=(name)
|
@@ -250,6 +255,66 @@ module IbmPowerHmc
|
|
250
255
|
def sys_uuid
|
251
256
|
href.path.split('/')[-3]
|
252
257
|
end
|
258
|
+
|
259
|
+
def networks_uuids
|
260
|
+
xml.get_elements("VirtualNetworks/link").map do |link|
|
261
|
+
extract_uuid_from_href(link.attributes["href"])
|
262
|
+
end.compact
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# Virtual Network information
|
267
|
+
class VirtualNetwork < AbstractRest
|
268
|
+
ATTRS = {
|
269
|
+
:name => "NetworkName",
|
270
|
+
:vlan_id => "NetworkVLANID",
|
271
|
+
:vswitch_id => "VswitchID",
|
272
|
+
:tagged => "TaggedNetwork"
|
273
|
+
}.freeze
|
274
|
+
|
275
|
+
def vswitch_uuid
|
276
|
+
href = singleton("AssociatedSwitch", "href")
|
277
|
+
extract_uuid_from_href(href)
|
278
|
+
end
|
279
|
+
|
280
|
+
def lpars_uuids
|
281
|
+
xml.get_elements("ConnectedPartitions/link").map do |link|
|
282
|
+
extract_uuid_from_href(link.attributes["href"])
|
283
|
+
end.compact
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# Virtual I/O Adapter information
|
288
|
+
class VirtualIOAdapter < AbstractRest
|
289
|
+
ATTRS = {
|
290
|
+
:type => "AdapterType", # "Server", "Client", "Unknown"
|
291
|
+
:location => "LocationCode",
|
292
|
+
:slot => "VirtualSlotNumber",
|
293
|
+
:required => "RequiredAdapter"
|
294
|
+
}.freeze
|
295
|
+
end
|
296
|
+
|
297
|
+
# Virtual Ethernet Adapter information
|
298
|
+
class VirtualEthernetAdapter < VirtualIOAdapter
|
299
|
+
ATTRS = ATTRS.merge({
|
300
|
+
:macaddr => "MACAddress",
|
301
|
+
:vswitch_id => "VirtualSwitchID",
|
302
|
+
:vlan_id => "PortVLANID"
|
303
|
+
}.freeze)
|
304
|
+
|
305
|
+
def vswitch_uuid
|
306
|
+
href = singleton("AssociatedVirtualSwitch/link", "href")
|
307
|
+
extract_uuid_from_href(href)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# Client Network Adapter information
|
312
|
+
class ClientNetworkAdapter < VirtualEthernetAdapter
|
313
|
+
def networks_uuids
|
314
|
+
xml.get_elements("VirtualNetworks/link").map do |link|
|
315
|
+
extract_uuid_from_href(link.attributes["href"])
|
316
|
+
end.compact
|
317
|
+
end
|
253
318
|
end
|
254
319
|
|
255
320
|
# HMC Event
|
@@ -262,15 +327,6 @@ module IbmPowerHmc
|
|
262
327
|
}.freeze
|
263
328
|
end
|
264
329
|
|
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
330
|
# Error response from HMC
|
275
331
|
class HttpErrorResponse < AbstractRest
|
276
332
|
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.5.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-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|