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.4-8-g9980fa2 ([email protected])


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

Message: 1
Date: Thu, 24 Jan 2013 06:25:00 -0800
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
        netdot-1.0.4-8-g9980fa2
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  9980fa2b89f46bc33901e94cdd16b9540c06bdfb (commit)
      from  c2261112eeb35670eea32bd4c4671bfe69cfdd91 (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 9980fa2b89f46bc33901e94cdd16b9540c06bdfb
Author: Carlos Vicente <[email protected]>
Date:   Thu Jan 24 09:24:54 2013 -0500

    Avoid duplicate errors when creating entities from BGP peerings

diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index 3c558b3..ba76391 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -2564,40 +2564,38 @@ sub update_bgp_peering {
     my ($peer, $oldpeerings) = @argv{"peer", "oldpeerings"};
     $self->isa_object_method('update_bgp_peering');
 
-    $self->throw_fatal("Model::Device::update_bgp_peering: Missing required 
arguments: peer, oldpeerings")
+    $self->throw_fatal('Model::Device::update_bgp_peering: '.
+                      'Missing required arguments: peer, oldpeerings')
        unless ( $peer && $oldpeerings );
-    my $host = $self->fqdn;
 
+    my $host = $self->fqdn;
     my $p; # bgppeering object
-
+    
     # Check if we have basic Entity info
     my $entity;
-    if ( exists ($peer->{asname}) || 
-        exists ($peer->{orgname})|| 
-        exists ($peer->{asnumber}) ){
+    if ( $peer->{asname}  || $peer->{orgname} || $peer->{asnumber} ){
        
        my $entityname = $peer->{orgname} || $peer->{asname};
-       $entityname .= " ($peer->{asnumber})";
+       $entityname .= " ($peer->{asnumber})" if $peer->{asnumber};
        
-       # Check if Entity exists
-       #
-       if ( $entity = Entity->search(asnumber => $peer->{asnumber})->first ||
-            Entity->search(asname => $peer->{asname})->first               ||
-            Entity->search(name   => $peer->{orgname})->first
-            ){
+       # Check if Entity exists (notice it's an OR search)
+       my @where;
+       push @where, { asnumber => $peer->{asnumber} } if $peer->{asnumber};
+       push @where, { asname   => $peer->{asname}   } if $peer->{asname};
+       push @where, { name     => $entityname       };
+       
+       if ( $entity = Entity->search_where(\@where)->first ){
            # Update AS stuff
            $entity->update({asname   => $peer->{asname},
                             asnumber => $peer->{asnumber}});
        }else{
            # Doesn't exist. Create Entity
-           #
            # Build Entity info
-           #
            my %etmp = ( name     => $entityname,
                         asname   => $peer->{asname},
                         asnumber => $peer->{asnumber},
                );
-       
+           
            $logger->info(sprintf("%s: Peer Entity %s not found. Inserting", 
                                  $host, $entityname ));
            

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

Summary of changes:
 lib/Netdot/Model/Device.pm |   30 ++++++++++++++----------------
 1 files changed, 14 insertions(+), 16 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 70, Issue 9
*******************************************

Reply via email to