Skip to content

Commit

Permalink
Fixed content
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Kelly committed Oct 31, 2010
1 parent 37198b1 commit 7d8eac9
Show file tree
Hide file tree
Showing 29 changed files with 92 additions and 92 deletions.
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NetdbManager
NetsvcManager
============

This plugin adds DNS and DHCP management to the foreman application whne running as a rails 2.3.5 application
Expand All @@ -17,8 +17,8 @@ require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot')
on the line directly below
require File.join(File.dirname(__FILE__), 'boot')

Now we install the netdb_manager plugin itself
git clone git://github.com/pikelly/netdb_manager.git netdb_manager
Now we install the netsvc_manager plugin itself
git clone git://github.com/pikelly/netdb_manager.git netsvc_manager

Now run script/generate plugin_migration netb_manager

Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test

desc 'Test the netdb_manager plugin.'
desc 'Test the netsvc_manager plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the netdb_manager plugin.'
desc 'Generate documentation for the netsvc_manager plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'NetdbManager'
rdoc.title = 'NetsvcManager'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
Expand Down
28 changes: 14 additions & 14 deletions app/controllers/netdbs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
class NetdbsController < ApplicationController
class NetsvcsController < ApplicationController
def index
@search = Netdb.search params[:search]
@netdbs = @search.paginate(:page => params[:page])
@search = Netsvc.search params[:search]
@netsvcs = @search.paginate(:page => params[:page])
end

def new
@netdb = Netdb.new
@netsvc = Netsvc.new
end

def create
@netdb = Netdb.new(params[:netdb])
if @netdb.save
@netsvc = Netsvc.new(params[:netsvc])
if @netsvc.save
flash[:foreman_notice] = "Successfully created network database"
redirect_to netdbs_url
redirect_to netsvcs_url
else
render :action => 'new'
end
end

def edit
@netdb = Netdb.find(params[:id])
@netsvc = Netsvc.find(params[:id])
end

def update
@netdb = Netdb.find(params[:id])
if @netdb.update_attributes(params[:netdb])
@netsvc = Netsvc.find(params[:id])
if @netsvc.update_attributes(params[:netsvc])
flash[:foreman_notice] = "Successfully updated network database"
redirect_to netdbs_url
redirect_to netsvcs_url
else
render :action => 'edit'
end
end

def destroy
@netdb = Netdb.find(params[:id])
@netdb.destroy
@netsvc = Netsvc.find(params[:id])
@netsvc.destroy
flash[:foreman_notice] = "Successfully destroyed network database"
redirect_to netdbs_url
redirect_to netsvcs_url
end
end
2 changes: 1 addition & 1 deletion app/helpers/netdbs_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
module NetdbsHelper
module NetsvcsHelper
end
2 changes: 1 addition & 1 deletion app/models/netdb.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Netdb < ActiveRecord::Base
class Netsvc < ActiveRecord::Base
belongs_to :vendor
belongs_to :servertype
has_many :subnets, :foreign_key => "dhcp_id"
Expand Down
2 changes: 1 addition & 1 deletion app/models/servertype.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Servertype < ActiveRecord::Base
has_many :netdbs
has_many :netsvcs

validates_uniqueness_of :name
validates_presence_of :name
Expand Down
2 changes: 1 addition & 1 deletion app/models/subnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Subnet < ActiveRecord::Base
has_many :hosts
has_many :sps, :class_name => 'Host', :foreign_key => 'sp_subnet_id'
belongs_to :domain
belongs_to :dhcp, :class_name => 'Netdb'
belongs_to :dhcp, :class_name => 'Netsvc'

validates_presence_of :number, :mask, :domain, :name
validates_uniqueness_of :number
Expand Down
2 changes: 1 addition & 1 deletion app/models/vendor.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Vendor < ActiveRecord::Base
has_many :netdbs
has_many :netsvcs

validates_uniqueness_of :name
validates_presence_of :name
Expand Down
2 changes: 1 addition & 1 deletion app/views/domains/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</p>
<p>
<%= f.label :dns_id %><br />
<%= f.collection_select :dns_id, Netdb.servertype_name_is("DNS"), :id, :name %>
<%= f.collection_select :dns_id, Netsvc.servertype_name_is("DNS"), :id, :name %>
</p>
<%= render :partial => "common_parameters/parameters", :locals => { :f => f, :type => :domain_parameters } %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/home/_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
['Host Groups', hostgroups_url],
['Installation Medias', medias_url],
['LDAP Authentication', auth_source_ldaps_url],
['Network Datbases', netdbs_url],
['Network Datbases', netsvcs_url],
['Operating Systems', operatingsystems_url],
['Partition Tables', ptables_url],
['Puppet Classes', puppetclasses_url],
Expand Down
2 changes: 1 addition & 1 deletion app/views/netdbs/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% form_for @netdb do |f| %>
<% form_for @netsvc do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/netdbs/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

<%= render :partial => 'form' %>

<p><%= link_to "View all network databases", netdbs_path %></p>
<p><%= link_to "View all network databases", netsvcs_path %></p>

20 changes: 10 additions & 10 deletions app/views/netdbs/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% title "Network databases" %>
<% title "Network services" %>

<table class="list">
<tr>
Expand All @@ -8,19 +8,19 @@
<th>Service</th>
<th></th>
</tr>
<% for netdb in @netdbs %>
<% for netsvc in @netsvcs %>
<tr class="<%= cycle("even", "odd") -%>">
<td><%=link_to h(netdb.name), edit_netdb_path(netdb)%></td>
<td><%=netdb.address%></td>
<td><%=netdb.vendor.name%></td>
<td><%=netdb.servertype.name%></td>
<td><%=link_to h(netsvc.name), edit_netsvc_path(netsvc)%></td>
<td><%=netsvc.address%></td>
<td><%=netsvc.vendor.name%></td>
<td><%=netsvc.servertype.name%></td>
<td align="right">
<%= link_to "Destroy", netdb, :confirm => "Delete #{netdb.name}?", :method => :delete %>
<%= link_to "Destroy", netsvc, :confirm => "Delete #{netsvc.name}?", :method => :delete %>
</td>
</tr>
<% end %>
</table>
<%= page_entries_info @netdbs %>
<%= will_paginate @netdbs %>
<%= page_entries_info @netsvcs %>
<%= will_paginate @netsvcs %>

<p><%= link_to "New network database", new_netdb_path %></p>
<p><%= link_to "New network service", new_netsvc_path %></p>
4 changes: 2 additions & 2 deletions app/views/netdbs/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% title "New network database" %>
<% title "New network service" %>

<%= render :partial => 'form' %>

<p><%= link_to "Back to List", netdbs_path %></p>
<p><%= link_to "Back to List", netsvcs_path %></p>
2 changes: 1 addition & 1 deletion app/views/subnets/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</p>
<p>
<%= f.label :dhcp_id %><br />
<%= f.collection_select :dhcp_id, Netdb.servertype_name_is("DHCP"), :id, :name %>
<%= f.collection_select :dhcp_id, Netsvc.servertype_name_is("DHCP"), :id, :name %>
</p>
<p>
<%= f.label :vlanid %><br />
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ActionController::Routing::Routes.draw do |map|
map.resources :subnets
map.resources :netdbs
map.resources :netsvcs
end
6 changes: 3 additions & 3 deletions db/migrate/20091212110059_create_netdbs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateNetdbs < ActiveRecord::Migration
class CreateNetsvcs < ActiveRecord::Migration
def self.up
create_table :netdbs do |t|
create_table :netsvcs do |t|
t.string :name, :limit => 32, :null => false
t.string :address, :limit => 32, :null => false
t.integer :servertype_id, :null => false
Expand Down Expand Up @@ -29,7 +29,7 @@ def self.up
end

def self.down
drop_table :netdbs
drop_table :netsvcs
remove_column :subnets, :dhcp_id
end
end
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#require_dependency File.join(File.dirname(__FILE__), "..", "..", "..", "config", "initializers", "foreman")
require_dependency 'netdb_manager'
require_dependency 'netsvc_manager'
ActiveSupport::Dependencies.load_once_paths.delete lib_path
2 changes: 1 addition & 1 deletion install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
File.open(routes, "r") do |src|
File.open(new_routes, "w") do |dst|
line = src.readline
dst.write("map.NetdbManagers") if line.match(/Routes.draw/)
dst.write("map.NetsvcManagers") if line.match(/Routes.draw/)
dst.write line
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/netdb_manager.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Patch the ActionController with a alias_method_chain that loads our modifications to the models
require_dependency 'netdb_manager/action_controller_ext'
require_dependency 'netsvc_manager/action_controller_ext'

ActionController::Base.prepend_view_path(File.join(File.dirname(__FILE__), '..', 'app', 'views'))

Expand Down
22 changes: 11 additions & 11 deletions lib/netdb_manager/action_controller_ext.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module NetdbManager
module NetsvcManager
mattr_accessor :dhcp_servers, :dhcp, :user_data

module ActionControllerExtensions
Expand All @@ -8,21 +8,21 @@ def self.included(base) #:nodoc:

base.send :include, InstanceMethods
base.class_eval do
alias_method_chain :process, :netdb_support
alias_method_chain :process, :netsvc_support
end
end

module InstanceMethods
def process_with_netdb_support *args
require_dependency 'netdb_manager/host_ext'
require_dependency 'netdb_manager/user_ext'
require_dependency 'netdb_manager/subnet_ext'
require_dependency 'netdb_manager/domain_ext'
require_dependency 'netdb_manager/application_controller_ext'
require_dependency 'netdb_manager/hosts_controller_ext'
process_without_netdb_support *args
def process_with_netsvc_support *args
require_dependency 'netsvc_manager/host_ext'
require_dependency 'netsvc_manager/user_ext'
require_dependency 'netsvc_manager/subnet_ext'
require_dependency 'netsvc_manager/domain_ext'
require_dependency 'netsvc_manager/application_controller_ext'
require_dependency 'netsvc_manager/hosts_controller_ext'
process_without_netsvc_support *args
end
end
end
end
ActionController::Base.send :include, NetdbManager::ActionControllerExtensions
ActionController::Base.send :include, NetsvcManager::ActionControllerExtensions
12 changes: 6 additions & 6 deletions lib/netdb_manager/application_controller_ext.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
module NetdbManager
module NetsvcManager
module ApplicationControllerExtensions
NET_TTL = 7200

def self.included(base) #:nodoc:
base.send :include, InstanceMethods
base.class_eval do
# Setting the filter chain here will not work as it is too late. Set it in each controller individually.
#before_filter :load_netdb_caches
#before_filter :load_netsvc_caches
end
true
end

module InstanceMethods
def load_netdb_caches
def load_netsvc_caches
raise RuntimeError "Unable to determine the user for this operation " unless @user
return true if SETTINGS[:unattended] and SETTINGS[:unattended] == false

# Fetch the user data mecache. This holds per-user data dependant on the server implementation
NetdbManager.user_data = Rails.cache.fetch("user_data", :expires_in => NET_TTL){{}}.dup
raise RuntimeError, "Unable to create user data cache storage" unless NetdbManager.user_data
NetsvcManager.user_data = Rails.cache.fetch("user_data", :expires_in => NET_TTL){{}}.dup
raise RuntimeError, "Unable to create user data cache storage" unless NetsvcManager.user_data

true
end

end
end
end
ApplicationController.send :include, NetdbManager::ApplicationControllerExtensions
ApplicationController.send :include, NetsvcManager::ApplicationControllerExtensions
6 changes: 3 additions & 3 deletions lib/netdb_manager/domain_ext.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module NetdbManager
module NetsvcManager
module DomainExtensions
def self.included(base) #:nodoc:
base.extend ClassMethods
base.send :include, InstanceMethods
base.class_eval do
belongs_to :dns, :class_name => 'Netdb'
belongs_to :dns, :class_name => 'Netsvc'
end
end

Expand All @@ -17,4 +17,4 @@ module ClassMethods
end
end
end
Domain.send :include, NetdbManager::DomainExtensions
Domain.send :include, NetsvcManager::DomainExtensions
Loading

0 comments on commit 7d8eac9

Please sign in to comment.