rbovirt 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.rdoc +18 -0
- data/README.rdoc +7 -3
- data/lib/client/vm_api.rb +13 -2
- data/lib/ovirt/base_object.rb +7 -1
- data/lib/ovirt/datacenter.rb +2 -1
- data/lib/ovirt/version.rb +2 -2
- data/lib/ovirt/volume.rb +25 -12
- data/rbovirt.gemspec +2 -2
- data/spec/integration/vm_crud_spec.rb +7 -0
- data/spec/spec_helper.rb +3 -3
- data/spec/unit/vm_spec.rb +2 -2
- metadata +23 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9848bea2f871ad9d719fe767623cb5a90693e1a6
|
4
|
+
data.tar.gz: bb231cd4f28257c2bae9d76cc721be3d39e5c705
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c08516ba05303b32daeee352a0ca5230447b820bbf4e781248af4bfbc01b8dfd3cf6d9c0385fee0cfa7ad2e0a3359a377be5793ca87ab82c1d505cd457ca15a
|
7
|
+
data.tar.gz: 00b59b5b92ebdb2f889b0dc7b6e0b0745ba0dc143cfabd7ea986e4f59c747981975a316048ab88664d14d9210e4ed2578f9f83f35a91bf1aa879381917e3e0c7
|
data/CHANGES.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
== Changes
|
2
|
+
|
3
|
+
This document describes the relevant changes beween releases of the
|
4
|
+
_rbovirt_ project.
|
5
|
+
|
6
|
+
Note that this list of changes was added with the 0.0.30 release,
|
7
|
+
previous releases aren't described here.
|
8
|
+
|
9
|
+
== 0.0.30 / 2014-11-25
|
10
|
+
|
11
|
+
New features:
|
12
|
+
|
13
|
+
* Added support for updating disks.
|
14
|
+
* Added support for the data center +local+ attribute.
|
15
|
+
|
16
|
+
Bug fixes:
|
17
|
+
|
18
|
+
* Parse correctly the +status+ element.
|
data/README.rdoc
CHANGED
@@ -16,14 +16,18 @@ A Ruby client for oVirt.
|
|
16
16
|
|
17
17
|
* Copy the file spec/endpoint.yml.example to spec/endpoint.yml
|
18
18
|
* Edit the endpoint properties (user, password and host name)
|
19
|
-
* `wget --no-check-certificate -O spec/ca_cert.pem https://host/ca.crt`
|
20
19
|
* From command line run => rake spec
|
21
20
|
|
22
|
-
RHEV/oVirt can be installed with all-in-one setup, but host certificate must be
|
21
|
+
RHEV/oVirt can be installed with all-in-one setup, but host certificate must be
|
22
|
+
self-signed otherwise one test will fail.
|
23
|
+
|
24
|
+
Also note that oVirt must be configured with correct certificate (hostname must
|
25
|
+
match, must be valid and oVirt must return correct CA under /ca.crt URL).
|
23
26
|
|
24
27
|
== Logging
|
25
28
|
|
26
|
-
If you want to see API requests and responses, use the following environment
|
29
|
+
If you want to see API requests and responses, use the following environment
|
30
|
+
variables:
|
27
31
|
|
28
32
|
RESTCLIENT_LOG=stdout RBOVIRT_LOG_RESPONSE=1 rake spec
|
29
33
|
|
data/lib/client/vm_api.rb
CHANGED
@@ -73,14 +73,25 @@ module OVIRT
|
|
73
73
|
|
74
74
|
def add_volume(vm_id, opts={})
|
75
75
|
search = opts[:search] || ("datacenter=%s" % current_datacenter.name)
|
76
|
-
storage_domain_id = opts[:storage_domain] || storagedomains(:role => 'data', :search => search).first.id
|
77
|
-
|
76
|
+
opts[:storage_domain_id] = opts[:storage_domain] || storagedomains(:role => 'data', :search => search).first.id
|
77
|
+
# If no size is given, default to a volume size of 8GB
|
78
|
+
opts[:size] = 8 * 1024 * 1024 * 1024 unless opts[:size]
|
79
|
+
opts[:type] = 'data' unless opts[:type]
|
80
|
+
opts[:bootable] = 'true' unless opts[:bootable]
|
81
|
+
opts[:interface] = 'virtio' unless opts[:interface]
|
82
|
+
opts[:format] = 'cow' unless opts[:format]
|
83
|
+
opts[:sparse] = 'true' unless opts[:sparse]
|
84
|
+
http_post("/vms/%s/disks" % vm_id, OVIRT::Volume.to_xml(opts))
|
78
85
|
end
|
79
86
|
|
80
87
|
def destroy_volume(vm_id, vol_id)
|
81
88
|
http_delete("/vms/%s/disks/%s" % [vm_id, vol_id])
|
82
89
|
end
|
83
90
|
|
91
|
+
def update_volume(vm_id, vol_id, opts={})
|
92
|
+
http_put("/vms/%s/disks/%s" % [vm_id, vol_id], OVIRT::Volume.to_xml(opts))
|
93
|
+
end
|
94
|
+
|
84
95
|
def vm_action(id, action, opts={})
|
85
96
|
xml_response = http_post("/vms/%s/%s" % [id, action],'<action/>', opts)
|
86
97
|
return (xml_response/'action/status').first.text.strip.upcase=="COMPLETE"
|
data/lib/ovirt/base_object.rb
CHANGED
@@ -12,5 +12,11 @@ module OVIRT
|
|
12
12
|
def parse_version xml
|
13
13
|
(xml/'version').first[:major] +"."+ (xml/'version').first[:minor]
|
14
14
|
end
|
15
|
+
|
16
|
+
def parse_bool text
|
17
|
+
return true if text =~ /^true$/i
|
18
|
+
return false if text =~ /^false$/i
|
19
|
+
raise ArgumentError.new %Q[The string "#{text}" isn't a valid boolean, it should be "true" or "false"]
|
20
|
+
end
|
15
21
|
end
|
16
|
-
end
|
22
|
+
end
|
data/lib/ovirt/datacenter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module OVIRT
|
3
3
|
class DataCenter < BaseObject
|
4
|
-
attr_reader :description, :status, :storage_type, :storage_format, :supported_versions, :version
|
4
|
+
attr_reader :description, :status, :local, :storage_type, :storage_format, :supported_versions, :version
|
5
5
|
|
6
6
|
def initialize(client, xml)
|
7
7
|
super(client, xml[:id], xml[:href], (xml/'name').first.text)
|
@@ -14,6 +14,7 @@ module OVIRT
|
|
14
14
|
def parse_xml_attributes!(xml)
|
15
15
|
@description = (xml/'description').first.text rescue nil
|
16
16
|
@status = (xml/'status').first.text.strip
|
17
|
+
@local = parse_bool((xml/'local').first.text) rescue nil
|
17
18
|
@storage_type = (xml/'storage_type').first.text rescue nil
|
18
19
|
@storage_format = (xml/'storage_format').first.text rescue nil
|
19
20
|
@supported_versions = (xml/'supported_versions').collect { |v|
|
data/lib/ovirt/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module OVIRT
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.30"
|
3
|
+
end
|
data/lib/ovirt/volume.rb
CHANGED
@@ -9,18 +9,32 @@ module OVIRT
|
|
9
9
|
self
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.to_xml(
|
12
|
+
def self.to_xml(opts={})
|
13
13
|
builder = Nokogiri::XML::Builder.new do
|
14
14
|
disk_{
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
if opts[:storage_domain_id]
|
16
|
+
storage_domains_{
|
17
|
+
storage_domain_(:id => opts[:storage_domain_id])
|
18
|
+
}
|
19
|
+
end
|
20
|
+
if opts[:size]
|
21
|
+
size_(opts[:size])
|
22
|
+
end
|
23
|
+
if opts[:type]
|
24
|
+
type_(opts[:type])
|
25
|
+
end
|
26
|
+
if opts[:bootable]
|
27
|
+
bootable_(opts[:bootable])
|
28
|
+
end
|
29
|
+
if opts[:interface]
|
30
|
+
interface_(opts[:interface])
|
31
|
+
end
|
32
|
+
if opts[:format]
|
33
|
+
format_(opts[:format])
|
34
|
+
end
|
35
|
+
if opts[:sparse]
|
36
|
+
sparse_(opts[:sparse])
|
37
|
+
end
|
24
38
|
if opts[:quota]
|
25
39
|
quota_( :id => opts[:quota])
|
26
40
|
end
|
@@ -37,8 +51,7 @@ module OVIRT
|
|
37
51
|
@interface = (xml/'interface').first.text
|
38
52
|
@format = ((xml/'format').first.text rescue nil)
|
39
53
|
@sparse = ((xml/'sparse').first.text rescue nil)
|
40
|
-
@status = ((xml/'status').first.text rescue nil)
|
41
|
-
@status ||= ((xml/'status/state').first.text rescue nil)
|
54
|
+
@status = ((xml/'status/state').first.text rescue nil)
|
42
55
|
@vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) rescue nil
|
43
56
|
@quota = ((xml/'quota').first[:id] rescue nil)
|
44
57
|
end
|
data/rbovirt.gemspec
CHANGED
@@ -26,5 +26,5 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_development_dependency('rake')
|
27
27
|
|
28
28
|
gem.rdoc_options << '--title' << gem.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
|
29
|
-
gem.extra_rdoc_files = ['README.rdoc']
|
30
|
-
end
|
29
|
+
gem.extra_rdoc_files = ['README.rdoc', 'CHANGES.rdoc']
|
30
|
+
end
|
@@ -66,6 +66,13 @@ shared_examples_for "Basic VM Life cycle" do
|
|
66
66
|
vm.class.to_s.should eql("OVIRT::VM")
|
67
67
|
@client.destroy_vm(vm.id)
|
68
68
|
end
|
69
|
+
|
70
|
+
it "test_should_update_volume" do
|
71
|
+
@client.update_volume(@vm.id, @vm.volumes.first.id, :size => 10737418240)
|
72
|
+
while @client.vm(@vm.id).volumes.first.status != 'ok' do
|
73
|
+
end
|
74
|
+
@client.vm(@vm.id).volumes.first.size.should eql("10737418240")
|
75
|
+
end
|
69
76
|
end
|
70
77
|
|
71
78
|
shared_examples_for "VM Life cycle without template" do
|
data/spec/spec_helper.rb
CHANGED
@@ -19,9 +19,9 @@ module OVIRT::RSpec
|
|
19
19
|
|
20
20
|
def setup_client(options = {})
|
21
21
|
user, password, url, datacenter = endpoint
|
22
|
-
|
23
|
-
|
24
|
-
}
|
22
|
+
cert = ca_cert(url)
|
23
|
+
store = OpenSSL::X509::Store.new().add_cert(OpenSSL::X509::Certificate.new(cert))
|
24
|
+
opts = { :ca_cert_store => store }
|
25
25
|
@client = ::OVIRT::Client.new(user, password, url, opts)
|
26
26
|
datacenter_id = @client.datacenters.find{|x| x.name == datacenter}.id rescue raise("Cannot find datacenter #{datacenter}")
|
27
27
|
opts.merge!(:datacenter_id => datacenter_id)
|
data/spec/unit/vm_spec.rb
CHANGED
@@ -171,7 +171,7 @@ END_HEREDOC
|
|
171
171
|
|
172
172
|
before(:each) do
|
173
173
|
@mock_client = double("mock_client")
|
174
|
-
|
174
|
+
@mock_client.stub(:vm_interfaces) do
|
175
175
|
xml = <<END_HEREDOC
|
176
176
|
<nic href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012" id="12345678-1234-1234-1234-123456789012">
|
177
177
|
<actions>
|
@@ -190,7 +190,7 @@ END_HEREDOC
|
|
190
190
|
END_HEREDOC
|
191
191
|
[OVIRT::Interface::new(nil, Nokogiri::XML(xml).xpath('/').first)]
|
192
192
|
end
|
193
|
-
|
193
|
+
@mock_client.stub(:vm_volumes) do
|
194
194
|
xml = <<END_HEREDOC
|
195
195
|
<disk href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012" id="12345678-1234-1234-1234-123456789012">
|
196
196
|
<actions>
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbovirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amos Benari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rest-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: shoulda
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.6'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.6'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: |2
|
@@ -88,9 +88,11 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files:
|
90
90
|
- README.rdoc
|
91
|
+
- CHANGES.rdoc
|
91
92
|
files:
|
92
|
-
-
|
93
|
-
-
|
93
|
+
- .document
|
94
|
+
- .gitignore
|
95
|
+
- CHANGES.rdoc
|
94
96
|
- Gemfile
|
95
97
|
- LICENSE.txt
|
96
98
|
- README.rdoc
|
@@ -128,27 +130,27 @@ licenses: []
|
|
128
130
|
metadata: {}
|
129
131
|
post_install_message:
|
130
132
|
rdoc_options:
|
131
|
-
-
|
133
|
+
- --title
|
132
134
|
- rbovirt
|
133
|
-
-
|
135
|
+
- --main
|
134
136
|
- README.rdoc
|
135
|
-
-
|
136
|
-
-
|
137
|
+
- --line-numbers
|
138
|
+
- --inline-source
|
137
139
|
require_paths:
|
138
140
|
- lib
|
139
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
142
|
requirements:
|
141
|
-
- -
|
143
|
+
- - '>='
|
142
144
|
- !ruby/object:Gem::Version
|
143
145
|
version: '0'
|
144
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
147
|
requirements:
|
146
|
-
- -
|
148
|
+
- - '>='
|
147
149
|
- !ruby/object:Gem::Version
|
148
150
|
version: '0'
|
149
151
|
requirements: []
|
150
152
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.1.11
|
152
154
|
signing_key:
|
153
155
|
specification_version: 4
|
154
156
|
summary: A Ruby client for oVirt REST API
|