rbovirt 0.0.21 → 0.0.22

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.

@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66f25b02a4d111b071e462bea72d9e77520b6dd1
4
+ data.tar.gz: 54b4faa6d9047cd217cce97992b72697a6cfe542
5
+ SHA512:
6
+ metadata.gz: 297ff6778ae94e0d29d8dbb42d9cc3927278ccd7c1bfdf34e5458026e58ae744ade61b49b0e21d6461635d7f28b997ef51746677cc9f958faf96aa02646b9e07
7
+ data.tar.gz: 788f983b0f7d1db2baf583a2cb35f965cc4da9e482a975b39e8dbef1ba42b87ce9e7a24b78ddef25523d00a0a8b8576d68e751252318695d591f84b1e5068674
@@ -0,0 +1,54 @@
1
+ Gemfile.lock
2
+ endpoint.yml
3
+
4
+ # rcov generated
5
+ coverage
6
+
7
+ # rdoc generated
8
+ rdoc
9
+
10
+ # yard generated
11
+ doc
12
+ .yardoc
13
+
14
+ # bundler
15
+ .bundle
16
+
17
+ # idea
18
+ .idea
19
+
20
+ # jeweler generated
21
+ pkg
22
+
23
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
24
+ #
25
+ # * Create a file at ~/.gitignore
26
+ # * Include files you want ignored
27
+ # * Run: git config --global core.excludesfile ~/.gitignore
28
+ #
29
+ # After doing this, these files will be ignored in all your git projects,
30
+ # saving you from having to 'pollute' every project you touch with them
31
+ #
32
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
33
+ #
34
+ # For MacOS:
35
+ #
36
+ #.DS_Store
37
+
38
+ # For TextMate
39
+ #*.tmproj
40
+ #tmtags
41
+
42
+ # For emacs:
43
+ #*~
44
+ #\#*
45
+ #.\#*
46
+
47
+ # For vim:
48
+ #*.swp
49
+
50
+ # For redcar:
51
+ #.redcar
52
+
53
+ # For rubinius:
54
+ #*.rbc
data/Gemfile CHANGED
@@ -4,13 +4,15 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  gem "nokogiri"
6
6
  gem "rest-client"
7
+ gem "rdoc"
8
+ gem "rspec"
7
9
 
8
10
  # Add dependencies to develop your gem here.
9
11
  # Include everything needed to run rake, tests, features, etc.
10
12
  group :development do
11
13
  gem "shoulda", ">= 0"
12
- gem "bundler", "~> 1.0.0"
14
+ gem "bundler", "> 1.0.0"
13
15
  gem "jeweler", "~> 1.6.4"
14
- gem "rcov", ">= 0"
16
+ gem "rcov", "<= 0.9.11"
15
17
  gem "rspec-rails", "~> 2.6"
16
18
  end
data/Rakefile CHANGED
@@ -1,60 +1,9 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "rbovirt"
18
- gem.homepage = "http://github.com/abenari/rbovirt"
19
- gem.license = "MIT"
20
- gem.summary = %Q{A Ruby client for oVirt REST API}
21
- gem.description = %Q{A Ruby client for oVirt REST API}
22
- gem.email = "abenari@redhat.com"
23
- gem.authors = ["Amos Benari"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |test|
30
- test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
33
- end
34
-
1
+ require "bundler/gem_tasks"
35
2
  require 'rspec/core/rake_task'
36
- RSpec::Core::RakeTask.new(:spec) do |test|
37
- #test.libs << 'lib' << 'spec'
38
- test.pattern = 'spec/**/*_spec.rb'
39
- test.verbose = true
40
- end
41
3
 
42
- require 'rcov/rcovtask'
43
- Rcov::RcovTask.new do |test|
44
- test.libs << 'test'
45
- test.pattern = 'test/**/test_*.rb'
46
- test.verbose = true
47
- test.rcov_opts << '--exclude "gems/*"'
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.pattern = "./spec/**/*_spec.rb"
6
+ task.rspec_opts = ['--color']
48
7
  end
49
8
 
50
- task :default => :test
51
-
52
- require 'rake/rdoctask'
53
- Rake::RDocTask.new do |rdoc|
54
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
55
-
56
- rdoc.rdoc_dir = 'rdoc'
57
- rdoc.title = "rbovirt #{version}"
58
- rdoc.rdoc_files.include('README*')
59
- rdoc.rdoc_files.include('lib/**/*.rb')
60
- end
9
+ task :default => :spec
@@ -1,7 +1,7 @@
1
1
  module OVIRT
2
2
  class Client
3
3
  def quota(quota_id, opts={})
4
- q = http_get("/datacenters/%s/quotas/%s" % current_datacenter.id % quota_id)
4
+ q = http_get("/datacenters/%s/quotas/%s" % [current_datacenter.id, quota_id])
5
5
  OVIRT::Quota::new(self, q.root)
6
6
  end
7
7
 
@@ -14,7 +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
- @storage_type = (xml/'storage_type').first.text
17
+ @storage_type = (xml/'storage_type').first.text rescue nil
18
18
  @storage_format = (xml/'storage_format').first.text rescue nil
19
19
  @supported_versions = (xml/'supported_versions').collect { |v|
20
20
  parse_version v
@@ -23,4 +23,4 @@ module OVIRT
23
23
  end
24
24
  end
25
25
 
26
- end
26
+ end
@@ -0,0 +1,3 @@
1
+ module OVIRT
2
+ VERSION = "0.0.22"
3
+ end
@@ -74,17 +74,18 @@ module OVIRT
74
74
  topology( :cores => (opts[:cores] || '1'), :sockets => '1' )
75
75
  }
76
76
  end
77
- if(opts[:first_boot_dev] && opts[:first_boot_dev] == 'network')
78
- os{
77
+ os({:type => opts[:os_type] || 'unassigned' }){
78
+ if(opts[:first_boot_dev] && opts[:first_boot_dev] == 'network')
79
79
  boot(:dev=> opts[:boot_dev1] || 'network')
80
80
  boot(:dev=> opts[:boot_dev2] || 'hd')
81
- }
82
- else
83
- os{
81
+ else
84
82
  boot(:dev=> opts[:boot_dev2] || 'hd')
85
83
  boot(:dev=> opts[:boot_dev1] || 'network')
86
- }
87
- end
84
+ end
85
+ kernel (opts[:os_kernel])
86
+ initrd (opts[:os_initrd])
87
+ cmdline (opts[:os_cmdline])
88
+ }
88
89
  display_{
89
90
  type_(opts[:display][:type])
90
91
  } if opts[:display]
@@ -135,6 +136,12 @@ module OVIRT
135
136
  :boot => (xml/'os/boot').collect {|boot| boot[:dev] }
136
137
  }
137
138
  @quota = ((xml/'quota').first[:id] rescue nil)
139
+
140
+ disks = xml/'disks/disk'
141
+ @volumes = disks.length > 0 ? disks.collect {|disk| OVIRT::Volume::new(@client, disk)} : nil
142
+
143
+ interfaces = xml/'nics/nic'
144
+ @interfaces = interfaces.length > 0 ? interfaces.collect {|nic| OVIRT::Interface::new(@client, nic)} : nil
138
145
  end
139
146
 
140
147
  end
@@ -21,7 +21,9 @@ module OVIRT
21
21
  interface_(opts[:interface] || 'virtio')
22
22
  format_(opts[:format] || 'cow')
23
23
  sparse_(opts[:sparse] || 'true')
24
- quota_( :id => opts[:quota])
24
+ if opts[:quota]
25
+ quota_( :id => opts[:quota])
26
+ end
25
27
  }
26
28
  end
27
29
  Nokogiri::XML(builder.to_xml).root.to_s
@@ -9,6 +9,7 @@ require "ovirt/volume"
9
9
  require "ovirt/interface"
10
10
  require "ovirt/network"
11
11
  require "ovirt/quota"
12
+ require "ovirt/version"
12
13
 
13
14
  require "client/vm_api"
14
15
  require "client/template_api"
@@ -133,10 +134,10 @@ module OVIRT
133
134
  end
134
135
 
135
136
  def http_headers(headers ={})
136
- headers.merge({
137
+ filter_header.merge(auth_header).merge({
137
138
  :content_type => 'application/xml',
138
139
  :accept => 'application/xml',
139
- }).merge(auth_header).merge(filter_header)
140
+ }).merge(headers)
140
141
  end
141
142
 
142
143
  def handle_fault(f)
@@ -1,89 +1,30 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ovirt/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "rbovirt"
8
- s.version = "0.0.21"
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rbovirt"
8
+ gem.version = OVIRT::VERSION
9
+ gem.authors = ['Amos Benari']
10
+ gem.email = ['abenari@redhat.com']
11
+ gem.homepage = "http://github.com/abenari/rbovirt"
12
+ gem.summary = %q{A Ruby client for oVirt REST API}
13
+ gem.description = <<-EOS
14
+ A Ruby client for oVirt REST API
15
+ EOS
9
16
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Amos Benari"]
12
- s.date = "2013-07-22"
13
- s.description = "A Ruby client for oVirt REST API"
14
- s.email = "abenari@redhat.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "LICENSE.txt",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/client/cluster_api.rb",
27
- "lib/client/datacenter_api.rb",
28
- "lib/client/host_api.rb",
29
- "lib/client/quota_api.rb",
30
- "lib/client/storage_domain_api.rb",
31
- "lib/client/template_api.rb",
32
- "lib/client/vm_api.rb",
33
- "lib/ovirt/base_object.rb",
34
- "lib/ovirt/cluster.rb",
35
- "lib/ovirt/datacenter.rb",
36
- "lib/ovirt/host.rb",
37
- "lib/ovirt/interface.rb",
38
- "lib/ovirt/network.rb",
39
- "lib/ovirt/quota.rb",
40
- "lib/ovirt/storage_domain.rb",
41
- "lib/ovirt/template.rb",
42
- "lib/ovirt/vm.rb",
43
- "lib/ovirt/volume.rb",
44
- "lib/rbovirt.rb",
45
- "rbovirt.gemspec",
46
- "spec/endpoint.yml.example",
47
- "spec/integration/api_spec.rb",
48
- "spec/integration/vm_crud_spec.rb",
49
- "spec/lib/endpoint.rb",
50
- "spec/spec_helper.rb",
51
- "spec/unit/vm_spec.rb"
52
- ]
53
- s.homepage = "http://github.com/abenari/rbovirt"
54
- s.licenses = ["MIT"]
55
- s.require_paths = ["lib"]
56
- s.rubygems_version = "1.8.24"
57
- s.summary = "A Ruby client for oVirt REST API"
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
58
21
 
59
- if s.respond_to? :specification_version then
60
- s.specification_version = 3
61
-
62
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
- s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
64
- s.add_runtime_dependency(%q<rest-client>, [">= 0"])
65
- s.add_development_dependency(%q<shoulda>, [">= 0"])
66
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
67
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
68
- s.add_development_dependency(%q<rcov>, [">= 0"])
69
- s.add_development_dependency(%q<rspec-rails>, ["~> 2.6"])
70
- else
71
- s.add_dependency(%q<nokogiri>, [">= 0"])
72
- s.add_dependency(%q<rest-client>, [">= 0"])
73
- s.add_dependency(%q<shoulda>, [">= 0"])
74
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
76
- s.add_dependency(%q<rcov>, [">= 0"])
77
- s.add_dependency(%q<rspec-rails>, ["~> 2.6"])
78
- end
79
- else
80
- s.add_dependency(%q<nokogiri>, [">= 0"])
81
- s.add_dependency(%q<rest-client>, [">= 0"])
82
- s.add_dependency(%q<shoulda>, [">= 0"])
83
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
84
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
85
- s.add_dependency(%q<rcov>, [">= 0"])
86
- s.add_dependency(%q<rspec-rails>, ["~> 2.6"])
87
- end
88
- end
22
+ gem.add_runtime_dependency('nokogiri')
23
+ gem.add_runtime_dependency('rest-client')
24
+ gem.add_development_dependency('shoulda')
25
+ gem.add_development_dependency('rspec-rails', '~> 2.6')
26
+ gem.add_development_dependency('rake')
89
27
 
28
+ gem.rdoc_options << '--title' << gem.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
29
+ gem.extra_rdoc_files = ['README.rdoc']
30
+ end
@@ -2,6 +2,7 @@
2
2
  #require 'bundler/setup'
3
3
 
4
4
  require 'rspec'
5
+ require 'rspec/mocks'
5
6
  require 'rbovirt'
6
7
 
7
8
  module OVIRT::RSpec end
@@ -10,4 +11,4 @@ require "#{File.dirname(__FILE__)}/lib/endpoint"
10
11
 
11
12
  RSpec.configure do |config|
12
13
  config.include OVIRT::RSpec::Endpoint
13
- end
14
+ end
@@ -0,0 +1,21 @@
1
+ require "#{File.dirname(__FILE__)}/../spec_helper"
2
+
3
+ describe OVIRT::Client do
4
+
5
+ context 'http comms' do
6
+ before(:each) do
7
+ @sut = OVIRT::Client::new('mockuser','mockpass','http://example.com/api')
8
+ end
9
+
10
+ it "should add Accept: headers" do
11
+ headers = @sut.send(:http_headers)
12
+ headers[:accept].should eql('application/xml')
13
+ end
14
+
15
+ it "should keep existing Accept: headers" do
16
+ value = "application/xml; detail=disks; detail=nics; detail=hosts"
17
+ headers = @sut.send(:http_headers, {:accept => value})
18
+ headers[:accept].should eql(value)
19
+ end
20
+ end
21
+ end
@@ -27,6 +27,48 @@ describe OVIRT::VM do
27
27
  <link rel="tags" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/tags"/>
28
28
  <link rel="permissions" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/permissions"/>
29
29
  <link rel="statistics" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/statistics"/>
30
+ <nics>
31
+ <nic href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012" id="12345678-1234-1234-1234-123456789012">
32
+ <actions>
33
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/deactivate" id="deactivate"/>
34
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/activate" id="activate"/>
35
+ </actions>
36
+ <name>nic1</name>
37
+ <vm href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549" id="76d29095-bc27-4cd0-8178-07e942aea549"/>
38
+ <network href="/api/networks/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
39
+ <linked>true</linked>
40
+ <interface>virtio</interface>
41
+ <mac address="00:11:22:33:44:55"/>
42
+ <active>true</active>
43
+ <plugged>true</plugged>
44
+ </nic>
45
+ </nics>
46
+ <disks>
47
+ <disk href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012" id="12345678-1234-1234-1234-123456789012">
48
+ <actions>
49
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/deactivate" id="deactivate"/>
50
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/move" id="move"/>
51
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/activate" id="activate"/>
52
+ </actions>
53
+ <name>diskName</name>
54
+ <image_id>00000000-0000-0000-0000-000000000000</image_id>
55
+ <storage_domains>
56
+ <storage_domain id="11111111-1111-1111-1111-111111111111"/>
57
+ </storage_domains>
58
+ <size>53687091200</size>
59
+ <provisioned_size>53687091200</provisioned_size>
60
+ <actual_size>143360</actual_size>
61
+ <status><state>ok</state></status>
62
+ <interface>virtio</interface>
63
+ <format>cow</format>
64
+ <sparse>true</sparse>
65
+ <bootable>true</bootable>
66
+ <shareable>false</shareable>
67
+ <wipe_after_delete>false</wipe_after_delete>
68
+ <propagate_errors>false</propagate_errors>
69
+ <active>true</active>
70
+ </disk>
71
+ </disks>
30
72
  <type>server</type>
31
73
  <status>
32
74
  <state>up</state>
@@ -64,6 +106,119 @@ describe OVIRT::VM do
64
106
  </usb>
65
107
  </vm>
66
108
  END_HEREDOC
109
+
110
+ @min_xml = <<END_HEREDOC
111
+ <vm id="76d29095-bc27-4cd0-8178-07e942aea549" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549">
112
+ <name>c-1326980484</name>
113
+ <actions>
114
+ <link rel="shutdown" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/shutdown"/>
115
+ <link rel="start" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/start"/>
116
+ <link rel="stop" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/stop"/>
117
+ <link rel="suspend" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/suspend"/>
118
+ <link rel="detach" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/detach"/>
119
+ <link rel="export" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/export"/>
120
+ <link rel="move" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/move"/>
121
+ <link rel="ticket" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/ticket"/>
122
+ <link rel="migrate" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/migrate"/>
123
+ <link rel="cancelmigration" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/cancelmigration"/>
124
+ </actions>
125
+ <link rel="disks" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/disks"/>
126
+ <link rel="nics" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics"/>
127
+ <link rel="cdroms" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/cdroms"/>
128
+ <link rel="snapshots" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/snapshots"/>
129
+ <link rel="tags" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/tags"/>
130
+ <link rel="permissions" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/permissions"/>
131
+ <link rel="statistics" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/statistics"/>
132
+ <type>server</type>
133
+ <status>
134
+ <state>up</state>
135
+ </status>
136
+ <memory>536870912</memory>
137
+ <cpu>
138
+ <topology cores="1" sockets="1"/>
139
+ </cpu>
140
+ <os type="unassigned">
141
+ <boot dev="network"/>
142
+ <boot dev="hd"/>
143
+ </os>
144
+ <high_availability>
145
+ <enabled>false</enabled>
146
+ <priority>0</priority>
147
+ </high_availability>
148
+ <display>
149
+ <type>vnc</type>
150
+ <monitors>1</monitors>
151
+ </display>
152
+ <cluster id="b68980dc-3ab8-11e1-bcbf-5254005f0f6f" href="/api/clusters/b68980dc-3ab8-11e1-bcbf-5254005f0f6f"/>
153
+ <template id="00000000-0000-0000-0000-000000000000" href="/api/templates/00000000-0000-0000-0000-000000000000"/>
154
+ <start_time>2012-01-19T14:41:58.428Z</start_time>
155
+ <creation_time>2012-01-19T13:41:24.405Z</creation_time>
156
+ <origin>rhev</origin>
157
+ <stateless>false</stateless>
158
+ <placement_policy>
159
+ <affinity>migratable</affinity>
160
+ </placement_policy>
161
+ <memory_policy>
162
+ <guaranteed>536870912</guaranteed>
163
+ </memory_policy>
164
+ <usb>
165
+ <enabled>true</enabled>
166
+ </usb>
167
+ </vm>
168
+ END_HEREDOC
169
+
170
+ end
171
+
172
+ before(:each) do
173
+ @mock_client = double("mock_client")
174
+ allow(@mock_client).to receive(:vm_interfaces) do
175
+ xml = <<END_HEREDOC
176
+ <nic href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012" id="12345678-1234-1234-1234-123456789012">
177
+ <actions>
178
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/deactivate" id="deactivate"/>
179
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/activate" id="activate"/>
180
+ </actions>
181
+ <name>nic2</name>
182
+ <vm href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549" id="76d29095-bc27-4cd0-8178-07e942aea549"/>
183
+ <network href="/api/networks/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
184
+ <linked>true</linked>
185
+ <interface>virtio</interface>
186
+ <mac address="00:11:22:33:44:55"/>
187
+ <active>true</active>
188
+ <plugged>true</plugged>
189
+ </nic>
190
+ END_HEREDOC
191
+ [OVIRT::Interface::new(nil, Nokogiri::XML(xml).xpath('/').first)]
192
+ end
193
+ allow(@mock_client).to receive(:vm_volumes) do
194
+ xml = <<END_HEREDOC
195
+ <disk href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012" id="12345678-1234-1234-1234-123456789012">
196
+ <actions>
197
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/deactivate" id="deactivate"/>
198
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/move" id="move"/>
199
+ <link href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics/12345678-1234-1234-1234-123456789012/activate" id="activate"/>
200
+ </actions>
201
+ <name>diskName2</name>
202
+ <image_id>00000000-0000-0000-0000-000000000000</image_id>
203
+ <storage_domains>
204
+ <storage_domain id="11111111-1111-1111-1111-111111111111"/>
205
+ </storage_domains>
206
+ <size>53687091200</size>
207
+ <provisioned_size>53687091200</provisioned_size>
208
+ <actual_size>143360</actual_size>
209
+ <status><state>ok</state></status>
210
+ <interface>virtio</interface>
211
+ <format>cow</format>
212
+ <sparse>true</sparse>
213
+ <bootable>true</bootable>
214
+ <shareable>false</shareable>
215
+ <wipe_after_delete>false</wipe_after_delete>
216
+ <propagate_errors>false</propagate_errors>
217
+ <active>true</active>
218
+ </disk>
219
+ END_HEREDOC
220
+ [OVIRT::Volume::new(nil, Nokogiri::XML(xml).xpath('/').first)]
221
+ end
67
222
  end
68
223
 
69
224
  it "should parse VM xml" do
@@ -82,7 +237,34 @@ END_HEREDOC
82
237
  vm.running?.should eql(true)
83
238
  end
84
239
 
240
+ it "should have one interface" do
241
+ vm = OVIRT::VM.new(nil, Nokogiri::XML(@xml).xpath('/').first)
242
+ vm.interfaces.length.should eql(1)
243
+
244
+ interface = vm.interfaces[0]
245
+ interface.name.should eql('nic1')
246
+ interface.mac.should eql('00:11:22:33:44:55')
247
+ interface.interface.should eql('virtio')
248
+ end
249
+
250
+ it "should have one volume" do
251
+ vm = OVIRT::VM.new(nil, Nokogiri::XML(@xml).xpath('/').first)
252
+ vm.volumes.length.should eql(1)
253
+
254
+ disk = vm.volumes[0]
255
+ disk.storage_domain.should eql('11111111-1111-1111-1111-111111111111')
256
+ disk.size.should eql('53687091200')
257
+ disk.interface.should eql('virtio')
258
+ end
85
259
 
260
+ it "should still fallback to the client" do
261
+ vm = OVIRT::VM.new(@mock_client, Nokogiri::XML(@min_xml).xpath('/').first)
262
+ vm.volumes.length.should eql(1)
263
+ vm.volumes[0].name.should eql('diskName2')
264
+
265
+ vm.interfaces.length.should eql(1)
266
+ vm.interfaces[0].name.should eql('nic2')
267
+ end
86
268
  end
87
269
 
88
270
  end
metadata CHANGED
@@ -1,136 +1,96 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rbovirt
3
- version: !ruby/object:Gem::Version
4
- hash: 53
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 21
10
- version: 0.0.21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.22
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Amos Benari
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-07-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
23
20
  type: :runtime
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- requirement: *id001
34
- - !ruby/object:Gem::Dependency
35
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
36
28
  name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
37
34
  type: :runtime
38
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
47
- requirement: *id002
48
- - !ruby/object:Gem::Dependency
49
35
  prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
50
42
  name: shoulda
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
51
48
  type: :development
52
- version_requirements: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
61
- requirement: *id003
62
- - !ruby/object:Gem::Dependency
63
49
  prerelease: false
64
- name: bundler
65
- type: :development
66
- version_requirements: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
69
59
  - - ~>
70
- - !ruby/object:Gem::Version
71
- hash: 23
72
- segments:
73
- - 1
74
- - 0
75
- - 0
76
- version: 1.0.0
77
- requirement: *id004
78
- - !ruby/object:Gem::Dependency
79
- prerelease: false
80
- name: jeweler
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
81
62
  type: :development
82
- version_requirements: &id005 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ~>
86
- - !ruby/object:Gem::Version
87
- hash: 7
88
- segments:
89
- - 1
90
- - 6
91
- - 4
92
- version: 1.6.4
93
- requirement: *id005
94
- - !ruby/object:Gem::Dependency
95
63
  prerelease: false
96
- name: rcov
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
97
76
  type: :development
98
- version_requirements: &id006 !ruby/object:Gem::Requirement
99
- none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
107
- requirement: *id006
108
- - !ruby/object:Gem::Dependency
109
77
  prerelease: false
110
- name: rspec-rails
111
- type: :development
112
- version_requirements: &id007 !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- hash: 15
118
- segments:
119
- - 2
120
- - 6
121
- version: "2.6"
122
- requirement: *id007
123
- description: A Ruby client for oVirt REST API
124
- email: abenari@redhat.com
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |2
84
+ A Ruby client for oVirt REST API
85
+ email:
86
+ - abenari@redhat.com
125
87
  executables: []
126
-
127
88
  extensions: []
128
-
129
- extra_rdoc_files:
130
- - LICENSE.txt
89
+ extra_rdoc_files:
131
90
  - README.rdoc
132
- files:
91
+ files:
133
92
  - .document
93
+ - .gitignore
134
94
  - Gemfile
135
95
  - LICENSE.txt
136
96
  - README.rdoc
@@ -152,6 +112,7 @@ files:
152
112
  - lib/ovirt/quota.rb
153
113
  - lib/ovirt/storage_domain.rb
154
114
  - lib/ovirt/template.rb
115
+ - lib/ovirt/version.rb
155
116
  - lib/ovirt/vm.rb
156
117
  - lib/ovirt/volume.rb
157
118
  - lib/rbovirt.rb
@@ -161,39 +122,43 @@ files:
161
122
  - spec/integration/vm_crud_spec.rb
162
123
  - spec/lib/endpoint.rb
163
124
  - spec/spec_helper.rb
125
+ - spec/unit/client_spec.rb
164
126
  - spec/unit/vm_spec.rb
165
127
  homepage: http://github.com/abenari/rbovirt
166
- licenses:
167
- - MIT
128
+ licenses: []
129
+ metadata: {}
168
130
  post_install_message:
169
- rdoc_options: []
170
-
171
- require_paths:
131
+ rdoc_options:
132
+ - --title
133
+ - rbovirt
134
+ - --main
135
+ - README.rdoc
136
+ - --line-numbers
137
+ - --inline-source
138
+ require_paths:
172
139
  - lib
173
- required_ruby_version: !ruby/object:Gem::Requirement
174
- none: false
175
- requirements:
176
- - - ">="
177
- - !ruby/object:Gem::Version
178
- hash: 3
179
- segments:
180
- - 0
181
- version: "0"
182
- required_rubygems_version: !ruby/object:Gem::Requirement
183
- none: false
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- hash: 3
188
- segments:
189
- - 0
190
- version: "0"
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
191
150
  requirements: []
192
-
193
151
  rubyforge_project:
194
- rubygems_version: 1.8.24
152
+ rubygems_version: 2.0.14
195
153
  signing_key:
196
- specification_version: 3
154
+ specification_version: 4
197
155
  summary: A Ruby client for oVirt REST API
198
- test_files: []
199
-
156
+ test_files:
157
+ - spec/endpoint.yml.example
158
+ - spec/integration/api_spec.rb
159
+ - spec/integration/vm_crud_spec.rb
160
+ - spec/lib/endpoint.rb
161
+ - spec/spec_helper.rb
162
+ - spec/unit/client_spec.rb
163
+ - spec/unit/vm_spec.rb
164
+ has_rdoc: