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] Netdot branch netdot-1.0 updated.
      netdot-1.0.6-45-g58594b5 ([email protected])
   2. Re: two issues (one possible bug, and PostgreSQL advice
      sought) (Carlos Vicente)
   3. [SCM] Netdot branch netdot-1.0 updated.
      netdot-1.0.6-46-gf8b0da5 ([email protected])
   4. [SCM] Netdot branch master updated.       netdot-1.0.6-46-gf8b0da5
      ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Sat, 23 Aug 2014 11:37:36 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
        netdot-1.0.6-45-g58594b5
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  58594b566d2f0f65fda57bd6f51ae3f2b8d6d186 (commit)
       via  bda5c41d535295fc003c3c042f76c8d4cb087d95 (commit)
       via  bb95a19a34c391f9823b9d19168c965e6843f598 (commit)
      from  5e343e0625796ce1d5ab009c4f8e139a311edf43 (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 58594b566d2f0f65fda57bd6f51ae3f2b8d6d186
Author: Carlos Vicente <[email protected]>
Date:   Sat Aug 23 14:37:18 2014 -0400

    Fix bug where only v4 tree would be rebuilt when specifying 'all' (William 
Bulley)

diff --git a/htdocs/management/ip.html b/htdocs/management/ip.html
index 9da909d..b13dc0b 100644
--- a/htdocs/management/ip.html
+++ b/htdocs/management/ip.html
@@ -604,7 +604,8 @@ if( $_action eq "SHOW_ROOTS" && !$id && $rootversion ){
 
     if ( $tree_version eq '4' || $tree_version eq 'all' ){
        Ipblock->build_tree(4);
-    }elsif ( $tree_version eq '6' || $tree_version eq 'all' ){
+    }    
+    if ( $tree_version eq '6' || $tree_version eq 'all' ){
        Ipblock->build_tree(6);
     }
     $m->comp('.show_message', title=>"Action Message", msg=>"IP Tree Rebuilt 
Successfully");

commit bda5c41d535295fc003c3c042f76c8d4cb087d95
Author: Carlos Vicente <[email protected]>
Date:   Sat Aug 23 14:33:15 2014 -0400

    Allow rest/host to insert new record when IP is given but subnet is not

diff --git a/htdocs/rest/host b/htdocs/rest/host
index fa363ec..d156249 100644
--- a/htdocs/rest/host
+++ b/htdocs/rest/host
@@ -34,10 +34,14 @@ my $headers = $rest->{request}->headers_in;
 # Deal with Accept header
 $rest->check_accept_header($headers->{Accept}) if ( $headers->{Accept} );
 
+my $method = $rest->{request}->method;
+my $req_args = $method eq 'POST' ? 
+    sprintf("%s", join(": ", %ARGS)) : $rest->{request}->args;
+
 my $logger = Netdot->log->get_logger("Netdot::REST");
 $logger->info(sprintf("/rest/host: %s request with args: %s from %s (%s)", 
-                     $rest->{request}->method, 
-                     $rest->{request}->args,
+                     $method, 
+                     $req_args,
                      $rest->{request}->connection->remote_ip, 
                      $headers->{'User-Agent'}
              ));
@@ -50,7 +54,7 @@ my %ips;
 </%init>
 <%perl>
     
-if ( $rest->{request}->method eq 'GET' ){
+if ( $method eq 'GET' ){
     if ( $rrid ){
        my $rr = RR->retrieve($rrid);
        $rest->throw(code=>Apache2::Const::NOT_FOUND, msg=>"RR not found")
@@ -98,7 +102,7 @@ if ( $rest->{request}->method eq 'GET' ){
 
     }elsif ( $zone ){
        # All RRs within given zone
-       my $zoneobj = Zone->objectify($zone) ||
+       my $zoneobj = Zone->objectify($zone) or
            $rest->throw(code=>Apache2::Const::HTTP_BAD_REQUEST, 
                         msg=>'Bad request: invalid zone'); 
        unless ( $manager->can($user, 'view', $zoneobj) ){
@@ -109,7 +113,7 @@ if ( $rest->{request}->method eq 'GET' ){
        map { $rrs{$_->id} = $_ } $zoneobj->records;
 
     }elsif ( $subnet ){
-       my $subnetobj = Ipblock->objectify($subnet) ||
+       my $subnetobj = Ipblock->objectify($subnet) or
            $rest->throw(code=>Apache2::Const::HTTP_BAD_REQUEST, 
                         msg=>'Bad request: invalid subnet'); 
        unless ( $manager->can($user, 'view', $subnetobj) ){
@@ -165,7 +169,7 @@ if ( $rest->{request}->method eq 'GET' ){
 
     $rest->print_formatted(\%ret);
 
-}elsif ( $rest->{request}->method eq 'POST' ){
+}elsif ( $method eq 'POST' ){
     if ( $rrid ){
        # We're updating
        my $rr = RR->retrieve($rrid);
@@ -272,40 +276,70 @@ if ( $rest->{request}->method eq 'GET' ){
        $add_args{duid} = $duid if $duid;
        $add_args{ethernet} = $ethernet if ( $ethernet && !$add_args{duid} );
 
-       my $subnetobj = Ipblock->objectify($subnet) ||
+       unless ( $subnet ){
+           if ( $address ){
+               $subnet = Ipblock->get_covering_block(address=>$address);
+           }else{
+               $rest->throw(code=>Apache2::Const::HTTP_BAD_REQUEST, 
+                            msg=>'Bad request: Need to pass either a subnet or 
IP address'); 
+           }
+       }
+
+       my $subnetobj = Ipblock->objectify($subnet) or
            $rest->throw(code=>Apache2::Const::HTTP_BAD_REQUEST, 
                         msg=>'Bad request: invalid subnet'); 
-       
+
        unless ( $manager->can($user, 'edit', $subnetobj) ){
            $rest->throw(code=>Apache2::Const::HTTP_FORBIDDEN, 
                         msg=>"User not allowed to edit this subnet");
        }
 
-       # Zone that corresponds to this subnet
+       # Zone that corresponds to this subnet. 
+       # This is our preferred zone
        my $zoneobj = $subnetobj->forward_zone();
 
-       if ( $zone ){
-           # user gave us a zone
-           my $givenzone = Zone->objectify($zone) ||
+       # If not set above, use the default zone from config
+       unless ( $zoneobj ){
+           my $dfzname = Netdot->config->get('DEFAULT_DNSDOMAIN');
+           $zoneobj = (Zone->search(name=>$dfzname))[0];
+       }
+
+       # Check if the given hostname falls within a given zone
+       my $zone_from_name = (Zone->search(name=>$name))[0];
+
+       # Our given zone name comes from either the $zone parameter
+       # or from the hostname itself
+       my $given_zone_name = $zone || $zone_from_name;
+       if ( $given_zone_name ){
+           my $given_zone = Zone->objectify($given_zone_name) or
                $rest->throw(code=>Apache2::Const::HTTP_BAD_REQUEST, 
-                            msg=>'Bad request: invalid zone'); 
-           # Normally, unprivileged users are not given permissions
-           # to a whole zone, so only fail if it doesn't match
-           # the zone that corresponds to this subnet
-           if ( !$zoneobj || ($zoneobj->id != $givenzone->id) ){
-               # We don't have a default zone, or they don't match, so we need 
to 
-               # make sure that this user has permissions to edit the given 
zone
-               if ( $manager->can($user, 'edit', $givenzone) ){
-                   $add_args{zone} = $givenzone;
+                            msg=>'Bad request: invalid zone given'); 
+
+           if ( !$zoneobj || ($zoneobj->id != $given_zone->id) ){
+               # We don't have a default zone, or it doesn't match
+               # the given zone, make sure that this user 
+               # has permissions to edit the given zone
+               if ( $manager->can($user, 'edit', $given_zone) ){
+                   $zoneobj = $given_zone;
                }else{
                    $rest->throw(code=>Apache2::Const::HTTP_FORBIDDEN, 
                                 msg=>"User not allowed to edit this zone");
                }
            }
        }
-       $add_args{zone} ||= $zoneobj; # If there's no default, it  will fail
+
+       # At this point we should have a zone object
+       $rest->throw(code=>Apache2::Const::HTTP_BAD_REQUEST, 
+                    msg=>"Could not determine a zone")
+           unless $zoneobj;
+
+       # In case that hostname contains zone name
+       my $zname = $zoneobj->name;
+       $add_args{name} =~ s/\.$zname$//;
+       $add_args{zone} = $zoneobj; 
+
        if ( $address ){
-           # User gave us an address
+           # We were given a specific address
            if ($manager->can($user, 'choose_ip', $subnetobj)){
                $add_args{address} = $address;
            }else{
@@ -323,7 +357,7 @@ if ( $rest->{request}->method eq 'GET' ){
        }
        $rest->print_formatted($rest->get(obj=>$rr, depth=>0));
     }
-}elsif ( $rest->{request}->method eq 'DELETE' ){
+}elsif ( $method eq 'DELETE' ){
     
     my @objs_to_delete;
     
diff --git a/lib/Netdot/Model/Ipblock.pm b/lib/Netdot/Model/Ipblock.pm
index 74a1831..aea8b47 100644
--- a/lib/Netdot/Model/Ipblock.pm
+++ b/lib/Netdot/Model/Ipblock.pm
@@ -790,7 +790,7 @@ sub reserve_first_n {
  Arguments: 
     IP address and (optional) prefix length
  Returns:   
-    Ipblock object or 0 if not found
+    Ipblock object or undef if not found
   Examples:
     my $ip = Ipblock->get_covering_block(address=>$address, prefix=>$prefix);
 
@@ -1403,7 +1403,7 @@ sub matches_v6 {
   Returns: 
     Ipblock object
   Examples:
-    my $ipb = Ipblock->objectify($zonestr);
+    my $ipb = Ipblock->objectify($thing);
 
 =cut
 

commit bb95a19a34c391f9823b9d19168c965e6843f598
Author: Carlos Vicente <[email protected]>
Date:   Wed Aug 20 11:02:04 2014 -0400

    When deleting RRADDR record, do not try to set IP status to available 
unless status is 'Static'

diff --git a/lib/Netdot/Model/RRADDR.pm b/lib/Netdot/Model/RRADDR.pm
index bd525d8..1cf533a 100644
--- a/lib/Netdot/Model/RRADDR.pm
+++ b/lib/Netdot/Model/RRADDR.pm
@@ -168,7 +168,8 @@ sub delete {
        foreach my $host ( $ipblock->dhcp_scopes ){
            $host->delete();
        }
-       if ( !$ipblock->interface && !$argv->{no_change_status} ){
+       if ( $ipblock->status->name eq 'Static' &&
+            !$ipblock->interface && !$argv->{no_change_status} ){
            # Not an interface IP, so it should be available
            # unless we're told not to touch it
            $ipblock->update({status=>"Available"});

-----------------------------------------------------------------------

Summary of changes:
 htdocs/management/ip.html   |  3 +-
 htdocs/rest/host            | 82 ++++++++++++++++++++++++++++++++-------------
 lib/Netdot/Model/Ipblock.pm |  4 +--
 lib/Netdot/Model/RRADDR.pm  |  3 +-
 4 files changed, 64 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
Netdot


------------------------------

Message: 2
Date: Sat, 23 Aug 2014 14:42:24 -0400
From: Carlos Vicente <[email protected]>
Subject: Re: [Netdot-devel] two issues (one possible bug,       and
        PostgreSQL advice sought)
To: William Bulley <[email protected]>
Cc: "[email protected]" <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252

Hi Web,

On Aug 22, 2014, at 9:47 AM, William Bulley <[email protected]> wrote:

> This is a question about a possible bug in htdocs/management/ip.html
> of v1.0.6 Netdot near line 600 (code reproduced here below):
> 
>   
> #######################################################################################
>   # REBUILD_TREE
>   #
>   
> #######################################################################################
>   }elsif ( $_action eq 'REBUILD_TREE' ){
> 
>       if ( $tree_version eq '4' || $tree_version eq 'all' ){
>           Ipblock->build_tree(4);
>       }elsif ( $tree_version eq '6' || $tree_version eq 'all' ){
>           Ipblock->build_tree(6);
>       }
>       $m->comp('.show_message', title=>"Action Message", msg=>"IP Tree 
> Rebuilt Successfully");
>   }
>   
> #######################################################################################
>   # View
>   #
>   
> #######################################################################################
> 
> It appears to me that the above "if" statement will either build
> the IPv4 tree OR the IPv6 tree, but NOT BOTH -- even if the value
> of "$tree_version" is 'all'!  Shouldn't there be two separate
> (parallel, if you will) "if" statements here, should the value of
> "$_action" be 'REBUILD_TREE'???
> 
>   if (test as above)
>      Ipblock->build_tree(4);
> 
>   if (test as above)
>      Ipblock->build_tree(6);
> 
> 
> =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
> 


You are correct. I have just fixed that. Thank you.



> 
> As Netdot moves toward PostgreSQL (as we have here) has anyone
> given any thought to database replication (in the case of having
> a "hot spare") or the best methods of database backup (saving)
> for PostgreSQL?  Are there any "industry" backup "best practices"
> that folks know of (thinking of Anton here...)?
> 
> The act of dumping the database to a DDL file (SQL commands to
> recreate the database later), while straightforward, does not
> scale well if one has tens of thousands of rows spread across
> several dozen tables (even without the *_history tables that are
> now not part of Netdot as of v1.0.6).
> 
> Regards,
> 
> web...
> 


DB replication is the best option. I do it with MySQL today, but I?m told that 
it works fine in Pg

http://www.postgresql.org/docs/9.1/static/high-availability.html

In addition to that, I always keep a week?s worth of daily DB dumps in a couple 
of places, just in case.

cv


------------------------------

Message: 3
Date: Sat, 23 Aug 2014 11:56:57 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
        netdot-1.0.6-46-gf8b0da5
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  f8b0da567592a185028ecf2386ecc73486062671 (commit)
      from  58594b566d2f0f65fda57bd6f51ae3f2b8d6d186 (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 f8b0da567592a185028ecf2386ecc73486062671
Author: Carlos Vicente <[email protected]>
Date:   Sat Aug 23 14:56:47 2014 -0400

    Fixed bug that produced mismatched IP tree in cache

diff --git a/lib/Netdot/Model/Ipblock.pm b/lib/Netdot/Model/Ipblock.pm
index aea8b47..06f1f8a 100644
--- a/lib/Netdot/Model/Ipblock.pm
+++ b/lib/Netdot/Model/Ipblock.pm
@@ -1630,7 +1630,7 @@ sub update {
 
     # Only rebuild the tree if address/prefix have changed
     if ( !$no_update_tree && ($self->address ne $bak{address} || $self->prefix 
ne $bak{prefix}) ){
-       $self->_update_tree(old_addr=>$bak{address}, old_prefix=>$bak{prefix});
+       $self->_update_tree(changed=>1);
     }
 
     # Now check for rules
@@ -3213,7 +3213,7 @@ sub _build_tree_mem {
 #   Non-address blocks trigger a full tree rebuild
 #
 #   Arguments:
-#     None
+#     changed (bool) Either address or prefix length changed
 #   Returns:
 #     True
 #   Examples:
@@ -3241,11 +3241,10 @@ 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} ) {
+        if ( $argv{changed} ) {
            $logger->debug("Ipblock::_update_tree: ". $self->get_label .
                           " changed address and/or prefix. Rebuilding.");
            $class->build_tree($version);
-           $class->_tree_save(version=>$self->version, tree=>$tree);
            return 1;
         }
        # At this point we can assume that the block is new

-----------------------------------------------------------------------

Summary of changes:
 lib/Netdot/Model/Ipblock.pm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
Netdot


------------------------------

Message: 4
Date: Sat, 23 Aug 2014 11:57:15 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch master updated.
        netdot-1.0.6-46-gf8b0da5
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, master has been updated
       via  f8b0da567592a185028ecf2386ecc73486062671 (commit)
       via  58594b566d2f0f65fda57bd6f51ae3f2b8d6d186 (commit)
       via  bda5c41d535295fc003c3c042f76c8d4cb087d95 (commit)
       via  bb95a19a34c391f9823b9d19168c965e6843f598 (commit)
      from  5e343e0625796ce1d5ab009c4f8e139a311edf43 (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 -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 htdocs/management/ip.html   |  3 +-
 htdocs/rest/host            | 82 ++++++++++++++++++++++++++++++++-------------
 lib/Netdot/Model/Ipblock.pm | 11 +++---
 lib/Netdot/Model/RRADDR.pm  |  3 +-
 4 files changed, 67 insertions(+), 32 deletions(-)


hooks/post-receive
-- 
Netdot


------------------------------

_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel


End of Netdot-devel Digest, Vol 89, Issue 6
*******************************************

Reply via email to