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 master updated.       netdot-1.0.7-25-gc9ac706
      ([email protected])
   2. [Netdot - Feature #1870] Improve zonefile and DHCPD       config
      file generation ([email protected])
   3. Re: [Netdot - Feature #1870] (New) Improve zonefile and DHCPD
      config file generation (Bob Harold)


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

Message: 1
Date: Fri, 10 Jul 2015 13:10:17 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch master updated.
        netdot-1.0.7-25-gc9ac706
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  c9ac706ab635cf06bd25011c795ebd0cddc7ffba (commit)
       via  c0d2fc5995d83b0dec1b2ab616264519509e1e38 (commit)
       via  012d2f9ab4debbbcb18d76e201f201a1e7191341 (commit)
      from  02f37069c2f9a7f20c06bfd2705e743d5ca86e45 (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 c9ac706ab635cf06bd25011c795ebd0cddc7ffba
Merge: 02f3706 c0d2fc5
Author: Carlos Vicente <[email protected]>
Date:   Fri Jul 10 08:46:49 2015 -0400

    Merge pull request #37 from cvicente/device_ip_delete
    
    Do not automatically delete IP addresses associated with devices


commit c0d2fc5995d83b0dec1b2ab616264519509e1e38
Author: Carlos Vicente <[email protected]>
Date:   Mon Jul 6 14:18:29 2015 -0400

    Do not automatically delete IP addresses associated with devices

diff --git a/etc/netdot.meta b/etc/netdot.meta
index cc33903..b75d014 100644
--- a/etc/netdot.meta
+++ b/etc/netdot.meta
@@ -5005,7 +5005,7 @@ $meta = {
         description => 'Device interface where this address is configured',
         length => '',
         linksto => {
-          cascade => 'Delete',
+          cascade => 'Nullify',
           method => 'ips',
           table => 'Interface'
         },
diff --git a/htdocs/generic/delete.html b/htdocs/generic/delete.html
index 5bad027..7b186dd 100644
--- a/htdocs/generic/delete.html
+++ b/htdocs/generic/delete.html
@@ -12,6 +12,7 @@ $selectall     => undef
 $selectall_ids => undef
 $return_url    => undef
 $warning       => undef
+$delete_device_ips => undef
 </%args>
 
 <%init>
@@ -93,6 +94,9 @@ if ( $table && $id ){
     }
 }
 </%perl>
+    <form method="POST" action="delete.html">
+    <input type="hidden" name="sid" value="<% $session->{_session_id} %>">
+    <input type="hidden" name="return_url" value="<% $return_url %>">
 
 % if ( $warning ne "" ){
     <nobr>
@@ -106,11 +110,15 @@ if ( $table && $id ){
     <nobr>
     <p>
     <strong>Device removal notice:</strong>
-     This hardware will be moved to the available asset pool. If you inted to 
-     decommission the hardware remember to remove the asset as well.
+    </p>
+    <p>
+    This hardware will be moved to the available asset pool. If you inted to 
+    decommission the hardware, remember to remove the asset as well.
+    </p>
+    <p>
+    <input type="checkbox" name="delete_device_ips" value="1"> Delete this 
Device's IP addresses. This will also delete any DNS A/AAAA records associated 
with each IP.
     </p>
     </nobr>
-    <br>
 % }
 
 % if ( %cascade ){
@@ -127,9 +135,6 @@ if ( $table && $id ){
     </ul>
 % }
  
-    <form method="POST" action="delete.html">
-    <input type="hidden" name="sid" value="<% $session->{_session_id} %>">
-    <input type="hidden" name="return_url" value="<% $return_url %>">
     <input name="submit" value="Confirm" type="submit">
     <input type="button" name="cancel" value="Cancel" 
onClick="history.go(-1);">
     </form>
@@ -151,6 +156,13 @@ if ( $table && $id ){
        my $obj = $table->retrieve($id);
        push @objs, $obj if $obj;
     }
+
+    my %dargs; # Arguments for delete()
+
+    if ( $delete_device_ips ){
+       $dargs{delete_ips} = 1;
+    }
+
     my @lbls = map { "$table " . $_->get_label } @objs;
     eval {
        Netdot::Model->do_transaction(sub{
@@ -158,7 +170,7 @@ if ( $table && $id ){
                unless ( $manager && $manager->can($user, "delete", $obj) ){
                    $ui->throw_user("You don't have permission to delete this 
object");
                }
-               $obj->delete();
+               $obj->delete(%dargs);
            }
                                      });
     };
diff --git a/lib/Netdot/Model/Device.pm b/lib/Netdot/Model/Device.pm
index f5e0117..f9fa03b 100644
--- a/lib/Netdot/Model/Device.pm
+++ b/lib/Netdot/Model/Device.pm
@@ -2414,6 +2414,7 @@ sub get_fwt {
 
   Arguments:
     no_delete_name - Do not attempt to delete name DNS record
+    delete_ips - Optionally delete IP addresses associated with this device
   Returns:
     True if successful
 
@@ -2426,11 +2427,14 @@ sub delete {
     my ($self, %argv) = @_;
     $self->isa_object_method('delete');
 
-    # We don't want to delete dynamic addresses
-    if ( my $ips = $self->get_ips ){
-       foreach my $ip ( @$ips ) {
-           if ( $ip->status && $ip->status->name eq 'Dynamic' ){
-               $ip->update({interface=>undef});
+    if ( $argv{delete_ips} ){
+       if ( my $ips = $self->get_ips ){
+           foreach my $ip ( @$ips ) {
+               # We don't want to delete dynamic addresses
+               if ( $ip->status && $ip->status->name eq 'Dynamic' ){
+                   next;
+               }
+               $ip->delete();
            }
        }
     }
@@ -2445,7 +2449,7 @@ sub delete {
        # Otherwise, we do it here.
        if ( my $rr = RR->retrieve($rrid) ){
            $rr->delete() unless $rr->sub_records;
-       }       
+       }
     }
     return 1;
 }
@@ -6333,31 +6337,22 @@ sub _update_interfaces {
     }
     
     ##############################################
-    # remove ip addresses that no longer exist
+    # Disconnect IP addresses no longer reported
     while ( my ($address, $obj) = each %old_ips ){
-       # Check that it still exists 
-       # (could have been deleted if its interface was deleted)
        next unless ( defined $obj );
-       next if ( ref($obj) =~ /deleted/i );
 
-       # Don't delete if interface was added manually, which means that
+       # Don't disconnect if interface was added manually, which means that
        # the IP was probably manually added too.
        next if ($obj->interface && $obj->interface->doc_status eq 'manual');
 
-       # Don't delete dynamic addresses, just unset the interface
-       if ( $obj->status && $obj->status->name eq 'Dynamic' ){
-           $obj->update({interface=>undef});
-           next;
-       }
-
-       # If interface is set to "Ignore IP", don't delete existing IP
+       # If interface is set to "Ignore IP", skip
        if ( $obj->interface && $obj->interface->ignore_ip ){
            $logger->debug(sub{sprintf("%s: IP %s not deleted: %s set to Ignore 
IP", 
                                       $host, $obj->address, 
$obj->interface->get_label)});
            next;
        }
 
-       # Don't delete snmp_target address unless updating via UI
+       # Skip snmp_target address unless updating via UI
        if ( $ENV{REMOTE_USER} eq 'netdot' && $self->snmp_target && 
             $self->snmp_target->id == $obj->id ){
            $logger->debug(sub{sprintf("%s: IP %s is snmp target. Skipping 
delete",
@@ -6365,9 +6360,10 @@ sub _update_interfaces {
            next;
        }
 
+       # Disconnect the IP from the interface (do not delete)
        $logger->info(sprintf("%s: IP %s no longer exists.  Removing.", 
                              $host, $obj->address));
-       $obj->delete(no_update_tree=>1);
+       $obj->update({interface=>undef});
     }
     
     ##############################################################

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

Summary of changes:
 etc/netdot.meta            |  2 +-
 htdocs/generic/delete.html | 26 +++++++++++++++++++-------
 lib/Netdot/Model/Device.pm | 36 ++++++++++++++++--------------------
 3 files changed, 36 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
Netdot


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

Message: 2
Date: Fri, 10 Jul 2015 13:14:27 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Feature #1870] Improve zonefile and
        DHCPD   config file generation
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8


Issue #1870 has been updated by Carlos Vicente.


Pull request available at:

https://github.com/cvicente/Netdot/pull/38
----------------------------------------
Feature #1870: Improve zonefile and DHCPD config file generation
https://osl.uoregon.edu/redmine/issues/1870#change-3308

Author: Carlos Vicente
Status: New
Priority: High
Assignee: Carlos Vicente
Category: Netdot
Target version: 1.1.0
Resolution: 


Currently, these exporter classes use a special table called 'hostaudit' to 
determine whether the files need to be exported. This table is updated with a 
new entry each time that a related record is updated in the DB. This process 
has some important drawbacks:

* The code is complex and ugly
* There are cases when a change is made, and a second operation cancels the 
previous change, resulting in two entries in the 'hostaudit' table. Even though 
the resulting files are the same, the export happens anyways because there 
isn't enough information to determine that the resulting file will be identical 
as the previous one (except for the zone serial)

The proposed solution is to:

* Remove the 'hostaudit' table and related code
* Add a 'checksum' field to both the 'zone' table and the 'dhcpscope' table
* Each time an export is requested, the file is generated in memory. A checksum 
is calculated on the result and it is compared with the current checksum in the 
DB. The file is only printed to disk if the checksums are different.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://osl.uoregon.edu/redmine/my/account


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

Message: 3
Date: Fri, 10 Jul 2015 16:54:33 -0400
From: Bob Harold <[email protected]>
Subject: Re: [Netdot-devel] [Netdot - Feature #1870] (New) Improve
        zonefile and DHCPD config file generation
To: [email protected]
Message-ID:
        <CA+nkc8AcWuyijzpBnG1rf9=vuzdxbi9no_abytvvh9c1ebp...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Can I suggest that generating checksums for every zone on every export
request could be slow?  Perhaps some of the existing code could simply set
a "touched" flag on the zone, and then only those need to have checksums
generated and checked.



-- 
Bob Harold
hostmaster, UMnet, ITcom
Information and Technology Services (ITS)
[email protected]
734-647-6524 desk

On Fri, Jul 10, 2015 at 2:21 PM, <[email protected]> wrote:

>
> Issue #1870 has been reported by Carlos Vicente.
>
> ----------------------------------------
> Feature #1870: Improve zonefile and DHCPD config file generation
> https://osl.uoregon.edu/redmine/issues/1870
>
> Author: Carlos Vicente
> Status: New
> Priority: High
> Assignee: Carlos Vicente
> Category: Netdot
> Target version: 1.1.0
> Resolution:
>
>
> Currently, these exporter classes use a special table called 'hostaudit'
> to determine whether the files need to be exported. This table is updated
> with a new entry each time that a related record is updated in the DB. This
> process has some important drawbacks:
>
> * The code is complex and ugly
> * There are cases when a change is made, and a second operation cancels
> the previous change, resulting in two entries in the 'hostaudit' table.
> Even though the resulting files are the same, the export happens anyways
> because there isn't enough information to determine that the resulting file
> will be identical as the previous one (except for the zone serial)
>
> The proposed solution is to:
>
> * Remove the 'hostaudit' table and related code
> * Add a 'checksum' field to both the 'zone' table and the 'dhcpscope' table
> * Each time an export is requested, the file is generated in memory. A
> checksum is calculated on the result and it is compared with the current
> checksum in the DB. The file is only printed to disk if the checksums are
> different.
>
>
> --
> You have received this notification because you have either subscribed to
> it, or are involved in it.
> To change your notification preferences, please click here:
> http://osl.uoregon.edu/redmine/my/account
> _______________________________________________
> Netdot-devel mailing list
> [email protected]
> https://osl.uoregon.edu/mailman/listinfo/netdot-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://osl.uoregon.edu/pipermail/netdot-devel/attachments/20150710/9ae2f161/attachment-0001.html
 

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

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


End of Netdot-devel Digest, Vol 100, Issue 3
********************************************

Reply via email to