Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: gmambro/manoc
base: 5975c0b00a
...
head fork: gmambro/manoc
compare: 96dffd6a2f
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
12 lib/Manoc/DB/Result/IPRange.pm
@@ -8,7 +8,9 @@ use base 'DBIx::Class';
use strict;
use warnings;
-__PACKAGE__->load_components(qw/ Core/);
+use Manoc::Utils;
+
+__PACKAGE__->load_components(qw/FilterColumn Core/);
__PACKAGE__->table('ip_range');
__PACKAGE__->add_columns(
@@ -62,4 +64,12 @@ __PACKAGE__->has_many(
{ 'foreign.parent' => 'self.name' }
);
__PACKAGE__->resultset_attributes( { order_by => [ 'from_addr', 'to_addr' ] } );
+
+foreach my $col (qw(from_addr to_addr network netmask)) {
+ __PACKAGE__->filter_column(
+ $col => {
+ filter_to_storage => sub { Manoc::Utils::padded_ipaddr($_[1]) },
+ });
+}
+
1;
View
5 lib/Manoc/Utils.pm
@@ -177,6 +177,11 @@ sub netmask2prefix {
return $INET_NETMASK{$netmask};
}
+sub padded_ipaddr {
+ my $addr = shift;
+ join('.', map { sprintf('%03d', $_) } split( /\./, $addr ))
+}
+
BEGIN {
my $netmask_i;
View
1  root/src/mngurlformat/save.tt
@@ -4,3 +4,4 @@
<div class="buttons">
[% form.render %]
</div>
+<p>Use <tt>%h</tt> as a placeholder for device address</p>
View
44 script/manoc_initdb.pl
@@ -13,17 +13,36 @@ package Manoc::InitDB;
use Manoc::Logger;
extends 'Manoc::App';
-#with 'Manoc::Logger::Role';
+with 'MooseX::Getopt::Dashes';
-use SQL::Translator;
+has 'reset_admin' => (
+ is => 'rw',
+ isa => 'Bool',
+ required => 0,
+ default => 0
+);
sub run {
my ($self) = @_;
+ if ($self->reset_admin) {
+ $self->do_reset_admin;
+ return;
+ }
+
+ # full init
+ $self->do_reset_admin;
+ $self->init_vlan;
+
+}
+
+sub do_reset_admin {
+ my ($self) = @_;
+
my $schema = $self->schema;
- $self->log->debug('Creating admin role... done.');
+ $self->log->info('Creating admin role.');
my $admin_role = $schema->resultset('Role')->update_or_create( { role => 'admin', } );
- $self->log->debug('Creating admin user... done.');
+ $self->log->info('Creating admin user.');
my $admin_user = $schema->resultset('User')->update_or_create(
{
login => 'admin',
@@ -36,7 +55,24 @@ sub run {
if ( $admin_user->roles->search( { role => 'admin' } )->count == 0 ) {
$admin_user->add_to_roles($admin_role);
}
+}
+
+sub init_vlan {
+ my ($self) = @_;
+ my $schema = $self->schema;
+ my $rs = $schema->resultset('VlanRange');
+ if ($rs->count() > 0) {
+ $self->log->info('We have a VLAN range: skipping init.');
+ return;
+ }
+ my $vlan_range = $schema->resultset('VlanRange')->update_or_create({
+ name => 'sample',
+ description => 'sample range',
+ start => 1,
+ end => 10,
+ });
+ $vlan_range->add_to_vlans({ name => 'native', id => 1 });
}
no Moose;

No commit comments for this range

Something went wrong with that request. Please try again.