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-9-gc7e5f10 ([email protected])
2. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
netdot-1.0.1-10-gc26c316 ([email protected])
----------------------------------------------------------------------
Message: 1
Date: Mon, 27 Aug 2012 09:49:06 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
updated. netdot-1.0.1-9-gc7e5f10
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 c7e5f10e3f543615fc6e1ab7d5ef8076da79016e (commit)
via 10e2c9a440c0329878a084ad2b59bf0974ae712a (commit)
from c6f167d5bef1864f7f4b3dbb6322ba3da03e2c65 (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 c7e5f10e3f543615fc6e1ab7d5ef8076da79016e
Author: Carlos Vicente <[email protected]>
Date: Mon Aug 27 12:49:09 2012 -0400
Fixed missing value in host.html
diff --git a/htdocs/management/host.html b/htdocs/management/host.html
index deba81a..02e22bd 100644
--- a/htdocs/management/host.html
+++ b/htdocs/management/host.html
@@ -40,6 +40,7 @@ if ( $id ) {
@tmp = @$rr;
}else {
push @tmp, $rr;
+ $id = $rr;
}
foreach ( @tmp ){
$_ = RR->retrieve($_) unless ref($_);
commit 10e2c9a440c0329878a084ad2b59bf0974ae712a
Author: Carlos Vicente <[email protected]>
Date: Mon Aug 27 12:34:48 2012 -0400
Changed how FWT and ARP tables are rotated. Copies of old tables will no
longer be kept in the DB.
diff --git a/bin/prune_db.pl b/bin/prune_db.pl
index dc29e08..06e4d6d 100755
--- a/bin/prune_db.pl
+++ b/bin/prune_db.pl
@@ -225,16 +225,12 @@ if ( $self{AUDIT} ){
if ( $self{FWT} ){
if ( $self{ROTATE} ){
- if ( $db_type eq 'mysql' ){
- unless ( $self{PRETEND} ){
- my $fwtable_def = &get_table_def('fwtable');
- my $fwtableentry_def = &get_table_def('fwtableentry');
- &rotate_table('fwtable', $fwtable_def);
- &rotate_table('fwtableentry', $fwtableentry_def);
- }
- }else{
+ if ( $db_type ne 'mysql' ){
die "Rotate function only implemented in mysql for now";
}
+ unless ( $self{PRETEND} ){
+ &rotate_tables('fwtableentry', 'fwtable');
+ }
}else{
###########################################################################################
# Delete FWTables (also deletes FwtableEntry records)
@@ -254,15 +250,11 @@ if ( $self{FWT} ){
if ( $self{ARP} ){
if ( $self{ROTATE} ){
- if ( $db_type eq 'mysql' or $db_type eq 'Pg' ){
- unless ( $self{PRETEND} ){
- my $arpcache_def = &get_table_def('arpcache');
- my $arpcacheentry_def = &get_table_def('arpcacheentry');
- &rotate_table('arpcache', $arpcache_def);
- &rotate_table('arpcacheentry', $arpcacheentry_def);
- }
- }else{
- die "Rotate function only implemented in mysql and postgreSQL for
now";
+ if ( $db_type ne 'mysql' ){
+ die "Rotate function only implemented in mysql for now";
+ }
+ unless ( $self{PRETEND} ){
+ &rotate_tables('arpcacheentry', 'arpcache');
}
}else{
###########################################################################################
@@ -316,7 +308,7 @@ sub optimize_table{
return;
}
-# Get table definition
+# Get table definition (mysql only)
sub get_table_def {
my $table = shift;
my $q = $dbh->selectall_arrayref("SHOW CREATE TABLE $table");
@@ -326,22 +318,18 @@ sub get_table_def {
return $def;
}
-sub rotate_table{
- my ($table, $def) = @_;
- die "Missing required arguments" unless $table && $def;
+sub rotate_tables{
+ my (@tables) = @_;
+
+ die "Missing table names" unless scalar @tables;
# We need DBA privileges here
-
my $db_host = Netdot->config->get('DB_HOST');
my $db_port = Netdot->config->get('DB_PORT');
my $db_user = Netdot->config->get('DB_DBA');
my $db_pass = Netdot->config->get('DB_DBA_PASSWORD');
my $db_db = Netdot->config->get('DB_DATABASE');
- if ( $db_type ne 'mysql' and $db_type ne 'Pg' ){
- die("didn't recognize the database we're using ($db_type), could not
rotate table $table");
- }
-
my $dbh = &dbconnect($db_type, $db_host, $db_port, $db_user, $db_pass,
$db_db)
|| die ("Cannot connect to database as root");
@@ -350,76 +338,33 @@ sub rotate_table{
my $timestamp = time;
- if ( $db_type eq 'mysql' ){
- # Tried to do this with just rename table and create table like
- # but the constraints complicate things
- eval{
- my @statements;
-
- # Constraint names are unique per database, so we need to
- # remove them from the backup table before creating the
- # new one
- my $fkq = "SELECT CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME,
- REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
- FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
- WHERE TABLE_NAME = '$table'
- AND TABLE_SCHEMA = 'netdot'
- AND REFERENCED_TABLE_NAME IS NOT NULL";
- my $rows = $dbh->selectall_arrayref($fkq);
-
- my $backup = $table.'_'.$timestamp;
- push @statements, ("RENAME TABLE $table TO $backup");
-
- foreach my $row ( @$rows ){
- my ($const, $table, $col, $reftable, $refcol) = @$row;
- push @statements, ("ALTER TABLE $backup DROP FOREIGN KEY
`$const`");
- }
- # Re-create the original table
- push @statements, $def;
- foreach my $st ( @statements ){
- $logger->debug($st);
- $dbh->do($st);
- }
- }
- }else{
- $logger->warn("Could not rotate table $table. Database $db_type not
supported");
+ my %defs;
+ my @statements;
+ foreach my $table ( @tables ){
+ $defs{$table} = &get_table_def($table);
+ push @statements, ("DROP TABLE $table");
+ }
+ # Re-create the original tables in reverse order
+ # to avoid integrity errors
+ foreach my $table ( reverse @tables ){
+ push @statements, $defs{$table};
}
+ eval {
+ foreach my $st ( @statements ){
+ $logger->debug($st);
+ $dbh->do($st);
+ }
+ };
+ my $table_list = join ', ', @tables;
if ( my $e = $@ ){
- $dbh->rollback;
- die "Error rotating table $table with database: $db_type, $db_host,
$db_db, changes not commited: $e\n";
+ $dbh->rollback;
+ die "Error rotating tables $table_list. Changes not commited: $e\n";
}
-
$dbh->commit;
- $logger->info("Table $table rotated successfully");
+ $logger->info("Tables $table_list rotated successfully");
# We can turn autocommit back on since the rest of the transactions are
basically atomic
$dbh->{AutoCommit} = 1;
- $logger->debug("Droping $table backups older than $self{NUM_DAYS} days");
- my $tables_q;
-
- if ( $db_type eq 'mysql' ){
- $tables_q = $dbh->selectall_arrayref("SHOW TABLES");
- }elsif ( $db_type eq 'Pg' ){
- $tables_q = $dbh->selectall_arrayref("SELECT tablename FROM
pg_tables");
- }
-
- my $epochdate = time-($self{NUM_DAYS}*24*60*60);
-
- foreach my $row ( @$tables_q ){
- my $tablename = $row->[0];
- if ( $tablename =~ /$table\_(\d+)/ ){
- my $tstamp = $1;
- if ( $tstamp < $epochdate ){
- $logger->debug("Droping $table\_$tstamp");
- $dbh->do("DROP TABLE $table\_$tstamp");
- }
- }
- }
-
- if ( $db_type eq 'Pg' ){
- # Since we just deleted every record from table during the copy, we
need to clean up a bit
- &optimize_table($table);
- }
&dbdisconnect($dbh);
return 1;
@@ -432,7 +377,7 @@ Carlos Vicente, C<< <cvicente at ns.uoregon.edu> >>
=head1 COPYRIGHT & LICENSE
-Copyright 2009 University of Oregon, all rights reserved.
+Copyright 2012 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
-----------------------------------------------------------------------
Summary of changes:
bin/prune_db.pl | 125 ++++++++++++-------------------------------
htdocs/management/host.html | 1 +
2 files changed, 36 insertions(+), 90 deletions(-)
hooks/post-receive
--
UNNAMED PROJECT
------------------------------
Message: 2
Date: Mon, 27 Aug 2012 11:15:33 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
updated. netdot-1.0.1-10-gc26c316
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 c26c316f4c58328aac2c118cdf9e6220f5bbe3a0 (commit)
from c7e5f10e3f543615fc6e1ab7d5ef8076da79016e (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 c26c316f4c58328aac2c118cdf9e6220f5bbe3a0
Author: Carlos Vicente <[email protected]>
Date: Mon Aug 27 14:15:30 2012 -0400
Be selective about which IP tree version is rebuilt after importing DNS
records
diff --git a/lib/Netdot/Model/Zone.pm b/lib/Netdot/Model/Zone.pm
index 9365912..f97e5bd 100644
--- a/lib/Netdot/Model/Zone.pm
+++ b/lib/Netdot/Model/Zone.pm
@@ -626,7 +626,7 @@ sub import_records {
$nrrs{$r->name} = $r;
}
- my $new_ips = 0;
+ my %new_ips;
foreach my $rr ( @$rrs ){
my $name = $rr->name;
@@ -672,7 +672,7 @@ sub import_records {
$ipb = Ipblock->insert({ address => $address,
status => 'Static',
no_update_tree => 1});
- $new_ips++;
+ $new_ips{$ipb->version}++;
}
my $rraddr;
my %args = (rr=>$nrr, ipblock=>$ipb);
@@ -751,7 +751,7 @@ sub import_records {
$ipb = Ipblock->insert({ address => $ipaddr,
status => 'Static',
no_update_tree => 1 });
- $new_ips++;
+ $new_ips{$ipb->version}++;
}
my %args = (rr=>$nrr, ptrdname=>$rr->ptrdname, ipblock=>$ipb);
if ( $argv{overwrite} || !($rrptr = RRPTR->search(%args)->first) ){
@@ -806,10 +806,10 @@ sub import_records {
}
}
- if ( $new_ips ){
+ if ( %new_ips ){
# Update IP space hierarchy
- Ipblock->build_tree(4);
- Ipblock->build_tree(6);
+ Ipblock->build_tree(4) if exists $new_ips{4};
+ Ipblock->build_tree(6) if exists $new_ips{6};
}
1;
@@ -825,7 +825,7 @@ sub import_records {
rr.id, rr.name, ip.id, ip.address, ip.version, rrptr.ptrdname
Args:
- ipblock object or ID (optional)
+ ipblock object or ID (optional)
Returns:
Arrayref of arrayrefs
Examples:
-----------------------------------------------------------------------
Summary of changes:
lib/Netdot/Model/Zone.pm | 14 +++++++-------
1 files changed, 7 insertions(+), 7 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 65, Issue 20
********************************************