Merge branch 'master' into em-device-ports-json

This commit is contained in:
Oliver Gorwits
2014-10-11 12:03:36 +01:00
33 changed files with 434 additions and 284 deletions

View File

@@ -4,7 +4,7 @@ use strict;
use warnings;
use 5.010_000;
our $VERSION = '2.029007';
our $VERSION = '2.029012';
use App::Netdisco::Configuration;
use Module::Find ();
@@ -123,6 +123,7 @@ install Netdisco and its dependencies into the C<netdisco> user's home area
su - netdisco
curl -L http://cpanmin.us/ | perl - --notest --local-lib ~/perl5 App::Netdisco
~/bin/localenv cpanm --notest --force Dancer@1.3126 DBIx::Class@0.08270
Link some of the newly installed apps into a handy location:
@@ -190,7 +191,11 @@ Netdisco 2, disable your system's cron jobs for the Netdisco 1.x poller.
For further documentation on deployment, see
L<Deployment|App::Netdisco::Manual::Deployment>.
=head1 Upgrading
=head1 Upgrading from 2.x
If you're running a version of Netdisco prior to 2.x then you should follow
the full installation instructions, above. This process is for upgrading
version 2.x only.
Before upgrading please review the latest L<Release
Notes|App::Netdisco::Manual::ReleaseNotes>. Then, the process is as follows:
@@ -198,6 +203,9 @@ Notes|App::Netdisco::Manual::ReleaseNotes>. Then, the process is as follows:
# upgrade Netdisco
~/bin/localenv cpanm --notest App::Netdisco
# workaround for current upstream bug
~/bin/localenv cpanm --notest --force Dancer@1.3126 DBIx::Class@0.08270
# apply database schema updates
~/bin/netdisco-deploy

View File

@@ -40,6 +40,15 @@ sub expire {
});
}
if (setting('expire_jobs') and setting('expire_jobs') > 0) {
schema('netdisco')->txn_do(sub {
schema('netdisco')->resultset('Admin')->search({
entered => \[q/< (now() - ?::interval)/,
(setting('expire_jobs') * 86400)],
})->delete();
});
}
return job_done("Checked expiry for all Devices and Nodes");
}

View File

@@ -256,16 +256,21 @@ code or HTML templates. For example:
FROM device d
ORDER BY name
The C<key> of each item in the C<reports> configuration is an alias for the
The C<tag> of each item in the C<reports> configuration is an alias for the
report, and becomes part of the web path.
You can munge the data retrieved from the database by placing a Perl script
with the same name as the C<reports> key into the C<site_plugins> directory of
Netdisco's home area. The script can access C<$config> for its configuration
and C<@data> for the retrieved data. It should return a list of munged data.
with the same name as the C<reports> key into the "C<site_plugins>" directory
of Netdisco's home area. The script can access C<$config> for its
configuration and C<@data> for the retrieved data. It should return a list of
munged data.
Within the tree you can provide each of the keys below:
=head4 C<tag>
Alias for the Report, which must be usable in a web path.
=head4 C<label>
Title for the Report.
@@ -295,6 +300,20 @@ C<query> may not be the same as those in the web report. Set this to a list of
the columns in C<query>. The C<columns> setting will then be used for the web
report.
=head4 C<bind_params> (optional)
You can use placeholders in the SQL C<query> (that is, "C<?>") to bind
user-supplied parameters. This setting should be a list of the parameters to
pick out of the URL query string and match to the placeholders in the same
order. For example:
query: |
SELECT ... FROM ... WHERE device = ? AND port = ?
bind-params: ['device', 'port']
# then
http://localhost:5000/report/my_special_report?device=192.0.2.1&port=Vlan142
=head3 C<jobqueue_refresh>
Value: Integer Number. Default: 5.
@@ -724,14 +743,14 @@ seconds as well as integers.
=head3 C<expire_devices>
Value: Number of Days.
Value: Number of Days. Default: 60
Devices that have not been refreshed in this number of days will be removed.
All nodes connected to this device will be removed as well.
=head3 C<expire_nodes>
Value: Number of Days.
Value: Number of Days. Default: 90
Nodes that have not been refreshed in this number of days will be removed from
the database. Archived and non-archived nodes are removed. This includes
@@ -739,11 +758,19 @@ SwitchPort/MAC and MAC/IP mappings.
=head3 C<expire_nodes_archive>
Value: Number of Days.
Value: Number of Days. Default: 60
Archived data for switch-port/MAC and MAC/IP mappings older than this number
of days will be removed.
=head3 C<expire_jobs>
Value: Number of Days. Default: 14
Jobs which entered the job queue more than this many days ago will be removed
from the queue during the scheduled expiry process (regardless of whether they
were ever run).
=head3 C<dns>
Value: Settings Tree. Default:

View File

@@ -36,6 +36,24 @@ but they are backwards compatible.
=back
=head1 2.029010
=head2 General Notices
When upgrading you will encounter a current incompatibility between Netdisco
and one of its components. To work around this, issue the following command:
~/bin/localenv cpanm --notest --force Dancer@1.3126 DBIx::Class@0.08270
=head1 2.029008
=head2 General Notices
When upgrading you will encounter a current incompatibility between Netdisco
and one of its components. To work around this, issue the following command:
~/bin/localenv cpanm --notest --force Dancer@1.3126
=head1 2.029002
=head2 General Notices

View File

@@ -23,8 +23,9 @@ the same context.
use strict;
use warnings;
use Moo;
use Dancer ':script';
use Expect;
use Moo;
=head1 PUBLIC METHODS

View File

@@ -22,6 +22,7 @@ can't be executed, falls back to the latter.
use strict;
use warnings;
use Dancer ':script';
use Moo;
=head1 PUBLIC METHODS

View File

@@ -16,7 +16,6 @@ use strict;
use warnings;
use Dancer ':script';
use Data::Printer;
use Moo;
=head1 PUBLIC METHODS

View File

@@ -16,9 +16,8 @@ use strict;
use warnings;
use Dancer ':script';
use Data::Printer;
use Moo;
use Expect;
use Moo;
=head1 PUBLIC METHODS

View File

@@ -16,9 +16,8 @@ use strict;
use warnings;
use Dancer ':script';
use Data::Printer;
use Moo;
use Expect;
use Moo;
=head1 PUBLIC METHODS

View File

@@ -22,11 +22,10 @@ foreach my $report (@{setting('reports')}) {
});
get "/ajax/content/report/$r" => require_login sub {
my $rs = schema('netdisco')->resultset('Virtual::GenericReport')->result_source;
# TODO: this should be done by creating a new Virtual Result class on
# the fly (package...) and then calling DBIC register_class on it.
my $rs = schema('netdisco')->resultset('Virtual::GenericReport')->result_source;
$rs->view_definition($report->{query});
$rs->remove_columns($rs->columns);
$rs->add_columns( exists $report->{query_columns}
@@ -35,13 +34,17 @@ foreach my $report (@{setting('reports')}) {
);
my $set = schema('netdisco')->resultset('Virtual::GenericReport')
->search(undef, {result_class => 'DBIx::Class::ResultClass::HashRefInflator'});
->search(undef, {
result_class => 'DBIx::Class::ResultClass::HashRefInflator',
( (exists $report->{bind_params})
? (bind => [map { param($_) } @{ $report->{bind_params} }]) : () ),
});
@data = $set->all;
# Data Munging support...
my $compartment = Safe->new;
$config = $report;
$config = $report; # closure for the config of this report
$compartment->share(qw/$config @data/);
$compartment->permit_only(qw/:default sort/);

View File

@@ -169,15 +169,23 @@ register 'register_report' => sub {
return error "bad config to register_report";
}
foreach my $item (@{setting('_reports_menu')->{ $config->{category} }}) {
if ($item eq $config->{tag}) {
setting('_reports')->{$config->{tag}} = $config;
return;
}
if (0 == scalar grep {$_ eq $config->{tag}}
@{setting('_reports_menu')->{ $config->{category} }}) {
push @{setting('_reports_menu')->{ $config->{category} }}, $config->{tag};
}
push @{setting('_reports_menu')->{ $config->{category} }}, $config->{tag};
setting('_reports')->{$config->{tag}} = $config;
foreach my $tag (@{setting('_reports_menu')->{ $config->{category} }}) {
if ($config->{tag} eq $tag) {
setting('_reports')->{$tag} = $config;
foreach my $rconfig (@{setting('reports')}) {
if ($rconfig->{tag} eq $tag) {
setting('_reports')->{$tag}->{'rconfig'} = $rconfig;
last;
}
}
}
}
};
register_plugin;