rbovirt 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rbovirt might be problematic. Click here for more details.

data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -13,9 +13,7 @@ module OVIRT
13
13
  def parse_xml_attributes!(xml)
14
14
  @description = ((xml/'description').first.text rescue nil)
15
15
  @version = parse_version(xml)
16
- unless (xml/'data_center').empty?
17
- @datacenter = Link::new(@client, (xml/'data_center').first[:id], (xml/'data_center').first[:href])
18
- end
16
+ @datacenter = Link::new(@client, (xml/'data_center').first[:id], (xml/'data_center').first[:href]) unless (xml/'data_center').empty?
19
17
  end
20
18
 
21
19
  end
@@ -0,0 +1,21 @@
1
+ module OVIRT
2
+ class Network < BaseObject
3
+ attr_reader :description, :datacenter, :cluster, :stp
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
+
13
+ def parse_xml_attributes!(xml)
14
+ @description = ((xml/'description').first.text rescue nil)
15
+ @stp = ((xml/'stp').first.text rescue false)
16
+ @datacenter = Link::new(@client, (xml/'data_center').first[:id], (xml/'data_center').first[:href]) unless (xml/'data_center').empty?
17
+ @cluster = Link::new(@client, (xml/'cluster').first[:id], (xml/'cluster').first[:href]) unless (xml/'cluster').empty?
18
+ end
19
+
20
+ end
21
+ end
@@ -32,7 +32,7 @@ module OVIRT
32
32
  :type => (xml/'display/type').first.text,
33
33
  :monitors => (xml/'display/monitors').first.text
34
34
  }
35
- @cores = ((xml/'cpu/topology').first[:cores] rescue nil)
35
+ @cores = ((xml/'cpu/topology').first[:cores].to_i * (xml/'cpu/topology').first[:sockets].to_i rescue nil)
36
36
  @storage = ((xml/'disks/disk/size').first.text rescue nil)
37
37
  @creation_time = (xml/'creation_time').text
38
38
  @os = {
@@ -21,8 +21,8 @@ module OVIRT
21
21
  @interfaces ||= @client.interfaces(id)
22
22
  end
23
23
 
24
- def disks
25
- @disks ||= @client.disks(id)
24
+ def volumes
25
+ @volumes ||= @client.disks(id)
26
26
  end
27
27
 
28
28
  def self.to_xml( opts={})
@@ -42,9 +42,9 @@ module OVIRT
42
42
  cluster_{ name_(opts[:cluster_name])}
43
43
  end
44
44
  type_ opts[:hwp_id] || 'Server'
45
- memory opts[:hwp_memory] ? (opts[:hwp_memory].to_i*1024*1024).to_s : (512*1024*1024).to_s
45
+ memory opts[:memory] ? opts[:memory].to_s : (512*1024*1024).to_s
46
46
  cpu {
47
- topology( :cores => (opts[:hwp_cpu] || '1'), :sockets => '1' )
47
+ topology( :cores => (opts[:cores] || '1'), :sockets => '1' )
48
48
  }
49
49
  os{
50
50
  boot(:dev=>'network')
@@ -82,7 +82,7 @@ module OVIRT
82
82
  :port => ((xml/'display/port').first.text rescue nil),
83
83
  :monitors => (xml/'display/monitors').first.text
84
84
  }
85
- @cores = ((xml/'cpu/topology').first[:cores] rescue nil)
85
+ @cores = ((xml/'cpu/topology').first[:cores].to_i * (xml/'cpu/topology').first[:sockets].to_i rescue nil)
86
86
  @storage = ((xml/'disks/disk/size').first.text rescue nil)
87
87
  @creation_time = (xml/'creation_time').text
88
88
  @ip = ((xml/'guest_info/ip').first[:address] rescue nil)
@@ -7,6 +7,7 @@ require "ovirt/template"
7
7
  require "ovirt/vm"
8
8
  require "ovirt/volume"
9
9
  require "ovirt/interface"
10
+ require "ovirt/network"
10
11
 
11
12
  require "nokogiri"
12
13
  require "rest_client"
@@ -144,7 +145,14 @@ module OVIRT
144
145
  def cluster(cluster_id)
145
146
  headers = {:accept => "application/xml; detail=datacenters"}
146
147
  cluster_xml = http_get("/clusters/%s" % cluster_id, headers)
147
- OVIRT::Cluster.new(self, cluster_xml)
148
+ OVIRT::Cluster.new(self, cluster_xml.root)
149
+ end
150
+
151
+ def networks(opts)
152
+ cluster_id = opts[:cluster_id] || current_cluster.id
153
+ http_get("/clusters/%s/networks" % cluster_id, http_headers).xpath('/networks/network').collect do |cl|
154
+ OVIRT::Network.new(self, cl)
155
+ end
148
156
  end
149
157
 
150
158
  def current_datacenter
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rbovirt}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Amos Benari"]
12
- s.date = %q{2012-01-30}
12
+ s.date = %q{2012-02-01}
13
13
  s.description = %q{A Ruby client for oVirt REST API}
14
14
  s.email = %q{abenari@redhat.com}
15
15
  s.extra_rdoc_files = [
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "lib/ovirt/datacenter.rb",
29
29
  "lib/ovirt/host.rb",
30
30
  "lib/ovirt/interface.rb",
31
+ "lib/ovirt/network.rb",
31
32
  "lib/ovirt/storage_domain.rb",
32
33
  "lib/ovirt/template.rb",
33
34
  "lib/ovirt/vm.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbovirt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Amos Benari
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-30 00:00:00 +02:00
18
+ date: 2012-02-01 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -142,6 +142,7 @@ files:
142
142
  - lib/ovirt/datacenter.rb
143
143
  - lib/ovirt/host.rb
144
144
  - lib/ovirt/interface.rb
145
+ - lib/ovirt/network.rb
145
146
  - lib/ovirt/storage_domain.rb
146
147
  - lib/ovirt/template.rb
147
148
  - lib/ovirt/vm.rb