ovirt 0.2.2 → 0.3.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: 63c172b4852f86b14fada5740c2478131f2f6010
4
- data.tar.gz: fb70dcc4727590b98ecc2fd05783b4d99bd5b2f1
3
+ metadata.gz: f4692aaa3e0f3118a4d794df4b468de40d22c9cc
4
+ data.tar.gz: 1a4443cbe30a58e4ff163bf43cad68d642a9ca15
5
5
  SHA512:
6
- metadata.gz: 9d36b7310b5e70778be4a65460067c9ee0511a04919a67399f7901876b79641ee5ad878d3c2c428333fd1e65e9207273416dcb47e886b506bbb8a4deb62b3613
7
- data.tar.gz: 9c2adee211422bcc3bf0d8650334792d7dc47bf4b5b11385b67c07a80ffb1217dfb6917ac5dc41fa373cc87ee98f388e594541187fdabc969098a46bce4ecd96
6
+ metadata.gz: ebc8be1e7aa00ab6ad93f5bdfd196c12709fcdf2882a6645c8e3b0d360e8c9c5dcbda806e7e01d7e10325e3ac86954c3232ac4b70f3b7afe6067387afc634f3b
7
+ data.tar.gz: d89c8c9f6ea61b805ba7534fa1bbd1c25da11b069c87a780211c05e712ae9355cec71e94c2c565e34cdc87537e5aa7860fe998eccf4c512584fb8bba4babb3b7
data/lib/ovirt/base.rb CHANGED
@@ -168,20 +168,20 @@ module Ovirt
168
168
  end
169
169
 
170
170
  def self.href_to_guid(href)
171
- href.split("/").last
171
+ href = href.to_s.split("/").last
172
+ href.guid? ? href : raise(ArgumentError, "href must contain a valid guid")
172
173
  end
174
+ private_class_method :href_to_guid
173
175
 
174
176
  def self.object_to_id(object)
175
177
  case object
176
178
  when Ovirt::Base
177
- object = object[:id]
179
+ object[:id]
178
180
  when String
179
- raise ArgumentError, "object must be a valid guid" unless object.guid?
180
- object = href_to_guid(object)
181
+ href_to_guid(object)
181
182
  else
182
183
  raise ArgumentError, "object must be a valid guid or an Ovirt Object"
183
184
  end
184
- object
185
185
  end
186
186
 
187
187
  def self.api_endpoint
@@ -26,11 +26,13 @@ module Ovirt
26
26
  standard_collection("domains")
27
27
  end
28
28
 
29
- def events(since = nil)
30
- if since.nil?
31
- standard_collection("events")
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)
32
34
  else
33
- standard_collection("events?from=#{since}", "event")
35
+ standard_collection("events")
34
36
  end
35
37
  end
36
38
 
@@ -94,8 +96,8 @@ module Ovirt
94
96
 
95
97
  private
96
98
 
97
- def standard_collection(uri_suffix, element_name = nil, paginate=false, sort_by=:name)
98
- @service.standard_collection(uri_suffix, element_name, paginate, sort_by)
99
+ def standard_collection(uri_suffix, element_name = nil, paginate = false, sort_by = :name, direction = :asc)
100
+ @service.standard_collection(uri_suffix, element_name, paginate, sort_by, direction)
99
101
  end
100
102
 
101
103
  # TODO: Remove this key/method translation and just use the method name as
data/lib/ovirt/service.rb CHANGED
@@ -102,9 +102,9 @@ module Ovirt
102
102
  xml_to_object(klass, doc.root)
103
103
  end
104
104
 
105
- def standard_collection(uri_suffix, element_name = nil, paginate=false, sort_by=:name)
105
+ def standard_collection(uri_suffix, element_name = nil, paginate = false, sort_by = :name, direction = :asc)
106
106
  if paginate
107
- doc = paginate_resource_get(uri_suffix, sort_by)
107
+ doc = paginate_resource_get(uri_suffix, sort_by, direction)
108
108
  else
109
109
  xml = resource_get(uri_suffix)
110
110
  doc = Nokogiri::XML(xml)
@@ -241,11 +241,10 @@ module Ovirt
241
241
  end
242
242
 
243
243
  def base_uri
244
- if port.blank?
245
- "#{scheme}://#{server}"
246
- else
247
- "#{scheme}://#{server}:#{port}"
248
- end
244
+ require 'uri'
245
+ uri = URI::Generic.build(:scheme => scheme.to_s, :port => port)
246
+ uri.hostname = server
247
+ uri.to_s
249
248
  end
250
249
 
251
250
  def resource_options
data/lib/ovirt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ovirt
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/ovirt.rb CHANGED
@@ -12,7 +12,6 @@ require 'ovirt/data_center'
12
12
  require 'ovirt/disk'
13
13
  require 'ovirt/domain'
14
14
  require 'ovirt/event'
15
- require 'ovirt/event_monitor'
16
15
  require 'ovirt/file'
17
16
  require 'ovirt/group'
18
17
  require 'ovirt/host'
data/spec/base_spec.rb CHANGED
@@ -9,4 +9,11 @@ describe Ovirt::Base do
9
9
  Ovirt::StorageDomain.api_endpoint.should == "storagedomains"
10
10
  Ovirt::DataCenter.api_endpoint.should == "datacenters"
11
11
  end
12
+
13
+ it ".href_to_guid" do
14
+ guid = "1c92b67c-9d10-4f48-85bd-28ba2fd6d9b3"
15
+ expect(Ovirt::Base.send(:href_to_guid, "/api/clusters/#{guid}")).to eq(guid)
16
+ expect(Ovirt::Base.send(:href_to_guid, guid)).to eq(guid)
17
+ expect { Ovirt::Base.send(:href_to_guid, 12345) }.to raise_error(ArgumentError)
18
+ end
12
19
  end
data/spec/service_spec.rb CHANGED
@@ -27,4 +27,39 @@ EOX
27
27
  expect { @service.resource_post('uri', 'data') }.to raise_error(Ovirt::Error, error_detail)
28
28
  end
29
29
  end
30
+
31
+ context "#base_uri" do
32
+ let(:defaults) { {:username => nil, :password => nil}}
33
+ subject { described_class.new(defaults.merge(@options)).send(:base_uri) }
34
+
35
+ it "ipv4" do
36
+ @options = {:server => "127.0.0.1"}
37
+ subject.should == "https://127.0.0.1:443"
38
+ end
39
+
40
+ it "ipv6" do
41
+ @options = {:server => "::1"}
42
+ subject.should == "https://[::1]:443"
43
+ end
44
+
45
+ it "hostname" do
46
+ @options = {:server => "nobody.com"}
47
+ subject.should == "https://nobody.com:443"
48
+ end
49
+
50
+ it "port 4443" do
51
+ @options = {:server => "nobody.com", :port => 4443}
52
+ subject.should == "https://nobody.com:4443"
53
+ end
54
+
55
+ it "blank port" do
56
+ @options = {:server => "nobody.com", :port => ""}
57
+ subject.should == "https://nobody.com"
58
+ end
59
+
60
+ it "nil port uses defaults" do
61
+ @options = {:server => "nobody.com", :port => nil}
62
+ subject.should == "https://nobody.com:443"
63
+ end
64
+ end
30
65
  end
metadata CHANGED
@@ -1,153 +1,160 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ovirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Frey
8
8
  - Brandon Dunne
9
9
  - Keenan Brock
10
+ - Joe Rafaniello
11
+ - Greg Blomquist
10
12
  autorequire:
11
13
  bindir: bin
12
14
  cert_chain: []
13
- date: 2014-11-07 00:00:00.000000000 Z
15
+ date: 2015-01-22 00:00:00.000000000 Z
14
16
  dependencies:
15
17
  - !ruby/object:Gem::Dependency
16
18
  name: bundler
17
19
  requirement: !ruby/object:Gem::Requirement
18
20
  requirements:
19
- - - ~>
21
+ - - "~>"
20
22
  - !ruby/object:Gem::Version
21
23
  version: '1.3'
22
24
  type: :development
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
25
27
  requirements:
26
- - - ~>
28
+ - - "~>"
27
29
  - !ruby/object:Gem::Version
28
30
  version: '1.3'
29
31
  - !ruby/object:Gem::Dependency
30
32
  name: rake
31
33
  requirement: !ruby/object:Gem::Requirement
32
34
  requirements:
33
- - - '>='
35
+ - - ">="
34
36
  - !ruby/object:Gem::Version
35
37
  version: '0'
36
38
  type: :development
37
39
  prerelease: false
38
40
  version_requirements: !ruby/object:Gem::Requirement
39
41
  requirements:
40
- - - '>='
42
+ - - ">="
41
43
  - !ruby/object:Gem::Version
42
44
  version: '0'
43
45
  - !ruby/object:Gem::Dependency
44
46
  name: rspec
45
47
  requirement: !ruby/object:Gem::Requirement
46
48
  requirements:
47
- - - ~>
49
+ - - "~>"
48
50
  - !ruby/object:Gem::Version
49
51
  version: '2.13'
50
52
  type: :development
51
53
  prerelease: false
52
54
  version_requirements: !ruby/object:Gem::Requirement
53
55
  requirements:
54
- - - ~>
56
+ - - "~>"
55
57
  - !ruby/object:Gem::Version
56
58
  version: '2.13'
57
59
  - !ruby/object:Gem::Dependency
58
60
  name: coveralls
59
61
  requirement: !ruby/object:Gem::Requirement
60
62
  requirements:
61
- - - '>='
63
+ - - ">="
62
64
  - !ruby/object:Gem::Version
63
65
  version: '0'
64
66
  type: :development
65
67
  prerelease: false
66
68
  version_requirements: !ruby/object:Gem::Requirement
67
69
  requirements:
68
- - - '>='
70
+ - - ">="
69
71
  - !ruby/object:Gem::Version
70
72
  version: '0'
71
73
  - !ruby/object:Gem::Dependency
72
74
  name: activesupport
73
75
  requirement: !ruby/object:Gem::Requirement
74
76
  requirements:
75
- - - '>='
77
+ - - ">="
76
78
  - !ruby/object:Gem::Version
77
79
  version: '0'
78
80
  type: :runtime
79
81
  prerelease: false
80
82
  version_requirements: !ruby/object:Gem::Requirement
81
83
  requirements:
82
- - - '>='
84
+ - - ">="
83
85
  - !ruby/object:Gem::Version
84
86
  version: '0'
85
87
  - !ruby/object:Gem::Dependency
86
88
  name: more_core_extensions
87
89
  requirement: !ruby/object:Gem::Requirement
88
90
  requirements:
89
- - - '>='
91
+ - - ">="
90
92
  - !ruby/object:Gem::Version
91
93
  version: '0'
92
94
  type: :runtime
93
95
  prerelease: false
94
96
  version_requirements: !ruby/object:Gem::Requirement
95
97
  requirements:
96
- - - '>='
98
+ - - ">="
97
99
  - !ruby/object:Gem::Version
98
100
  version: '0'
99
101
  - !ruby/object:Gem::Dependency
100
102
  name: nokogiri
101
103
  requirement: !ruby/object:Gem::Requirement
102
104
  requirements:
103
- - - '>='
105
+ - - ">="
104
106
  - !ruby/object:Gem::Version
105
107
  version: '0'
106
108
  type: :runtime
107
109
  prerelease: false
108
110
  version_requirements: !ruby/object:Gem::Requirement
109
111
  requirements:
110
- - - '>='
112
+ - - ">="
111
113
  - !ruby/object:Gem::Version
112
114
  version: '0'
113
115
  - !ruby/object:Gem::Dependency
114
116
  name: parallel
115
117
  requirement: !ruby/object:Gem::Requirement
116
118
  requirements:
117
- - - '>='
119
+ - - ">="
118
120
  - !ruby/object:Gem::Version
119
121
  version: '0'
120
122
  type: :runtime
121
123
  prerelease: false
122
124
  version_requirements: !ruby/object:Gem::Requirement
123
125
  requirements:
124
- - - '>='
126
+ - - ">="
125
127
  - !ruby/object:Gem::Version
126
128
  version: '0'
127
129
  - !ruby/object:Gem::Dependency
128
130
  name: rest-client
129
131
  requirement: !ruby/object:Gem::Requirement
130
132
  requirements:
131
- - - ~>
133
+ - - "~>"
132
134
  - !ruby/object:Gem::Version
133
135
  version: 1.7.2
134
136
  type: :runtime
135
137
  prerelease: false
136
138
  version_requirements: !ruby/object:Gem::Requirement
137
139
  requirements:
138
- - - ~>
140
+ - - "~>"
139
141
  - !ruby/object:Gem::Version
140
142
  version: 1.7.2
141
143
  description: Ovirt provides a simple Object Oriented interface to the REST API of
142
144
  oVirt and RHEV-M servers.
143
145
  email:
144
- - jfrey@redhat.com
146
+ - fryguy9@gmail.com
145
147
  - bdunne@redhat.com
146
148
  - keenan@thebrocks.net
149
+ - jrafanie@redhat.com
150
+ - gblomqui@redhat.com
147
151
  executables: []
148
152
  extensions: []
149
153
  extra_rdoc_files: []
150
154
  files:
155
+ - ".rspec"
156
+ - LICENSE.txt
157
+ - README.md
151
158
  - lib/ovirt.rb
152
159
  - lib/ovirt/api.rb
153
160
  - lib/ovirt/base.rb
@@ -157,7 +164,6 @@ files:
157
164
  - lib/ovirt/disk.rb
158
165
  - lib/ovirt/domain.rb
159
166
  - lib/ovirt/event.rb
160
- - lib/ovirt/event_monitor.rb
161
167
  - lib/ovirt/exception.rb
162
168
  - lib/ovirt/file.rb
163
169
  - lib/ovirt/group.rb
@@ -180,15 +186,12 @@ files:
180
186
  - lib/ovirt/version.rb
181
187
  - lib/ovirt/vm.rb
182
188
  - lib/ovirt/vmpool.rb
183
- - README.md
184
- - LICENSE.txt
185
189
  - spec/base_spec.rb
186
190
  - spec/event_spec.rb
187
191
  - spec/service_spec.rb
188
192
  - spec/spec_helper.rb
189
193
  - spec/template_spec.rb
190
194
  - spec/vm_spec.rb
191
- - .rspec
192
195
  homepage: http://github.com/ManageIQ/ovirt
193
196
  licenses:
194
197
  - Apache
@@ -199,17 +202,17 @@ require_paths:
199
202
  - lib
200
203
  required_ruby_version: !ruby/object:Gem::Requirement
201
204
  requirements:
202
- - - '>='
205
+ - - ">="
203
206
  - !ruby/object:Gem::Version
204
207
  version: '0'
205
208
  required_rubygems_version: !ruby/object:Gem::Requirement
206
209
  requirements:
207
- - - '>='
210
+ - - ">="
208
211
  - !ruby/object:Gem::Version
209
212
  version: '0'
210
213
  requirements: []
211
214
  rubyforge_project:
212
- rubygems_version: 2.0.14
215
+ rubygems_version: 2.2.2
213
216
  signing_key:
214
217
  specification_version: 4
215
218
  summary: Ovirt provides a simple Object Oriented interface to the REST API of oVirt
@@ -221,4 +224,5 @@ test_files:
221
224
  - spec/spec_helper.rb
222
225
  - spec/template_spec.rb
223
226
  - spec/vm_spec.rb
224
- - .rspec
227
+ - ".rspec"
228
+ has_rdoc:
@@ -1,36 +0,0 @@
1
- module Ovirt
2
- class EventMonitor
3
- def initialize(options={})
4
- @options = options
5
- end
6
-
7
- def inventory
8
- @inventory ||= Inventory.new(@options)
9
- end
10
-
11
- def start
12
- trap(:TERM) { $rhevm_log.info "EventMonitor#start: ignoring SIGTERM" }
13
- @since = nil
14
- @inventory = nil
15
- @monitor_events = true
16
- end
17
-
18
- def stop
19
- @monitor_events = false
20
- end
21
-
22
- def each_batch
23
- while @monitor_events do
24
- events = inventory.events(@since).sort_by { |e| e[:id].to_i }
25
- @since = events.last[:id].to_i unless events.empty?
26
- yield events
27
- end
28
- end
29
-
30
- def each
31
- each_batch do |events|
32
- events.each { |e| yield e }
33
- end
34
- end
35
- end
36
- end