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.
      bb5a70db394e184775d0b73eaeb0e8a9f8028639 (Apache)
   2. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
      2af0949fe89a2efde748ddaa72f6bf4b04af079f (Apache)
   3. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
      8cfb81368f51d304e9195a1e34ef2e833714326c (Apache)
   4. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
      e21b5df8316d89e797e902323c741a569d93f31f (Apache)
   5. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
      dc9a90fe743a5cd908d19858cc72ce6802740fb1 (Apache)
   6. [SCM] UNNAMED PROJECT branch netdot-1.0 updated.
      8471c5e29554fdd32d929961282e809ceb3305d9 (Apache)


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

Message: 1
Date: Tue, 7 Aug 2012 06:46:20 -0700
From: Apache <[email protected]>
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
        updated.        bb5a70db394e184775d0b73eaeb0e8a9f8028639
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  bb5a70db394e184775d0b73eaeb0e8a9f8028639 (commit)
      from  b8d116ff8532abfb3e09b737e549af0e88265834 (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 bb5a70db394e184775d0b73eaeb0e8a9f8028639
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 09:45:53 2012 -0400

    Corrections

diff --git a/htdocs/reports/macs_by_vendor.html 
b/htdocs/reports/macs_by_vendor.html
index 8015afd..24fb275 100644
--- a/htdocs/reports/macs_by_vendor.html
+++ b/htdocs/reports/macs_by_vendor.html
@@ -10,59 +10,70 @@ MAC address Report
 title   => 'MAC Address Report' 
 section => 'Reports'
 </%attr>
+
 <%args>
 $topn => 100;
 $type => 'node'
+$submit => undef
 </%args>
+
 <%init>
 my $DEBUG = 0;
-my ($stats, $total) = PhysAddr->vendor_count($type);
-print "<pre>", Dumper($stats), "</pre>" if $DEBUG;
-</%init>
-<%perl>
+my ($stats, $total);
 my (@headers, @rows) = ();
+</%init>
 
-@headers = ( 'OUI', 'Vendor', 'Count', '%', );
+<%perl>
+if ( $submit ){
+    ($stats, $total) = PhysAddr->vendor_count($type);
+    print "<pre>", Dumper($stats), "</pre>" if $DEBUG;
 
-my @row = ();
-push( @row, "Total in Database" );
-push( @row, "" );
-push( @row, "<strong>$total</strong>" );
-push( @row, "&nbsp;" );
-push( @rows, \@row );
+    @headers = ( 'OUI', 'Vendor', 'Count', '%', );
 
-my $i;
-foreach my $oui ( sort { $stats->{$b}{total} <=> $stats->{$a}{total} } keys 
%$stats ){
-    $i++;
     my @row = ();
-    my $vendor = $stats->{$oui}{vendor};
-    my $count  = $stats->{$oui}{total};
-    my $srch   = "$oui*";
-    my $slink  = "<a 
href=\"../generic/search_obj.html?table=PhysAddr&address=$srch&res=1\">$oui</a>";
-    push( @row, $slink, $vendor, $count );
-    push( @row, sprintf("%02.2f",$count/$total * 100) );
+    push( @row, "Total in Database" );
+    push( @row, "" );
+    push( @row, "<strong>$total</strong>" );
+    push( @row, "&nbsp;" );
     push( @rows, \@row );
-    last if ( $i == $topn );
+
+    my $i;
+    foreach my $oui ( sort { $stats->{$b}{total} <=> $stats->{$a}{total} } 
keys %$stats ){
+       $i++;
+       my @row = ();
+       my $vendor = $stats->{$oui}{vendor};
+       my $count  = $stats->{$oui}{total};
+       my $srch   = "$oui*";
+       my $slink  = "<a 
href=\"../generic/search_obj.html?table=PhysAddr&address=$srch&res=1\">$oui</a>";
+       push( @row, $slink, $vendor, $count );
+       push( @row, sprintf("%02.2f",$count/$total * 100) );
+       push( @rows, \@row );
+       last if ( $i == $topn );
+    }
 }
 </%perl>
 
 <div class="container">
-<div class="containerhead">MAC Addresses by Vendor (top <% $topn %>)</div>
-<div class="containerbody">
-<p>
-<form action="macs_by_vendor.html" method="POST">
-Top <input type="text" size="4" name="topn" value="<% $topn %>"> Vendors of 
type: 
+ <div class="containerhead">MAC Addresses by Vendor (top <% $topn %>)</div>
+ <div class="containerbody">
+ <p>
+ <form action="macs_by_vendor.html" method="POST">
+ Top <input type="text" size="4" name="topn" value="<% $topn %>"> Vendors of 
type: 
 % my %checked = (node => "",  infrastructure => "",   all => "");
 % $checked{$type} = "SELECTED";
 % 
-<select name="type">
-  <option value="node" <% $checked{node} %>>Node</option>
-  <option value="infrastructure" <% $checked{infrastructure} 
%>>Infrastructure</option>
-  <option value="all" <% $checked{all} %>>All</option>
-</select>
-<input type="submit" value="Submit" name="submit">
-</form>
-<& /generic/data_table.mhtml, field_headers=>\@headers, data=>\@rows, 
style=>['', '', 'text-align: right', 'text-align: right'] &>
+ <select name="type">
+   <option value="node" <% $checked{node} %>>Node</option>
+   <option value="infrastructure" <% $checked{infrastructure} 
%>>Infrastructure</option>
+   <option value="all" <% $checked{all} %>>All</option>
+ </select>
+ <input type="submit" value="Submit" name="submit">
+ </form>
 
+% if ( $submit ){
+ <& /generic/data_table.mhtml, field_headers=>\@headers, data=>\@rows, 
+   style=>['', '', 'text-align: right', 'text-align: right'] &>
+% }
+ </div>
 </div>
-</div>
+

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

Summary of changes:
 htdocs/reports/macs_by_vendor.html |   81 ++++++++++++++++++++---------------
 1 files changed, 46 insertions(+), 35 deletions(-)


hooks/post-receive
-- 
UNNAMED PROJECT


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

Message: 2
Date: Tue, 7 Aug 2012 07:21:12 -0700
From: Apache <[email protected]>
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
        updated.        2af0949fe89a2efde748ddaa72f6bf4b04af079f
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  2af0949fe89a2efde748ddaa72f6bf4b04af079f (commit)
      from  bb5a70db394e184775d0b73eaeb0e8a9f8028639 (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 2af0949fe89a2efde748ddaa72f6bf4b04af079f
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 10:20:47 2012 -0400

    Allow user to specify installed, not installed, or all in Asset search

diff --git a/htdocs/management/asset_tasks.html 
b/htdocs/management/asset_tasks.html
index 527c385..6c89eb9 100644
--- a/htdocs/management/asset_tasks.html
+++ b/htdocs/management/asset_tasks.html
@@ -18,6 +18,7 @@ $view               => 'search'
 $show_tasks         => undef
 $showheader         => 1
 $search             => undef
+$search_type        => 'all'  # installed, not installed, all
 </%args>
 
 
@@ -92,6 +93,15 @@ my @list;
                 <p>
                 <label for="Find">Keywords:</label>
                 <input type="text" name="search" class="txt" value="<% $search 
%>"> 
+               <select name="search_type">
+%              foreach my $type ( 'installed', 'not installed', 'all' ){
+%                   if ( $search_type eq $type ){
+                       <option value="<% $type %>" SELECTED><% $type 
%></option>
+%                   }else{
+                       <option value="<% $type %>"><% $type %></option>
+%                   }
+%              }   
+               </select>
                 <input name="submit" value="Search" class="btn" type="submit">
                 </p>
             </form>
@@ -214,11 +224,21 @@ if ( $submit ){
        
 
     }elsif ( $submit eq 'Search' ){
-       $m->comp('/generic/no_search_criteria.html')
-           unless $search;
+       
+       my %installed;
+       if ( $search_type ne 'all' ){
+           my $dbh = Netdot::Model->db_Main();
+           my $rows = $dbh->selectall_arrayref('SELECT asset.id FROM asset, 
device 
+                                                  WHERE 
device.asset_id=asset.id');
+           foreach my $row ( @$rows ){
+               my $id = $row->[0];
+               $installed{$id} = 1;
+           }
+       }
+       print '%installed contains: ', Dumper(%installed) if $DEBUG;
 
        # Search for labels in Asset table and foreign objects recursively
-       my $res = $ui->select_query(table=>'Asset', terms=>[$search]);
+       my $r1 = $ui->select_query(table=>'Asset', terms=>[$search]);
 
        # Search for other fields in Asset table
        my @where;
@@ -227,9 +247,15 @@ if ( $submit ){
            push @where, { $field => { '-like' => '%'.$search.'%' } };
        }
        my @assets = Asset->search_where(\@where);
-       for ( @assets ) { $res->{$_->id} = $_ };
-       @list = values %$res;
-
+       my %res;
+       for ( @assets, values %$r1 ) {
+           if ( $search_type eq 'all' || 
+                ($search_type eq 'installed' && $installed{$_->id}) ||
+                ($search_type eq 'not installed' && !exists 
$installed{$_->id}) ){
+               $res{$_->id} = $_;
+           }
+       }
+       @list = values %res;
        if ( @list ){
            $m->comp('/generic/show_search_results.mhtml', search=>$search, 
list=>\@list, dowindow=>1 );
        }else{

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

Summary of changes:
 htdocs/management/asset_tasks.html |   38 ++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
UNNAMED PROJECT


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

Message: 3
Date: Tue, 7 Aug 2012 07:24:25 -0700
From: Apache <[email protected]>
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
        updated.        8cfb81368f51d304e9195a1e34ef2e833714326c
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  8cfb81368f51d304e9195a1e34ef2e833714326c (commit)
      from  2af0949fe89a2efde748ddaa72f6bf4b04af079f (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 8cfb81368f51d304e9195a1e34ef2e833714326c
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 10:24:00 2012 -0400

    Correction

diff --git a/htdocs/management/asset_tasks.html 
b/htdocs/management/asset_tasks.html
index 6c89eb9..a761873 100644
--- a/htdocs/management/asset_tasks.html
+++ b/htdocs/management/asset_tasks.html
@@ -228,8 +228,11 @@ if ( $submit ){
        my %installed;
        if ( $search_type ne 'all' ){
            my $dbh = Netdot::Model->db_Main();
-           my $rows = $dbh->selectall_arrayref('SELECT asset.id FROM asset, 
device 
-                                                  WHERE 
device.asset_id=asset.id');
+           my $rows = $dbh->selectall_arrayref('
+                       SELECT asset.id 
+                       FROM   asset, device, devicemodule 
+                       WHERE  device.asset_id=asset.id
+                         OR   devicemodule.asset_id=asset.id');
            foreach my $row ( @$rows ){
                my $id = $row->[0];
                $installed{$id} = 1;

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

Summary of changes:
 htdocs/management/asset_tasks.html |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
UNNAMED PROJECT


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

Message: 4
Date: Tue, 7 Aug 2012 08:17:11 -0700
From: Apache <[email protected]>
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
        updated.        e21b5df8316d89e797e902323c741a569d93f31f
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  e21b5df8316d89e797e902323c741a569d93f31f (commit)
      from  8cfb81368f51d304e9195a1e34ef2e833714326c (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 e21b5df8316d89e797e902323c741a569d93f31f
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 11:16:48 2012 -0400

    Corrections

diff --git a/htdocs/management/asset_tasks.html 
b/htdocs/management/asset_tasks.html
index a761873..c8d44b3 100644
--- a/htdocs/management/asset_tasks.html
+++ b/htdocs/management/asset_tasks.html
@@ -225,20 +225,8 @@ if ( $submit ){
 
     }elsif ( $submit eq 'Search' ){
        
-       my %installed;
-       if ( $search_type ne 'all' ){
-           my $dbh = Netdot::Model->db_Main();
-           my $rows = $dbh->selectall_arrayref('
-                       SELECT asset.id 
-                       FROM   asset, device, devicemodule 
-                       WHERE  device.asset_id=asset.id
-                         OR   devicemodule.asset_id=asset.id');
-           foreach my $row ( @$rows ){
-               my $id = $row->[0];
-               $installed{$id} = 1;
-           }
-       }
-       print '%installed contains: ', Dumper(%installed) if $DEBUG;
+       my $installed = Asset->get_installed_hash() 
+           unless $search_type eq 'all';
 
        # Search for labels in Asset table and foreign objects recursively
        my $r1 = $ui->select_query(table=>'Asset', terms=>[$search]);
@@ -253,8 +241,8 @@ if ( $submit ){
        my %res;
        for ( @assets, values %$r1 ) {
            if ( $search_type eq 'all' || 
-                ($search_type eq 'installed' && $installed{$_->id}) ||
-                ($search_type eq 'not installed' && !exists 
$installed{$_->id}) ){
+                ($search_type eq 'installed' && $installed->{$_->id}) ||
+                ($search_type eq 'not installed' && !exists 
$installed->{$_->id}) ){
                $res{$_->id} = $_;
            }
        }
diff --git a/htdocs/reports/asset_inventory.html 
b/htdocs/reports/asset_inventory.html
index d07d5be..8d939f3 100644
--- a/htdocs/reports/asset_inventory.html
+++ b/htdocs/reports/asset_inventory.html
@@ -25,18 +25,8 @@ if ( $report_type eq 'type_product' || $report_type eq 
'detailed' ){
               WHERE  asset.product_id=product.id
                  AND product.type=producttype.id");
     
-    my $iassets = $dbh->selectall_arrayref("
-               SELECT device.asset_id, devicemodule.asset_id 
-                 FROM device, devicemodule
-                WHERE device.asset_id IS NOT NULL 
-                  AND devicemodule.asset_id IS NOT NULL
-                  AND device.asset_id < devicemodule.asset_id");
     
-    my %installed;
-    foreach my $row ( @$iassets ){
-       $installed{$row->[0]} = 1;
-       $installed{$row->[1]} = 1;
-    }
+    my $installed = Asset->get_installed_hash();
     
     foreach my $row ( @$assets ){
        my ($id, $sn, $inv, $res, $pid, $pname, $ptype) = @$row;
@@ -44,7 +34,7 @@ if ( $report_type eq 'type_product' || $report_type eq 
'detailed' ){
        $t{$ptype}{prod}{$pname}{total}++;
        $t{$ptype}{prod}{$pname}{id}  = $pid;
        $t{$ptype}{prod}{$pname}{assets}{$sn}{id}  = $id;
-       $t{$ptype}{prod}{$pname}{assets}{$sn}{installed} = 
(exists($installed{$id}))? 1 : 0;
+       $t{$ptype}{prod}{$pname}{assets}{$sn}{installed} = 
(exists($installed->{$id}))? 1 : 0;
        $t{$ptype}{prod}{$pname}{assets}{$sn}{inv} = $inv;
        $t{$ptype}{prod}{$pname}{assets}{$sn}{res} = $res;
        $grandtotal++;
@@ -54,7 +44,7 @@ if ( $report_type eq 'type_product' || $report_type eq 
'detailed' ){
        use Data::Dumper;
        print '<pre>';
        print Dumper(%t);
-       print Dumper(%installed);
+       print Dumper($installed);
        print '</pre>';
     }
 }
diff --git a/lib/Netdot/Model/Asset.pm b/lib/Netdot/Model/Asset.pm
index 9dc6a01..b60ba68 100644
--- a/lib/Netdot/Model/Asset.pm
+++ b/lib/Netdot/Model/Asset.pm
@@ -4,8 +4,49 @@ use base 'Netdot::Model';
 use warnings;
 use strict;
 
+=head1 NAME
 
-############################################################################
+Netdot::Model::Asset - Asset class
+
+=head1 SYNOPSIS
+
+my $installed = Asset->get_installed_hash();
+
+=head1 CLASS METHODS
+=cut
+
+###########################################################################
+=head2 get_installed_hash - Build a hash of installed assets keyed by id
+
+  Arguments: 
+    None
+  Returns: 
+    Hashref with key = asset.id, value = 1
+
+=cut
+sub get_installed_hash {
+    my ($class) = @_;
+    my %installed;
+    my $dbh = $class->db_Main();
+    # Note: Tried to do this in one query but for some reason it takes forever
+    my $rows1 = $dbh->selectall_arrayref('
+                       SELECT DISTINCT(asset.id) 
+                       FROM   asset, device
+                       WHERE  device.asset_id=asset.id');
+    
+    my $rows2 = $dbh->selectall_arrayref('
+                       SELECT DISTINCT(asset.id) 
+                       FROM   asset, device
+                       WHERE  device.asset_id=asset.id');
+    
+    foreach my $row ( @$rows1, @$rows2 ){
+       my $id = $row->[0];
+       $installed{$id} = 1;
+    }
+    return \%installed;
+}
+
+###########################################################################
 =head2 search_like -  Search for asset objects.  Allow substrings
 
   Overridden to allow producttype to be searched on
@@ -16,7 +57,6 @@ use strict;
     Array of Asset objects or iterator
 
 =cut
-
 sub search_like{
     my ($class, %argv) = @_;
     $class->isa_class_method('search_like');

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

Summary of changes:
 htdocs/management/asset_tasks.html  |   20 +++------------
 htdocs/reports/asset_inventory.html |   16 ++----------
 lib/Netdot/Model/Asset.pm           |   44 +++++++++++++++++++++++++++++++++-
 3 files changed, 49 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
UNNAMED PROJECT


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

Message: 5
Date: Tue, 7 Aug 2012 08:19:24 -0700
From: Apache <[email protected]>
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
        updated.        dc9a90fe743a5cd908d19858cc72ce6802740fb1
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  dc9a90fe743a5cd908d19858cc72ce6802740fb1 (commit)
      from  e21b5df8316d89e797e902323c741a569d93f31f (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 dc9a90fe743a5cd908d19858cc72ce6802740fb1
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 11:19:01 2012 -0400

    Corrections

diff --git a/lib/Netdot/Model/Asset.pm b/lib/Netdot/Model/Asset.pm
index b60ba68..da5b8f4 100644
--- a/lib/Netdot/Model/Asset.pm
+++ b/lib/Netdot/Model/Asset.pm
@@ -36,8 +36,8 @@ sub get_installed_hash {
     
     my $rows2 = $dbh->selectall_arrayref('
                        SELECT DISTINCT(asset.id) 
-                       FROM   asset, device
-                       WHERE  device.asset_id=asset.id');
+                       FROM   asset, devicemodule
+                       WHERE  devicemodule.asset_id=asset.id');
     
     foreach my $row ( @$rows1, @$rows2 ){
        my $id = $row->[0];

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

Summary of changes:
 lib/Netdot/Model/Asset.pm |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
UNNAMED PROJECT


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

Message: 6
Date: Tue, 7 Aug 2012 10:19:23 -0700
From: Apache <[email protected]>
Subject: [Netdot-devel] [SCM] UNNAMED PROJECT branch netdot-1.0
        updated.        8471c5e29554fdd32d929961282e809ceb3305d9
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  8471c5e29554fdd32d929961282e809ceb3305d9 (commit)
       via  05a668f0e9a166869df432d83a3e83d7ae41abc1 (commit)
       via  e1a06c122596bca4182b593b4df373f10e55c7b3 (commit)
      from  dc9a90fe743a5cd908d19858cc72ce6802740fb1 (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 8471c5e29554fdd32d929961282e809ceb3305d9
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 13:18:59 2012 -0400

    Corrections

diff --git a/htdocs/user_management/add_host.html 
b/htdocs/user_management/add_host.html
index de19d41..2a357fd 100644
--- a/htdocs/user_management/add_host.html
+++ b/htdocs/user_management/add_host.html
@@ -64,8 +64,6 @@ unless ( $manager && $manager->can($user, "edit", $block) ){
 my $zone;
 if ( $zone_id ){
     $zone = Zone->retrieve($zone_id);
-}else{
-    $zone = $block->forward_zone();
 }
 
 if ( $submit ){
@@ -288,20 +286,26 @@ function showIPv6Input(selectObj, Layer){
             <% $zone->get_label %>
 %       }else{
             <select name="zone_id" id="zone">
-%           my $default_domain = Netdot->config->get('DEFAULT_DNSDOMAIN');
-%           my $default_zone = (Zone->search(name=>$default_domain))[0];
+%           my $default_zone;
 %          # Show only zones that this user has access to
 %           my $ao = $ui->get_allowed_objects($r, $user);
-%           my @zones;
+%           my %zones;
 %           if ( exists $ao->{Zone} ){
 %               foreach my $id ( keys %{$ao->{Zone}} ){
 %                  if ( my $zone = Zone->retrieve($id) ){
-%                      push @zones, $zone;
+%                      $zones{$id} = $zone;
 %                  }
 %               }
 %           }
+%          if ( my $fz = $block->forward_zone ){
+%               $zones{$fz->id} = $fz;
+%               $default_zone = $fz;
+%          }else{
+%               my $default_domain = Netdot->config->get('DEFAULT_DNSDOMAIN');
+%               $default_zone = (Zone->search(name=>$default_domain))[0];
+%           }
             <option value="">-- Select --</option>
-%           foreach my $z ( sort { $a->get_label cmp $b->get_label } @zones ){
+%           foreach my $z ( sort { $a->get_label cmp $b->get_label } values 
%zones ){
 %               if ( $default_zone && $default_zone->id == $z->id ){
                     <option value="<% $z->id %>" SELECTED><% $z->get_label 
%></option>
 %               }else{

commit 05a668f0e9a166869df432d83a3e83d7ae41abc1
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 12:02:13 2012 -0400

    Corrections

diff --git a/htdocs/management/host.html b/htdocs/management/host.html
index 9caf771..deba81a 100644
--- a/htdocs/management/host.html
+++ b/htdocs/management/host.html
@@ -803,6 +803,7 @@ foreach my $o ( values %rrs ) {
     
#####################################################################################################
     #RRNS
     if ( $o->name eq '@' || $o->name eq $o->zone->name || (!$o->a_records && 
!$o->ptr_records)  ){
+
        print '<div class="container" style="margin-left:10px">';
        print '<div class="containerheadleft"><b>Name Servers 
'.$ui->table_descr_link('RRNS', '(NS)').'</b></div>';
        print '<div class="containerheadright">';
@@ -829,8 +830,14 @@ foreach my $o ( values %rrs ) {
        #display/edit
        print '<div class="containerbody">';
        if (my @nss = $o->ns_records()) {
+           my $ns_edit = $edit;
+           unless ( $manager && $manager->can($user, 'access_section', 
'edit_ns_records') 
+                && $manager->can($user, 'edit', $o) ){
+               # Do not allow edits unless they have permissions
+               $ns_edit = 0;
+           }
            foreach my $ns (@nss) {
-               $ui->add_to_fields(o=>$ns, edit=>$edit, fields=>['nsdname', 
'ttl'],
+               $ui->add_to_fields(o=>$ns, edit=>$ns_edit, fields=>['nsdname', 
'ttl'],
                                   field_headers=>\@field_headers, 
cell_data=>\@cell_data,
                                   linkpages=>['view.html',''], with_delete=>1);
                $m->comp('/generic/attribute_table.mhtml', %comphash);
@@ -862,7 +869,8 @@ foreach my $o ( values %rrs ) {
        print '<script type="text/javascript" 
language="javascript">uricomponents[\'rrds_'.$o.'_content\']=encodeURIComponent(\''.$newds.'\');</script>';
        print '&nbsp;';
        if ( !$edit ){
-           if ( $manager && $manager->can($user, 'edit', $o) ){
+           if ( $manager && $manager->can($user, 'access_section', 
'add_ds_records') 
+                && $manager->can($user, 'edit', $o) ){
                print '<div id="rrds_'.$o.'"><a href="#" 
onClick="dynamicAdd(\'rrds\', \''.$o.'\', 1, \'rr\')">[add]</a></div>';
            }
        }
@@ -871,8 +879,14 @@ foreach my $o ( values %rrs ) {
        #display/edit
        print '<div class="containerbody">';
        if (my @dss = $o->ds_records()) {
+           my $ds_edit = $edit;
+           unless ( $manager && $manager->can($user, 'access_section', 
'edit_ns_records') 
+                && $manager->can($user, 'edit', $o) ){
+               # Do not allow edits unless they have permissions
+               $ds_edit = 0;
+           }
            foreach my $ds (@dss) {
-               $ui->add_to_fields(o=>$ds, edit=>$edit, fields=>\@field_names,
+               $ui->add_to_fields(o=>$ds, edit=>$ds_edit, 
fields=>\@field_names,
                                   field_headers=>\@field_headers, 
cell_data=>\@cell_data,
                                   with_delete=>1);
                $m->comp('/generic/attribute_table.mhtml', %comphash);
diff --git a/htdocs/user_management/hostinfo_tasks.html 
b/htdocs/user_management/hostinfo_tasks.html
index 8326f53..c2d6aa5 100644
--- a/htdocs/user_management/hostinfo_tasks.html
+++ b/htdocs/user_management/hostinfo_tasks.html
@@ -176,7 +176,8 @@ if ( $submit && $ipblock ){
        my $ipblock = Ipblock->retrieve($ipblock);
        if ( my $zone = $ipblock->forward_zone ){
            my $records = $zone->get_hosts($ipblock->id);
-           $m->comp('/management/hostlist.mhtml', records=>$records, 
withedit=>1, return_args=>"?ipblock=$ipblock&ipblock_action='browse_records'");
+           $m->comp('/management/hostlist.mhtml', records=>$records, 
withedit=>1, 
+                    
return_args=>"?ipblock=$ipblock&ipblock_action='browse_records'");
        }else{
            $m->comp('/generic/error.mhtml', error=>$ipblock->get_label." not 
associated with a zone");
        }

commit e1a06c122596bca4182b593b4df373f10e55c7b3
Author: Carlos Vicente <[email protected]>
Date:   Tue Aug 7 11:37:20 2012 -0400

    Avoid duplicate subnets in list of blocks for user

diff --git a/htdocs/user_management/hostinfo_tasks.html 
b/htdocs/user_management/hostinfo_tasks.html
index f7da8ba..8326f53 100644
--- a/htdocs/user_management/hostinfo_tasks.html
+++ b/htdocs/user_management/hostinfo_tasks.html
@@ -60,21 +60,21 @@ my $MAC  = Netdot->get_mac_regex();
     <div class="containerbody" id="tasks" style="display:<% ($show_tasks eq 
"show"?"block":"none") %>">
 
 <%perl>
-my (@ipblocks, @zones);
+my (%ipblocks, @zones);
 my $ao = $ui->get_allowed_objects($r, $user);
 print '<pre>', Dumper($ao), '<pre>' if $DEBUG;
 if ( exists $ao->{Ipblock} ){
     foreach my $id ( keys %{$ao->{Ipblock}} ){
        if ( my $ip = Ipblock->retrieve($id) ){
            if ( $ip->status->name eq 'Subnet' ){
-               push @ipblocks, $ip;
+               $ipblocks{$id} = $ip;
            }elsif ( $ip->status->name eq 'Container' ){
                foreach my $n ( @{$ip->get_descendants_trie} ){
                    next unless defined $n;
                    my $chid = $n->data;
                    if ( my $ch = Ipblock->retrieve($chid) ){
                        if ( $ch->status->name eq 'Subnet' ){
-                           push @ipblocks, $ch;
+                           $ipblocks{$chid} = $ch;
                        }
                    }
                }
@@ -115,13 +115,13 @@ my %ipb_actions = (
         </form>
     </fieldset>
 
-% if ( @ipblocks ){
+% if ( %ipblocks ){
     <fieldset class="small">
         <legend>IP Block Actions</legend>
         <form name="actions_form" action="hostinfo_tasks.html" method="POST">
         <select name="ipblock">
             <option value="">- Select Block -</option>
-%       foreach my $o ( sort { $a->address_numeric <=> $b->address_numeric } 
@ipblocks ){
+%       foreach my $o ( sort { $a->address_numeric <=> $b->address_numeric } 
values %ipblocks ){
 %           if ( $ipblock && $ipblock eq $o->id ){
                 <option value="<% $o %>" SELECTED><% $o->get_label %></option>
 %           }else{
@@ -192,7 +192,7 @@ if ( $submit && $ipblock ){
     $search =~ s/^\s*(.*)\s*$/$1/g;
     my %rrids;
     my @allrecords;
-    foreach my $ipblock ( @ipblocks ){
+    foreach my $ipblock ( values %ipblocks ){
        if ( my $zone = $ipblock->forward_zone ){
            my $records = $zone->get_hosts($ipblock->id);
            push @allrecords, @$records;

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

Summary of changes:
 htdocs/management/host.html                |   20 +++++++++++++++++---
 htdocs/user_management/add_host.html       |   18 +++++++++++-------
 htdocs/user_management/hostinfo_tasks.html |   15 ++++++++-------
 3 files changed, 36 insertions(+), 17 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 8
*******************************************

Reply via email to