Changeset 397


Ignore:
Timestamp:
05/10/10 17:33:13 (14 years ago)
Author:
Kris Deugau
Message:

/trunk

Merge basic node-tracking from r393:396 into trunk. See #13.

Location:
trunk
Files:
10 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/assign.html

    r345 r397  
    2424</tr><tr class="color1">
    2525<td>Route from/through:&nbsp;</td><td>
    26 <select name="pop"><option selected>-</option>
     26<select name="pop"><option selected value=>-</option>
    2727$$POPLIST$$
    2828</select>
    2929</td>
    30 </tr><tr class="color2">
     30</tr>
     31<tr class="hack"><td>Wifi tower/Fibre demarc</td><td>
     32<select name="node"><option selected>-</option>
     33$$NODELIST$$
     34</select>
     35&nbsp;<a href="javascript:popNotes('/ip/newnode.html')">Add new location</a>
     36</td></tr>
     37<tr class="color2">
    3138<td>Route/allocate from this master:&nbsp;</td><td>$$MASTERLIST$$
    3239Allow automatic allocation from private IP ranges:<input type=checkbox name=allowpriv>
  • trunk/cgi-bin/IPDB.pm

    r371 r397  
    292292# Returns a success code and optional error message.
    293293sub allocateBlock {
    294   my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$privdata) = @_;
     294  my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$privdata,$nodeid) = @_;
    295295
    296296  my $cidr = new NetAddr::IP $_[1];
     
    333333        " where ip='$cidr'");
    334334      $sth->execute;
     335# node hack
     336      if ($nodeid && $nodeid ne '') {
     337        $sth = $dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
     338        $sth->execute("$cidr",$nodeid);
     339      }
     340# end node hack
    335341      $dbh->commit;
    336342    };
     
    393399        } # routing vs non-routing netblock
    394400
     401# node hack
     402      if ($nodeid && $nodeid ne '') {
     403        $sth = $dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
     404        $sth->execute("$cidr",$nodeid);
     405      }
     406# end node hack
    395407        $dbh->commit;
    396408      }; # end of eval
     
    497509        } # done with netblock alloctype != rm
    498510
     511# node hack
     512      if ($nodeid && $nodeid ne '') {
     513        $sth = $dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
     514        $sth->execute("$cidr",$nodeid);
     515      }
     516# end node hack
    499517        $dbh->commit;
    500518      }; # end eval
  • trunk/cgi-bin/ipdb.psql

    r388 r397  
    213213        "auto" character(1) DEFAULT 'y'
    214214);
     215
     216-- Network nodes - allows finding customers affected by a broken <x> quickly
     217CREATE TABLE noderef (
     218    block inet NOT NULL PRIMARY KEY,
     219    node_id integer
     220);
     221
     222CREATE TABLE nodes (
     223    node_id serial NOT NULL PRIMARY KEY,
     224    node_type character varying(2),
     225    node_name character varying(40),
     226    node_ip inet
     227);
  • trunk/cgi-bin/main.cgi

    r380 r397  
    126126elsif($webvar{action} eq 'finaldelete') {
    127127  finalDelete();
     128}
     129elsif ($webvar{action} eq 'nodesearch') {
     130  open HTML, "<../nodesearch.html";
     131  my $html = join('',<HTML>);
     132  close HTML;
     133
     134  $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     135  $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     136  my $nodes = '';
     137  while (my ($nid,$nname) = $sth->fetchrow_array()) {
     138    $nodes .= "<option value='$nid'>$nname</option>\n";
     139  }
     140  $html =~ s/\$\$NODELIST\$\$/$nodes/;
     141
     142  print $html;
    128143}
    129144
     
    613628  }
    614629  $html =~ s|\$\$ALLCITIES\$\$|$cities|g;
     630
     631## node hack
     632  $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     633  $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     634  my $nodes = '';
     635  while (my ($nid,$nname) = $sth->fetchrow_array()) {
     636    $nodes .= "<option value='$nid'>$nname</option>\n";
     637  }
     638  $html =~ s/\$\$NODELIST\$\$/$nodes/;
     639## end node hack
    615640
    616641  my $i = 0;
     
    779804  close HTML;
    780805
     806## node hack
     807  if ($webvar{node} && $webvar{node} ne '-') {
     808    $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
     809    $sth->execute($webvar{node});
     810    my ($nodename) = $sth->fetchrow_array();
     811    $html =~ s/\$\$NODENAME\$\$/$nodename/;
     812    $html =~ s/\$\$NODEID\$\$/$webvar{node}/;
     813  } else {
     814    $html =~ s/\$\$NODENAME\$\$//;
     815    $html =~ s/\$\$NODEID\$\$//;
     816  }
     817## end node hack
     818
    781819### gotta fix this in final
    782820  # Stick in customer info as necessary - if it's blank, it just ends
     
    841879  my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from},
    842880        $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
    843         $webvar{circid}, $webvar{privdata});
     881        $webvar{circid}, $webvar{privdata}, $webvar{node});
    844882
    845883  if ($code eq 'OK') {
     
    10061044      $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g;
    10071045    }
     1046## node hack
     1047  $sth = $ip_dbh->prepare("SELECT node_id FROM noderef WHERE block='$webvar{block}'");
     1048  $sth->execute;
     1049  my ($nodeid) = $sth->fetchrow_array();
     1050  if ($nodeid) {
     1051    $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     1052    $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1053    my $nodes = "<select name=node>\n";
     1054    while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1055      $nodes .= "<option".($nodeid == $nid ? ' selected' : '')." value='$nid'>$nname</option>\n";
     1056    }
     1057    $nodes .= "</select>\n";
     1058    $html =~ s/\$\$NODE\$\$/$nodes/;
     1059  } else {
     1060    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     1061      $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     1062      $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1063      my $nodes = "<select name=node>\n<option value=>--</option>\n";
     1064      while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1065        $nodes .= "<option value='$nid'>$nname</option>\n";
     1066      }
     1067      $nodes .= "</select>\n";
     1068      $html =~ s/\$\$NODE\$\$/$nodes/;
     1069    } else {
     1070      $html =~ s|\$\$NODE\$\$|N/A|;
     1071    }
     1072  }
     1073## end node hack
    10081074    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
    10091075    $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g;
     
    10121078    $html =~ s|\$\$NOTES\$\$|<textarea rows="8" cols="64" name="notes" class="regular">$data[6]</textarea>|g;
    10131079  } else {
     1080## node hack
     1081    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     1082      $sth = $ip_dbh->prepare("SELECT node_name FROM nodes INNER JOIN noderef".
     1083        " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'");
     1084      $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1085      my ($node) = $sth->fetchrow_array;
     1086      $html =~ s/\$\$NODE\$\$/$node/;
     1087    } else {
     1088      $html =~ s|\$\$NODE\$\$|N/A|;
     1089    }
     1090## end node hack
    10141091    $html =~ s/\$\$CUSTID\$\$/$data[1]/g;
    10151092    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
     
    11101187    $sth = $ip_dbh->prepare($sql);
    11111188    $sth->execute;
     1189## node hack
     1190    if ($webvar{node}) {
     1191      $ip_dbh->do("DELETE FROM noderef WHERE block='$webvar{block}'");
     1192      $sth = $ip_dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
     1193      $sth->execute($webvar{block},$webvar{node});
     1194    }
     1195## end node hack
    11121196    $ip_dbh->commit;
    11131197  };
  • trunk/cgi-bin/search.cgi

    r382 r397  
    187187    printError "No matches found.  Try eliminating one of the criteria,".
    188188        " or making one or more criteria more general.";
     189  } else {
     190    # Add the limit/offset clauses
     191    $sql .= " order by cidr";
     192    $sql .= " limit $RESULTS_PER_PAGE offset $offset" if $RESULTS_PER_PAGE != 0;
     193    # And tell the user.
     194    print "<div class=heading>Searching...............</div>\n";
     195    queryResults($sql, $webvar{page}, $count);
     196  }
     197
     198} elsif ($webvar{stype} eq 'n') {
     199  # Node search.
     200
     201  my $sql = "SELECT cidr,custid,type,city,description FROM searchme".
     202        " WHERE cidr IN (SELECT block FROM noderef WHERE node_id=$webvar{node})";
     203
     204  # Find the offset for multipage results
     205  my $offset = ($webvar{page}-1)*$RESULTS_PER_PAGE;
     206
     207  # Find out how many rows the "core" query will return.
     208  my $count = countRows($sql);
     209
     210  if ($count == 0) {
     211    printError "No customers currently listed as connected through this node.";
    189212  } else {
    190213    # Add the limit/offset clauses
  • trunk/confirm.html

    r345 r397  
    1010</tr><tr class="color1">
    1111<td>City:&nbsp;</td><td>&nbsp;$$CITY$$<input type="hidden" name="city" value="$$CITY$$"></td>
     12</tr><tr class="hack">
     13<td>Demarc switch/wifi tower:&nbsp;</td><td>&nbsp;$$NODENAME$$<input type="hidden" name="node" value="$$NODEID$$"></td>
    1214</tr><tr class="color2">
    1315<td>Allocation type:&nbsp;</td><td>&nbsp;$$TYPEFULL$$</td>
  • trunk/editDisplay.html

    r320 r397  
    1111
    1212<tr class="color1"><td class=heading>Type:</td><td class=regular>$$TYPESELECT$$</td></tr>
     13
     14<tr class="hack"><td class=heading>Demarc/tower:</td><td class=regular>$$NODE$$</td></tr>
    1315
    1416<tr class="color2"><td class=heading>CustID:</td><td class="regular">$$CUSTID$$</td></tr>
  • trunk/fb-assign.html

    r345 r397  
    1818</tr><tr class="color2">
    1919<td>Customer ID:&nbsp;</td><td><input type="text" name="custid" size="15" maxlength="15"> (Only required for Customer allocations)</td>
    20 </tr><tr class="color1">
     20</tr>
     21<tr class="hack"><td>Wifi tower/Fibre demarc</td><td>
     22<select name="node"><option selected>-</option>
     23$$NODELIST$$
     24</select>
     25&nbsp;<a href="javascript:popNotes('/ip/newnode.html')">Add new location</a>
     26</td></tr>
     27<tr class="color1">
    2128<td valign="top">Description/Name:&nbsp;</td><td><input name="desc" size=40></td>
    2229</tr><tr class="color2">
  • trunk/header.inc

    r380 r397  
    6060  </tr>
    6161</tbody></table>
    62 <table width="98%" border=0><tr><td align=right><a href="javascript:popNotes('/ip/changes.html')">Recent Changes</a></td></tr></table>
     62<table width="98%" border=0><tr><td align=right>
     63<a href="/ip/cgi-bin/main.cgi?action=nodesearch">Find by connection point</a>&nbsp; &nbsp;
     64<a href="javascript:popNotes('/ip/changes.html')">Recent Changes</a>
     65</td></tr></table>
    6366<br>
  • trunk/ipdb.css

    r371 r397  
    3333tr.color2 {
    3434        background-color: #A8C4D0;
     35        font-family: Verdana, Arial, Helvetica, sans-serif;
     36        font-size: 90%;
     37}
     38
     39tr.hack {
     40        background-color: #E4EEE8;
    3541        font-family: Verdana, Arial, Helvetica, sans-serif;
    3642        font-size: 90%;
Note: See TracChangeset for help on using the changeset viewer.