From 7d8eac9b122b197882758d81c1d71462312b1253 Mon Sep 17 00:00:00 2001 From: Paul Kelly Date: Sun, 31 Oct 2010 20:11:49 +0000 Subject: [PATCH] Fixed content --- README | 6 ++-- Rakefile | 6 ++-- app/controllers/netdbs_controller.rb | 28 +++++++++---------- app/helpers/netdbs_helper.rb | 2 +- app/models/netdb.rb | 2 +- app/models/servertype.rb | 2 +- app/models/subnet.rb | 2 +- app/models/vendor.rb | 2 +- app/views/domains/_form.html.erb | 2 +- app/views/home/_settings.html.erb | 2 +- app/views/netdbs/_form.html.erb | 2 +- app/views/netdbs/edit.html.erb | 2 +- app/views/netdbs/index.html.erb | 20 ++++++------- app/views/netdbs/new.html.erb | 4 +-- app/views/subnets/_form.html.erb | 2 +- config/routes.rb | 2 +- db/migrate/20091212110059_create_netdbs.rb | 6 ++-- init.rb | 2 +- install.rb | 2 +- lib/netdb_manager.rb | 2 +- lib/netdb_manager/action_controller_ext.rb | 22 +++++++-------- .../application_controller_ext.rb | 12 ++++---- lib/netdb_manager/domain_ext.rb | 6 ++-- lib/netdb_manager/host_ext.rb | 22 +++++++-------- lib/netdb_manager/hosts_controller_ext.rb | 4 +-- lib/netdb_manager/subnet_ext.rb | 6 ++-- lib/netdb_manager/user_ext.rb | 10 +++---- tasks/netdb_manager_tasks.rake | 2 +- test/netdb_manager_test.rb | 2 +- 29 files changed, 92 insertions(+), 92 deletions(-) diff --git a/README b/README index b091b5a..c6782b8 100644 --- a/README +++ b/README @@ -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 @@ -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 diff --git a/Rakefile b/Rakefile index 6c9b0d5..7c7e91d 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ 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' @@ -13,10 +13,10 @@ Rake::TestTask.new(:test) do |t| 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') diff --git a/app/controllers/netdbs_controller.rb b/app/controllers/netdbs_controller.rb index a90edec..f78f3a7 100644 --- a/app/controllers/netdbs_controller.rb +++ b/app/controllers/netdbs_controller.rb @@ -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 diff --git a/app/helpers/netdbs_helper.rb b/app/helpers/netdbs_helper.rb index 191f3c0..1626796 100644 --- a/app/helpers/netdbs_helper.rb +++ b/app/helpers/netdbs_helper.rb @@ -1,2 +1,2 @@ -module NetdbsHelper +module NetsvcsHelper end diff --git a/app/models/netdb.rb b/app/models/netdb.rb index 64b7a49..c2d467d 100644 --- a/app/models/netdb.rb +++ b/app/models/netdb.rb @@ -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" diff --git a/app/models/servertype.rb b/app/models/servertype.rb index c19bc72..7a88a7d 100644 --- a/app/models/servertype.rb +++ b/app/models/servertype.rb @@ -1,5 +1,5 @@ class Servertype < ActiveRecord::Base - has_many :netdbs + has_many :netsvcs validates_uniqueness_of :name validates_presence_of :name diff --git a/app/models/subnet.rb b/app/models/subnet.rb index 68cf5b7..5393113 100644 --- a/app/models/subnet.rb +++ b/app/models/subnet.rb @@ -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 diff --git a/app/models/vendor.rb b/app/models/vendor.rb index 63fab6f..3d5fcaa 100644 --- a/app/models/vendor.rb +++ b/app/models/vendor.rb @@ -1,5 +1,5 @@ class Vendor < ActiveRecord::Base - has_many :netdbs + has_many :netsvcs validates_uniqueness_of :name validates_presence_of :name diff --git a/app/views/domains/_form.html.erb b/app/views/domains/_form.html.erb index 1f9218d..a66f1a4 100644 --- a/app/views/domains/_form.html.erb +++ b/app/views/domains/_form.html.erb @@ -10,7 +10,7 @@

<%= f.label :dns_id %>
- <%= f.collection_select :dns_id, Netdb.servertype_name_is("DNS"), :id, :name %> + <%= f.collection_select :dns_id, Netsvc.servertype_name_is("DNS"), :id, :name %>

<%= render :partial => "common_parameters/parameters", :locals => { :f => f, :type => :domain_parameters } %> diff --git a/app/views/home/_settings.html.erb b/app/views/home/_settings.html.erb index b855ed4..5b61f4f 100644 --- a/app/views/home/_settings.html.erb +++ b/app/views/home/_settings.html.erb @@ -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], diff --git a/app/views/netdbs/_form.html.erb b/app/views/netdbs/_form.html.erb index 1500792..3a97d9a 100644 --- a/app/views/netdbs/_form.html.erb +++ b/app/views/netdbs/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @netdb do |f| %> +<% form_for @netsvc do |f| %> <%= f.error_messages %>

<%= f.label :name %>
diff --git a/app/views/netdbs/edit.html.erb b/app/views/netdbs/edit.html.erb index 66b40e1..dc767de 100644 --- a/app/views/netdbs/edit.html.erb +++ b/app/views/netdbs/edit.html.erb @@ -2,5 +2,5 @@ <%= render :partial => 'form' %> -

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

+

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

diff --git a/app/views/netdbs/index.html.erb b/app/views/netdbs/index.html.erb index 6e291e3..3f2e512 100644 --- a/app/views/netdbs/index.html.erb +++ b/app/views/netdbs/index.html.erb @@ -1,4 +1,4 @@ -<% title "Network databases" %> +<% title "Network services" %> @@ -8,19 +8,19 @@ - <% for netdb in @netdbs %> + <% for netsvc in @netsvcs %> "> - - - - + + + + <% end %>
Service
<%=link_to h(netdb.name), edit_netdb_path(netdb)%><%=netdb.address%><%=netdb.vendor.name%><%=netdb.servertype.name%><%=link_to h(netsvc.name), edit_netsvc_path(netsvc)%><%=netsvc.address%><%=netsvc.vendor.name%><%=netsvc.servertype.name%> - <%= link_to "Destroy", netdb, :confirm => "Delete #{netdb.name}?", :method => :delete %> + <%= link_to "Destroy", netsvc, :confirm => "Delete #{netsvc.name}?", :method => :delete %>
-<%= page_entries_info @netdbs %> -<%= will_paginate @netdbs %> +<%= page_entries_info @netsvcs %> +<%= will_paginate @netsvcs %> -

<%= link_to "New network database", new_netdb_path %>

+

<%= link_to "New network service", new_netsvc_path %>

diff --git a/app/views/netdbs/new.html.erb b/app/views/netdbs/new.html.erb index e4e5ec9..3a0dd4c 100644 --- a/app/views/netdbs/new.html.erb +++ b/app/views/netdbs/new.html.erb @@ -1,5 +1,5 @@ -<% title "New network database" %> +<% title "New network service" %> <%= render :partial => 'form' %> -

<%= link_to "Back to List", netdbs_path %>

+

<%= link_to "Back to List", netsvcs_path %>

diff --git a/app/views/subnets/_form.html.erb b/app/views/subnets/_form.html.erb index f5d2f3a..3d5d320 100644 --- a/app/views/subnets/_form.html.erb +++ b/app/views/subnets/_form.html.erb @@ -22,7 +22,7 @@

<%= f.label :dhcp_id %>
- <%= f.collection_select :dhcp_id, Netdb.servertype_name_is("DHCP"), :id, :name %> + <%= f.collection_select :dhcp_id, Netsvc.servertype_name_is("DHCP"), :id, :name %>

<%= f.label :vlanid %>
diff --git a/config/routes.rb b/config/routes.rb index bf7352b..cf5187b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ ActionController::Routing::Routes.draw do |map| map.resources :subnets - map.resources :netdbs + map.resources :netsvcs end diff --git a/db/migrate/20091212110059_create_netdbs.rb b/db/migrate/20091212110059_create_netdbs.rb index cb6724c..8af9705 100644 --- a/db/migrate/20091212110059_create_netdbs.rb +++ b/db/migrate/20091212110059_create_netdbs.rb @@ -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 @@ -29,7 +29,7 @@ def self.up end def self.down - drop_table :netdbs + drop_table :netsvcs remove_column :subnets, :dhcp_id end end diff --git a/init.rb b/init.rb index 51d35ab..2a4739d 100644 --- a/init.rb +++ b/init.rb @@ -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 \ No newline at end of file diff --git a/install.rb b/install.rb index 17b1c2b..13503d0 100755 --- a/install.rb +++ b/install.rb @@ -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 diff --git a/lib/netdb_manager.rb b/lib/netdb_manager.rb index 94fad07..b27cac1 100644 --- a/lib/netdb_manager.rb +++ b/lib/netdb_manager.rb @@ -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')) diff --git a/lib/netdb_manager/action_controller_ext.rb b/lib/netdb_manager/action_controller_ext.rb index 86cbee0..f0cb675 100644 --- a/lib/netdb_manager/action_controller_ext.rb +++ b/lib/netdb_manager/action_controller_ext.rb @@ -1,4 +1,4 @@ -module NetdbManager +module NetsvcManager mattr_accessor :dhcp_servers, :dhcp, :user_data module ActionControllerExtensions @@ -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 diff --git a/lib/netdb_manager/application_controller_ext.rb b/lib/netdb_manager/application_controller_ext.rb index c6736a2..1a072fe 100644 --- a/lib/netdb_manager/application_controller_ext.rb +++ b/lib/netdb_manager/application_controller_ext.rb @@ -1,4 +1,4 @@ -module NetdbManager +module NetsvcManager module ApplicationControllerExtensions NET_TTL = 7200 @@ -6,19 +6,19 @@ 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 @@ -26,4 +26,4 @@ def load_netdb_caches end end end -ApplicationController.send :include, NetdbManager::ApplicationControllerExtensions +ApplicationController.send :include, NetsvcManager::ApplicationControllerExtensions diff --git a/lib/netdb_manager/domain_ext.rb b/lib/netdb_manager/domain_ext.rb index 2d10e13..3ada14a 100644 --- a/lib/netdb_manager/domain_ext.rb +++ b/lib/netdb_manager/domain_ext.rb @@ -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 @@ -17,4 +17,4 @@ module ClassMethods end end end -Domain.send :include, NetdbManager::DomainExtensions +Domain.send :include, NetsvcManager::DomainExtensions diff --git a/lib/netdb_manager/host_ext.rb b/lib/netdb_manager/host_ext.rb index a67571a..945e8cc 100644 --- a/lib/netdb_manager/host_ext.rb +++ b/lib/netdb_manager/host_ext.rb @@ -1,4 +1,4 @@ -module NetdbManager +module NetsvcManager module HostExtensions def self.included(base) # This implementation requires memcache @@ -21,10 +21,10 @@ def self.included(base) base.send :include, InstanceMethods base.class_eval do attr_accessor :dns, :dhcp - before_create :initialize_proxies, :check_netdbs - after_create :create_netdbs, :initialize_tftp - after_update :initialize_proxies, :update_netdbs - after_destroy :initialize_proxies, :destroy_netdbs + before_create :initialize_proxies, :check_netsvcs + after_create :create_netsvcs, :initialize_tftp + after_update :initialize_proxies, :update_netsvcs + after_destroy :initialize_proxies, :destroy_netsvcs end true end @@ -36,7 +36,7 @@ def initialize_tftp end # Checks whether DNS or DHCP entries already exist # Returns: Boolean true if no entries exists - def check_netdbs + def check_netsvcs continue = true if (address = @resolver.getaddress(name) rescue false) errors.add_to_base "#{name} is already in DNS with an address of #{address}" @@ -141,7 +141,7 @@ def initialize_proxies @resolver = Resolv::DNS.new :search => domain.name, :nameserver => domain.dns.address end - def destroy_netdbs + def destroy_netsvcs return true if RAILS_ENV == "test" # We do not care about entries not being present when we delete them but comms errors, etc, must be reported @@ -163,10 +163,10 @@ def destroy_netdbs false end - def create_netdbs + def create_netsvcs return true if RAILS_ENV == "test" - # We have just tested the validity of the DNS operation in check_netdbs, so if the operation fails it is not due to a conflict + # We have just tested the validity of the DNS operation in check_netsvcs, so if the operation fails it is not due to a conflict # Therefore the operation failed because the write failed and therefore we do not need to rollback the DNS operation if setDNS unless setDHCP @@ -182,7 +182,7 @@ def create_netdbs false end - def update_netdbs + def update_netsvcs old = clone for key in (changed_attributes.keys - ["updated_at"]) old.send "#{key}=", changed_attributes[key] @@ -232,4 +232,4 @@ module ClassMethods end end -Host.send :include, NetdbManager::HostExtensions +Host.send :include, NetsvcManager::HostExtensions diff --git a/lib/netdb_manager/hosts_controller_ext.rb b/lib/netdb_manager/hosts_controller_ext.rb index bfcb939..72ddbf7 100644 --- a/lib/netdb_manager/hosts_controller_ext.rb +++ b/lib/netdb_manager/hosts_controller_ext.rb @@ -1,4 +1,4 @@ -module NetdbManager +module NetsvcManager module HostsControllerExtensions def self.included(base) #:nodoc: base.send :include, InstanceMethods @@ -11,4 +11,4 @@ module InstanceMethods end end end -HostsController.send :include, NetdbManager::HostsControllerExtensions +HostsController.send :include, NetsvcManager::HostsControllerExtensions diff --git a/lib/netdb_manager/subnet_ext.rb b/lib/netdb_manager/subnet_ext.rb index 28a6af6..1143260 100644 --- a/lib/netdb_manager/subnet_ext.rb +++ b/lib/netdb_manager/subnet_ext.rb @@ -1,10 +1,10 @@ -module NetdbManager +module NetsvcManager module SubnetExtensions def self.included(base) #:nodoc: base.extend ClassMethods base.send :include, InstanceMethods base.class_eval do - belongs_to :dhcp, :class_name => 'Netdb' + belongs_to :dhcp, :class_name => 'Netsvc' validate_on_create :must_be_unique_per_site end @@ -27,4 +27,4 @@ module ClassMethods end end end -Subnet.send :include, NetdbManager::SubnetExtensions +Subnet.send :include, NetsvcManager::SubnetExtensions diff --git a/lib/netdb_manager/user_ext.rb b/lib/netdb_manager/user_ext.rb index 3f948b7..a1a156b 100644 --- a/lib/netdb_manager/user_ext.rb +++ b/lib/netdb_manager/user_ext.rb @@ -1,4 +1,4 @@ -module NetdbManager +module NetsvcManager module UserExtensions NET_TTL = 7200 def self.included(base) #:nodoc: @@ -6,7 +6,7 @@ def self.included(base) #:nodoc: base.send :include, InstanceMethods base.class_eval do class << self - alias_method_chain :try_to_login, :netdb_support + alias_method_chain :try_to_login, :netsvc_support end end end @@ -16,8 +16,8 @@ module InstanceMethods module ClassMethods - def try_to_login_with_netdb_support(login, password) - if user = self.try_to_login_without_netdb_support(login, password) + def try_to_login_with_netsvc_support(login, password) + if user = self.try_to_login_without_netsvc_support(login, password) User.capture_user_data user end user @@ -33,4 +33,4 @@ def capture_user_data user end end end -User.send :include, NetdbManager::UserExtensions +User.send :include, NetsvcManager::UserExtensions diff --git a/tasks/netdb_manager_tasks.rake b/tasks/netdb_manager_tasks.rake index a33b692..6642696 100644 --- a/tasks/netdb_manager_tasks.rake +++ b/tasks/netdb_manager_tasks.rake @@ -1,4 +1,4 @@ # desc "Explaining what the task does" -# task :netdb_manager do +# task :netsvc_manager do # # Task goes here # end diff --git a/test/netdb_manager_test.rb b/test/netdb_manager_test.rb index 05857b0..245f210 100644 --- a/test/netdb_manager_test.rb +++ b/test/netdb_manager_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class NetdbManagerTest < ActiveSupport::TestCase +class NetsvcManagerTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true