ovirt-engine-sdk 4.0.0.alpha15 → 4.0.0.alpha16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.adoc +13 -0
- data/lib/ovirtsdk4/http.rb +11 -84
- data/lib/ovirtsdk4/type.rb +54 -0
- data/lib/ovirtsdk4/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c80b2e7a94752a957caf5fbd45ff4a91d5889d12
|
4
|
+
data.tar.gz: 41c7ca64c5079f96b24e15df22132158bbe951d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ddc42749d4ee4783ab17ea5099c4c772d17677e87c35ebf1e2bc174e03201de2cac044260131ebc527d38a53f6eaa30293dda1821787640df4f10af1460976
|
7
|
+
data.tar.gz: 6922ca5d7c89985404dd5270aaf1af139afaa15cd4b11602e6b8e3e35bd9cad4de0b4a8632f6d5e83a31310a56248227d46e331fae399d8f04901f4d0192ebcc
|
data/CHANGES.adoc
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
= Changes
|
2
|
+
|
3
|
+
This document describes the relevant changes between releases of the
|
4
|
+
API model.
|
5
|
+
|
6
|
+
== 4.0.0.alpha16 / Jul 15 2016
|
7
|
+
|
8
|
+
New features:
|
9
|
+
|
10
|
+
* Use `Logger` instead of file for the `:log` parameter of the
|
11
|
+
connection class.
|
12
|
+
|
13
|
+
* Add `dig` method to all types.
|
data/lib/ovirtsdk4/http.rb
CHANGED
@@ -109,13 +109,10 @@ module OvirtSDK4
|
|
109
109
|
# certificates store is used.
|
110
110
|
#
|
111
111
|
# @option opts [Boolean] :debug (false) A boolean flag indicating if debug output should be generated. If the
|
112
|
-
# values is `true`
|
113
|
-
# user names and passwords will also be written, so handle
|
112
|
+
# values is `true` and the `log` parameter isn't `nil` then the data sent to and received from the server will be
|
113
|
+
# written to the log. Be aware that user names and passwords will also be written, so handle with care.
|
114
114
|
#
|
115
|
-
# @option opts [
|
116
|
-
# containing a file name or an IO object. If it is a file name then the file will be created if it doesn't
|
117
|
-
# exist, and the debug output will be added to the end. The file will be closed when the connection is closed.
|
118
|
-
# If it is an IO object then the debug output will be written directly, and it won't be closed.
|
115
|
+
# @option opts [Logger] :log The logger where the log messages will be written.
|
119
116
|
#
|
120
117
|
# @option opts [Boolean] :kerberos (false) A boolean flag indicating if Kerberos uthentication should be used
|
121
118
|
# instead of the default basic authentication.
|
@@ -145,16 +142,6 @@ module OvirtSDK4
|
|
145
142
|
# certificate presented by the SSO server will be verified using these CA certificates. Default is value of
|
146
143
|
# `ca_file`.
|
147
144
|
#
|
148
|
-
# @option opts [Boolean] :sso_debug A boolean flag indicating if SSO debug output should be generated. If the
|
149
|
-
# values is `true` all the data sent to and received from the SSO server will be written to `$stdout`. Be aware
|
150
|
-
# that user names and passwords will also be written, so handle it with care. Default is value of `debug`.
|
151
|
-
#
|
152
|
-
# @option opts [String, IO] :sso_log The log file where the SSO debug output will be written. The value can be a
|
153
|
-
# string containing a file name or an IO object. If it is a file name then the file will be created if it doesn't
|
154
|
-
# exist, and the SSO debug output will be added to the end. The file will be closed when the connection is closed.
|
155
|
-
# If it is an IO object then the SSO debug output will be written directly, and it won't be closed. Default is
|
156
|
-
# value of `log`.
|
157
|
-
#
|
158
145
|
# @option opts [Boolean] :sso_timeout The maximun total time to wait for the SSO response, in seconds. A value
|
159
146
|
# of zero means wait for ever. If the timeout expires before the SSO response is received an exception will be
|
160
147
|
# raised. Default is value of `timeout`.
|
@@ -169,8 +156,8 @@ module OvirtSDK4
|
|
169
156
|
password = opts[:password]
|
170
157
|
insecure = opts[:insecure] || false
|
171
158
|
ca_file = opts[:ca_file]
|
172
|
-
debug = opts[:debug] || false
|
173
|
-
log = opts[:log]
|
159
|
+
@debug = opts[:debug] || false
|
160
|
+
@log = opts[:log]
|
174
161
|
kerberos = opts[:kerberos] || false
|
175
162
|
timeout = opts[:timeout] || 0
|
176
163
|
compress = opts[:compress] || false
|
@@ -178,8 +165,6 @@ module OvirtSDK4
|
|
178
165
|
sso_revoke_url = opts[:sso_revoke_url]
|
179
166
|
sso_insecure = opts[:sso_insecure] || insecure
|
180
167
|
sso_ca_file = opts[:sso_ca_file] || ca_file
|
181
|
-
sso_debug = opts[:sso_debug] || debug
|
182
|
-
sso_log = opts[:sso_log] || log
|
183
168
|
sso_timeout = opts[:sso_timeout] || timeout
|
184
169
|
sso_token_name = opts[:sso_token_name] || 'access_token'
|
185
170
|
|
@@ -199,10 +184,7 @@ module OvirtSDK4
|
|
199
184
|
@kerberos = kerberos
|
200
185
|
@sso_insecure = sso_insecure
|
201
186
|
@sso_ca_file = sso_ca_file
|
202
|
-
@sso_log_file = sso_log
|
203
|
-
@sso_debug = sso_debug
|
204
187
|
@sso_timeout = sso_timeout
|
205
|
-
@log_file = log
|
206
188
|
@sso_token_name = sso_token_name
|
207
189
|
|
208
190
|
# Create the cURL handle:
|
@@ -229,35 +211,13 @@ module OvirtSDK4
|
|
229
211
|
end
|
230
212
|
|
231
213
|
# Configure debug mode:
|
232
|
-
@
|
233
|
-
if debug
|
234
|
-
if log.nil?
|
235
|
-
@log = STDOUT
|
236
|
-
elsif log.is_a?(String)
|
237
|
-
@log = ::File.open(log, 'a')
|
238
|
-
@close_log = true
|
239
|
-
else
|
240
|
-
@log = log
|
241
|
-
end
|
214
|
+
if @debug && @log
|
242
215
|
@curl.verbose = true
|
243
|
-
@curl.on_debug do |
|
244
|
-
case type
|
245
|
-
when Curl::CURLINFO_DATA_IN
|
246
|
-
prefix = '< '
|
247
|
-
when Curl::CURLINFO_DATA_OUT
|
248
|
-
prefix = '> '
|
249
|
-
when Curl::CURLINFO_HEADER_IN
|
250
|
-
prefix = '< '
|
251
|
-
when Curl::CURLINFO_HEADER_OUT
|
252
|
-
prefix = '> '
|
253
|
-
else
|
254
|
-
prefix = '* '
|
255
|
-
end
|
216
|
+
@curl.on_debug do |_, data|
|
256
217
|
lines = data.gsub("\r\n", "\n").strip.split("\n")
|
257
218
|
lines.each do |line|
|
258
|
-
@log.
|
219
|
+
@log.debug(line)
|
259
220
|
end
|
260
|
-
@log.flush
|
261
221
|
end
|
262
222
|
end
|
263
223
|
|
@@ -416,37 +376,13 @@ module OvirtSDK4
|
|
416
376
|
sso_curl.timeout = @sso_timeout
|
417
377
|
|
418
378
|
# Configure debug mode:
|
419
|
-
|
420
|
-
if @sso_debug
|
421
|
-
if @sso_log_file.nil?
|
422
|
-
sso_log = STDOUT
|
423
|
-
elsif @sso_log_file == @log_file
|
424
|
-
sso_log = @log
|
425
|
-
elsif @sso_log_file.is_a?(String)
|
426
|
-
sso_log = ::File.open(@sso_log_file, 'a')
|
427
|
-
sso_close_log = true
|
428
|
-
else
|
429
|
-
sso_log = @sso_log_file
|
430
|
-
end
|
379
|
+
if @debug && @log
|
431
380
|
sso_curl.verbose = true
|
432
|
-
sso_curl.on_debug do |
|
433
|
-
case type
|
434
|
-
when Curl::CURLINFO_DATA_IN
|
435
|
-
prefix = '< '
|
436
|
-
when Curl::CURLINFO_DATA_OUT
|
437
|
-
prefix = '> '
|
438
|
-
when Curl::CURLINFO_HEADER_IN
|
439
|
-
prefix = '< '
|
440
|
-
when Curl::CURLINFO_HEADER_OUT
|
441
|
-
prefix = '> '
|
442
|
-
else
|
443
|
-
prefix = '* '
|
444
|
-
end
|
381
|
+
sso_curl.on_debug do |_, data|
|
445
382
|
lines = data.gsub("\r\n", "\n").strip.split("\n")
|
446
383
|
lines.each do |line|
|
447
|
-
|
384
|
+
@log.debug(line)
|
448
385
|
end
|
449
|
-
sso_log.flush
|
450
386
|
end
|
451
387
|
end
|
452
388
|
|
@@ -499,10 +435,6 @@ module OvirtSDK4
|
|
499
435
|
return JSON.parse(sso_curl.body_str)
|
500
436
|
ensure
|
501
437
|
sso_curl.close
|
502
|
-
# Close the log file, if we did open it:
|
503
|
-
if sso_close_log
|
504
|
-
sso_log.close
|
505
|
-
end
|
506
438
|
end
|
507
439
|
end
|
508
440
|
|
@@ -619,11 +551,6 @@ module OvirtSDK4
|
|
619
551
|
# Revoke the SSO access token:
|
620
552
|
revoke_access_token
|
621
553
|
|
622
|
-
# Close the log file, if we did open it:
|
623
|
-
if @close_log
|
624
|
-
@log.close
|
625
|
-
end
|
626
|
-
|
627
554
|
# Release resources used by the cURL handle:
|
628
555
|
@curl.close
|
629
556
|
end
|
data/lib/ovirtsdk4/type.rb
CHANGED
@@ -39,6 +39,60 @@ module OvirtSDK4
|
|
39
39
|
@href = value
|
40
40
|
end
|
41
41
|
|
42
|
+
#
|
43
|
+
# Returns the attribute corresponding to the given set of keys, but will not generate a `NoMethodError` when
|
44
|
+
# the value corresponding to the key is `nil`, it will return `nil` instead. It is intended to simplify access
|
45
|
+
# to deeply nested attributes within an structure, and mostly copied from the Ruby 2.3 `dig` method available
|
46
|
+
# for hashes.
|
47
|
+
#
|
48
|
+
# For example, to access the alias of the first disk attached to a virtual machine that is part of an event without
|
49
|
+
# having to check for `nil` several times:
|
50
|
+
#
|
51
|
+
# [source,ruby]
|
52
|
+
# ----
|
53
|
+
# event = ...
|
54
|
+
# first_disk_id = event.dig(:vm, :disk_attachments, 0, :disk, :alias)
|
55
|
+
# ----
|
56
|
+
#
|
57
|
+
# Which is equivalent to this:
|
58
|
+
#
|
59
|
+
# [source,ruby]
|
60
|
+
# ----
|
61
|
+
# event = ...
|
62
|
+
# first_disk_id = nil
|
63
|
+
# vm = event.vm
|
64
|
+
# if !vm.nil?
|
65
|
+
# disk_attachments = vm.disk_attachments
|
66
|
+
# if !disk_attachments.nil?
|
67
|
+
# first_disk_attachment = disk_attachments[0]
|
68
|
+
# if !first_disk_attachment.nil?
|
69
|
+
# disk = first_disk_attachment.disk
|
70
|
+
# if !disk.nil?
|
71
|
+
# first_disk_id = disk.id
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
# ----
|
77
|
+
#
|
78
|
+
# @param keys [Array<Symbol, Integer>] An array of symbols corresponding to attribute names of structs, or integers
|
79
|
+
# corresponding to list indexes.
|
80
|
+
#
|
81
|
+
def dig(*keys)
|
82
|
+
current = self
|
83
|
+
keys.each do |key|
|
84
|
+
if key.is_a?(Symbol)
|
85
|
+
current = current.send(key)
|
86
|
+
elsif key.is_a?(Integer)
|
87
|
+
current = current[key]
|
88
|
+
else
|
89
|
+
raise TypeError.new("The key '#{key}' isn't a symbol or integer")
|
90
|
+
end
|
91
|
+
break if current.nil?
|
92
|
+
end
|
93
|
+
current
|
94
|
+
end
|
95
|
+
|
42
96
|
end
|
43
97
|
|
44
98
|
#
|
data/lib/ovirtsdk4/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ovirt-engine-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.alpha16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Hernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -74,6 +74,7 @@ extensions:
|
|
74
74
|
- ext/ovirtsdk4c/extconf.rb
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- CHANGES.adoc
|
77
78
|
- LICENSE.txt
|
78
79
|
- README.adoc
|
79
80
|
- ext/ovirtsdk4c/extconf.rb
|