deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 6/7] CIMI: Added AddressTemplate database model
Date Wed, 02 Jan 2013 12:23:56 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/db.rb                  |  1 +
 server/lib/db/address_template.rb | 17 +++++++++++++++++
 server/lib/db/provider.rb         |  5 +++++
 3 files changed, 23 insertions(+)
 create mode 100644 server/lib/db/address_template.rb

diff --git a/server/lib/db.rb b/server/lib/db.rb
index 2a5114d..9564b79 100644
--- a/server/lib/db.rb
+++ b/server/lib/db.rb
@@ -9,6 +9,7 @@ module Deltacloud
     require_relative './db/provider'
     require_relative './db/entity'
     require_relative './db/machine_template'
+    require_relative './db/address_template'
   end
 
   DATABASE_LOCATION = ENV['DATABASE_LOCATION'] || File.join('/', 'var', 'tmp', "deltacloud-mock-#{ENV['USER']}",
'db.sqlite')
diff --git a/server/lib/db/address_template.rb b/server/lib/db/address_template.rb
new file mode 100644
index 0000000..c3272c4
--- /dev/null
+++ b/server/lib/db/address_template.rb
@@ -0,0 +1,17 @@
+module Deltacloud
+  module Database
+
+    class AddressTemplate < Entity
+      belongs_to :provider
+
+      property :ip, String
+      property :allocation, String, :default => 'dynamic'
+      property :default_gateway, String, :default => 'unknown'
+      property :dns, String, :default => 'unknown'
+      property :protocol, String, :default => 'ipv4'
+      property :mask, String, :default => 'unknown'
+      property :network, String
+    end
+
+  end
+end
diff --git a/server/lib/db/provider.rb b/server/lib/db/provider.rb
index 25e2ca9..789bf3e 100644
--- a/server/lib/db/provider.rb
+++ b/server/lib/db/provider.rb
@@ -10,6 +10,7 @@ module Deltacloud
 
       has n, :entities
       has n, :machine_templates
+      has n, :address_templates
 
       # This is a workaround for strange bug in Fedora MRI:
       #
@@ -17,6 +18,10 @@ module Deltacloud
         MachineTemplate.all(:provider_id => self.id)
       end
 
+      def address_templates
+        AddressTemplate.all(:provider_id => self.id)
+      end
+
       def entities
         Entity.all(:provider_id => self.id)
       end
-- 
1.8.0.2


Mime
View raw message