Changeset 394


Ignore:
Timestamp:
Feb 19, 2010, 1:10:34 PM (13 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Basic support for network node references: Add, view, edit nodes and

referencess

Probably excludes a bunch of real use-cases for various reasons

Location:
branches/stable
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/assign.html

    r286 r394  
    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>
  • branches/stable/cgi-bin/IPDB.pm

    r387 r394  
    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
  • branches/stable/cgi-bin/ipdb.psql

    r377 r394  
    212212);
    213213
     214-- Network nodes - allows finding customers affected by a broken <x> quickly
     215CREATE TABLE noderef (
     216    block inet NOT NULL PRIMARY KEY,
     217    node_id integer
     218);
     219
     220CREATE TABLE nodes (
     221    node_id serial NOT NULL PRIMARY KEY,
     222    node_type character varying(2),
     223    node_name character varying(40),
     224    node_ip inet
     225);
  • branches/stable/cgi-bin/main.cgi

    r390 r394  
    614614  }
    615615  $html =~ s|\$\$ALLCITIES\$\$|$cities|g;
     616
     617## node hack
     618  $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     619  $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     620  my $nodes = '';
     621  while (my ($nid,$nname) = $sth->fetchrow_array()) {
     622    $nodes .= "<option value='$nid'>$nname</option>\n";
     623  }
     624  $html =~ s/\$\$NODELIST\$\$/$nodes/;
     625## end node hack
    616626
    617627  my $i = 0;
     
    780790  close HTML;
    781791
     792## node hack
     793  if ($webvar{node} && $webvar{node} ne '-') {
     794    $sth = $ip_dbh->prepare("SELECT node_name FROM nodes WHERE node_id=?");
     795    $sth->execute($webvar{node});
     796    my ($nodename) = $sth->fetchrow_array();
     797    $html =~ s/\$\$NODENAME\$\$/$nodename/;
     798    $html =~ s/\$\$NODEID\$\$/$webvar{node}/;
     799  } else {
     800    $html =~ s/\$\$NODENAME\$\$//;
     801    $html =~ s/\$\$NODEID\$\$//;
     802  }
     803## end node hack
     804
    782805### gotta fix this in final
    783806  # Stick in customer info as necessary - if it's blank, it just ends
     
    849872  my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from},
    850873        $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
    851         $webvar{circid}, $webvar{privdata});
     874        $webvar{circid}, $webvar{privdata}, $webvar{node});
    852875
    853876  if ($code eq 'OK') {
     
    10311054      $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g;
    10321055    }
     1056## node hack
     1057  $sth = $ip_dbh->prepare("SELECT node_id FROM noderef WHERE block='$webvar{block}'");
     1058  $sth->execute;
     1059  my ($nodeid) = $sth->fetchrow_array();
     1060  if ($nodeid) {
     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";
     1064    while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1065      $nodes .= "<option".($nodeid == $nid ? ' selected' : '')." value='$nid'>$nname</option>\n";
     1066    }
     1067    $nodes .= "</select>\n";
     1068    $html =~ s/\$\$NODE\$\$/$nodes/;
     1069  } else {
     1070    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     1071      $sth = $ip_dbh->prepare("SELECT node_id, node_name FROM nodes ORDER BY node_type,node_id");
     1072      $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1073      my $nodes = "<select name=node>\n<option value=>--</option>\n";
     1074      while (my ($nid,$nname) = $sth->fetchrow_array()) {
     1075        $nodes .= "<option value='$nid'>$nname</option>\n";
     1076      }
     1077      $nodes .= "</select>\n";
     1078      $html =~ s/\$\$NODE\$\$/$nodes/;
     1079    } else {
     1080      $html =~ s|\$\$NODE\$\$|N/A|;
     1081    }
     1082  }
     1083## end node hack
    10331084    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
    10341085    $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g;
     
    10371088    $html =~ s|\$\$NOTES\$\$|<textarea rows="8" cols="64" name="notes" class="regular">$data[6]</textarea>|g;
    10381089  } else {
     1090## node hack
     1091    if ($data[2] eq 'fr' || $data[2] eq 'bi') {
     1092      $sth = $ip_dbh->prepare("SELECT node_name FROM nodes INNER JOIN noderef".
     1093        " ON nodes.node_id=noderef.node_id WHERE noderef.block='$webvar{block}'");
     1094      $sth->execute() or print "DEBUG: failed retrieval from nodes: ".$sth->errstr,"<br>\n";
     1095      my ($node) = $sth->fetchrow_array;
     1096      $html =~ s/\$\$NODE\$\$/$node/;
     1097    } else {
     1098      $html =~ s|\$\$NODE\$\$|N/A|;
     1099    }
     1100## end node hack
    10391101    $html =~ s/\$\$CUSTID\$\$/$data[1]/g;
    10401102    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
     
    11351197    $sth = $ip_dbh->prepare($sql);
    11361198    $sth->execute;
     1199## node hack
     1200    if ($webvar{node}) {
     1201      $ip_dbh->do("DELETE FROM noderef WHERE block='$webvar{block}'");
     1202      $sth = $ip_dbh->prepare("INSERT INTO noderef (block,node_id) VALUES (?,?)");
     1203      $sth->execute($webvar{block},$webvar{node});
     1204    }
     1205## end node hack
    11371206    $ip_dbh->commit;
    11381207  };
  • branches/stable/confirm.html

    r286 r394  
    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>
  • branches/stable/editDisplay.html

    r318 r394  
    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>
  • branches/stable/fb-assign.html

    r286 r394  
    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">
  • branches/stable/ipdb.css

    r360 r394  
    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.