ovirt 0.12.1 → 0.13.0

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
  SHA1:
3
- metadata.gz: f613c2d824b0dbb9ba03acef085787bb0a173c35
4
- data.tar.gz: d3678ad7665af01b60c8b2c9bdb2e1a1c013db76
3
+ metadata.gz: c82f2d658955528e5e35c3c3eceafa20d0757168
4
+ data.tar.gz: 73b2a0d08d55af23d29d8cda5efc7d2a942b78ef
5
5
  SHA512:
6
- metadata.gz: c9acc652791095ccdaf69511f4fb51fc0b2b5a8c009ef2d68cf949c94a8848f29249f79e125f89f70811c78db247fdad41c3d4ea37412d9531f817465cdb7978
7
- data.tar.gz: 3ad7fb06019661a9899bdf3dbc058b4fc2140c4c76ecc67be09c6c1ab0253a1b7ed6b5edea07fcd008bb6be779ed5250be5c270b6a4586280523574aa65787d5
6
+ metadata.gz: 64f341695af226e85a2ed87d237e5481ace077c554f2180219665b523d27ed2148d21dfda1182189bb476c3f353f3f71a48a6063a361290af3852ed5e97db025
7
+ data.tar.gz: 7e181ac7fbdd65a6a0a123d4dabb41d55733df29b6d0850a8b3577a3e0eb04ee24e5f134e88f2d28b3b7ac8c6284698390b221f9e516e838b72fe253edb6b813
data/lib/ovirt/host.rb CHANGED
@@ -54,7 +54,7 @@ module Ovirt
54
54
 
55
55
  if has_first_node?(node, 'os/version')
56
56
  parse_first_node_with_hash(node, 'os/version', hash.store_path(:os, :version, {}),
57
- :attribute => [:full_version])
57
+ :attribute => [:full_version, :major, :minor, :build])
58
58
  end
59
59
 
60
60
  parse_first_node(node, :libvirt_version, hash,
data/lib/ovirt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ovirt
2
- VERSION = "0.12.1"
2
+ VERSION = "0.13.0"
3
3
  end
data/lib/ovirt.rb CHANGED
@@ -17,7 +17,6 @@ require 'ovirt/file'
17
17
  require 'ovirt/group'
18
18
  require 'ovirt/host'
19
19
  require 'ovirt/host_nic'
20
- require 'ovirt/inventory'
21
20
  require 'ovirt/network'
22
21
  require 'ovirt/nic'
23
22
  require 'ovirt/permission'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ovirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Frey
@@ -21,10 +21,11 @@ authors:
21
21
  - Martin Betak
22
22
  - Tomas Jelinek
23
23
  - Piotr Kliczewski
24
+ - Moti Asayag
24
25
  autorequire:
25
26
  bindir: bin
26
27
  cert_chain: []
27
- date: 2016-08-17 00:00:00.000000000 Z
28
+ date: 2016-08-23 00:00:00.000000000 Z
28
29
  dependencies:
29
30
  - !ruby/object:Gem::Dependency
30
31
  name: activesupport
@@ -138,20 +139,6 @@ dependencies:
138
139
  - - ">="
139
140
  - !ruby/object:Gem::Version
140
141
  version: 1.6.8
141
- - !ruby/object:Gem::Dependency
142
- name: parallel
143
- requirement: !ruby/object:Gem::Requirement
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- version: '0'
148
- type: :runtime
149
- prerelease: false
150
- version_requirements: !ruby/object:Gem::Requirement
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: '0'
155
142
  - !ruby/object:Gem::Dependency
156
143
  name: rest-client
157
144
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +173,7 @@ email:
186
173
  - mbetak@redhat.com
187
174
  - tjelinek@redhat.com
188
175
  - piotr.kliczewski@gmail.com
176
+ - masayag@redhat.com
189
177
  executables: []
190
178
  extensions: []
191
179
  extra_rdoc_files: []
@@ -207,7 +195,6 @@ files:
207
195
  - lib/ovirt/group.rb
208
196
  - lib/ovirt/host.rb
209
197
  - lib/ovirt/host_nic.rb
210
- - lib/ovirt/inventory.rb
211
198
  - lib/ovirt/legacy_support/cloud_init_via_floppy_payload.rb
212
199
  - lib/ovirt/logging.rb
213
200
  - lib/ovirt/network.rb
@@ -1,207 +0,0 @@
1
- module Ovirt
2
- class Inventory
3
- attr_accessor :service
4
-
5
- def initialize(options = {})
6
- @service = Service.new(options)
7
- end
8
-
9
- def api
10
- standard_collection('api').first
11
- end
12
-
13
- def capabilities
14
- standard_collection("capabilities")
15
- end
16
-
17
- def clusters
18
- standard_collection("clusters")
19
- end
20
-
21
- def datacenters
22
- standard_collection("datacenters", "data_center")
23
- end
24
-
25
- def domains
26
- standard_collection("domains")
27
- end
28
-
29
- def events(options = {})
30
- if options[:since]
31
- standard_collection("events?from=#{options[:since]}", "event")
32
- elsif options[:max]
33
- standard_collection("events;max=#{options[:max]}", "event", false, "time", :desc)
34
- else
35
- standard_collection("events")
36
- end
37
- end
38
-
39
- def groups
40
- standard_collection("groups")
41
- end
42
-
43
- def hosts
44
- standard_collection("hosts", nil, true)
45
- end
46
-
47
- def networks
48
- standard_collection("networks")
49
- end
50
-
51
- def roles
52
- standard_collection("roles")
53
- end
54
-
55
- def storagedomains
56
- standard_collection("storagedomains", "storage_domain", true)
57
- end
58
-
59
- def tags
60
- standard_collection("tags")
61
- end
62
-
63
- def templates
64
- standard_collection("templates")
65
- end
66
-
67
- def users
68
- standard_collection("users")
69
- end
70
-
71
- def vms
72
- standard_collection("vms", nil, true)
73
- end
74
-
75
- def vmpools
76
- standard_collection("vmpools")
77
- end
78
-
79
- def get_vm(path)
80
- vm_guid = ::File.basename(path, '.*')
81
- vm = get_resource_by_ems_ref("/api/vms/#{vm_guid}") rescue nil
82
- vm = get_resource_by_ems_ref("/api/templates/#{vm_guid}") if vm.blank?
83
- vm
84
- end
85
-
86
- def get_resource_by_ems_ref(uri_suffix, element_name = nil)
87
- @service.get_resource_by_ems_ref(uri_suffix, element_name)
88
- end
89
-
90
- def get_resources_by_uri_path(uri_suffix, element_name = nil)
91
- @service.get_resources_by_uri_path(uri_suffix, element_name)
92
- end
93
-
94
- def refresh
95
- # TODO: Change to not return native objects to the caller. The caller
96
- # should just expect raw data.
97
- primary_items = collect_primary_jobs(primary_item_jobs)
98
- collect_secondary_items(primary_items, SECONDARY_ITEMS)
99
- end
100
-
101
- def targeted_refresh(methods)
102
- primary_items = collect_primary_targeted_jobs(methods[:primary].to_a)
103
- collect_secondary_items(primary_items, methods[:secondary])
104
- end
105
-
106
- def api_path
107
- @service.api_path
108
- end
109
-
110
- private
111
-
112
- def standard_collection(uri_suffix, element_name = nil, paginate = false, sort_by = :name, direction = :asc)
113
- @service.standard_collection(uri_suffix, element_name, paginate, sort_by, direction)
114
- end
115
-
116
- # TODO: Remove this key/method translation and just use the method name as
117
- # the key directly.
118
- PRIMARY_ITEMS = {
119
- # Key RHEVM API method
120
- :cluster => :clusters,
121
- :vmpool => :vmpools,
122
- :network => :networks,
123
- :storage => :storagedomains,
124
- :datacenter => :datacenters,
125
- :host => :hosts,
126
- :vm => :vms,
127
- :template => :templates
128
- }
129
-
130
- SECONDARY_ITEMS = {
131
- # Key RHEVM API methods
132
- :datacenter => [:storagedomains],
133
- :host => [:statistics, :host_nics], # :cdroms, tags
134
- :vm => [:disks, :snapshots, :nics],
135
- :template => [:disks]
136
- }
137
-
138
- def primary_item_jobs
139
- PRIMARY_ITEMS.to_a
140
- end
141
-
142
- # Returns all combinations of primary resources and the methods to run on those resources.
143
- #
144
- # > secondary_item_jobs({:vm, => [v1, v2]})
145
- # => [[v1, :disks], [v1, :snapshots], [v1, :nics], [v2, :disks], [v2, :snapshots], [v2, :nics]]
146
- def secondary_item_jobs(primary_items, secondary_items)
147
- secondary_items.flat_map do |key, methods|
148
- primary_items[key].product(methods)
149
- end
150
- end
151
-
152
- def collect_primary_jobs(jobs)
153
- results = collect_in_parallel(jobs) do |_, method|
154
- send(method)
155
- end
156
-
157
- jobs.zip(results).each_with_object({}) do |((key, _), result), hash|
158
- hash[key] = result
159
- end
160
- end
161
-
162
- def collect_primary_targeted_jobs(jobs)
163
- results = collect_in_parallel(jobs) do |key, ems_ref|
164
- if ems_ref.kind_of?(Array)
165
- ems_ref.flat_map { |item| get_resources_by_uri_path(item) rescue Array.new }
166
- elsif ems_ref.kind_of?(Hash)
167
- collection, element_name = ems_ref.first
168
- standard_collection(collection, element_name, true)
169
- else
170
- get_resources_by_uri_path(ems_ref) rescue Array.new
171
- end
172
- end
173
-
174
- jobs.zip(results).each_with_object({}) do |((key, _), result), hash|
175
- hash[key] = result
176
- end
177
- end
178
-
179
- def collect_secondary_items(primary_items, secondary_items)
180
- jobs = secondary_item_jobs(primary_items, secondary_items)
181
-
182
- results = collect_in_parallel(jobs) do |resource, method|
183
- resource.send(method) rescue nil
184
- end
185
-
186
- jobs.zip(results).each do |(resource, method), result|
187
- resource.attributes[method] = result
188
- end
189
-
190
- primary_items
191
- end
192
-
193
- def collect_in_parallel(jobs, &block)
194
- require 'parallel'
195
- Parallel.map(jobs, :in_threads => num_threads, &block)
196
- end
197
-
198
- def num_threads
199
- use_threads? ? 8 : 0
200
- end
201
-
202
- # HACK: VCR is not threadsafe, and so tests running under VCR fail
203
- def use_threads?
204
- !defined?(VCR)
205
- end
206
- end
207
- end