|
From: <pe...@go...> - 2010-12-14 22:26:23
|
I set up multiple frontends/databases once so it can be made to
work. It was at my previous employer though so the following is off
the top of my head - let us know what doesn't work out...
On 09/12/2010 23:12, Bill Anderson wrote:
> I created a new database for a second Netdisco instance, and can
> successfully discover devices and populate the second database tables.
Okay it looks like you have netdisco.conf and netdisco_dese.conf. I
assume the netdisco.conf and netdisco_dese.conf files are identical
apart from the database connection details and perhaps the variables
used only for backend polling (ignore_* etc).
We'll start with the Apache2 configuration...
# You do need to replicate most items for each frontend you have.
Alias /netdisco "/usr/share/netdisco/html"
Alias /netdisco_dese "/usr/share/netdisco/html"
# I implemented some of this using LocationMatch to save repetition.
<LocationMatch "/netdisco(_dese)?">
Options +Indexes
</LocationMatch>
# Note that I've moved the PerlSetVar here inside the LocationMatch:
# Turn on MASON for .html documents
<LocationMatch "/netdisco/.*\.html$">
SetHandler perl-script
PerlSetVar site "netdisco"
PerlHandler netdisco::Mason
</LocationMatch>
# Turn on MASON for .html documents
<LocationMatch "/netdisco_dese/.*\.html$">
SetHandler perl-script
PerlSetVar site "netdisco_dese"
PerlHandler netdisco::Mason
</LocationMatch>
# We can save space again with a change to the LocationMatch:
# Decline access to mason internals
<LocationMatch "/netdisco(_dese)?/.*(\.mc|autohandler|dhandler)$">
SetHandler perl-script
PerlInitHandler Apache::Constants::NOT_FOUND
</LocationMatch>
Next up the MASON conf...
# We only need one of these stanza, so pick either config file.
# Whichever file you pick will set things like the network map type.
{ package HTML::Mason::Commands;
use netdisco qw/:all/;
&netdisco::config('/etc/netdisco/netdisco.conf');
}
# Now we set up one Mason Session Handler for each frontend
# the customized items are:
# the package name
# session_cookie_name
# session_data_source (i.e. db name)
# Also you will see two variables have been added to the handler()
# webpath
# db_Pg (same as the session_data_source)
# Setup Mason and Session Handler
{ package netdisco::Mason;
use HTML::Mason;
use HTML::Mason::ApacheHandler;
use strict;
my $ah = new HTML::Mason::ApacheHandler(
args_method => 'mod_perl',
comp_root => '/usr/share/netdisco/html',
data_dir => '/var/lib/netdisco/mason',
request_class => 'MasonX::Request::WithApacheSession',
session_class => 'Apache::Session::Postgres',
session_commit => 1,
session_use_cookie => 1,
session_cookie_expires => '+1y',
session_cookie_name => 'netdisco',
session_data_source => 'dbi:Pg:dbname=netdisco',
session_user_name => 'netdisco',
session_password => 'dbpassword',
);
sub handler {
my $request = shift;
$netdisco::CONFIG{webpath} = '/netdisco';
$netdisco::CONFIG{db_Pg} = 'dbi:Pg:dbname=netdisco';
return $ah->handle_request($request);
}
}
# Setup Mason and Session Handler
{ package netdisco_dese::Mason;
use HTML::Mason;
use HTML::Mason::ApacheHandler;
use strict;
my $ah = new HTML::Mason::ApacheHandler(
args_method => 'mod_perl',
comp_root => '/usr/share/netdisco/html',
data_dir => '/var/lib/netdisco/mason',
request_class => 'MasonX::Request::WithApacheSession',
session_class => 'Apache::Session::Postgres',
session_commit => 1,
session_use_cookie => 1,
session_cookie_expires => '+1y',
session_cookie_name => 'netdisco_dese',
session_data_source => 'dbi:Pg:dbname=netdisco_dese',
session_user_name => 'netdisco',
session_password => 'dbpassword',
);
sub handler {
my $request = shift;
$netdisco::CONFIG{webpath} = '/netdisco_dese';
$netdisco::CONFIG{db_Pg} = 'dbi:Pg:dbname=netdisco_dese';
return $ah->handle_request($request);
}
}
|