Skip to content

Commit

Permalink
Merge ec2c301 into 03b6add
Browse files Browse the repository at this point in the history
  • Loading branch information
plribeiro3000 committed Jul 17, 2014
2 parents 03b6add + ec2c301 commit 9d92acc
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -20,3 +20,4 @@ tmp
*.o
*.a
mkmf.log
gemfiles/*.lock
10 changes: 7 additions & 3 deletions .travis.yml
Expand Up @@ -2,18 +2,22 @@ matrix:
include:
- rvm: 1.8.7
gemfile: gemfiles/Gemfile.1.8.7
env: COVERAGE=false
- rvm: 1.9.2
gemfile: gemfiles/Gemfile.1.9.2+
env: COVERAGE=true
- rvm: 1.9.3
gemfile: gemfiles/Gemfile.1.9.2+
env: COVERAGE=true
- rvm: 2.0.0
gemfile: gemfiles/Gemfile.1.9.2+
env: COVERAGE=true
- rvm: 2.1.1
gemfile: gemfiles/Gemfile.1.9.2+
env: COVERAGE=true
- rvm: ree
gemfile: gemfiles/Gemfile.1.8.7
env: COVERAGE=false
- rvm: jruby
gemfile: gemfiles/Gemfile.1.9.2+
allow_failures:
- rvm: 1.8.7
- rvm: ree
env: COVERAGE=true
2 changes: 1 addition & 1 deletion fog-xenserver.gemspec
Expand Up @@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake'
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'turn'
spec.add_development_dependency 'coveralls'
spec.add_development_dependency 'coveralls' if RUBY_VERSION.to_f >= 1.9
end
7 changes: 1 addition & 6 deletions lib/fog/compute/xen_server/models/host_metrics.rb
Expand Up @@ -10,17 +10,12 @@ class HostMetrics < Fog::Model

identity :reference

attribute :last_updated
attribute :last_updated, :type => :time
attribute :live
attribute :memory_free
attribute :memory_total
attribute :other_config
attribute :uuid

def initialize(attributes = {})
super
self.last_updated = attributes[:last_updated].to_time
end
end
end
end
Expand Down
7 changes: 1 addition & 6 deletions lib/fog/compute/xen_server/models/vbd_metrics.rb
Expand Up @@ -12,14 +12,9 @@ class VbdMetrics < Fog::Model

attribute :io_read_kbs
attribute :io_write_kbs
attribute :last_updated
attribute :last_updated, :type => :time
attribute :other_config
attribute :uuid

def initialize(attributes = {})
super
self.last_updated = attributes[:last_updated].to_time
end
end
end
end
Expand Down
17 changes: 7 additions & 10 deletions lib/fog/compute/xen_server/models/vdi.rb
Expand Up @@ -22,17 +22,17 @@ class Vdi < Fog::Model
attribute :missing
attribute :name, :aliases => :name_label
attribute :on_boot
attribute :other_config
attribute :other_config, :default => {}
attribute :physical_utilisation
attribute :read_only
attribute :sharable
attribute :read_only, :default => false
attribute :sharable, :default => false
attribute :sm_config
attribute :snapshot_time
attribute :storage_lock
attribute :tags
attribute :tags, :default => 'system'
attribute :type
attribute :uuid
attribute :virtual_size
attribute :virtual_size, :default => '8589934592'
attribute :xenstore_data

has_many :crash_dumps, :crash_dumps
Expand All @@ -45,17 +45,14 @@ class Vdi < Fog::Model
alias_method :storage_repository, :sr

#
# Default VDI type is system
# Default size 8GB
# Sharable is false by default
# read_only is false by default
# There is a bug on fog-core that need to be solved before
# default_values work with false value
#
def initialize(attributes = {})
self.virtual_size ||= '8589934592' unless attributes[:virtual_size]
self.type ||= 'system' unless attributes[:type]
self.read_only ||= false unless attributes[:read_only]
self.sharable ||= false unless attributes[:sharable]
self.other_config ||= {} unless attributes[:other_config]
super
end

Expand Down
12 changes: 12 additions & 0 deletions spec/fog/compute/xen_server/models/host_metrics_spec.rb
@@ -1,4 +1,5 @@
require 'minitest_helper'
require 'xmlrpc/datetime'

describe Fog::Compute::XenServer::Models::HostMetrics do
let(:host_metrics_class) do
Expand All @@ -9,6 +10,7 @@ def self.read_identity
end
Fog::Compute::XenServer::Models::HostMetrics
end
let(:host_metrics) { Fog::Compute::XenServer::Models::HostMetrics.new }

it 'should associate to a provider class' do
host_metrics_class.provider_class.must_equal('host_metrics')
Expand All @@ -31,4 +33,14 @@ def self.read_identity
it "shouldn't have aliases" do
host_metrics_class.aliases.must_equal({})
end

describe '#last_updated' do
before :each do
host_metrics.last_updated = XMLRPC::DateTime.new(2000, 7, 8, 10, 20, 34)
end

it 'should be an instance of Time' do
host_metrics.last_updated.must_be_instance_of(Time)
end
end
end
12 changes: 12 additions & 0 deletions spec/fog/compute/xen_server/models/vbd_metrics_spec.rb
@@ -1,4 +1,5 @@
require 'minitest_helper'
require 'xmlrpc/datetime'

describe Fog::Compute::XenServer::Models::VbdMetrics do
let(:vbd_metrics_class) do
Expand All @@ -9,6 +10,7 @@ def self.read_identity
end
Fog::Compute::XenServer::Models::VbdMetrics
end
let(:vbd_metrics) { Fog::Compute::XenServer::Models::VbdMetrics.new }

it 'should associate to a provider class' do
vbd_metrics_class.provider_class.must_equal('VBD_metrics')
Expand All @@ -30,4 +32,14 @@ def self.read_identity
it "should't have aliases" do
vbd_metrics_class.aliases.must_equal({})
end

describe '#last_updated' do
before :each do
vbd_metrics.last_updated = XMLRPC::DateTime.new(2000, 7, 8, 10, 20, 34)
end

it 'should be an instance of Time' do
vbd_metrics.last_updated.must_be_instance_of(Time)
end
end
end
26 changes: 16 additions & 10 deletions spec/fog/compute/xen_server/models/vdi_spec.rb
Expand Up @@ -53,15 +53,21 @@ def self.read_identity
end

it 'should have 10 aliases' do
vdi_class.aliases.must_equal({ :name_label => :name,
:name_description => :description,
:parent => :__parent,
:VBDs => :__vbds,
:vbds => :__vbds,
:SR => :__sr,
:sr => :__sr,
:crash_dumps => :__crash_dumps,
:snapshots => :__snapshots,
:snapshot_of => :__snapshot_of })
vdi_class.aliases.must_equal(:name_label => :name,
:name_description => :description,
:parent => :__parent,
:VBDs => :__vbds,
:vbds => :__vbds,
:SR => :__sr,
:sr => :__sr,
:crash_dumps => :__crash_dumps,
:snapshots => :__snapshots,
:snapshot_of => :__snapshot_of)
end

it 'should have 3 default values' do
vdi_class.default_values.must_equal(:other_config => {},
:tags => 'system',
:virtual_size => '8589934592')
end
end
15 changes: 10 additions & 5 deletions spec/minitest_helper.rb
@@ -1,8 +1,6 @@
require 'minitest/spec'
require 'minitest/autorun'
require 'simplecov'
require 'turn'
require 'coveralls'

Turn.config do |c|
# use one of output formats:
Expand All @@ -19,10 +17,17 @@
c.natural = true
end

SimpleCov.start do
add_filter '/spec/'
if ENV['COVERAGE']
require 'coveralls'
require 'simplecov'

SimpleCov.start do
add_filter '/spec/'
end
end

require File.join(File.dirname(__FILE__), '../lib/fog/xenserver.rb')

Coveralls.wear!
if ENV['COVERAGE']
Coveralls.wear!
end

0 comments on commit 9d92acc

Please sign in to comment.