Send Netdot-devel mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."
Today's Topics:
1. Re: [Netdot - Bug #1766] Error with Ipblocks with more than
one Ipblock attribute (Anton Berezin)
2. Re: [Netdot - Bug #1766] Error with Ipblocks with more than
one Ipblock attribute (William Bulley)
3. Re: [Netdot - Bug #1766] Error with Ipblocks with more than
one Ipblock attribute (Carlos Vicente)
4. Re: [Netdot - Bug #1766] Error with Ipblocks with more than
one Ipblock attribute (William Bulley)
5. Re: [Netdot - Bug #1766] Error with Ipblocks with more than
one Ipblock attribute (Anton Berezin)
6. Re: [Netdot - Bug #1766] Error with Ipblocks with more than
one Ipblock attribute (William Bulley)
7. [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-83-g5cf619d ([email protected])
----------------------------------------------------------------------
Message: 1
Date: Wed, 24 Jul 2013 21:15:30 +0200
From: Anton Berezin <[email protected]>
Subject: Re: [Netdot-devel] [Netdot - Bug #1766] Error with Ipblocks
with more than one Ipblock attribute
To: William Bulley <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi,
On Wed, Jul 24, 2013 at 02:51:50PM -0400, William Bulley wrote:
> According to [email protected] on Tue, 07/23/13 at 17:11:
> >
> > Issue #1766 has been updated by Anton Berezin.
> >
> > Should be really fixed with
> >
> > https://github.com/tobez/Netdot/commit/9f507894c84f93d6646f77d7c20d1c2b80efb652
>
> I am a bit confused by the above URL.
>
> I have compared the code of htdocs/generic/sortresults.mhtml from
> version 1.0.4 with the HEAD of the master branch in the repository
> (no changes to this file from middle of last year - 2012) with the
> diffs in the above URL. I do not see the "use NetAddr::IP;" pragma
> in the 1.0.4 or master branch files.
The 9f507894 commit is "a fix to a fix",
https://github.com/tobez/Netdot/commit/fa0b6e2b0590491b533dc107ea137b75345d1bb2
.
The fa0b6e2b commit has introduced "use NetAddr::IP", and 9f507894 removed
that since it was not needed. So you need to apply both patches in sequence
to get the intended result.
> Also, the changes show a call
> to the "can()" method on (the new) line 151. Where does this "can"
> method appear (in which Perl module or library)? Thanks!
->can() is a method of class UNIVERSAL, which is a base class for ALL Perl
classes, and thus is available to any perl object.
\Anton.
--
Our society can survive even a large amount of irrational regulation.
-- John McCarthy
------------------------------
Message: 2
Date: Thu, 25 Jul 2013 10:24:55 -0400
From: William Bulley <[email protected]>
Subject: Re: [Netdot-devel] [Netdot - Bug #1766] Error with Ipblocks
with more than one Ipblock attribute
To: Anton Berezin <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
According to Anton Berezin <[email protected]> on Wed, 07/24/13 at 15:15:
>
> The 9f507894 commit is "a fix to a fix",
> https://github.com/tobez/Netdot/commit/fa0b6e2b0590491b533dc107ea137b75345d1bb2
> .
>
> The fa0b6e2b commit has introduced "use NetAddr::IP", and 9f507894 removed
> that since it was not needed. So you need to apply both patches in sequence
> to get the intended result.
Okay, thanks. But it must not be part of the HEAD (master branch)
since the last date on this file is mid-2012, and the call to the
can() method is not present there, so where is the actual file
content to be found?
> ->can() is a method of class UNIVERSAL, which is a base class for ALL Perl
> classes, and thus is available to any perl object.
Thanks.
When I issue this shell command:
unix% perldoc -rf can
No documentation for perl function 'can' found
Where do I find documentation about this "can" method?
Ahhh, nevermind. I just found it by running this:
unix% perldoc UNIVERSAL
Thanks again!
Regards,
web...
--
William Bulley Email: [email protected]
72 characters width template ----------------------------------------->|
------------------------------
Message: 3
Date: Thu, 25 Jul 2013 10:30:09 -0400
From: Carlos Vicente <[email protected]>
Subject: Re: [Netdot-devel] [Netdot - Bug #1766] Error with Ipblocks
with more than one Ipblock attribute
To: William Bulley <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Web,
Anton's code is in his github fork. I haven't merged his changes yet. I
will do so soon.
cv
On 7/25/13 10:24 AM, William Bulley wrote:
> Okay, thanks. But it must not be part of the HEAD (master branch)
> since the last date on this file is mid-2012, and the call to the
> can() method is not present there, so where is the actual file
> content to be found?
------------------------------
Message: 4
Date: Thu, 25 Jul 2013 10:37:23 -0400
From: William Bulley <[email protected]>
Subject: Re: [Netdot-devel] [Netdot - Bug #1766] Error with Ipblocks
with more than one Ipblock attribute
To: Carlos Vicente <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
According to Carlos Vicente <[email protected]> on Thu, 07/25/13 at 10:30:
>
> Anton's code is in his github fork. I haven't merged his changes yet. I
> will do so soon.
Okay, thanks. Sorry for all the confusion. :-(
Regards,
web...
--
William Bulley Email: [email protected]
72 characters width template ----------------------------------------->|
------------------------------
Message: 5
Date: Thu, 25 Jul 2013 16:40:29 +0200
From: Anton Berezin <[email protected]>
Subject: Re: [Netdot-devel] [Netdot - Bug #1766] Error with Ipblocks
with more than one Ipblock attribute
To: William Bulley <[email protected]>
Cc: Carlos Vicente <[email protected]>,
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Thu, Jul 25, 2013 at 10:37:23AM -0400, William Bulley wrote:
> According to Carlos Vicente <[email protected]> on Thu, 07/25/13 at 10:30:
> >
> > Anton's code is in his github fork. I haven't merged his changes yet. I
> > will do so soon.
>
> Okay, thanks. Sorry for all the confusion. :-(
And at any rate, if you want to fetch the whole file from my fork, you can
download it from
https://raw.github.com/tobez/Netdot/master/htdocs/generic/sortresults.mhtml
\Anton.
--
Our society can survive even a large amount of irrational regulation.
-- John McCarthy
------------------------------
Message: 6
Date: Thu, 25 Jul 2013 10:43:20 -0400
From: William Bulley <[email protected]>
Subject: Re: [Netdot-devel] [Netdot - Bug #1766] Error with Ipblocks
with more than one Ipblock attribute
To: Anton Berezin <[email protected]>
Cc: Carlos Vicente <[email protected]>,
[email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
According to Anton Berezin <[email protected]> on Thu, 07/25/13 at 10:40:
>
> And at any rate, if you want to fetch the whole file from my fork, you can
> download it from
>
> https://raw.github.com/tobez/Netdot/master/htdocs/generic/sortresults.mhtml
Thanks! May I inquire approximately as to where (geographically) you
are located? I am located in Michigan, USA.
Regards,
web...
--
William Bulley Email: [email protected]
72 characters width template ----------------------------------------->|
------------------------------
Message: 7
Date: Thu, 25 Jul 2013 09:01:23 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.4-83-g5cf619d
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, netdot-1.0 has been updated
via 5cf619dbcc5bf26ee33f69183aa4270c9be4e3e2 (commit)
via 4af46e5cad637c7ed5d9d0d2ed4b7d747fb0ee99 (commit)
from 4a28508ad754a2a6b476a8bce2e74d1e6bc1ffec (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5cf619dbcc5bf26ee33f69183aa4270c9be4e3e2
Author: Carlos Vicente <[email protected]>
Date: Thu Jul 25 12:00:52 2013 -0400
Feature #1758 (New fields for bgppeering table
diff --git a/etc/netdot.meta b/etc/netdot.meta
index 053b587..b289187 100644
--- a/etc/netdot.meta
+++ b/etc/netdot.meta
@@ -667,6 +667,19 @@ $meta = {
tag => 'Peer ID',
type => 'varchar'
},
+ contactlist => {
+ default => '',
+ description => 'Who to contact about this peering session. Also used
for Nagios alarms.',
+ length => '',
+ linksto => {
+ cascade => 'Nullify',
+ method => 'peerings',
+ table => 'ContactList'
+ },
+ nullable => 0,
+ tag => 'Contact List',
+ type => 'bigint'
+ },
device => {
default => '',
description => 'Device where BGP peering exists (the local device,
that is)',
@@ -709,6 +722,14 @@ $meta = {
tag => 'Comments',
type => 'text'
},
+ last_changed => {
+ default => '',
+ description => 'Time when the state last changed',
+ length => '',
+ nullable => 0,
+ tag => 'Last Changed',
+ type => 'timestamp'
+ },
max_v4_prefixes => {
default => '',
description => 'Maximum number of IPv4 prefixes we will permit from
this peer',
@@ -733,18 +754,21 @@ $meta = {
tag => 'Monitored?',
type => 'bool'
},
- monitorstatus => {
+ state => {
default => '',
- description => 'Monitoring Status of this Peering',
- length => '',
- linksto => {
- cascade => 'Fail',
- method => 'bgppeers',
- table => 'MonitorStatus'
- },
+ description => 'Peering state',
+ length => '255',
nullable => 1,
- tag => 'Monitored Status',
- type => 'bigint'
+ tag => 'State',
+ type => 'varchar'
+ },
+ peer_group => {
+ default => '',
+ description => 'Name of the peer group',
+ length => '255',
+ nullable => 1,
+ tag => 'Peer Group',
+ type => 'varchar'
},
},
description => 'A BGP Peering',
@@ -772,11 +796,14 @@ $meta = {
'entity',
'bgppeerid',
'bgppeeraddr',
+ 'state',
+ 'last_changed',
'max_v4_prefixes',
'max_v6_prefixes',
'monitored',
- 'monitorstatus',
'authkey',
+ 'peer_group',
+ 'contactlist',
'info',
],
brief => [
diff --git a/htdocs/management/device.html b/htdocs/management/device.html
index 43a583c..7201a01 100644
--- a/htdocs/management/device.html
+++ b/htdocs/management/device.html
@@ -1235,10 +1235,12 @@ push( @headers, '<a href="device.html?id=' . $id .
'&view=' . $view . '&peersort
push( @headers, '<a href="device.html?id=' . $id . '&view=' . $view .
'&peersort=entity">Entity</a>' );
push( @headers, '<a href="device.html?id=' . $id . '&view=' . $view .
'&peersort=asname">AS Name</a>' );
push( @headers, '<a href="device.html?id=' . $id . '&view=' . $view .
'&peersort=asnumber">AS Number</a>' );
+push( @headers, '<a href="device.html?id=' . $id . '&view=' . $view .
'&peersort=state">State</a>' );
push( @headers, 'Monitored?' );
+push( @headers, 'Contact List' );
if ( $epeers ){
- push @rows, ["<strong>External (eBGP)</strong>", "", "", "", "", ""];
+ push @rows, ["<strong>External (eBGP)</strong>", "", "", "", "", "", "",
""];
foreach my $peer ( @$epeers ){
my (@row) = ();
@@ -1255,13 +1257,16 @@ if ( $epeers ){
}else{
push( @row, $asn );
}
+ push( @row, $peer->state );
push( @row, $ui->radio_group_boolean(object=>$peer,
column=>"monitored", edit=>$editbgp, returnAsVar=>1) );
+ push( @row, $ui->form_field(object=>$peer, column=>"contactlist",
+ edit=>$editbgp, linkPage=>"view.html",
returnValOnly=>1) );
push( @rows, \@row );
}
- push @rows, [" ", "", "", "", "", ""];
+ push @rows, [" ", "", "", "", "", "", "", ""];
}
if ( $ipeers ){
- push @rows, ["<strong>Internal (iBGP)</strong>", "", "", "", "", ""];
+ push @rows, ["<strong>Internal (iBGP)</strong>", "", "", "", "", "", "",
""];
foreach my $peer (@$ipeers){
my (@row) = ();
@@ -1278,7 +1283,10 @@ if ( $ipeers ){
}else{
push( @row, $peer->entity->asnumber );
}
+ push( @row, $peer->state );
push( @row, $ui->radio_group_boolean(object=>$peer,
column=>"monitored", edit=>$editbgp, returnAsVar=>1) );
+ push( @row, $ui->form_field(object=>$peer, column=>"contactlist",
+ edit=>$editbgp, linkPage=>"view.html",
returnValOnly=>1) );
push( @rows, \@row );
}
}
diff --git a/lib/Netdot/Exporter.pm b/lib/Netdot/Exporter.pm
index eccace4..3fecfa2 100644
--- a/lib/Netdot/Exporter.pm
+++ b/lib/Netdot/Exporter.pm
@@ -89,7 +89,7 @@ sub get_device_info {
i.id, i.number, i.name, i.description, i.admin_status,
i.monitored, i.contactlist,
ip.id, ip.address, ip.version, ip.parent, ip.monitored,
rr.name, zone.name,
service.id, service.name, ipservice.monitored,
ipservice.contactlist,
- bgppeering.bgppeeraddr, bgppeering.monitored
+ bgppeering.bgppeeraddr, bgppeering.monitored,
bgppeering.contactlist
FROM rr, zone, device d
LEFT OUTER JOIN bgppeering ON d.id=bgppeering.device
LEFT OUTER JOIN devicecontacts ON d.id=devicecontacts.device
@@ -114,7 +114,7 @@ sub get_device_info {
$intid, $intnumber, $intname, $intdesc, $intadmin, $intmon, $intcl,
$ip_id, $ip_addr, $ip_version, $subnet, $ip_mon, $name, $zone,
$srv_id, $srv_name, $srv_mon, $srv_cl,
- $peeraddr, $peermon) = @$row;
+ $peeraddr, $peermon, $peercl) = @$row;
my $hostname = ($name eq '@')? $zone : $name.'.'.$zone;
$device_info{$devid}{target_id} = $target_id;
$device_info{$devid}{hostname} = $hostname;
@@ -128,13 +128,14 @@ sub get_device_info {
$device_info{$devid}{site_number} = $site_number if defined
$site_number;
$device_info{$devid}{site_alias} = $site_alias if defined
$site_alias;
$device_info{$devid}{contactlist}{$clid} = 1 if defined $clid;
- $device_info{$devid}{peering}{$peeraddr}{monitored} = $peermon if
defined $peeraddr;
- $device_info{$devid}{interface}{$intid}{number} = $intnumber;
- $device_info{$devid}{interface}{$intid}{name} = $intname;
- $device_info{$devid}{interface}{$intid}{description} = $intdesc;
- $device_info{$devid}{interface}{$intid}{admin} = $intadmin;
- $device_info{$devid}{interface}{$intid}{monitored} = $intmon;
- $device_info{$devid}{interface}{$intid}{contactlist} = $intcl;
+ $device_info{$devid}{peering}{$peeraddr}{monitored} = $peermon if
defined $peeraddr;
+ $device_info{$devid}{peering}{$peeraddr}{contactlist} = $peercl if
defined $peeraddr;
+ $device_info{$devid}{interface}{$intid}{number} = $intnumber;
+ $device_info{$devid}{interface}{$intid}{name} = $intname;
+ $device_info{$devid}{interface}{$intid}{description} = $intdesc;
+ $device_info{$devid}{interface}{$intid}{admin} = $intadmin;
+ $device_info{$devid}{interface}{$intid}{monitored} = $intmon;
+ $device_info{$devid}{interface}{$intid}{contactlist} = $intcl;
if ( defined $ip_id ){
$device_info{$devid}{interface}{$intid}{ip}{$ip_id}{addr} =
$ip_addr;
$device_info{$devid}{interface}{$intid}{ip}{$ip_id}{version} =
$ip_version;
diff --git a/lib/Netdot/Exporter/Nagios.pm b/lib/Netdot/Exporter/Nagios.pm
index 411bf7a..9ff71e3 100644
--- a/lib/Netdot/Exporter/Nagios.pm
+++ b/lib/Netdot/Exporter/Nagios.pm
@@ -261,7 +261,13 @@ sub generate_configs {
$hosts{$ip}{service}{$srvname}{peeraddr} = $peeraddr;
$hosts{$ip}{service}{$srvname}{srvname} = $srvname;
$hosts{$ip}{service}{$srvname}{community} =
$devh->{community};
- $hosts{$ip}{service}{$srvname}{contactlists} = \@clids;
+ my @peercls;
+ if ( $peering->{contactlist} ){
+ push @peercls, $peering->{contactlist};
+ }else{
+ push @peercls, @clids;
+ }
+ $hosts{$ip}{service}{$srvname}{contactlists} = \@peercls;
}
}
diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index ccb5d2a..4b1de3f 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -730,7 +730,7 @@ sub get_snmp_info {
}
if ( $args{bgp_peers} || $self->config->get('ADD_BGP_PEERS')) {
- push @SMETHODS, qw( bgp_peers bgp_peer_id bgp_peer_as );
+ push @SMETHODS, qw( bgp_peers bgp_peer_id bgp_peer_as bgp_peer_state );
}
my %hashes;
@@ -1212,6 +1212,9 @@ sub get_snmp_info {
}else{
$logger->warn("Could not determine AS number of peer $peer");
}
+ if ( my $state = $hashes{'bgp_peer_state'}->{$peer} ){
+ $dev{bgp_peer}{$peer}{state} = $state;
+ }
}
}
@@ -2637,7 +2640,9 @@ sub update_bgp_peering {
my %pstate = (device => $self,
entity => $entity,
bgppeerid => $peer->{bgppeerid},
- bgppeeraddr => $peer->{address});
+ bgppeeraddr => $peer->{address},
+ state => $peer->{state},
+ );
# Check if peering exists
foreach my $peerid ( keys %{ $old_peerings } ){
@@ -2655,6 +2660,11 @@ sub update_bgp_peering {
}
if ( $p ){
# Update in case anything has changed
+ # Only change last_changed if the state has changed
+ if ( defined $p->state && defined $pstate{state} &&
+ $p->state ne $pstate{state} ){
+ $pstate{last_changed} = $self->timestamp;
+ }
my $r = $p->update(\%pstate);
$logger->debug(sub{ sprintf("%s: Updated Peering with: %s. ", $host,
$entity->name)}) if $r;
@@ -2666,6 +2676,7 @@ sub update_bgp_peering {
}else{
$pstate{monitored} = 0;
}
+ $pstate{last_changed} = $self->timestamp;
$p = BGPPeering->insert(\%pstate);
my $peer_label;
$peer_label = $entity->name if ($entity && ref($entity)) ;
@@ -3603,7 +3614,7 @@ sub bgppeers_by_entity {
ip <address> Return peers whose Remote IP matches <address>
as <integer> Return peers whose AS matches <integer>
type <string> Return peers of type [internal|external|all*]
- sort <string> Sort by [entity*|asnumber|asname|id|ip]
+ sort <string> Sort by [entity*|asnumber|asname|id|ip|state]
(*) default
@@ -3649,6 +3660,8 @@ sub get_bgp_peers {
return $self->bgppeers_by_ip(\@peers);
}elsif( $argv{sort} eq "id" ){
return $self->bgppeers_by_id(\@peers);
+ }elsif( $argv{sort} eq "state" ){
+ @peers = sort { $a->state cmp $b->state } @peers;
}else{
$self->throw_fatal("Model::Device::get_bgp_peers: Invalid sort
argument: $argv{sort}");
}
diff --git a/upgrade/updatedb b/upgrade/updatedb
index 5f0a7d7..4b8e131 100644
--- a/upgrade/updatedb
+++ b/upgrade/updatedb
@@ -203,6 +203,14 @@ sub upg_104_105 {
push @statements, "ALTER TABLE device MODIFY bgplocalas bigint;";
push @statements, "UPDATE device,asn SET device.bgplocalas=asn.id WHERE
device.bgplocalas=asn.number;";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN contactlist bigint
NOT NULL;";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN last_changed
timestamp NOT NULL;";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN peer_group
varchar(255);";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN state
varchar(255);";
+ push @statements, "ALTER TABLE bgppeering DROP FOREIGN KEY
`fk_monitorstatus`;";
+ push @statements, "ALTER TABLE bgppeering DROP INDEX monitorstatus;";
+ push @statements, "ALTER TABLE bgppeering DROP COLUMN monitorstatus;";
+
}elsif ( $dbms eq 'Pg' ){
@@ -236,6 +244,12 @@ sub upg_104_105 {
push @statements, "ALTER TABLE device ALTER COLUMN bgplocalas TYPE
bigint;";
push @statements, "UPDATE device SET bgplocalas=asn.id FROM asn WHERE
device.bgplocalas=asn.number;";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN contactlist bigint
NOT NULL;";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN last_changed
timestamp NOT NULL";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN peer_group
character varying(255);";
+ push @statements, "ALTER TABLE bgppeering ADD COLUMN state character
varying(255);";
+ push @statements, "ALTER TABLE bgppeering DROP COLUMN monitorstatus;";
+
}
push @statements, "UPDATE schemainfo SET version='1.0.5' WHERE id=1;";
commit 4af46e5cad637c7ed5d9d0d2ed4b7d747fb0ee99
Author: Carlos Vicente <[email protected]>
Date: Thu Jul 18 16:20:12 2013 -0400
ASN class
diff --git a/lib/Netdot/Model/ASN.pm b/lib/Netdot/Model/ASN.pm
new file mode 100644
index 0000000..11b87c8
--- /dev/null
+++ b/lib/Netdot/Model/ASN.pm
@@ -0,0 +1,137 @@
+package Netdot::Model::ASN;
+
+use base 'Netdot::Model';
+use warnings;
+use strict;
+
+my $logger = Netdot->log->get_logger('Netdot::Model');
+
+=head1 NAME
+
+Netdot::Model::ASN - Autonomous System Number class
+
+=head1 CLASS METHODS
+=cut
+
+##################################################################
+
+=head2 insert - Insert a new ASN
+
+ Override parent method to:
+ - Validate arguments
+
+ Arguments:
+ Hash ref of key/value pairs
+ Returns:
+ New ASN object
+ Examples:
+ ASN->insert(\%data);
+
+=cut
+
+sub insert {
+ my ($class, $argv) = @_;
+ $class->isa_class_method('insert');
+
+ $class->throw_fatal("Missing required arguments: number")
+ unless ( exists $argv->{number} );
+
+ $class->_validate($argv);
+
+ my $new;
+ if ( $new = $class->search(number=>$argv->{number})->first ){
+ $class->throw_user("ASN number ".$argv->{number}." already exists!");
+ }else{
+ $new = $class->SUPER::insert($argv);
+ }
+
+ return $new;
+}
+
+=head1 INSTANCE METHODS
+=cut
+
+############################################################################
+
+=head2 update
+
+ Override parent method to:
+ - Validate arguments
+
+ Args:
+ Hashref
+ Returns:
+ See Class::DBI
+ Examples:
+ $asn->update(\%args);
+=cut
+
+sub update{
+ my ($self, $argv) = @_;
+ $self->isa_object_method('update');
+
+ $self->_validate($argv);
+
+ my @res = $self->SUPER::update($argv);
+ return @res;
+}
+
+##################################################################
+# Private Methods
+##################################################################
+
+##################################################################
+# _validate - Validate block when creating and updating
+#
+# Arguments:
+# Hash ref of arguments passed to insert/set
+# Returns:
+# True if object is valid. Throws exception if not.
+# Examples:
+# $asn->_validate($args);
+
+
+sub _validate {
+ my ($self, $args) = @_;
+
+ my $num = $args->{number};
+ if ( $num < 1 || $num > 4294967295 ){
+ $self->throw_user("Invalid AS number: $num");
+ }
+
+ if ( my $rir = $args->{rir} ){
+ my $re = $self->config->get('VALID_RIR_REGEX');
+ unless ( $rir =~ /$re/ ){
+ $self->throw_user("Invalid RIR: $rir");
+ }
+ }
+
+ return 1;
+}
+
+=head1 AUTHOR
+
+Carlos Vicente, C<< <cvicente at ns.uoregon.edu> >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2013 University of Oregon, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+=cut
+
+#Be sure to return 1
+1;
-----------------------------------------------------------------------
Summary of changes:
etc/netdot.meta | 49 +++++++++++---
htdocs/management/device.html | 14 +++-
lib/Netdot/Exporter.pm | 19 +++---
lib/Netdot/Exporter/Nagios.pm | 8 ++-
lib/Netdot/Model/ASN.pm | 137 +++++++++++++++++++++++++++++++++++++++++
lib/Netdot/Model/Device.pm | 19 +++++-
upgrade/updatedb | 14 ++++
7 files changed, 233 insertions(+), 27 deletions(-)
create mode 100644 lib/Netdot/Model/ASN.pm
hooks/post-receive
--
Netdot
------------------------------
_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
End of Netdot-devel Digest, Vol 76, Issue 16
********************************************