summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-03-09 13:43:57 -0800
committerNick Lewis <nick@puppetlabs.com>2011-03-09 13:43:57 -0800
commit40e8b48eb19973ec413518be656249e134344ee0 (patch)
tree8f6a10924b74ff2b52efe992feb4be420b7ae2f7 /lib/puppet/rails
parenteae17c3cba159d895e5ec2e87e4abe8c125a9562 (diff)
parent531e25836e1313cd508ab8394e16cf438a62ac7b (diff)
downloadpuppet-40e8b48eb19973ec413518be656249e134344ee0.tar.gz
puppet-40e8b48eb19973ec413518be656249e134344ee0.tar.xz
puppet-40e8b48eb19973ec413518be656249e134344ee0.zip
Merge branch 'maint/2.6.next/6338' into 2.6.next
Diffstat (limited to 'lib/puppet/rails')
-rw-r--r--lib/puppet/rails/database/004_add_inventory_service_tables.rb18
-rw-r--r--lib/puppet/rails/database/schema.rb8
-rw-r--r--lib/puppet/rails/inventory_fact.rb5
-rw-r--r--lib/puppet/rails/inventory_node.rb (renamed from lib/puppet/rails/inventory_host.rb)2
4 files changed, 16 insertions, 17 deletions
diff --git a/lib/puppet/rails/database/004_add_inventory_service_tables.rb b/lib/puppet/rails/database/004_add_inventory_service_tables.rb
index 22298437a..a819cac1a 100644
--- a/lib/puppet/rails/database/004_add_inventory_service_tables.rb
+++ b/lib/puppet/rails/database/004_add_inventory_service_tables.rb
@@ -1,35 +1,35 @@
class AddInventoryServiceTables < ActiveRecord::Migration
def self.up
- unless ActiveRecord::Base.connection.tables.include?("inventory_hosts")
- create_table :inventory_hosts do |t|
+ unless ActiveRecord::Base.connection.tables.include?("inventory_nodes")
+ create_table :inventory_nodes do |t|
t.column :name, :string, :null => false
t.column :timestamp, :datetime, :null => false
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :inventory_hosts, :name, :unique => true
+ add_index :inventory_nodes, :name, :unique => true
end
unless ActiveRecord::Base.connection.tables.include?("inventory_facts")
create_table :inventory_facts, :id => false do |t|
- t.column :inventory_host_id, :integer, :null => false
+ t.column :inventory_node_id, :integer, :null => false
t.column :name, :string, :null => false
t.column :value, :text, :null => false
end
- add_index :inventory_facts, [:inventory_host_id, :name], :unique => true
+ add_index :inventory_facts, [:inventory_node_id, :name], :unique => true
end
end
def self.down
- unless ActiveRecord::Base.connection.tables.include?("inventory_hosts")
- remove_index :inventory_hosts, :name
- drop_table :inventory_hosts
+ unless ActiveRecord::Base.connection.tables.include?("inventory_nodes")
+ remove_index :inventory_nodes, :name
+ drop_table :inventory_nodes
end
if ActiveRecord::Base.connection.tables.include?("inventory_facts")
- remove_index :inventory_facts, [:inventory_host_id, :name]
+ remove_index :inventory_facts, [:inventory_node_id, :name]
drop_table :inventory_facts
end
end
diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/database/schema.rb
index 5e455d6c0..9fd640fe4 100644
--- a/lib/puppet/rails/database/schema.rb
+++ b/lib/puppet/rails/database/schema.rb
@@ -104,22 +104,22 @@ class Puppet::Rails::Schema
end
add_index :param_names, :name
- create_table :inventory_hosts do |t|
+ create_table :inventory_nodes do |t|
t.column :name, :string, :null => false
t.column :timestamp, :datetime, :null => false
t.column :updated_at, :datetime
t.column :created_at, :datetime
end
- add_index :inventory_hosts, :name, :unique => true
+ add_index :inventory_nodes, :name, :unique => true
create_table :inventory_facts, :id => false do |t|
- t.column :inventory_host_id, :integer, :null => false
+ t.column :inventory_node_id, :integer, :null => false
t.column :name, :string, :null => false
t.column :value, :text, :null => false
end
- add_index :inventory_facts, [:inventory_host_id, :name], :unique => true
+ add_index :inventory_facts, [:inventory_node_id, :name], :unique => true
end
end
ensure
diff --git a/lib/puppet/rails/inventory_fact.rb b/lib/puppet/rails/inventory_fact.rb
index ecb6e41ee..aa6334eef 100644
--- a/lib/puppet/rails/inventory_fact.rb
+++ b/lib/puppet/rails/inventory_fact.rb
@@ -1,6 +1,5 @@
-require 'puppet/rails/inventory_host'
+require 'puppet/rails/inventory_node'
class Puppet::Rails::InventoryFact < ::ActiveRecord::Base
- belongs_to :host, :class_name => "Puppet::Rails::InventoryHost"
- serialize :value
+ belongs_to :node, :class_name => "Puppet::Rails::InventoryNode"
end
diff --git a/lib/puppet/rails/inventory_host.rb b/lib/puppet/rails/inventory_node.rb
index 10dd62083..b3e321f94 100644
--- a/lib/puppet/rails/inventory_host.rb
+++ b/lib/puppet/rails/inventory_node.rb
@@ -1,6 +1,6 @@
require 'puppet/rails/inventory_fact'
-class Puppet::Rails::InventoryHost < ::ActiveRecord::Base
+class Puppet::Rails::InventoryNode < ::ActiveRecord::Base
has_many :facts, :class_name => "Puppet::Rails::InventoryFact", :dependent => :delete_all
named_scope :has_fact_with_value, lambda { |name,value|