You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2013/01/21 10:52:12 UTC
[7/8] git commit: Added validation to database models
Added validation to database models
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/37186869
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/37186869
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/37186869
Branch: refs/heads/master
Commit: 37186869fbca59e7b3b9ba94b07d6b97fc23c962
Parents: 656a464
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed Jan 16 12:52:00 2013 +0100
Committer: Michal fojtik <mf...@redhat.com>
Committed: Mon Jan 21 10:51:53 2013 +0100
----------------------------------------------------------------------
server/lib/db.rb | 7 +++++--
server/lib/db/address_template.rb | 7 +++++++
server/lib/db/machine_template.rb | 2 ++
server/lib/db/volume_configuration.rb | 2 ++
server/lib/db/volume_template.rb | 2 ++
5 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/37186869/server/lib/db.rb
----------------------------------------------------------------------
diff --git a/server/lib/db.rb b/server/lib/db.rb
index c441021..6dc32c3 100644
--- a/server/lib/db.rb
+++ b/server/lib/db.rb
@@ -4,8 +4,11 @@ module Deltacloud
ENV['RACK_ENV'] == 'test'
end
- require 'sequel' unless test_environment?
- require 'logger'
+ unless test_environment?
+ require 'sequel'
+ require 'logger'
+ Sequel::Model.plugin :validation_class_methods
+ end
DATABASE_LOCATION = ENV['DATABASE_LOCATION'] ||
'sqlite://'+File.join('/', 'var', 'tmp', "deltacloud-mock-#{ENV['USER']}", 'db.sqlite')
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/37186869/server/lib/db/address_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/db/address_template.rb b/server/lib/db/address_template.rb
index 8586255..55771d1 100644
--- a/server/lib/db/address_template.rb
+++ b/server/lib/db/address_template.rb
@@ -2,6 +2,13 @@ module Deltacloud
module Database
class AddressTemplate < Entity
+ validates_presence_of :ip
+ validates_presence_of :hostname
+ validates_presence_of :allocation
+ validates_presence_of :default_gateway
+ validates_presence_of :dns
+ validates_presence_of :protocol
+ validates_presence_of :mask
end
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/37186869/server/lib/db/machine_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/db/machine_template.rb b/server/lib/db/machine_template.rb
index 1b34161..61f57c1 100644
--- a/server/lib/db/machine_template.rb
+++ b/server/lib/db/machine_template.rb
@@ -2,6 +2,8 @@ module Deltacloud
module Database
class MachineTemplate < Entity
+ validates_presence_of :machine_config
+ validates_presence_of :machine_image
end
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/37186869/server/lib/db/volume_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/db/volume_configuration.rb b/server/lib/db/volume_configuration.rb
index aa956ce..ebf59c2 100644
--- a/server/lib/db/volume_configuration.rb
+++ b/server/lib/db/volume_configuration.rb
@@ -2,6 +2,8 @@ module Deltacloud
module Database
class VolumeConfiguration < Entity
+ validates_presence_of :format
+ validates_presence_of :capacity
end
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/37186869/server/lib/db/volume_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/db/volume_template.rb b/server/lib/db/volume_template.rb
index 0d876bf..8a4953a 100644
--- a/server/lib/db/volume_template.rb
+++ b/server/lib/db/volume_template.rb
@@ -2,6 +2,8 @@ module Deltacloud
module Database
class VolumeTemplate < Entity
+ validates_presence_of :volume_config
+ validates_presence_of :volume_Image
end
end