rbovirt.patch
rbovirt-0.0.15/lib/client/quota_api.rb 2013-03-08 08:49:32.853000035 -0500 | ||
---|---|---|
1 |
module OVIRT |
|
2 |
class Client |
|
3 |
def quota(quota_id, opts={}) |
|
4 |
q = http_get("/datacenters/%s/quotas/%s" % current_datacenter.id % quota_id) |
|
5 |
OVIRT::Quota::new(self, q.root) |
|
6 |
end |
|
7 | ||
8 |
def quotas(opts={}) |
|
9 |
http_get("/datacenters/%s/quotas" % CGI.escape(current_datacenter.id)).xpath('/quotas/quota').collect do |q| |
|
10 |
OVIRT::Quota::new(self, q) |
|
11 |
end.compact |
|
12 |
end |
|
13 |
end |
|
14 |
end |
rbovirt-0.0.15/lib/client/template_api.rb 2013-03-08 07:42:06.987992454 -0500 | ||
---|---|---|
34 | 34 |
end |
35 | 35 |
end |
36 | 36 |
end |
37 |
end |
|
37 |
end |
rbovirt-0.0.15/lib/ovirt/quota.rb 2013-03-08 07:27:04.575999883 -0500 | ||
---|---|---|
1 |
module OVIRT |
|
2 |
class Quota < BaseObject |
|
3 |
attr_reader :name, :description |
|
4 | ||
5 |
def initialize(client, xml) |
|
6 |
super(client, xml[:id], xml[:href], (xml/'name').first.text) |
|
7 |
parse_xml_attributes!(xml) |
|
8 |
self |
|
9 |
end |
|
10 | ||
11 |
private |
|
12 |
def parse_xml_attributes!(xml) |
|
13 |
@desciption = ((xml/'description').first.text rescue nil) |
|
14 |
end |
|
15 |
end |
|
16 |
end |
|
17 |
rbovirt-0.0.15/lib/ovirt/vm.rb 2013-03-08 09:50:22.034000077 -0500 | ||
---|---|---|
5 | 5 | |
6 | 6 |
class VM < BaseObject |
7 | 7 |
attr_reader :description, :status, :memory, :profile, :display, :host, :cluster, :template |
8 |
attr_reader :storage, :cores, :creation_time, :os, :ips, :vnc |
|
8 |
attr_reader :storage, :cores, :creation_time, :os, :ips, :vnc, :quota
|
|
9 | 9 |
attr_accessor :interfaces, :volumes |
10 | 10 | |
11 | 11 |
def initialize(client, xml) |
... | ... | |
31 | 31 |
@interfaces ||= @client.vm_interfaces(id) |
32 | 32 |
end |
33 | 33 | |
34 |
def quota |
|
35 |
@quota ||= @client.quota(id) |
|
36 |
end |
|
37 | ||
34 | 38 |
def volumes |
35 | 39 |
@volumes ||= @client.vm_volumes(id) |
36 | 40 |
end |
... | ... | |
53 | 57 |
else |
54 | 58 |
template_{name_('Blank')} |
55 | 59 |
end |
60 |
if opts[:quota] |
|
61 |
quota_( :id => opts[:quota]) |
|
62 |
end |
|
56 | 63 |
if opts[:cluster] |
57 | 64 |
cluster_( :id => opts[:cluster]) |
58 | 65 |
elsif opts[:cluster_name] |
rbovirt-0.0.15/lib/ovirt/volume.rb 2013-03-08 17:44:34.957000083 -0500 | ||
---|---|---|
1 | 1 |
module OVIRT |
2 | 2 | |
3 | 3 |
class Volume < BaseObject |
4 |
attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :status, :storage_domain, :vm |
|
4 |
attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :status, :storage_domain, :vm, :quota
|
|
5 | 5 | |
6 | 6 |
def initialize(client, xml) |
7 | 7 |
super(client, xml[:id], xml[:href], (xml/'name').first.text) |
... | ... | |
21 | 21 |
interface_(opts[:interface] || 'virtio') |
22 | 22 |
format_(opts[:format] || 'cow') |
23 | 23 |
sparse_(opts[:sparse] || 'true') |
24 |
quota_( :id => opts[:quota]) |
|
24 | 25 |
} |
25 | 26 |
end |
26 | 27 |
Nokogiri::XML(builder.to_xml).root.to_s |
... | ... | |
35 | 36 |
@format = (xml/'format').first.text |
36 | 37 |
@sparse = (xml/'sparse').first.text |
37 | 38 |
@status = (xml/'status').first.text |
38 |
@vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) |
|
39 |
@vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) rescue nil |
|
40 |
@quota = ((xml/'quota').first.text rescue nil) |
|
39 | 41 |
end |
40 | 42 | |
41 | 43 |
end |
42 |
end |
|
44 |
end |
rbovirt-0.0.15/lib/rbovirt.rb 2013-03-08 01:23:44.930000075 -0500 | ||
---|---|---|
8 | 8 |
require "ovirt/volume" |
9 | 9 |
require "ovirt/interface" |
10 | 10 |
require "ovirt/network" |
11 |
require "ovirt/quota" |
|
11 | 12 | |
12 | 13 |
require "client/vm_api" |
13 | 14 |
require "client/template_api" |
... | ... | |
15 | 16 |
require "client/host_api" |
16 | 17 |
require "client/datacenter_api" |
17 | 18 |
require "client/storage_domain_api" |
19 |
require "client/quota_api" |
|
18 | 20 | |
19 | 21 |
require "nokogiri" |
20 | 22 |
require "rest_client" |