rbovirt 0.0.13 → 0.0.14

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.

@@ -12,6 +12,11 @@ A Ruby client for oVirt.
12
12
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
13
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
14
 
15
+ == Running the tests
16
+ * Copy the file spec/endpoint.yml.example to spec/endpoint.yml
17
+ * Edit the endpoint properties (user, password and host name)
18
+ * From command line run => rake spec
19
+
15
20
  == Copyright
16
21
 
17
22
  Copyright (c) 2012 Amos Benari. See LICENSE.txt for
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "rbovirt"
18
- gem.homepage = "http://github.com/abenari/rbovirt"
18
+ gem.homepage = "http://github.com/rbovirt/rbovirt"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{A Ruby client for oVirt REST API}
21
21
  gem.description = %Q{A Ruby client for oVirt REST API}
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
@@ -14,7 +14,17 @@ module OVIRT
14
14
  end
15
15
 
16
16
  def running?
17
- !(@status =~ /down/i)
17
+ !(@status =~ /down/i) && !(@status =~ /wait_for_launch/i)
18
+ end
19
+
20
+ # In oVirt 3.1 a vm can be marked down and not locked while its volumes are locked.
21
+ # This method indicates if it is safe to launch the vm.
22
+ def ready?
23
+ return false unless @status =~ /down/i
24
+ volumes.each do |volume|
25
+ return false if volume.status =~ /locked/i
26
+ end if @client.api_version?("3","1")
27
+ true
18
28
  end
19
29
 
20
30
  def interfaces
@@ -72,7 +82,7 @@ module OVIRT
72
82
  } if(opts[:user_data_method] && opts[:user_data_method] == :custom_property)
73
83
  payloads {
74
84
  payload(:type => 'floppy') {
75
- file(:name => "#{opts[:fileinject_path] || OVIRT::FILEINJECT_PATH}") { content(Base64::decode64(opts[:user_data])) }
85
+ _file(:name => "#{opts[:fileinject_path] || OVIRT::FILEINJECT_PATH}") { content(Base64::decode64(opts[:user_data])) }
76
86
  }
77
87
  } if(opts[:user_data_method] && opts[:user_data_method] == :payload)
78
88
  }
@@ -1,7 +1,7 @@
1
1
  module OVIRT
2
2
 
3
3
  class Volume < BaseObject
4
- attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :storage_domain, :vm
4
+ attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :status, :storage_domain, :vm
5
5
 
6
6
  def initialize(client, xml)
7
7
  super(client, xml[:id], xml[:href], (xml/'name').first.text)
@@ -34,6 +34,7 @@ module OVIRT
34
34
  @interface = (xml/'interface').first.text
35
35
  @format = (xml/'format').first.text
36
36
  @sparse = (xml/'sparse').first.text
37
+ @status = (xml/'status').first.text
37
38
  @vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href])
38
39
  end
39
40
 
@@ -45,12 +45,13 @@ module OVIRT
45
45
  end
46
46
 
47
47
  def api_version
48
+ return @api_version unless @api_version.nil?
48
49
  xml = http_get("/")/'/api/product_info/version'
49
- (xml/'version').first[:major] +"."+ (xml/'version').first[:minor]
50
+ @api_version = (xml/'version').first[:major] +"."+ (xml/'version').first[:minor]
50
51
  end
51
52
 
52
- def api_version?(major)
53
- api_version.split('.')[0] == major
53
+ def api_version?(major, minor=nil)
54
+ (api_version.split('.')[0] == major) && (minor.nil? ? true : api_version.split('.')[1] == minor)
54
55
  end
55
56
 
56
57
  def floppy_hook?
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rbovirt"
8
- s.version = "0.0.13"
8
+ s.version = File.read('VERSION')
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"]
@@ -14,12 +14,7 @@ describe OVIRT, "API" do
14
14
  # be changed for new major releases.
15
15
 
16
16
  before(:all) do
17
- user="admin@internal"
18
- password="123123"
19
- hostname = "covirt.sat.lab.tlv.redhat.com"
20
- port = "8080"
21
- url = "http://#{hostname}:#{port}/api"
22
- @blank_template_id = "00000000-0000-0000-0000-000000000000"
17
+ user, password, url = endpoint
23
18
  @client = ::OVIRT::Client.new(user, password, url)
24
19
  end
25
20
 
@@ -28,7 +23,7 @@ describe OVIRT, "API" do
28
23
 
29
24
  context 'basic api and listing' do
30
25
  it "test_should_return_a_version" do
31
- @client.api_version.should eql('3.0')
26
+ @client.api_version.class.should eql(String)
32
27
  end
33
28
 
34
29
  it "test_should_return_datacenters" do
@@ -3,12 +3,7 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
3
3
  describe "VM Life cycle" do
4
4
 
5
5
  before(:all) do
6
- user="admin@internal"
7
- password="123123"
8
- hostname = "covirt.sat.lab.tlv.redhat.com"
9
- port = "8080"
10
- url = "http://#{hostname}:#{port}/api"
11
- @blank_template_id = "00000000-0000-0000-0000-000000000000"
6
+ user, password, url = endpoint
12
7
  @client = ::OVIRT::Client.new(user, password, url)
13
8
  end
14
9
 
@@ -19,7 +14,7 @@ describe "VM Life cycle" do
19
14
  @vm = @client.create_vm(:name => name)
20
15
  @client.add_volume(@vm.id)
21
16
  @client.add_interface(@vm.id)
22
- while @client.vm(@vm.id).status !~ /down/i do
17
+ while !@client.vm(@vm.id).ready? do
23
18
  end
24
19
  end
25
20
 
@@ -31,7 +26,7 @@ describe "VM Life cycle" do
31
26
  template_name = "test_template"
32
27
  template = @client.create_template(:vm => @vm.id, :name => template_name, :description => "test_template")
33
28
  template.class.to_s.should eql("OVIRT::Template")
34
- while @client.vm(@vm.id).status !~ /down/i do
29
+ while !@client.vm(@vm.id).ready? do
35
30
  end
36
31
  @client.destroy_template(template.id)
37
32
  end
@@ -51,6 +46,8 @@ describe "VM Life cycle" do
51
46
 
52
47
  it "test_should_set_vm_ticket" do
53
48
  @client.vm_action(@vm.id, :start)
49
+ while !@client.vm(@vm.id).running? do
50
+ end
54
51
  @client.set_ticket(@vm.id)
55
52
  @client.vm_action(@vm.id, :shutdown)
56
53
  end
@@ -5,3 +5,9 @@ require 'rspec'
5
5
  require 'rbovirt'
6
6
 
7
7
  module OVIRT::RSpec end
8
+
9
+ require "#{File.dirname(__FILE__)}/lib/endpoint"
10
+
11
+ RSpec.configure do |config|
12
+ config.include OVIRT::RSpec::Endpoint
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbovirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: