summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/rails/database/schema.rb22
-rw-r--r--lib/puppet/rails/fact.rb1
-rw-r--r--lib/puppet/rails/host.rb5
-rw-r--r--lib/puppet/rails/param.rb2
-rw-r--r--lib/puppet/rails/resource.rb8
5 files changed, 13 insertions, 25 deletions
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index 9397916c2..cc8daf2b2 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -40,31 +40,21 @@ class Puppet::Rails::Schema
t.column :source_file_id, :integer
end
- create_table :fact_names do |t|
+ create_table :facts do |t|
t.column :name, :string, :null => false
+ t.column :value, :text, :null => false
t.column :host_id, :integer, :null => false
t.column :updated_at, :date
end
- create_table :fact_values do |t|
- t.column :value, :text, :null => false
- t.column :fact_name_id, :integer, :null => false
- t.column :updated_at, :date
- end
-
- create_table :param_values do |t|
- t.column :value, :text, :null => false
- t.column :param_name_id, :integer, :null => false
- t.column :updated_at, :date
- end
-
- create_table :param_names do |t|
+ create_table :params do |t|
t.column :name, :string, :null => false
- t.column :resource_id, :integer
+ t.column :value, :text, :null => false
t.column :line, :integer
t.column :updated_at, :date
+ t.column :resource_id, :integer
end
-
+
create_table :tags do |t|
t.column :name, :string
t.column :updated_at, :date
diff --git a/lib/puppet/rails/fact.rb b/lib/puppet/rails/fact.rb
index ba8462c23..6c44f68e1 100644
--- a/lib/puppet/rails/fact.rb
+++ b/lib/puppet/rails/fact.rb
@@ -1,3 +1,4 @@
class Puppet::Rails::Fact < ActiveRecord::Base
+ belongs_to :host
end
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index 900cda6cc..e81117c48 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -1,10 +1,11 @@
require 'puppet/rails/resource'
+require 'puppet/rails/fact'
require 'puppet/util/rails/collection_merger'
class Puppet::Rails::Host < ActiveRecord::Base
include Puppet::Util::CollectionMerger
- has_many :facts, :dependent => :destroy
+ has_many :facts
belongs_to :puppet_classes
has_many :source_files
has_many :resources,
@@ -71,7 +72,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
def setfacts(facts)
collection_merge(:facts, facts) do |name, value|
- f = facts.find_by_name(name) || facts.build(:name => name)
+ f = self.facts.find_by_name(name) || self.facts.build(:name => name, :value => value)
# We're only ever going to have one fact value, at this point.
f
end
diff --git a/lib/puppet/rails/param.rb b/lib/puppet/rails/param.rb
index 2e98bd258..108bc48d4 100644
--- a/lib/puppet/rails/param.rb
+++ b/lib/puppet/rails/param.rb
@@ -8,7 +8,7 @@ class Puppet::Rails::Param < ActiveRecord::Base
hash = {}
hash[:name] = self.name.to_sym
hash[:source] = source
- hash[:value] = self.param.value.find(:all).collect { |v| v.value }
+ hash[:value] = self.value
if hash[:value].length == 1
hash[:value] = hash[:value].shift
end
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index b0bfc1ed6..68f3dba8b 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -1,4 +1,5 @@
require 'puppet'
+require 'puppet/rails/source_file'
require 'puppet/rails/external/tagging/init'
require 'puppet/rails/param'
require 'puppet/util/rails/collection_merger'
@@ -12,11 +13,6 @@ class Puppet::Rails::Resource < ActiveRecord::Base
acts_as_taggable
- Puppet::Type.eachtype do |type|
- klass = Class.new(Puppet::Rails::Resource)
- Object.const_set("Puppet%s" % type.name.to_s.capitalize, klass)
- end
-
def tags=(tags)
tags.each do |tag|
self.tag_with tag
@@ -32,7 +28,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
end
def parameter(param)
- if p = params.find_by_name(param)
+ if p = self.params.find_by_name(param)
return p.value
end
end