rbovirt 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/client/disk_api.rb +15 -0
- data/lib/client/vm_api.rb +23 -1
- data/lib/ovirt/version.rb +1 -1
- data/lib/rbovirt.rb +6 -3
- data/lib/restclient_ext/resource.rb +12 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b1a09fa531efef2e54dd5c404ba08ce97a9c74
|
4
|
+
data.tar.gz: fa387d78d334b399cf9ddbb22396bb332f9ddf38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e18435aa8392a306e9fab8e37896c6d1f352ec29997443e1ae5bdef29bb919c1fc2921687a718bf9527b0d3e99590f83c1f7a49363393b7c9d649e6b0de92b3
|
7
|
+
data.tar.gz: 5ca4da6f911d4eddb41b1f49343989abb0338c85cc77bcb08ed5b41465e158e8a7615fff99bd8277f785f35b8d745943fe67fd21f60cbcb823e8b530639d0ce5
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module OVIRT
|
2
|
+
class Client
|
3
|
+
def disks(opts={})
|
4
|
+
path = "/disks" + search_url(opts)
|
5
|
+
http_get(path).xpath('/disks/disk').collect do |d|
|
6
|
+
OVIRT::Volume.new(self, d)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def disk(disk_id)
|
11
|
+
disk_xml = http_get("/disks/%s" % disk_id)
|
12
|
+
OVIRT::Volume.new(self, disk_xml.root)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/client/vm_api.rb
CHANGED
@@ -30,7 +30,6 @@ module OVIRT
|
|
30
30
|
raise BackendVersionUnsupportedException.new
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
33
|
opts[:cluster_name] ||= clusters.first.name unless opts[:cluster]
|
35
34
|
OVIRT::VM::new(self, http_post("/vms",OVIRT::VM.to_xml(opts)).root)
|
36
35
|
end
|
@@ -92,6 +91,29 @@ module OVIRT
|
|
92
91
|
http_put("/vms/%s/disks/%s" % [vm_id, vol_id], OVIRT::Volume.to_xml(opts))
|
93
92
|
end
|
94
93
|
|
94
|
+
def volume_active?(vm_id, vol_id)
|
95
|
+
http_response = http_get("/vms/%s/disks/%s" % [vm_id, vol_id, http_headers])
|
96
|
+
http_response.xpath("/disk/active").first.text.upcase == "TRUE"
|
97
|
+
end
|
98
|
+
|
99
|
+
def activate_volume(vm_id, vol_id)
|
100
|
+
http_post("/vms/%s/disks/%s/activate" % [vm_id, vol_id], '<action/>') unless volume_active?(vm_id, vol_id)
|
101
|
+
end
|
102
|
+
|
103
|
+
def deactivate_volume(vm_id, vol_id)
|
104
|
+
http_post("/vms/%s/disks/%s/deactivate" % [vm_id, vol_id], '<action/>') if volume_active?(vm_id, vol_id)
|
105
|
+
end
|
106
|
+
|
107
|
+
def attach_volume(vm_id, vol_id, activate=true)
|
108
|
+
http_post("/vms/%s/disks" % vm_id, "<disk id='%s'/>" % vol_id)
|
109
|
+
activate_volume(vm_id, vol_id) if activate
|
110
|
+
end
|
111
|
+
|
112
|
+
def detach_volume(vm_id, vol_id)
|
113
|
+
deactivate_volume(vm_id, vol_id)
|
114
|
+
http_delete("/vms/%s/disks/%s" % [vm_id, vol_id], '<action><detach>true</detach></action>')
|
115
|
+
end
|
116
|
+
|
95
117
|
def vm_action(id, action, opts={})
|
96
118
|
xml_response = http_post("/vms/%s/%s" % [id, action],'<action/>', opts)
|
97
119
|
return (xml_response/'action/status').first.text.strip.upcase=="COMPLETE"
|
data/lib/ovirt/version.rb
CHANGED
data/lib/rbovirt.rb
CHANGED
@@ -19,10 +19,12 @@ require "client/host_api"
|
|
19
19
|
require "client/datacenter_api"
|
20
20
|
require "client/storage_domain_api"
|
21
21
|
require "client/quota_api"
|
22
|
+
require "client/disk_api"
|
22
23
|
|
23
24
|
require "nokogiri"
|
24
25
|
require "rest_client"
|
25
26
|
require "restclient_ext/request"
|
27
|
+
require "restclient_ext/resource"
|
26
28
|
|
27
29
|
module OVIRT
|
28
30
|
|
@@ -131,10 +133,11 @@ module OVIRT
|
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
134
|
-
def http_delete(suburl)
|
136
|
+
def http_delete(suburl, body=nil, headers={})
|
135
137
|
begin
|
136
|
-
headers =
|
137
|
-
|
138
|
+
headers = body ? http_headers(headers) :
|
139
|
+
{:accept => 'application/xml'}.merge(auth_header).merge(filter_header)
|
140
|
+
res = rest_client(suburl).delete(body, headers)
|
138
141
|
puts "#{res}\n" if ENV['RBOVIRT_LOG_RESPONSE']
|
139
142
|
Nokogiri::XML(res)
|
140
143
|
rescue
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module RestClient
|
2
|
+
class Resource
|
3
|
+
def delete(payload, additional_headers={}, &block)
|
4
|
+
headers = (options[:headers] || {}).merge(additional_headers)
|
5
|
+
Request.execute(options.merge(
|
6
|
+
:method => :delete,
|
7
|
+
:url => url,
|
8
|
+
:payload => payload,
|
9
|
+
:headers => headers), &(block || @block))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amos Benari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- Rakefile
|
100
100
|
- lib/client/cluster_api.rb
|
101
101
|
- lib/client/datacenter_api.rb
|
102
|
+
- lib/client/disk_api.rb
|
102
103
|
- lib/client/host_api.rb
|
103
104
|
- lib/client/quota_api.rb
|
104
105
|
- lib/client/storage_domain_api.rb
|
@@ -119,6 +120,7 @@ files:
|
|
119
120
|
- lib/ovirt/volume.rb
|
120
121
|
- lib/rbovirt.rb
|
121
122
|
- lib/restclient_ext/request.rb
|
123
|
+
- lib/restclient_ext/resource.rb
|
122
124
|
- rbovirt.gemspec
|
123
125
|
- spec/endpoint.yml.example
|
124
126
|
- spec/integration/api_spec.rb
|