ovirt-engine-sdk 4.1.8 → 4.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.adoc +21 -0
- data/README.adoc +47 -20
- data/ext/ovirtsdk4c/ov_http_client.c +7 -3
- data/lib/ovirtsdk4/connection.rb +91 -55
- data/lib/ovirtsdk4/reader.rb +3 -3
- data/lib/ovirtsdk4/readers.rb +193 -0
- data/lib/ovirtsdk4/service.rb +65 -30
- data/lib/ovirtsdk4/services.rb +1131 -559
- data/lib/ovirtsdk4/types.rb +418 -0
- data/lib/ovirtsdk4/version.rb +1 -1
- data/lib/ovirtsdk4/writers.rb +69 -0
- metadata +2 -2
data/lib/ovirtsdk4/readers.rb
CHANGED
@@ -2012,6 +2012,8 @@ module OvirtSDK4
|
|
2012
2012
|
object.cpu_profiles = CpuProfileReader.read_many(reader)
|
2013
2013
|
when 'data_center'
|
2014
2014
|
object.data_center = DataCenterReader.read_one(reader)
|
2015
|
+
when 'enabled_features'
|
2016
|
+
object.enabled_features = ClusterFeatureReader.read_many(reader)
|
2015
2017
|
when 'gluster_hooks'
|
2016
2018
|
object.gluster_hooks = GlusterHookReader.read_many(reader)
|
2017
2019
|
when 'gluster_volumes'
|
@@ -2078,6 +2080,8 @@ module OvirtSDK4
|
|
2078
2080
|
object.affinity_groups = list
|
2079
2081
|
when 'cpuprofiles'
|
2080
2082
|
object.cpu_profiles = list
|
2083
|
+
when 'enabledfeatures'
|
2084
|
+
object.enabled_features = list
|
2081
2085
|
when 'glusterhooks'
|
2082
2086
|
object.gluster_hooks = list
|
2083
2087
|
when 'glustervolumes'
|
@@ -2097,6 +2101,82 @@ module OvirtSDK4
|
|
2097
2101
|
|
2098
2102
|
end
|
2099
2103
|
|
2104
|
+
class ClusterFeatureReader < Reader
|
2105
|
+
|
2106
|
+
def self.read_one(reader)
|
2107
|
+
# Do nothing if there aren't more tags:
|
2108
|
+
return nil unless reader.forward
|
2109
|
+
|
2110
|
+
# Create the object:
|
2111
|
+
object = ClusterFeature.new
|
2112
|
+
|
2113
|
+
# Process the attributes:
|
2114
|
+
object.href = reader.get_attribute('href')
|
2115
|
+
value = reader.get_attribute('comment')
|
2116
|
+
object.comment = value if not value.nil?
|
2117
|
+
value = reader.get_attribute('description')
|
2118
|
+
object.description = value if not value.nil?
|
2119
|
+
value = reader.get_attribute('id')
|
2120
|
+
object.id = value if not value.nil?
|
2121
|
+
value = reader.get_attribute('name')
|
2122
|
+
object.name = value if not value.nil?
|
2123
|
+
|
2124
|
+
# Discard the start tag:
|
2125
|
+
empty = reader.empty_element?
|
2126
|
+
reader.read
|
2127
|
+
return object if empty
|
2128
|
+
|
2129
|
+
# Process the inner elements:
|
2130
|
+
while reader.forward do
|
2131
|
+
case reader.node_name
|
2132
|
+
when 'comment'
|
2133
|
+
object.comment = Reader.read_string(reader)
|
2134
|
+
when 'description'
|
2135
|
+
object.description = Reader.read_string(reader)
|
2136
|
+
when 'id'
|
2137
|
+
object.id = Reader.read_string(reader)
|
2138
|
+
when 'name'
|
2139
|
+
object.name = Reader.read_string(reader)
|
2140
|
+
when 'cluster_level'
|
2141
|
+
object.cluster_level = ClusterLevelReader.read_one(reader)
|
2142
|
+
else
|
2143
|
+
reader.next_element
|
2144
|
+
end
|
2145
|
+
end
|
2146
|
+
|
2147
|
+
# Discard the end tag:
|
2148
|
+
reader.read
|
2149
|
+
|
2150
|
+
return object
|
2151
|
+
end
|
2152
|
+
|
2153
|
+
|
2154
|
+
def self.read_many(reader)
|
2155
|
+
# Do nothing if there aren't more tags:
|
2156
|
+
list = List.new
|
2157
|
+
return list unless reader.forward
|
2158
|
+
|
2159
|
+
# Process the attributes:
|
2160
|
+
list.href = reader.get_attribute('href')
|
2161
|
+
|
2162
|
+
# Discard the start tag:
|
2163
|
+
empty = reader.empty_element?
|
2164
|
+
reader.read
|
2165
|
+
return list if empty
|
2166
|
+
|
2167
|
+
# Process the inner elements:
|
2168
|
+
while reader.forward do
|
2169
|
+
list << read_one(reader)
|
2170
|
+
end
|
2171
|
+
|
2172
|
+
# Discard the end tag:
|
2173
|
+
reader.read
|
2174
|
+
|
2175
|
+
return list
|
2176
|
+
end
|
2177
|
+
|
2178
|
+
end
|
2179
|
+
|
2100
2180
|
class ClusterLevelReader < Reader
|
2101
2181
|
|
2102
2182
|
def self.read_one(reader)
|
@@ -2137,6 +2217,10 @@ module OvirtSDK4
|
|
2137
2217
|
object.name = Reader.read_string(reader)
|
2138
2218
|
when 'permits'
|
2139
2219
|
object.permits = PermitReader.read_many(reader)
|
2220
|
+
when 'cluster_features'
|
2221
|
+
object.cluster_features = ClusterFeatureReader.read_many(reader)
|
2222
|
+
when 'link'
|
2223
|
+
read_link(reader, object)
|
2140
2224
|
else
|
2141
2225
|
reader.next_element
|
2142
2226
|
end
|
@@ -2173,6 +2257,23 @@ module OvirtSDK4
|
|
2173
2257
|
return list
|
2174
2258
|
end
|
2175
2259
|
|
2260
|
+
def self.read_link(reader, object)
|
2261
|
+
# Process the attributes:
|
2262
|
+
rel = reader.get_attribute('rel')
|
2263
|
+
href = reader.get_attribute('href')
|
2264
|
+
if rel && href
|
2265
|
+
list = List.new
|
2266
|
+
list.href = href
|
2267
|
+
case rel
|
2268
|
+
when 'clusterfeatures'
|
2269
|
+
object.cluster_features = list
|
2270
|
+
end
|
2271
|
+
end
|
2272
|
+
|
2273
|
+
# Discard the rest of the element:
|
2274
|
+
reader.next_element
|
2275
|
+
end
|
2276
|
+
|
2176
2277
|
end
|
2177
2278
|
|
2178
2279
|
class ConfigurationReader < Reader
|
@@ -9243,6 +9344,94 @@ module OvirtSDK4
|
|
9243
9344
|
|
9244
9345
|
end
|
9245
9346
|
|
9347
|
+
class LinkLayerDiscoveryProtocolElementReader < Reader
|
9348
|
+
|
9349
|
+
def self.read_one(reader)
|
9350
|
+
# Do nothing if there aren't more tags:
|
9351
|
+
return nil unless reader.forward
|
9352
|
+
|
9353
|
+
# Create the object:
|
9354
|
+
object = LinkLayerDiscoveryProtocolElement.new
|
9355
|
+
|
9356
|
+
# Process the attributes:
|
9357
|
+
object.href = reader.get_attribute('href')
|
9358
|
+
value = reader.get_attribute('comment')
|
9359
|
+
object.comment = value if not value.nil?
|
9360
|
+
value = reader.get_attribute('description')
|
9361
|
+
object.description = value if not value.nil?
|
9362
|
+
value = reader.get_attribute('id')
|
9363
|
+
object.id = value if not value.nil?
|
9364
|
+
value = reader.get_attribute('name')
|
9365
|
+
object.name = value if not value.nil?
|
9366
|
+
value = reader.get_attribute('oui')
|
9367
|
+
object.oui = value if not value.nil?
|
9368
|
+
value = reader.get_attribute('subtype')
|
9369
|
+
object.subtype = value if not value.nil?
|
9370
|
+
value = reader.get_attribute('type')
|
9371
|
+
object.type = value if not value.nil?
|
9372
|
+
|
9373
|
+
# Discard the start tag:
|
9374
|
+
empty = reader.empty_element?
|
9375
|
+
reader.read
|
9376
|
+
return object if empty
|
9377
|
+
|
9378
|
+
# Process the inner elements:
|
9379
|
+
while reader.forward do
|
9380
|
+
case reader.node_name
|
9381
|
+
when 'comment'
|
9382
|
+
object.comment = Reader.read_string(reader)
|
9383
|
+
when 'description'
|
9384
|
+
object.description = Reader.read_string(reader)
|
9385
|
+
when 'id'
|
9386
|
+
object.id = Reader.read_string(reader)
|
9387
|
+
when 'name'
|
9388
|
+
object.name = Reader.read_string(reader)
|
9389
|
+
when 'oui'
|
9390
|
+
object.oui = Reader.read_integer(reader)
|
9391
|
+
when 'properties'
|
9392
|
+
object.properties = PropertyReader.read_many(reader)
|
9393
|
+
when 'subtype'
|
9394
|
+
object.subtype = Reader.read_integer(reader)
|
9395
|
+
when 'type'
|
9396
|
+
object.type = Reader.read_integer(reader)
|
9397
|
+
else
|
9398
|
+
reader.next_element
|
9399
|
+
end
|
9400
|
+
end
|
9401
|
+
|
9402
|
+
# Discard the end tag:
|
9403
|
+
reader.read
|
9404
|
+
|
9405
|
+
return object
|
9406
|
+
end
|
9407
|
+
|
9408
|
+
|
9409
|
+
def self.read_many(reader)
|
9410
|
+
# Do nothing if there aren't more tags:
|
9411
|
+
list = List.new
|
9412
|
+
return list unless reader.forward
|
9413
|
+
|
9414
|
+
# Process the attributes:
|
9415
|
+
list.href = reader.get_attribute('href')
|
9416
|
+
|
9417
|
+
# Discard the start tag:
|
9418
|
+
empty = reader.empty_element?
|
9419
|
+
reader.read
|
9420
|
+
return list if empty
|
9421
|
+
|
9422
|
+
# Process the inner elements:
|
9423
|
+
while reader.forward do
|
9424
|
+
list << read_one(reader)
|
9425
|
+
end
|
9426
|
+
|
9427
|
+
# Discard the end tag:
|
9428
|
+
reader.read
|
9429
|
+
|
9430
|
+
return list
|
9431
|
+
end
|
9432
|
+
|
9433
|
+
end
|
9434
|
+
|
9246
9435
|
class LogicalUnitReader < Reader
|
9247
9436
|
|
9248
9437
|
def self.read_one(reader)
|
@@ -18468,6 +18657,8 @@ module OvirtSDK4
|
|
18468
18657
|
Reader.register('cloud_inits', CloudInitReader.method(:read_many))
|
18469
18658
|
Reader.register('cluster', ClusterReader.method(:read_one))
|
18470
18659
|
Reader.register('clusters', ClusterReader.method(:read_many))
|
18660
|
+
Reader.register('cluster_feature', ClusterFeatureReader.method(:read_one))
|
18661
|
+
Reader.register('cluster_features', ClusterFeatureReader.method(:read_many))
|
18471
18662
|
Reader.register('cluster_level', ClusterLevelReader.method(:read_one))
|
18472
18663
|
Reader.register('cluster_levels', ClusterLevelReader.method(:read_many))
|
18473
18664
|
Reader.register('configuration', ConfigurationReader.method(:read_one))
|
@@ -18616,6 +18807,8 @@ module OvirtSDK4
|
|
18616
18807
|
Reader.register('kernels', KernelReader.method(:read_many))
|
18617
18808
|
Reader.register('ksm', KsmReader.method(:read_one))
|
18618
18809
|
Reader.register('ksms', KsmReader.method(:read_many))
|
18810
|
+
Reader.register('link_layer_discovery_protocol_element', LinkLayerDiscoveryProtocolElementReader.method(:read_one))
|
18811
|
+
Reader.register('link_layer_discovery_protocol_elements', LinkLayerDiscoveryProtocolElementReader.method(:read_many))
|
18619
18812
|
Reader.register('logical_unit', LogicalUnitReader.method(:read_one))
|
18620
18813
|
Reader.register('logical_units', LogicalUnitReader.method(:read_many))
|
18621
18814
|
Reader.register('mac', MacReader.method(:read_one))
|
data/lib/ovirtsdk4/service.rb
CHANGED
@@ -22,15 +22,15 @@ module OvirtSDK4
|
|
22
22
|
#
|
23
23
|
# Creates a new future result.
|
24
24
|
#
|
25
|
-
# @param
|
25
|
+
# @param service [Service] The service that created this future.
|
26
26
|
# @param request [HttpRequest] The request that this future will wait for when the `wait` method is called.
|
27
27
|
# @param block [Block] The block that will be executed to check the response, and to convert its body into the
|
28
28
|
# right type of object.
|
29
29
|
#
|
30
30
|
# @api private
|
31
31
|
#
|
32
|
-
def initialize(
|
33
|
-
@
|
32
|
+
def initialize(service, request, &block)
|
33
|
+
@service = service
|
34
34
|
@request = request
|
35
35
|
@block = block
|
36
36
|
end
|
@@ -41,7 +41,7 @@ module OvirtSDK4
|
|
41
41
|
# @return [Object] The result of the operation that created this future.
|
42
42
|
#
|
43
43
|
def wait
|
44
|
-
response = @connection.wait(@request)
|
44
|
+
response = @service.connection.wait(@request)
|
45
45
|
raise response if response.is_a?(Exception)
|
46
46
|
@block.call(response)
|
47
47
|
end
|
@@ -54,14 +54,18 @@ module OvirtSDK4
|
|
54
54
|
#
|
55
55
|
# Creates a new implementation of the service.
|
56
56
|
#
|
57
|
-
# @param
|
57
|
+
# @param parent [Service, Connection] The parent of this service. For most services the parent will be another
|
58
|
+
# service. For example, for the `vm` service that manages virtual machine `123` the parent will be the `vms`
|
59
|
+
# service that manages the collection of virtual machines. For the root of the services tree the parent will
|
60
|
+
# be the connection.
|
58
61
|
#
|
59
|
-
# @param path [String] The
|
62
|
+
# @param path [String] The path of this service, relative to its parent. For example, the path of the `vm`
|
63
|
+
# service that manages virtual machine `123` will be `vm/123`.
|
60
64
|
#
|
61
65
|
# @api private
|
62
66
|
#
|
63
|
-
def initialize(
|
64
|
-
@
|
67
|
+
def initialize(parent, path)
|
68
|
+
@parent = parent
|
65
69
|
@path = path
|
66
70
|
end
|
67
71
|
|
@@ -75,7 +79,7 @@ module OvirtSDK4
|
|
75
79
|
#
|
76
80
|
def check_fault(response)
|
77
81
|
body = internal_read_body(response)
|
78
|
-
|
82
|
+
connection.raise_error(response, body) if body.is_a?(Fault)
|
79
83
|
raise Error, "Expected a fault, but got '#{body.class.name.split('::').last}'"
|
80
84
|
end
|
81
85
|
|
@@ -91,14 +95,29 @@ module OvirtSDK4
|
|
91
95
|
#
|
92
96
|
def check_action(response)
|
93
97
|
body = internal_read_body(response)
|
94
|
-
|
98
|
+
connection.raise_error(response, body) if body.is_a?(Fault)
|
95
99
|
if body.is_a?(Action)
|
96
100
|
return body if body.fault.nil?
|
97
|
-
|
101
|
+
connection.raise_error(response, body.fault)
|
98
102
|
end
|
99
103
|
raise Error, "Expected an action or a fault, but got '#{body.class.name.split('::').last}'"
|
100
104
|
end
|
101
105
|
|
106
|
+
#
|
107
|
+
# Returns the connection used by this service.
|
108
|
+
#
|
109
|
+
# This method is intended for internal use by other components of the SDK. Refrain from using it directly, as
|
110
|
+
# backwards compatibility isn't guaranteed.
|
111
|
+
#
|
112
|
+
# @return [Connection] The connection used by this service.
|
113
|
+
#
|
114
|
+
# @api private
|
115
|
+
#
|
116
|
+
def connection
|
117
|
+
return @parent if @parent.is_a? Connection
|
118
|
+
@parent.connection
|
119
|
+
end
|
120
|
+
|
102
121
|
protected
|
103
122
|
|
104
123
|
#
|
@@ -122,12 +141,12 @@ module OvirtSDK4
|
|
122
141
|
end
|
123
142
|
request = HttpRequest.new
|
124
143
|
request.method = :GET
|
125
|
-
request.url =
|
144
|
+
request.url = absolute_path
|
126
145
|
request.headers = headers
|
127
146
|
request.query = query
|
128
147
|
request.timeout = timeout
|
129
|
-
|
130
|
-
result = Future.new(
|
148
|
+
connection.send(request)
|
149
|
+
result = Future.new(self, request) do |response|
|
131
150
|
raise response if response.is_a?(Exception)
|
132
151
|
case response.code
|
133
152
|
when 200
|
@@ -164,13 +183,13 @@ module OvirtSDK4
|
|
164
183
|
end
|
165
184
|
request = HttpRequest.new
|
166
185
|
request.method = :POST
|
167
|
-
request.url =
|
186
|
+
request.url = absolute_path
|
168
187
|
request.headers = headers
|
169
188
|
request.query = query
|
170
189
|
request.body = Writer.write(object, indent: true)
|
171
190
|
request.timeout = timeout
|
172
|
-
|
173
|
-
result = Future.new(
|
191
|
+
connection.send(request)
|
192
|
+
result = Future.new(self, request) do |response|
|
174
193
|
raise response if response.is_a?(Exception)
|
175
194
|
case response.code
|
176
195
|
when 200, 201, 202
|
@@ -207,13 +226,13 @@ module OvirtSDK4
|
|
207
226
|
end
|
208
227
|
request = HttpRequest.new
|
209
228
|
request.method = :PUT
|
210
|
-
request.url =
|
229
|
+
request.url = absolute_path
|
211
230
|
request.headers = headers
|
212
231
|
request.query = query
|
213
232
|
request.body = Writer.write(object, indent: true)
|
214
233
|
request.timeout = timeout
|
215
|
-
|
216
|
-
result = Future.new(
|
234
|
+
connection.send(request)
|
235
|
+
result = Future.new(self, request) do |response|
|
217
236
|
raise response if response.is_a?(Exception)
|
218
237
|
case response.code
|
219
238
|
when 200
|
@@ -247,12 +266,12 @@ module OvirtSDK4
|
|
247
266
|
end
|
248
267
|
request = HttpRequest.new
|
249
268
|
request.method = :DELETE
|
250
|
-
request.url =
|
269
|
+
request.url = absolute_path
|
251
270
|
request.headers = headers
|
252
271
|
request.query = query
|
253
272
|
request.timeout = timeout
|
254
|
-
|
255
|
-
result = Future.new(
|
273
|
+
connection.send(request)
|
274
|
+
result = Future.new(self, request) do |response|
|
256
275
|
raise response if response.is_a?(exception)
|
257
276
|
check_fault(response) unless response.code == 200
|
258
277
|
end
|
@@ -263,14 +282,14 @@ module OvirtSDK4
|
|
263
282
|
#
|
264
283
|
# Executes an action method.
|
265
284
|
#
|
266
|
-
# @param
|
285
|
+
# @param name [Symbol] The name of the action, for example `:start`.
|
267
286
|
# @param member [Symbol] The name of the action member that contains the result. For example `:is_attached`. Can
|
268
287
|
# be `nil` if the action doesn't return any value.
|
269
288
|
# @param opts [Hash] The hash containing the parameters of the action.
|
270
289
|
#
|
271
290
|
# @api private
|
272
291
|
#
|
273
|
-
def internal_action(
|
292
|
+
def internal_action(name, member, opts)
|
274
293
|
headers = opts[:headers] || {}
|
275
294
|
query = opts[:query] || {}
|
276
295
|
timeout = opts[:timeout]
|
@@ -279,13 +298,13 @@ module OvirtSDK4
|
|
279
298
|
action = Action.new(opts)
|
280
299
|
request = HttpRequest.new
|
281
300
|
request.method = :POST
|
282
|
-
request.url = "#{
|
301
|
+
request.url = "#{absolute_path}/#{name}"
|
283
302
|
request.headers = headers
|
284
303
|
request.query = query
|
285
304
|
request.body = Writer.write(action, indent: true)
|
286
305
|
request.timeout = timeout
|
287
|
-
|
288
|
-
result = Future.new(
|
306
|
+
connection.send(request)
|
307
|
+
result = Future.new(self, request) do |response|
|
289
308
|
raise response if response.is_a?(Exception)
|
290
309
|
case response.code
|
291
310
|
when 200, 201, 202
|
@@ -311,14 +330,30 @@ module OvirtSDK4
|
|
311
330
|
def internal_read_body(response)
|
312
331
|
# First check if the response body is empty, as it makes no sense to check the content type if there is
|
313
332
|
# no body:
|
314
|
-
|
333
|
+
connection.raise_error(response, nil) if response.body.nil? || response.body.length.zero?
|
315
334
|
|
316
335
|
# Check the content type, as otherwise the parsing will fail, and the resulting error message won't be explicit
|
317
336
|
# about the cause of the problem:
|
318
|
-
|
337
|
+
connection.check_xml_content_type(response)
|
319
338
|
|
320
339
|
# Parse the XML and generate the SDK object:
|
321
340
|
Reader.read(response.body)
|
322
341
|
end
|
342
|
+
|
343
|
+
#
|
344
|
+
# Returns the absolute path of this service.
|
345
|
+
#
|
346
|
+
# @return [String] The absolute path of this service. For example, the path of the `vm` service that manages
|
347
|
+
# virtual machine `123` will be `vms/123`. Note that this absolute path doesn't include the `/ovirt-engine/api/'
|
348
|
+
# prefix.
|
349
|
+
#
|
350
|
+
# @api private
|
351
|
+
#
|
352
|
+
def absolute_path
|
353
|
+
return @path if @parent.is_a? Connection
|
354
|
+
prefix = @parent.absolute_path
|
355
|
+
return @path if prefix.empty?
|
356
|
+
"#{prefix}/#{@path}"
|
357
|
+
end
|
323
358
|
end
|
324
359
|
end
|