ovirt-engine-sdk 4.0.0.alpha12 → 4.0.0.alpha13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +2 -1
- data/lib/ovirtsdk4/http.rb +28 -34
- data/lib/ovirtsdk4/reader.rb +17 -17
- data/lib/ovirtsdk4/readers.rb +412 -180
- data/lib/ovirtsdk4/service.rb +6 -6
- data/lib/ovirtsdk4/services.rb +8451 -3621
- data/lib/ovirtsdk4/type.rb +8 -8
- data/lib/ovirtsdk4/types.rb +13533 -11515
- data/lib/ovirtsdk4/version.rb +3 -3
- data/lib/ovirtsdk4/writer.rb +12 -12
- data/lib/ovirtsdk4/writers.rb +163 -91
- data/lib/ovirtsdk4.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33908ba5949e1f10edc66d7c0ca0a99fe3149c4f
|
4
|
+
data.tar.gz: e487f795b8ffe9d2f194abf098c42e876fb5234b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e8b89c2ffe1f29612826ffce6aee91a19bb769c94ae27a89360317e788067c6e1aa8a8180dcfe3489d8c9aa3ac3d0aaeeb56b5a9e3b5d3d17fd2262fd539e18
|
7
|
+
data.tar.gz: c91b62007c94d7c5e0c55fb4684693d41785ede5a7327af2f686692fc21c31e27d0d1bb2785cc31a7b563dda124defd72b7ad96162bae7b6352bc92812ea40d9
|
data/README.adoc
CHANGED
@@ -39,7 +39,8 @@ connection.close
|
|
39
39
|
|
40
40
|
The `ca.pem` file is required when connecting to a server protected
|
41
41
|
with TLS. In an usual oVirt installation it will be in
|
42
|
-
`/etc/pki/ovirt-engine/ca.pem`.
|
42
|
+
`/etc/pki/ovirt-engine/ca.pem`. If you don't specify `ca_file`, then
|
43
|
+
the system wide CA certificate store will be used.
|
43
44
|
|
44
45
|
Once you have the reference to the system service you can use it to get
|
45
46
|
references to other services, and call their methods. For example, to
|
data/lib/ovirtsdk4/http.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#
|
2
2
|
# Copyright (c) 2015-2016 Red Hat, Inc.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
|
-
|
15
|
+
#
|
16
16
|
|
17
17
|
require 'curb'
|
18
18
|
require 'json'
|
@@ -20,7 +20,7 @@ require 'uri'
|
|
20
20
|
|
21
21
|
module OvirtSDK4
|
22
22
|
|
23
|
-
|
23
|
+
#
|
24
24
|
# This class represents an HTTP request.
|
25
25
|
#
|
26
26
|
# @api private
|
@@ -32,7 +32,7 @@ module OvirtSDK4
|
|
32
32
|
attr_accessor :headers
|
33
33
|
attr_accessor :body
|
34
34
|
|
35
|
-
|
35
|
+
#
|
36
36
|
# Creates a new HTTP request.
|
37
37
|
#
|
38
38
|
def initialize(opts = {})
|
@@ -45,7 +45,7 @@ module OvirtSDK4
|
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
#
|
49
49
|
# This class represents an HTTP response.
|
50
50
|
#
|
51
51
|
# @api private
|
@@ -56,7 +56,7 @@ module OvirtSDK4
|
|
56
56
|
attr_accessor :headers
|
57
57
|
attr_accessor :message
|
58
58
|
|
59
|
-
|
59
|
+
#
|
60
60
|
# Creates a new HTTP response.
|
61
61
|
#
|
62
62
|
def initialize(opts = {})
|
@@ -67,14 +67,14 @@ module OvirtSDK4
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
#
|
71
71
|
# This class is responsible for managing an HTTP connection to the engine server. It is intended as the entry
|
72
72
|
# point for the SDK, and it provides access to the `system` service and, from there, to the rest of the services
|
73
73
|
# provided by the API.
|
74
74
|
#
|
75
75
|
class Connection
|
76
76
|
|
77
|
-
|
77
|
+
#
|
78
78
|
# Creates a new connection to the API server.
|
79
79
|
#
|
80
80
|
# Note that all the parameters with names starting with `sso` are intended for use with external authentication
|
@@ -105,7 +105,8 @@ module OvirtSDK4
|
|
105
105
|
# name should be checked.
|
106
106
|
#
|
107
107
|
# @option opts [String] :ca_file The name of a PEM file containing the trusted CA certificates. The certificate
|
108
|
-
# presented by the server will be verified using these CA certificates.
|
108
|
+
# presented by the server will be verified using these CA certificates. If not set then the system wide CA
|
109
|
+
# certificates store is used.
|
109
110
|
#
|
110
111
|
# @option opts [Boolean] :debug (false) A boolean flag indicating if debug output should be generated. If the
|
111
112
|
# values is `true` all the data sent to and received from the server will be written to `$stdout`. Be aware that
|
@@ -212,11 +213,8 @@ module OvirtSDK4
|
|
212
213
|
if insecure
|
213
214
|
@curl.ssl_verify_peer = false
|
214
215
|
@curl.ssl_verify_host = false
|
215
|
-
elsif ca_file.nil?
|
216
|
-
raise ArgumentError.new("The \"ca_file\"
|
217
|
-
elsif not ::File.file?(ca_file)
|
218
|
-
raise ArgumentError.new("The CA file \"#{ca_file}\" doesn't exist.")
|
219
|
-
else
|
216
|
+
elsif !ca_file.nil?
|
217
|
+
raise ArgumentError.new("The CA file \"#{ca_file}\" doesn't exist.") unless ::File.file?(ca_file)
|
220
218
|
@curl.cacert = ca_file
|
221
219
|
end
|
222
220
|
end
|
@@ -265,7 +263,7 @@ module OvirtSDK4
|
|
265
263
|
|
266
264
|
end
|
267
265
|
|
268
|
-
|
266
|
+
#
|
269
267
|
# Returns the base URL of this connection.
|
270
268
|
#
|
271
269
|
# @return [String]
|
@@ -274,7 +272,7 @@ module OvirtSDK4
|
|
274
272
|
return @url
|
275
273
|
end
|
276
274
|
|
277
|
-
|
275
|
+
#
|
278
276
|
# Returns a reference to the root of the services tree.
|
279
277
|
#
|
280
278
|
# @return [SystemService]
|
@@ -284,7 +282,7 @@ module OvirtSDK4
|
|
284
282
|
return @system_service
|
285
283
|
end
|
286
284
|
|
287
|
-
|
285
|
+
#
|
288
286
|
# Returns a reference to the service corresponding to the given path. For example, if the `path` parameter
|
289
287
|
# is `vms/123/disks` then it will return a reference to the service that manages the disks for the virtual
|
290
288
|
# machine with identifier `123`.
|
@@ -297,11 +295,10 @@ module OvirtSDK4
|
|
297
295
|
return system_service.service(path)
|
298
296
|
end
|
299
297
|
|
300
|
-
|
298
|
+
#
|
301
299
|
# Sends an HTTP request and waits for the response.
|
302
300
|
#
|
303
301
|
# @param request [Request] The Request object containing the details of the HTTP request to send.
|
304
|
-
# @param last [Boolean] A boolean flag indicating if this is the last request.
|
305
302
|
# @return [Response] A request object containing the details of the HTTP response received.
|
306
303
|
#
|
307
304
|
# @api private
|
@@ -349,7 +346,7 @@ module OvirtSDK4
|
|
349
346
|
return response
|
350
347
|
end
|
351
348
|
|
352
|
-
|
349
|
+
#
|
353
350
|
# Obtains the access token from SSO to be used for Bearer authentication.
|
354
351
|
#
|
355
352
|
# @return [String] The URL.
|
@@ -377,7 +374,7 @@ module OvirtSDK4
|
|
377
374
|
return sso_response[@sso_token_name]
|
378
375
|
end
|
379
376
|
|
380
|
-
|
377
|
+
#
|
381
378
|
# Revoke the SSO access token.
|
382
379
|
#
|
383
380
|
# @api private
|
@@ -401,7 +398,7 @@ module OvirtSDK4
|
|
401
398
|
end
|
402
399
|
end
|
403
400
|
|
404
|
-
|
401
|
+
#
|
405
402
|
# Execute a get request to the SSO server and return the response.
|
406
403
|
#
|
407
404
|
# @return [Hash] The JSON response.
|
@@ -456,11 +453,8 @@ module OvirtSDK4
|
|
456
453
|
if @sso_insecure
|
457
454
|
sso_curl.ssl_verify_peer = false
|
458
455
|
sso_curl.ssl_verify_host = false
|
459
|
-
elsif
|
460
|
-
raise ArgumentError.new("The \"sso_ca_file\"
|
461
|
-
elsif not ::File.file?(@sso_ca_file)
|
462
|
-
raise ArgumentError.new("The CA file \"#{@sso_ca_file}\" doesn't exist.")
|
463
|
-
else
|
456
|
+
elsif !@sso_ca_file.nil?
|
457
|
+
raise ArgumentError.new("The CA file \"#{@sso_ca_file}\" doesn't exist.") unless ::File.file?(@sso_ca_file)
|
464
458
|
sso_curl.cacert = @sso_ca_file
|
465
459
|
end
|
466
460
|
end
|
@@ -509,7 +503,7 @@ module OvirtSDK4
|
|
509
503
|
end
|
510
504
|
end
|
511
505
|
|
512
|
-
|
506
|
+
#
|
513
507
|
# Builds a request URL to acquire the access token from SSO. The URLS are different for basic auth and Kerberos,
|
514
508
|
# @return [String] The URL.
|
515
509
|
#
|
@@ -535,7 +529,7 @@ module OvirtSDK4
|
|
535
529
|
return "#{sso_url}sso/oauth/#{entry_point}?grant_type=#{grant_type}&scope=#{scope}"
|
536
530
|
end
|
537
531
|
|
538
|
-
|
532
|
+
#
|
539
533
|
# Builds a request URL to revoke the SSO access token.
|
540
534
|
# @return [String] The URL.
|
541
535
|
#
|
@@ -549,7 +543,7 @@ module OvirtSDK4
|
|
549
543
|
return "#{sso_url}services/sso-logout?scope=&token=#{@sso_token}"
|
550
544
|
end
|
551
545
|
|
552
|
-
|
546
|
+
#
|
553
547
|
# Tests the connectivity with the server. If connectivity works correctly it returns `true`. If there is any
|
554
548
|
# connectivity problem it will either return `false` or raise an exception if the `raise_exception` parameter is
|
555
549
|
# `true`.
|
@@ -567,7 +561,7 @@ module OvirtSDK4
|
|
567
561
|
end
|
568
562
|
end
|
569
563
|
|
570
|
-
|
564
|
+
#
|
571
565
|
# Indicates if the given object is a link. An object is a link if it has an `href` attribute.
|
572
566
|
#
|
573
567
|
# @return [Boolean]
|
@@ -576,7 +570,7 @@ module OvirtSDK4
|
|
576
570
|
return !object.href.nil?
|
577
571
|
end
|
578
572
|
|
579
|
-
|
573
|
+
#
|
580
574
|
# Follows the `href` attribute of the given object, retrieves the target object and returns it.
|
581
575
|
#
|
582
576
|
# @param object [Type] The object containing the `href` attribute.
|
@@ -605,7 +599,7 @@ module OvirtSDK4
|
|
605
599
|
return service.get
|
606
600
|
end
|
607
601
|
|
608
|
-
|
602
|
+
#
|
609
603
|
# Releases the resources used by this connection.
|
610
604
|
#
|
611
605
|
def close
|
@@ -627,7 +621,7 @@ module OvirtSDK4
|
|
627
621
|
@curl.close
|
628
622
|
end
|
629
623
|
|
630
|
-
|
624
|
+
#
|
631
625
|
# Builds a request URL from a path, and the set of query parameters.
|
632
626
|
#
|
633
627
|
# @params opts [Hash] The options used to build the URL.
|
data/lib/ovirtsdk4/reader.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#
|
2
2
|
# Copyright (c) 2015 Red Hat, Inc.
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -12,11 +12,11 @@
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
|
-
|
15
|
+
#
|
16
16
|
|
17
17
|
module OvirtSDK4
|
18
18
|
|
19
|
-
|
19
|
+
#
|
20
20
|
# This is the base class for all the XML readers used by the SDK. It contains the utility methods used by all
|
21
21
|
# of them.
|
22
22
|
#
|
@@ -24,7 +24,7 @@ module OvirtSDK4
|
|
24
24
|
#
|
25
25
|
class Reader
|
26
26
|
|
27
|
-
|
27
|
+
#
|
28
28
|
# Reads a string value, assuming that the cursor is positioned at the start element that contains the value.
|
29
29
|
#
|
30
30
|
# @param reader [XmlReader]
|
@@ -34,7 +34,7 @@ module OvirtSDK4
|
|
34
34
|
return reader.read_element
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
#
|
38
38
|
# Reads a list of string values, assuming that the cursor is positioned at the start of the element that contains
|
39
39
|
# the first value.
|
40
40
|
#
|
@@ -45,7 +45,7 @@ module OvirtSDK4
|
|
45
45
|
return reader.read_elements
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
#
|
49
49
|
# Converts the given text to a boolean value.
|
50
50
|
#
|
51
51
|
# @param text [String]
|
@@ -63,7 +63,7 @@ module OvirtSDK4
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
#
|
67
67
|
# Reads a boolean value, assuming that the cursor is positioned at the start element that contains the value.
|
68
68
|
#
|
69
69
|
# @param reader [XmlReader]
|
@@ -73,7 +73,7 @@ module OvirtSDK4
|
|
73
73
|
return Reader.parse_boolean(reader.read_element)
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
#
|
77
77
|
# Reads a list of boolean values, assuming that the cursor is positioned at the start element that contains
|
78
78
|
# the values.
|
79
79
|
#
|
@@ -84,7 +84,7 @@ module OvirtSDK4
|
|
84
84
|
return reader.read_elements.map { |text| Reader.parse_boolean(text) }
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
#
|
88
88
|
# Converts the given text to an integer value.
|
89
89
|
#
|
90
90
|
# @param text [String]
|
@@ -99,7 +99,7 @@ module OvirtSDK4
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
|
102
|
+
#
|
103
103
|
# Reads an integer value, assuming that the cursor is positioned at the start element that contains the value.
|
104
104
|
#
|
105
105
|
# @param reader [XmlReader]
|
@@ -109,7 +109,7 @@ module OvirtSDK4
|
|
109
109
|
return Reader.parse_integer(reader.read_element)
|
110
110
|
end
|
111
111
|
|
112
|
-
|
112
|
+
#
|
113
113
|
# Reads a list of integer values, assuming that the cursor is positioned at the start element that contains the
|
114
114
|
# values.
|
115
115
|
#
|
@@ -120,7 +120,7 @@ module OvirtSDK4
|
|
120
120
|
return reader.read_elements.map { |text| Reader.parse_integer(text) }
|
121
121
|
end
|
122
122
|
|
123
|
-
|
123
|
+
#
|
124
124
|
# Converts the given text to a decimal value.
|
125
125
|
#
|
126
126
|
# @return [Fixnum]
|
@@ -134,7 +134,7 @@ module OvirtSDK4
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
|
137
|
+
#
|
138
138
|
# Reads a decimal value, assuming that the cursor is positioned at the start element that contains the value.
|
139
139
|
#
|
140
140
|
# @param reader [XmlReader]
|
@@ -144,7 +144,7 @@ module OvirtSDK4
|
|
144
144
|
return Reader.parse_decimal(reader.read_element)
|
145
145
|
end
|
146
146
|
|
147
|
-
|
147
|
+
#
|
148
148
|
# Reads a list of decimal values, assuming that the cursor is positioned at the start element that contains the
|
149
149
|
# values.
|
150
150
|
#
|
@@ -155,7 +155,7 @@ module OvirtSDK4
|
|
155
155
|
return reader.read_elements.map { |text| Reader.parse_decimal(text) }
|
156
156
|
end
|
157
157
|
|
158
|
-
|
158
|
+
#
|
159
159
|
# Converts the given text to a date value.
|
160
160
|
#
|
161
161
|
# @param text [String]
|
@@ -170,7 +170,7 @@ module OvirtSDK4
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
-
|
173
|
+
#
|
174
174
|
# Reads a date value, assuming that the cursor is positioned at the start element that contains the value.
|
175
175
|
#
|
176
176
|
# @param reader [XmlReader]
|
@@ -180,7 +180,7 @@ module OvirtSDK4
|
|
180
180
|
return Reader.parse_date(reader.read_element)
|
181
181
|
end
|
182
182
|
|
183
|
-
|
183
|
+
#
|
184
184
|
# Reads a list of dates values, assuming that the cursor is positioned at the start element that contains the
|
185
185
|
# values.
|
186
186
|
#
|