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. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
netdot-1.0.1-52-gc985e9f ([email protected])
2. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
netdot-1.0.1-54-g9e923fc ([email protected])
3. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
netdot-1.0.1-57-g6489894 ([email protected])
----------------------------------------------------------------------
Message: 1
Date: Wed, 26 Sep 2012 13:07:20 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
updated. netdot-1.0.1-52-gc985e9f
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 "UNNAMED PROJECT".
The branch, netdot-1.0 has been updated
via c985e9f187378d9248b4cbc8ef0f73fd6030ce38 (commit)
via 93b478701dce0f3a2449cc45296715289ef570b8 (commit)
via 235463eab295c93269829a81ec04dead2c0b07d3 (commit)
via 98f0802ecfe801a675f41304e6c81de79fa99b78 (commit)
via 99600a640106b1836b7ff414ff52b88d4ebf0860 (commit)
from d073fb95d00541a0519ee837d6554cc176074925 (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 c985e9f187378d9248b4cbc8ef0f73fd6030ce38
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 16:07:02 2012 -0400
Change order of Asset display fields
diff --git a/etc/netdot.meta b/etc/netdot.meta
index 944bb5b..037bf1a 100644
--- a/etc/netdot.meta
+++ b/etc/netdot.meta
@@ -521,7 +521,7 @@ $meta = {
index => [ ['serial_number'], ['inventory_number'], ['po_number'] ],
isjoin => '0',
primary_key => 'id',
- label => ['serial_number', 'physaddr', 'product_id' ],
+ label => ['product_id', 'serial_number', 'physaddr' ],
unique => [ ['physaddr'], ['product_id', 'serial_number'] ]
},
Availability => {
commit 93b478701dce0f3a2449cc45296715289ef570b8
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 13:20:33 2012 -0400
Fix for 1691 (DeviceModule duplicates problem)
diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index 7e79634..b063f79 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -5393,8 +5393,9 @@ sub _update_modules {
my %oldmodules;
map { $oldmodules{$_->number} = $_ } $self->modules();
- foreach my $number ( sort { $a <=> $b } keys %{$modules} ){
- my %mod_args = %{$modules->{$number}};
+ foreach my $key ( keys %{$modules} ){
+ my $number = $modules->{$key}->{number};
+ my %mod_args = %{$modules->{$key}};
$mod_args{device} = $self->id;
my $show_name = $mod_args{name} || $number;
# find or create asset object for given serial number and product
commit 235463eab295c93269829a81ec04dead2c0b07d3
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 13:19:16 2012 -0400
Ignore em* interfaces from Juniper devices
diff --git a/etc/Default.conf b/etc/Default.conf
index 9abbcbe..83238c5 100644
--- a/etc/Default.conf
+++ b/etc/Default.conf
@@ -283,7 +283,7 @@ IFNAME_SHORT => 0,
# Ignore interfaces containing these strings in their names
-IFRESERVED => "bme|pime|mtun|lsi|jsrv|pimd|vt-|tap|pe-|pd-|dsc|rptr|unrouted",
+IFRESERVED =>
'^bme|pime|mtun|lsi|jsrv|pimd|vt-|tap|pe-|pd-|dsc|rptr|unrouted|em\d+',
# Ignore the following VLANs
commit 98f0802ecfe801a675f41304e6c81de79fa99b78
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 11:32:56 2012 -0400
Avoid trying to match specific errors from DB. It doesn't work in other
locales
diff --git a/lib/Netdot/Model.pm b/lib/Netdot/Model.pm
index 25302c2..4fd6eab 100644
--- a/lib/Netdot/Model.pm
+++ b/lib/Netdot/Model.pm
@@ -454,20 +454,7 @@ sub insert {
}else{
$error = $e;
}
- my $msg = "Error while inserting $class: ";
- if ( $e =~ /Duplicate entry/i ){
- $msg .= "Some values are duplicated\n\n";
- $msg .= "Error details: ".$error;
- }elsif ( $e =~ /cannot be null|not-null constraint/i ){
- $msg .= "Some fields cannot be null\n\n";
- $msg .= "Error details: ".$error;
- }elsif ( $e =~ /invalid input syntax/i ){
- $msg .= "Some fields have invalid input syntax.";
- }elsif ( $e =~ /out of range/i ){
- $msg .= "Some values are out of valid range.";
- }else{
- $msg .= $error;
- }
+ my $msg = "Error while inserting $class: $error";
$class->throw_user("$msg");
}
@@ -671,8 +658,6 @@ sub raw_sql {
$st->execute();
};
if ( my $e = $@ ){
- # parse out SQL error message from the entire error
- $e =~ s/execute failed:(.*)\"] at/$1/io;
$self->throw_user("SQL Error: $e");
}
$result{headers} = $st->{"NAME_lc"};
@@ -830,18 +815,7 @@ sub update {
$res = $self->SUPER::update();
};
if ( my $e = $@ ){
- my $msg = "Error while updating $class: ";
- # Class::DBI shows a full stack trace
- # Try to make it less frightening for the user
- if ( $e =~ /Duplicate/i ){
- $msg .= "Some values are duplicated. Full error: $e";
- }elsif ( $e =~ /invalid input syntax/i ){
- $msg .= "Some fields have invalid input syntax";
- }elsif ( $e =~ /out of range/i ){
- $msg .= "Some values are out of valid range.";
- }else{
- $msg .= $e;
- }
+ my $msg = "Error while updating $class: $e";
$self->throw_user("$msg");
}
if ( @changed_keys ){
@@ -878,11 +852,7 @@ sub delete {
$self->SUPER::delete();
};
if ( my $e = $@ ){
- my $msg;
- if ( $e =~ /objects still refer to/i ){
- $msg = "Other objects refer to this object ($class id $id). Delete
failed.";
- }
- $self->throw_user($msg);
+ $self->throw_user($e);
}
$logger->debug( sub { sprintf("Model::delete: Deleted %s id %i",
$class, $id) } );
diff --git a/lib/Netdot/Model/Ipblock.pm b/lib/Netdot/Model/Ipblock.pm
index 214ca24..10df7ff 100644
--- a/lib/Netdot/Model/Ipblock.pm
+++ b/lib/Netdot/Model/Ipblock.pm
@@ -703,13 +703,9 @@ sub reserve_first_n {
$class->insert({address=>$addr, status=>'Reserved',
validate=>0});
};
if ( my $e = $@ ){
- if ( $e =~ /Duplicate/io ){
- # This happens often when running parallel processes
- # Just go on
- }else{
- $logger->warn("Ipblock::insert: Failed to insert one of
first ".
- "N addresses in subnet: $e");
- }
+ # Dups are possible when running parallel processes
+ # Just warn and go on
+ $logger->warn("Ipblock::reserve_first_n: Failed to insert
address: $e");
}
}
}
commit 99600a640106b1836b7ff414ff52b88d4ebf0860
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 10:51:17 2012 -0400
Fix for Bug #1675: Netdot 1.0.1 with localized PostgreSQL
diff --git a/lib/Netdot/Model/Ipblock.pm b/lib/Netdot/Model/Ipblock.pm
index 8a93d84..214ca24 100644
--- a/lib/Netdot/Model/Ipblock.pm
+++ b/lib/Netdot/Model/Ipblock.pm
@@ -1052,15 +1052,12 @@ sub fast_update{
);
};
if ( my $e = $@ ){
- if ( $e =~ /Duplicate/i ){
- eval {
- $sth1->execute($attrs->{timestamp}, $dec_addr);
- };
- if ( my $e = $@ ){
- $class->throw_fatal($e);
- }
- }else{
- $class->throw_fatal($e);
+ # Probably duplicate. Try to update.
+ eval {
+ $sth1->execute($attrs->{timestamp}, $dec_addr);
+ };
+ if ( my $e2 = $@ ){
+ $logger->error($e2);
}
}
}
diff --git a/lib/Netdot/Model/PhysAddr.pm b/lib/Netdot/Model/PhysAddr.pm
index 21d75dc..9217c3a 100644
--- a/lib/Netdot/Model/PhysAddr.pm
+++ b/lib/Netdot/Model/PhysAddr.pm
@@ -191,16 +191,13 @@ sub fast_update {
$sth2->execute($address, $timestamp, $timestamp);
};
if ( my $e = $@ ){
- if ( $e =~ /Duplicate/i ){
- # Update
- eval {
- $sth1->execute($timestamp, $address);
- };
- if ( my $e = $@ ){
- $class->throw_fatal($e);
- }
- }else{
- $class->throw_fatal($e);
+ # Probably duplicate. That's OK. Update
+ eval {
+ $sth1->execute($timestamp, $address);
+ };
+ if ( my $e2 = $@ ){
+ # Something else is wrong
+ $logger->error($e2);
}
}
}
-----------------------------------------------------------------------
Summary of changes:
etc/Default.conf | 2 +-
etc/netdot.meta | 2 +-
lib/Netdot/Model.pm | 36 +++---------------------------------
lib/Netdot/Model/Device.pm | 5 +++--
lib/Netdot/Model/Ipblock.pm | 25 +++++++++----------------
lib/Netdot/Model/PhysAddr.pm | 17 +++++++----------
6 files changed, 24 insertions(+), 63 deletions(-)
hooks/post-receive
--
UNNAMED PROJECT
------------------------------
Message: 2
Date: Wed, 26 Sep 2012 13:10:04 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
updated. netdot-1.0.1-54-g9e923fc
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 "UNNAMED PROJECT".
The branch, netdot-1.0 has been updated
via 9e923fc2cab8bf652950772d67793b4ff2ed863b (commit)
via 8b78d043f1fdd8517e2ef6a718a4fcdd87f6e04e (commit)
from c985e9f187378d9248b4cbc8ef0f73fd6030ce38 (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 9e923fc2cab8bf652950772d67793b4ff2ed863b
Merge: 8b78d04 c985e9f
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 13:10:02 2012 -0700
Merge branch 'netdot-1.0' of
git+ssh://netdot.uoregon.edu//home/netdot/git/netdot into netdot-1.0
commit 8b78d043f1fdd8517e2ef6a718a4fcdd87f6e04e
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 13:09:37 2012 -0700
Included aliases in Site label
diff --git a/etc/netdot.meta b/etc/netdot.meta
index 944bb5b..a6ebdb1 100644
--- a/etc/netdot.meta
+++ b/etc/netdot.meta
@@ -7268,7 +7268,7 @@ $meta = {
],
isjoin => '0',
label => [
- 'name'
+ 'name', 'aliases'
],
primary_key => 'id',
unique => [ ['name'], ['number'] ],
diff --git a/lib/Netdot/Model/Site.pm b/lib/Netdot/Model/Site.pm
index 7054b8e..4c74186 100644
--- a/lib/Netdot/Model/Site.pm
+++ b/lib/Netdot/Model/Site.pm
@@ -104,6 +104,9 @@ sub get_label {
my $self = shift;
$self->isa_object_method('get_label');
my $lbl = $self->name;
+ if ( my $aliases = $self->aliases ){
+ $lbl .= " ($aliases)";
+ }
if ( my $number = $self->number ){
$lbl .= " ($number)";
}
-----------------------------------------------------------------------
Summary of changes:
etc/netdot.meta | 2 +-
lib/Netdot/Model/Site.pm | 3 +++
2 files changed, 4 insertions(+), 1 deletions(-)
hooks/post-receive
--
UNNAMED PROJECT
------------------------------
Message: 3
Date: Wed, 26 Sep 2012 19:16:34 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
updated. netdot-1.0.1-57-g6489894
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 "UNNAMED PROJECT".
The branch, netdot-1.0 has been updated
via 6489894af3d875a03448a9c67348395cab635c33 (commit)
via 2ce0e902b062e23f15569e255eace1a7035b7ab4 (commit)
via f8b66e3ae8504fd4dd0bcc19827bf3b533c8ee04 (commit)
from 9e923fc2cab8bf652950772d67793b4ff2ed863b (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 6489894af3d875a03448a9c67348395cab635c33
Merge: 2ce0e90 9e923fc
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 22:16:34 2012 -0400
Merge branch 'netdot-1.0' of
ssh://netdot.uoregon.edu//home/netdot/git/netdot into netdot-1.0
commit 2ce0e902b062e23f15569e255eace1a7035b7ab4
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 22:15:59 2012 -0400
Several corrections to previous changes in Ipblock
diff --git a/lib/Netdot/Model/Ipblock.pm b/lib/Netdot/Model/Ipblock.pm
index 10df7ff..c0c3a43 100644
--- a/lib/Netdot/Model/Ipblock.pm
+++ b/lib/Netdot/Model/Ipblock.pm
@@ -616,6 +616,7 @@ sub insert {
# assume any errors from _update_tree are caused by $newblock
$newblock->delete();
$e->rethrow() if ref($e);
+ $class->throw_fatal($e);
}
}
@@ -700,7 +701,9 @@ sub reserve_first_n {
for ( 1..$num ){
my $addr = $self->get_next_free();
eval {
- $class->insert({address=>$addr, status=>'Reserved',
validate=>0});
+ $class->insert({address=>$addr, status=>'Reserved',
+ parent=>$self->id, no_update_tree=>1,
+ validate=>0});
};
if ( my $e = $@ ){
# Dups are possible when running parallel processes
@@ -939,46 +942,6 @@ sub build_tree {
return 1;
}
-############################################################################
-=head2 retrieve_all_hashref
-
- Retrieves all IPs from the DB and stores them in a hash, keyed by
- numeric address. The value is the Ipblock id.
-
- Arguments:
- None
- Returns:
- Hash reference
- Examples:
- my $db_ips = Ipblock->retriev_all_hash();
-
-=cut
-sub retrieve_all_hashref {
- my ($class) = @_;
- $class->isa_class_method('retrieve_all_hashref');
-
- # Build the search-all-ips SQL
- $logger->debug(sub{"Ipblock::retrieve_all_hashref: Retrieving all IPs..."
});
- my ($ip_aref, %db_ips, $sth);
-
- my $dbh = $class->db_Main;
- eval {
- $sth = $dbh->prepare_cached("SELECT id,address FROM ipblock");
- $sth->execute();
- $ip_aref = $sth->fetchall_arrayref;
- };
- if ( my $e = $@ ){
- $class->throw_fatal($e);
- }
- # Build a hash of ip addresses.
- foreach my $row ( @$ip_aref ){
- my ($id, $address) = @$row;
- $db_ips{$address} = $id;
- }
- $logger->debug(sub{"Ipblock::retrieve_all_hashref: ...done" });
-
- return \%db_ips;
-}
##################################################################
=head2 fast_update - Faster updates for specific cases
@@ -2613,8 +2576,9 @@ sub get_host_addrs {
$nip = $self->netaddr;
}else{
$subnet = shift;
- $nip = $self->netaddr(address=>$subnet) or
- $class->throw_fatal("Invalid Subnet: $subnet");
+ my ($address, $prefix) = split /\//, $subnet;
+ $nip = Ipblock->netaddr(address=>$address, prefix=>$prefix) or
+ $self->throw_fatal("Invalid Subnet: $subnet");
}
# Populating an array with all addresses in most IPv6 blocks
@@ -2645,25 +2609,13 @@ sub get_next_free {
my ($self, %argv) = @_;
$self->isa_object_method('get_next_free');
my $class = ref($self);
- $self->throw_user("Invalid call to this method on a non-subnet")
+ $self->throw_user('Invalid call to this method on a non-subnet')
unless ( $self->status->name eq 'Subnet' );
- $logger->debug("Getting next free address in ".$self->get_label);
-
- my $dbh = $self->db_Main();
- my $id = $self->id;
- my $rows = $dbh->selectall_arrayref("
- SELECT ipblock.address, ipblockstatus.name
- FROM ipblock, ipblockstatus
- WHERE ipblock.status=ipblockstatus.id
- AND ipblock.parent=$id
- ");
-
+ # Build hash with address and status for fast lookup
my %used;
- foreach my $row ( @$rows ){
- my ($numeric, $status) = @$row;
- next unless ( $numeric && $status );
- $used{$numeric} = $status;
+ foreach my $kid ( $self->children ){
+ $used{$kid->address_numeric} = $kid->status->name;
}
my $strategy = $argv{strategy} ||
Netdot->config->get('IP_ALLOCATION_STRATEGY');
@@ -2671,32 +2623,38 @@ sub get_next_free {
my $s = $self->netaddr;
my $ret;
if ( $strategy eq 'first' ){
- for ( my $addr=Math::BigInt->new($s->first->numeric); $addr <=
$s->last->numeric; $addr++ ){
- $ret = &_do_addr($class, $addr, \%used, $self->version);
- last if $ret;
+ my $start = $s->first->numeric;
+ my $end = $s->last->numeric;
+ my $addr = ($self->version == 6)? Math::BigInt->new($start) : $start;
+ while ( $addr <= $end ){
+ $ret = &_chk_addr($class, $addr, \%used, $self->version);
+ return $ret if $ret;
+ $addr++;
}
}elsif ( $strategy eq 'last' ){
- for ( my $addr=Math::BigInt->new($s->last->numeric); $addr >=
$s->first->numeric; $addr-- ){
- $ret = &_do_addr($class, $addr, \%used, $self->version);
- last if $ret;
+ my $start = $s->last->numeric;
+ my $end = $s->first->numeric;
+ my $addr = ($self->version == 6)? Math::BigInt->new($start) : $start;
+ while ( $addr >= $end ){
+ $ret = &_chk_addr($class, $addr, \%used, $self->version);
+ return $ret if $ret;
+ $addr--;
}
}else{
$self->throw_fatal("Ipblock::get_next_free: Invalid strategy:
$strategy");
}
- # Return what we got
- return $ret;
- sub _do_addr(){
+ sub _chk_addr(){
my ($class, $addr, $used, $version) = @_;
# Ignore anything that exists, unless it's marked as available
- if (exists $used->{$addr} && $used->{$addr} ne 'Available'){
+ if ( exists $used->{$addr} && $used->{$addr} ne 'Available' ){
return undef;
}
if ( my $ipb = Ipblock->search(address=>$addr,
version=>$version)->first ){
# IP may have been incorrectly set as Available
# Correct and move on
if ( $ipb->a_records || $ipb->dhcp_scopes ){
- $ipb->update({status=>'Static'});
+ $ipb->SUPER::update({status=>'Static'});
return undef;
}
}
@@ -3041,7 +2999,6 @@ sub _update_tree{
}else{
# This is a non-address block
-
# This block's address and/or prefix were changed
if ( $argv{old_addr} || $argv{old_prefix} ) {
$logger->debug("Ipblock::_update_tree: ". $self->get_label .
@@ -3050,7 +3007,7 @@ sub _update_tree{
$class->_tree_save(version=>$self->version, tree=>$tree);
return 1;
}
-
+ # At this point we can assume that the block is new
# Find the closest parent
my $n = $class->_tree_find(
address => $self->address,
@@ -3061,7 +3018,6 @@ sub _update_tree{
if ( $n && $n != $self->id ){
my $parent_id = $n;
-
# Now insert it in the tree
my $n = $class->_tree_insert(
address => $self->address,
@@ -3076,7 +3032,7 @@ sub _update_tree{
my %parents;
$parents{$self->id} = $parent_id;
- # Now, deal with my children and my parent's children
+ # Now, deal with my parent's children
# They could be my children or my siblings, so
# we need to rebuild this section of the tree
@@ -3084,17 +3040,32 @@ sub _update_tree{
my $sth1 = $dbh->prepare_cached("SELECT id,address,prefix,parent
FROM ipblock
WHERE parent=?
- OR parent=?
ORDER BY prefix"
);
- $sth1->execute($parent_id, $self->id);
+ $sth1->execute($parent_id);
while ( my ($id,$address,$prefix,$par) = $sth1->fetchrow_array ){
+ next if $id == $self->id;
my $n = $class->_tree_find(iaddress => $address,
prefix => $prefix,
tree => $tree,
version => $version,
);
+
+ if ( $n && $n == $id ){
+ # address is in tree. Need to remove it.
+ my $cidr = $class->int2ip($address, $version);
+ $cidr .= "/$prefix";
+ $tree->remove_string($cidr);
+
+ # Search again, to find parent
+ $n = $class->_tree_find(iaddress => $address,
+ prefix => $prefix,
+ tree => $tree,
+ version => $version,
+ );
+ }
if ( $n && $n != $id && $n != $par ){
+ $logger->debug("New parent for $address is $n");
$parents{$id} = $n;
}
# We do not insert end nodes in the tree for speed
@@ -3109,6 +3080,8 @@ sub _update_tree{
);
}
}
+ $class->_tree_save(version=>$self->version, tree=>$tree);
+
# Now update the DB
my $sth2 = $dbh->prepare_cached("UPDATE ipblock SET parent=? WHERE
id=?");
foreach my $id ( keys %parents ){
@@ -3123,7 +3096,6 @@ sub _update_tree{
$class->build_tree($version);
}
- $class->_tree_save(version=>$self->version, tree=>$tree);
}
return 1;
}
commit f8b66e3ae8504fd4dd0bcc19827bf3b533c8ee04
Author: Carlos Vicente <[email protected]>
Date: Wed Sep 26 22:15:33 2012 -0400
Updated unit tests for Ipblock
diff --git a/t/Ipblock.t b/t/Ipblock.t
index 7a8643d..cccc24b 100644
--- a/t/Ipblock.t
+++ b/t/Ipblock.t
@@ -5,23 +5,23 @@ use lib "lib";
BEGIN { use_ok('Netdot::Model::Ipblock'); }
my $container = Ipblock->insert({
- address => "169.254.0.0",
- prefix => '16',
+ address => "192.0.2.0",
+ prefix => '24',
version => 4,
status => 'Container',
});
is($container->status->name, 'Container', 'insert container');
my $subnet = Ipblock->insert({
- address => "169.254.60.0",
- prefix => '24',
+ address => "192.0.2.0",
+ prefix => '25',
version => 4,
status => 'Subnet',
});
is($subnet->status->name, 'Subnet', 'insert subnet');
my $address = Ipblock->insert({
- address => "169.254.60.27",
+ address => "192.0.2.10",
prefix => '32',
version => 4,
status => 'Static',
@@ -34,21 +34,21 @@ is($address->is_address, 1, 'is_address');
is($address->parent, $subnet, 'address/subnet hierarchy');
is($subnet->parent, $container, 'subnet/container hierarchy');
-is($address->address, '169.254.60.27', 'address method');
-is($address->address_numeric, '2852011035', 'address_numeric method');
+is($address->address, '192.0.2.10', 'address method');
+is($address->address_numeric, '3221225994', 'address_numeric method');
is($address->prefix, '32', 'prefix method');
-is($subnet->num_addr(), '254', 'num_addr');
-is($subnet->address_usage(), '1', 'num_addr');
+is($subnet->num_addr(), '126', 'num_addr');
+is($subnet->address_usage(), '6', 'address_usage');
-is($container->subnet_usage(), '256', 'subnet_usage');
+is($container->subnet_usage(), '128', 'subnet_usage');
-is($address->get_label(), '169.254.60.27', 'address label');
-is($subnet->get_label(), '169.254.60.0/24', 'subnet label');
+is($address->get_label(), '192.0.2.10', 'address label');
+is($subnet->get_label(), '192.0.2.0/25', 'subnet label');
-is(Ipblock->search(address=>'169.254.60.0', prefix=>'24')->first, $subnet,
'search' );
+is(Ipblock->search(address=>'192.0.2.0', prefix=>'25')->first, $subnet,
'search' );
-is(scalar(Ipblock->search_like(address=>'169.254')), 3, 'search_like' );
+is(scalar(Ipblock->search_like(address=>'192.0')), 8, 'search_like' );
$subnet->update({description=>'test subnet'});
is(((Ipblock->keyword_search('test subnet'))[0])->id, $subnet->id,
'keyword_search');
@@ -70,16 +70,16 @@ is($ancestors[0], $subnet, 'get_ancestors');
is($ancestors[1], $container, 'get_ancestors');
my ($s,$p) = Ipblock->get_subnet_addr( address => $address->address,
- prefix => 24 );
+ prefix => 25 );
is($s, $subnet->address, 'get_subnet_addr');
my $hosts = Ipblock->get_host_addrs( $subnet->address ."/". $subnet->prefix );
-is($hosts->[0], '169.254.60.1', 'get_host_addrs');
+is($hosts->[0], '192.0.2.1', 'get_host_addrs');
ok(Ipblock->is_loopback('127.0.0.1'), 'is_loopback');
ok(Ipblock->is_link_local('fe80:abcd::1234'), 'is_link_local');
-is(Ipblock->get_covering_block(address=>'169.254.60.5', prefix=>'32'), $subnet,
+is(Ipblock->get_covering_block(address=>'192.0.2.5', prefix=>'32'), $subnet,
'get_covering_block');
@@ -95,36 +95,29 @@ is(Ipblock->subnetmask(256), 24, 'subnetmask');
is(Ipblock->subnetmask_v6(4), 126, 'subnetmask_v6');
-is($subnet->get_next_free, '169.254.60.1', 'get_next_free');
-is($subnet->get_next_free(strategy=>'last'), '169.254.60.254',
'get_next_free');
-
-my $all = Ipblock->retrieve_all_hashref();
-is($all->{$container->address_numeric}, $container->id,
'retrieve_all_hashref');
-is($all->{$subnet->address_numeric}, $subnet->id, 'retrieve_all_hashref');
-is($all->{$address->address_numeric}, $address->id, 'retrieve_all_hashref');
-
-is(($container->get_dot_arpa_names)[0], '254.169.in-addr.arpa',
'get_dot_arpa_names_v4_16');
+is($subnet->get_next_free, '192.0.2.6', 'get_next_free');
+is($subnet->get_next_free(strategy=>'last'), '192.0.2.126',
'get_next_free_last');
-is(($subnet->get_dot_arpa_names)[0], '60.254.169.in-addr.arpa',
'get_dot_arpa_names_v4_24');
+is(($subnet->get_dot_arpa_names)[0], '0-25.2.0.192.in-addr.arpa',
'get_dot_arpa_names_v4_25');
my $subnet2 = Ipblock->insert({
- address => "169.254.10.32",
+ address => "192.0.2.160",
prefix => '27',
version => 4,
status => 'Subnet',
});
-is(($subnet2->get_dot_arpa_names)[0], '32-27.10.254.169.in-addr.arpa',
'get_dot_arpa_names_v4_27');
-
-my $subnet3 = Ipblock->insert({
- address => "169.254.100.0",
- prefix => '23',
- version => 4,
- status => 'Subnet',
-});
-my @arpa_names = ('100.254.169.in-addr.arpa', '101.254.169.in-addr.arpa');
-my @a = $subnet3->get_dot_arpa_names();
-is($a[0], $arpa_names[0], 'get_dot_arpa_names_v4_23');
-is($a[1], $arpa_names[1], 'get_dot_arpa_names_v4_23');
+is(($subnet2->get_dot_arpa_names)[0], '160-27.2.0.192.in-addr.arpa',
'get_dot_arpa_names_v4_27');
+
+# my $subnet3 = Ipblock->insert({
+# address => "169.254.100.0",
+# prefix => '23',
+# version => 4,
+# status => 'Subnet',
+# });
+# my @arpa_names = ('100.254.169.in-addr.arpa', '101.254.169.in-addr.arpa');
+# my @a = $subnet3->get_dot_arpa_names();
+# is($a[0], $arpa_names[0], 'get_dot_arpa_names_v4_23');
+# is($a[1], $arpa_names[1], 'get_dot_arpa_names_v4_23');
my $blk = Ipblock->insert({
address => "8.0.0.0",
@@ -132,54 +125,64 @@ my $blk = Ipblock->insert({
version => 4,
status => 'Container',
});
-@arpa_names = ('8.in-addr.arpa', '9.in-addr.arpa');
-@a = $blk->get_dot_arpa_names();
+my @arpa_names = ('8.in-addr.arpa', '9.in-addr.arpa');
+my @a = $blk->get_dot_arpa_names();
is($a[0], $arpa_names[0], 'get_dot_arpa_names_v4_7');
is($a[1], $arpa_names[1], 'get_dot_arpa_names_v4_7');
$blk->delete();
my $v6container = Ipblock->insert({
- address => "fe80::",
- prefix => '10',
+ address => "2001:0db8::",
+ prefix => '32',
version => 6,
status => 'Container',
});
-is(($v6container->get_dot_arpa_names)[0], '8.e.f.ip6.arpa',
'get_dot_arpa_name_v6_10');
+is(($v6container->get_dot_arpa_names)[0], '8.b.d.0.1.0.0.2.ip6.arpa',
'get_dot_arpa_name_v6_32');
-my $v6container2 = Ipblock->insert({
- address => "fe80::",
+my $v6subnet = Ipblock->insert({
+ address => "2001:0db8::",
prefix => '62',
version => 6,
- status => 'Container',
+ status => 'Subnet',
});
-is(($v6container2->get_dot_arpa_names)[0],
'0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa', 'get_dot_arpa_name_v6_62');
-is(($v6container2->get_dot_arpa_names)[1],
'1.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa', 'get_dot_arpa_name_v6_62');
-is(($v6container2->get_dot_arpa_names)[2],
'2.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa', 'get_dot_arpa_name_v6_62');
-is(($v6container2->get_dot_arpa_names)[3],
'3.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa', 'get_dot_arpa_name_v6_62');
+is($v6subnet->parent, $v6container, 'v6_parent');
-is($v6container2->parent, $v6container, 'v6 hierarchy');
+is(($v6subnet->get_dot_arpa_names)[0],
'0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa',
+ 'get_dot_arpa_name_v6_62');
+is(($v6subnet->get_dot_arpa_names)[1],
'1.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa',
+ 'get_dot_arpa_name_v6_62');
+is(($v6subnet->get_dot_arpa_names)[2],
'2.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa',
+ 'get_dot_arpa_name_v6_62');
+is(($v6subnet->get_dot_arpa_names)[3],
'3.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa',
+'get_dot_arpa_name_v6_62');
-# update_tree
my $v6container3 = Ipblock->insert({
- address => "fe80::",
- prefix => '32',
+ address => "2001:0db8::",
+ prefix => '48',
version => 6,
status => 'Container',
});
-is($v6container3->parent, $v6container, 'v6 hierarchy');
-is($v6container2->parent, $v6container3, 'v6 hierarchy');
+is($v6container3->parent, $v6container, 'v6_parent2');
+# Refresh object to avoid looking at old data
+my $tmpid = $v6subnet->id;
+$v6subnet = undef;
+$v6subnet = Ipblock->retrieve($tmpid);
+is($v6subnet->parent, $v6container3, 'v6_parent3');
+
+is($v6subnet->get_next_free, '2001:db8::6', 'get_next_free_v6');
+is($v6subnet->get_next_free(strategy=>'last'),
'2001:db8:0:3:ffff:ffff:ffff:fffe', 'get_next_free_last_v6');
is(Ipblock->matches_v4($address->address), 1, 'matches_v4_1');
-is(Ipblock->matches_v4($v6container2->address), 0, 'matches_v4_2');
+is(Ipblock->matches_v4($v6subnet->address), 0, 'matches_v4_2');
-is(Ipblock->matches_v6($v6container2->address), 1, 'matches_v6_1');
+is(Ipblock->matches_v6($v6subnet->address), 1, 'matches_v6_1');
is(Ipblock->matches_v6($address->address), 0, 'matches_v6_2');
-is(Ipblock->matches_ip($v6container2->address), 1, 'matches_ip_1');
+is(Ipblock->matches_ip($v6subnet->address), 1, 'matches_ip_1');
is(Ipblock->matches_ip($address->address), 1, 'matches_ip_2');
my $ar1 = Ipblock->matches_cidr($address->cidr);
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Ipblock.pm | 126 +++++++++++++++++--------------------------
t/Ipblock.t | 125 ++++++++++++++++++++++---------------------
2 files changed, 113 insertions(+), 138 deletions(-)
hooks/post-receive
--
UNNAMED PROJECT
------------------------------
_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
End of Netdot-devel Digest, Vol 66, Issue 22
********************************************