[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

James Turnbull james at lovedthanlost.net
Wed Jul 14 10:29:22 UTC 2010


The following commit has been merged in the upstream branch:
commit c61335f66f897bc64992c4e9209ea517193c8e30
Author: Avi Miller <avi.miller at gmail.com>
Date:   Fri Oct 2 21:55:35 2009 +1000

    Patch to address feature #2571 to add Oracle support to Puppet
    
    Adapter requires specifying database, username and password.
    
    Signed-off-by: Avi Miller <avi.miller at gmail.com>

diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb
index fc8eacd..ec2d618 100644
--- a/lib/puppet/rails.rb
+++ b/lib/puppet/rails.rb
@@ -51,6 +51,10 @@ module Puppet::Rails
 
             socket          = Puppet[:dbsocket]
             args[:socket]   = socket unless socket.empty?
+	when "oracle_enhanced":
+	    args[:database] = Puppet[:dbname] unless Puppet[:dbname].empty?
+	    args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].empty?
+	    args[:password] = Puppet[:dbpassword] unless Puppet[:dbpassword].empty?
         else
             raise ArgumentError, "Invalid db adapter %s" % adapter
         end
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index d8fcbb4..434197b 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -21,9 +21,10 @@ class Puppet::Rails::Schema
 
                 # Thanks, mysql!  MySQL requires a length on indexes in text fields.
                 # So, we provide them for mysql and handle everything else specially.
+		# Oracle doesn't index on CLOB fields, so we skip it
                 if Puppet[:dbadapter] == "mysql"
                     execute "CREATE INDEX typentitle ON resources (restype,title(50));"
-                else
+                elsif Puppet[:dbadapter] != "oracle_enhanced"
                     add_index :resources, [:title, :restype]
                 end
 
@@ -49,7 +50,11 @@ class Puppet::Rails::Schema
                     t.column :updated_at, :datetime
                     t.column :created_at, :datetime
                 end
-                add_index :puppet_tags, :id, :integer => true
+
+		# Oracle automatically creates a primary key index
+		if Puppet[:dbadapter] != "oracle_enhanced"
+                    add_index :puppet_tags, :id, :integer => true
+		end
 
                 create_table :hosts do |t|
                     t.column :name, :string, :null => false
diff --git a/lib/puppet/rails/param_value.rb b/lib/puppet/rails/param_value.rb
index 21415ef..b298924 100644
--- a/lib/puppet/rails/param_value.rb
+++ b/lib/puppet/rails/param_value.rb
@@ -48,7 +48,7 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base
 
     # returns an array of hash containing all the parameters of a given resource
     def self.find_all_params_from_resource(db_resource)
-        params = db_resource.connection.select_all("SELECT v.id, v.value, v.line, v.resource_id, v.param_name_id, n.name FROM param_values as v INNER JOIN param_names as n ON v.param_name_id=n.id WHERE v.resource_id=%s" % db_resource.id)
+        params = db_resource.connection.select_all("SELECT v.id, v.value, v.line, v.resource_id, v.param_name_id, n.name FROM param_values v INNER JOIN param_names n ON v.param_name_id=n.id WHERE v.resource_id=%s" % db_resource.id)
         params.each do |val|
             val['value'] = unserialize_value(val['value'])
             val['line'] = val['line'] ? Integer(val['line']) : nil
@@ -59,7 +59,7 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base
 
     # returns an array of hash containing all the parameters of a given host
     def self.find_all_params_from_host(db_host)
-        params = db_host.connection.select_all("SELECT v.id, v.value,  v.line, v.resource_id, v.param_name_id, n.name FROM param_values as v INNER JOIN resources r ON v.resource_id=r.id INNER JOIN param_names as n ON v.param_name_id=n.id WHERE r.host_id=%s" % db_host.id)
+        params = db_host.connection.select_all("SELECT v.id, v.value,  v.line, v.resource_id, v.param_name_id, n.name FROM param_values v INNER JOIN resources r ON v.resource_id=r.id INNER JOIN param_names n ON v.param_name_id=n.id WHERE r.host_id=%s" % db_host.id)
         params.each do |val|
             val['value'] = unserialize_value(val['value'])
             val['line'] = val['line'] ? Integer(val['line']) : nil
diff --git a/lib/puppet/rails/resource_tag.rb b/lib/puppet/rails/resource_tag.rb
index 8aeec0e..8d088fd 100644
--- a/lib/puppet/rails/resource_tag.rb
+++ b/lib/puppet/rails/resource_tag.rb
@@ -8,7 +8,7 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base
 
     # returns an array of hash containing tags of resource
     def self.find_all_tags_from_resource(db_resource)
-        tags = db_resource.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags as t INNER JOIN puppet_tags as p ON t.puppet_tag_id=p.id WHERE t.resource_id=%s" % db_resource.id)
+        tags = db_resource.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags t INNER JOIN puppet_tags p ON t.puppet_tag_id=p.id WHERE t.resource_id=%s" % db_resource.id)
         tags.each do |val|
             val['resource_id'] = Integer(val['resource_id'])
         end
@@ -17,7 +17,7 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base
 
     # returns an array of hash containing tags of a host
     def self.find_all_tags_from_host(db_host)
-        tags = db_host.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags as t INNER JOIN resources r ON t.resource_id=r.id INNER JOIN puppet_tags as p ON t.puppet_tag_id=p.id WHERE r.host_id=%s" % db_host.id)
+        tags = db_host.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags t INNER JOIN resources r ON t.resource_id=r.id INNER JOIN puppet_tags p ON t.puppet_tag_id=p.id WHERE r.host_id=%s" % db_host.id)
         tags.each do |val|
             val['resource_id'] = Integer(val['resource_id'])
         end
diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb
index d98c887..d838f0b 100755
--- a/spec/unit/rails.rb
+++ b/spec/unit/rails.rb
@@ -76,7 +76,7 @@ describe Puppet::Rails, "when initializing a sqlite3 connection" do
     end
 end
 
-describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
+describe Puppet::Rails, "when initializing a mysql connection" do
     confine "Cannot test without ActiveRecord" => Puppet.features.rails?
 
     it "should provide the adapter, log_level, and host, username, password, and database arguments" do
@@ -118,3 +118,82 @@ describe Puppet::Rails, "when initializing a mysql or postgresql connection" do
         }
     end
 end
+
+describe Puppet::Rails, "when initializing a postgresql connection" do
+    confine "Cannot test without ActiveRecord" => Puppet.features.rails?
+
+    it "should provide the adapter, log_level, and host, username, password, and database arguments" do
+        Puppet.settings.stubs(:value).with(:dbadapter).returns("postgresql")
+        Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+        Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
+        Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+        Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+        Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+        Puppet.settings.stubs(:value).with(:dbsocket).returns("")
+
+        Puppet::Rails.database_arguments.should == {
+            :adapter => "postgresql",
+            :log_level => "testlevel",
+            :host => "testserver",
+            :username => "testuser",
+            :password => "testpassword",
+            :database => "testname"
+        }
+    end
+
+    it "should provide the adapter, log_level, and host, username, password, database, and socket arguments" do
+        Puppet.settings.stubs(:value).with(:dbadapter).returns("postgresql")
+        Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+        Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
+        Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+        Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+        Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+        Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
+
+        Puppet::Rails.database_arguments.should == {
+            :adapter => "postgresql",
+            :log_level => "testlevel",
+            :host => "testserver",
+            :username => "testuser",
+            :password => "testpassword",
+            :database => "testname",
+            :socket => "testsocket"
+        }
+    end
+end
+
+describe Puppet::Rails, "when initializing an Oracle connection" do
+    confine "Cannot test without ActiveRecord" => Puppet.features.rails?
+
+    it "should provide the adapter, log_level, and username, password, and database arguments" do
+        Puppet.settings.stubs(:value).with(:dbadapter).returns("oracle_enhanced")
+        Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+        Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+        Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+        Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+
+        Puppet::Rails.database_arguments.should == {
+            :adapter => "oracle_enhanced",
+            :log_level => "testlevel",
+            :username => "testuser",
+            :password => "testpassword",
+            :database => "testname"
+        }
+    end
+
+    it "should provide the adapter, log_level, and host, username, password, database, and socket arguments" do
+        Puppet.settings.stubs(:value).with(:dbadapter).returns("oracle_enhanced")
+        Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+        Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+        Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+        Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+
+        Puppet::Rails.database_arguments.should == {
+            :adapter => "oracle_enhanced",
+            :log_level => "testlevel",
+            :username => "testuser",
+            :password => "testpassword",
+            :database => "testname",
+        }
+    end
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list