Changeset 598
- Timestamp:
- 05/16/13 16:43:45 (12 years ago)
- Location:
- branches/stable
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/IPDB.pm
r595 r598 396 396 397 397 # Snag the allocations for this block 398 my $sth = $dbh->prepare("SELECT cidr,city,type,custid,swip,description ".398 my $sth = $dbh->prepare("SELECT cidr,city,type,custid,swip,description,vrf". 399 399 " FROM allocations WHERE cidr <<= ? ORDER BY cidr"); 400 400 $sth->execute($routed); … … 405 405 406 406 my @blocklist; 407 while (my ($cidr,$city,$type,$custid,$swip,$desc) = $sth->fetchrow_array()) { 407 while (my ($cidr,$city,$type,$custid,$swip,$desc,$vrf) = $sth->fetchrow_array()) { 408 $desc .= " - vrf:$vrf" if $desc && $vrf; 409 $desc = "vrf:$vrf" if !$desc && $vrf; 408 410 $custsth->execute($custid); 409 411 my ($ncust) = $custsth->fetchrow_array(); … … 462 464 my $pool = shift; 463 465 464 my $sth = $dbh->prepare("SELECT ip,custid,available,description,type ".466 my $sth = $dbh->prepare("SELECT ip,custid,available,description,type,vrf". 465 467 " FROM poolips WHERE pool = ? ORDER BY ip"); 466 468 $sth->execute($pool); 467 469 my @poolips; 468 while (my ($ip,$custid,$available,$desc,$type) = $sth->fetchrow_array) { 470 while (my ($ip,$custid,$available,$desc,$type,$vrf) = $sth->fetchrow_array) { 471 $desc .= " - vrf:$vrf" if $desc && $vrf; 472 $desc = "vrf:$vrf" if !$desc && $vrf; 469 473 my %row = ( 470 474 ip => $ip, … … 673 677 # Returns a success code and optional error message. 674 678 sub allocateBlock { 675 my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$privdata,$nodeid ) = @_;679 my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$privdata,$nodeid,$vrf) = @_; 676 680 $privdata = '' if !defined($privdata); 681 $vrf = '' if !defined($vrf); 677 682 678 683 my $cidr = new NetAddr::IP $_[1]; … … 720 725 undef, ($alloc_from) ); 721 726 } 722 $dbh->do("UPDATE poolips SET custid=?,city=?,available='n',description=?,notes=?,circuitid=?,privdata=? ". 723 "WHERE ip=?", undef, ($custid, $city, $desc, $notes, $circid, $privdata, $cidr) ); 727 $dbh->do("UPDATE poolips SET custid=?,city=?,available='n',description=?,". 728 "notes=?,circuitid=?,privdata=?,vrf=? ". 729 "WHERE ip=?", undef, ($custid, $city, $desc, $notes, $circid, $privdata, $vrf, $cidr) ); 724 730 725 731 # node hack … … 771 777 } 772 778 $sth = $dbh->prepare("insert into allocations". 773 " (cidr,custid,type,city,description,notes,maskbits,circuitid,privdata )".774 " values (?,?,?,?,?,?,?,?,? )");775 $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata );779 " (cidr,custid,type,city,description,notes,maskbits,circuitid,privdata,vrf)". 780 " values (?,?,?,?,?,?,?,?,?,?)"); 781 $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata, $vrf); 776 782 777 783 # And initialize the pool, if necessary … … 884 890 # Insert the allocations entry 885 891 $sth = $dbh->prepare("insert into allocations (cidr,custid,type,city,". 886 "description,notes,maskbits,circuitid,privdata )".887 " values (?,?,?,?,?,?,?,?,? )");888 $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata );892 "description,notes,maskbits,circuitid,privdata,vrf)". 893 " values (?,?,?,?,?,?,?,?,?,?)"); 894 $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata, $vrf); 889 895 890 896 # And initialize the pool, if necessary … … 997 1003 my @fieldlist; 998 1004 my @vallist; 999 foreach ('custid', 'city', 'description', 'notes', 'circuitid', 'privdata' ) {1005 foreach ('custid', 'city', 'description', 'notes', 'circuitid', 'privdata', 'vrf') { 1000 1006 if ($args{$_}) { 1001 1007 push @fieldlist, $_; … … 1100 1106 $msg = "Unable to delete master block $cidr"; 1101 1107 eval { 1102 $sth = $dbh->prepare("delete from masterblocks where cidr= '$cidr'");1103 $sth->execute ;1104 $sth = $dbh->prepare("delete from freeblocks where cidr <<= '$cidr'");1105 $sth->execute ;1108 $sth = $dbh->prepare("delete from masterblocks where cidr=?"); 1109 $sth->execute($cidr); 1110 $sth = $dbh->prepare("delete from freeblocks where cidr <<= ?"); 1111 $sth->execute($cidr); 1106 1112 $dbh->commit; 1107 1113 }; … … 1264 1270 ## IPDB::getBlockData() 1265 1271 # Get CIDR or IP, custid, type, city, circuit ID, description, notes, modification time, private/restricted 1266 # data, for a CIDR block or pool IP1272 # data, and VRF tag, for a CIDR block or pool IP 1267 1273 # Also returns SWIP status flag for CIDR blocks 1268 1274 # Takes the block/IP to look up … … 1286 1292 } 1287 1293 my $binfo = $dbh->selectrow_hashref("SELECT $keycol AS block, custid, type, city, circuitid, description,". 1288 " notes, modifystamp AS lastmod, privdata ".($poolip ? '' : ', swip')." FROM $blocktable".1294 " notes, modifystamp AS lastmod, privdata, vrf".($poolip ? '' : ', swip')." FROM $blocktable". 1289 1295 " WHERE $keycol = ?", undef, ($block) ); 1290 1296 return $binfo; -
branches/stable/cgi-bin/ipdb.psql
r592 r598 33 33 ); 34 34 35 CREATE TABLE "temp" (36 "ofs" integer37 );38 39 35 CREATE TABLE "freeblocks" ( 40 36 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY, … … 57 53 "createstamp" timestamp DEFAULT now(), 58 54 "modifystamp" timestamp DEFAULT now(), 55 "vrf" character varying(128) DEFAULT '' NOT NULL, 59 56 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar))) 60 57 ); … … 73 70 "custid" character varying(16) DEFAULT '', 74 71 swip character(1) DEFAULT 'n' 72 "vrf" character varying(128) DEFAULT '' NOT NULL, 75 73 ); 76 74 77 CREATE VIEW "searchme" as SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, allocations.description, allocations.notes, allocations.circuitid FROM allocations UNION SELECT poolips.ip, poolips.custid, poolips.type, poolips.city, poolips.description, poolips.notes, poolips.circuitidFROM poolips;75 CREATE VIEW "searchme" as SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, allocations.description, allocations.notes, allocations.circuitid, allocations.vrf FROM allocations UNION SELECT poolips.ip, poolips.custid, poolips.type, poolips.city, poolips.description, poolips.notes, poolips.circuitid, poolips.vrf FROM poolips; 78 76 79 77 CREATE TABLE "alloctypes" ( … … 154 152 155 153 CREATE TABLE "users" ( 156 "username" varchar( 16) NOT NULL PRIMARY KEY,157 "password" varchar( 16) DEFAULT '',158 "acl" varchar( 16) DEFAULT 'b'154 "username" varchar(40) NOT NULL PRIMARY KEY, 155 "password" varchar(60) DEFAULT '', 156 "acl" varchar(30) DEFAULT 'b' 159 157 ); 160 158 161 159 -- Default password is admin 162 160 INSERT INTO users VALUES ('admin','luef5C4XumqIs','bacdsA'); 163 164 CREATE TABLE "dns" (165 "ip" inet NOT NULL PRIMARY KEY,166 "hostname" character varying(128),167 "auto" character(1) DEFAULT 'y'168 );169 161 170 162 -- Network nodes - allows finding customers affected by a broken <x> quickly -
branches/stable/cgi-bin/main.cgi
r596 r598 331 331 type => $ipinfo->{type}, 332 332 allocfrom => $pool, 333 vrf => $ipinfo->{vrf}, 333 334 ); 334 335 } elsif ($webvar{fbtype} eq 'n') { … … 477 478 $page->param(cidr => $cidr); 478 479 $page->param(city => $q->escapeHTML($webvar{city})); 480 $page->param(vrf => $webvar{vrf}); 479 481 $page->param(custid => $webvar{custid}); 480 482 $page->param(circid => $q->escapeHTML($webvar{circid})); … … 521 523 my ($code,$msg) = allocateBlock($ip_dbh, $webvar{fullcidr}, $webvar{alloc_from}, 522 524 $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes}, 523 $webvar{circid}, $webvar{privdata}, $webvar{node} );525 $webvar{circid}, $webvar{privdata}, $webvar{node}, $webvar{vrf}); 524 526 525 527 if ($code eq 'OK' || $code eq 'WARN') { … … 695 697 ## end node hack 696 698 699 $page->param(vrf => $blockinfo->{vrf}); 700 697 701 my ($lastmod,undef) = split /\s+/, $blockinfo->{lastmod}; 698 702 $page->param(lastmod => $lastmod); … … 735 739 type => $webvar{alloctype}, 736 740 swip => $webvar{swip}, 741 vrf => $webvar{vrf}, 737 742 ); 738 743 … … 784 789 $page->param(city => $webvar{city}); 785 790 $page->param(disptype => $disp_alloctypes{$webvar{alloctype}}); 791 $page->param(vrf => $webvar{vrf}); 786 792 $page->param(custid => $webvar{custid}); 787 793 $page->param(swip => $webvar{swip} eq 'on' ? 'Yes' : 'No'); … … 869 875 # need to retrieve block data before deleting so we can notify on that 870 876 my $blockinfo = getBlockData($ip_dbh, $webvar{block}); 877 # hack pthui. This goes away with the new structure, since routed 878 # and master blocks can be retrieved with getBlockData() 879 if ($webvar{alloctype} eq 'rm') { 880 $blockinfo = { custid => 'N/A', city => $webvar{city}, description => 'N/A' }; 881 } elsif ($webvar{alloctype} eq 'mm') { 882 $blockinfo = { custid => 'N/A', city => 'N/A', description => 'N/A' }; 883 } 871 884 872 885 my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{alloctype}); -
branches/stable/templates/assign.tmpl
r595 r598 92 92 </tr> 93 93 94 <tr class="<TMPL_VAR NAME=rowa>"><td>VRF instance</td><td><input name="vrf" size="40" value="<TMPL_VAR NAME=vrf>"></td></tr> 95 94 96 <TMPL_UNLESS allocfrom> 95 <tr class="<TMPL_VAR NAME=row a>">97 <tr class="<TMPL_VAR NAME=rowb>"> 96 98 <td>Limit to blocks in this location:</td> 97 99 <td> … … 104 106 </tr> 105 107 106 <tr class="<TMPL_VAR NAME=row b>">108 <tr class="<TMPL_VAR NAME=rowa>"> 107 109 <td>Limit to blocks in this master: </td> 108 110 <td> … … 116 118 </TMPL_UNLESS> 117 119 118 <tr class="<TMPL_VAR NAME=row a>">120 <tr class="<TMPL_VAR NAME=rowb>"> 119 121 <td>Circuit ID:</td> 120 122 <td><input name="circid" size="40"></td> 121 123 </tr> 122 124 123 <tr class="<TMPL_VAR NAME=row b>">125 <tr class="<TMPL_VAR NAME=rowa>"> 124 126 <td>Description/Name:</td> 125 127 <td><input name="desc" size="40"></td> 126 128 </tr> 127 129 128 <tr class="<TMPL_VAR NAME=row a>">130 <tr class="<TMPL_VAR NAME=rowb>"> 129 131 <td>Notes: </td> 130 132 <td><textarea name="notes" rows="3" cols="40"></textarea></td> … … 132 134 133 135 <TMPL_IF privdata> 134 <tr class="<TMPL_VAR NAME=row b>">136 <tr class="<TMPL_VAR NAME=rowa>"> 135 137 <td>Restricted data:</td> 136 138 <td><textarea rows="3" cols="64" name="privdata" class="regular"></textarea></td> … … 138 140 </TMPL_IF> 139 141 140 <tr class="<TMPL_IF privdata><TMPL_VAR NAME=row a><TMPL_ELSE><TMPL_VAR NAME=rowb></TMPL_IF>">142 <tr class="<TMPL_IF privdata><TMPL_VAR NAME=rowb><TMPL_ELSE><TMPL_VAR NAME=rowb></TMPL_IF>"> 141 143 <td class="center" colspan="2"><input type="submit" value=" Assign "></td> 142 144 </tr> -
branches/stable/templates/confirm.tmpl
r593 r598 42 42 43 43 <tr class="row0"> 44 <td>VRF instance: </td> 45 <td><TMPL_VAR NAME=vrf><input type="hidden" name="vrf" value="<TMPL_VAR NAME=vrf>"></td> 46 </tr> 47 48 <tr class="row1"> 44 49 <td>Allocation type:</td> 45 50 <td><TMPL_VAR NAME=typefull></td> 46 51 </tr> 47 52 48 <tr class="row 1">53 <tr class="row0"> 49 54 <td>Customer ID:</td> 50 55 <td><TMPL_VAR NAME=custid></td> 51 56 </tr> 52 57 53 <tr class="row 0">58 <tr class="row1"> 54 59 <td valign="top">Circuit ID:</td> 55 60 <td><TMPL_VAR NAME=circid></td> 56 61 </tr> 57 62 58 <tr class="row 1">63 <tr class="row0"> 59 64 <td valign="top">Description/name:</td> 60 65 <td><TMPL_VAR NAME=desc></td> 61 66 </tr> 62 67 63 <tr class="row 0">68 <tr class="row1"> 64 69 <td valign="top">Notes:</td> 65 70 <td><TMPL_VAR NAME=notes></td> … … 67 72 68 73 <TMPL_IF privdata> 69 <tr class="row 1">74 <tr class="row0"> 70 75 <td>Restricted data:</td> 71 76 <td><TMPL_VAR NAME=privdata></td> … … 74 79 75 80 <!-- warn --> 76 <tr class="<TMPL_IF privdata>row 0<TMPL_ELSE>row1</TMPL_IF>">81 <tr class="<TMPL_IF privdata>row1<TMPL_ELSE>row0</TMPL_IF>"> 77 82 <td class="center" colspan="2"> 78 83 <TMPL_UNLESS poollist><input type="hidden" name="alloc_from" value="<TMPL_VAR NAME=alloc_from>"></TMPL_UNLESS> -
branches/stable/templates/delete.tmpl
r594 r598 61 61 <input type="hidden" name="block" value="<TMPL_VAR NAME=block>"> 62 62 <input type="hidden" name="alloctype" value="<TMPL_VAR NAME=type>"> 63 <input type="hidden" name="city" value="<TMPL_VAR NAME=city>"> 63 64 <input type="hidden" name="action" value="finaldelete"> 64 65 </fieldset> -
branches/stable/templates/edit.tmpl
r594 r598 67 67 68 68 <tr class="row0"> 69 <td class=heading>VRF instance:</td> 70 <td class="regular"> 71 <TMPL_IF maychange> 72 <input type="text" name="vrf" value="<TMPL_VAR NAME=vrf>"> 73 <TMPL_ELSE> 74 <TMPL_VAR NAME=vrf> 75 </TMPL_IF> 76 </td> 77 </tr> 78 79 <tr class="row1"> 69 80 <td class=heading>CustID:</td> 70 81 <td class="regular"> … … 77 88 </tr> 78 89 79 <tr class="row 1">90 <tr class="row0"> 80 91 <td class=heading>SWIPed?:</td> 81 92 <td class=regular> … … 92 103 </tr> 93 104 94 <tr class="row 0">105 <tr class="row1"> 95 106 <td class=heading>Last modified:</td> 96 107 <td class=regular><TMPL_VAR NAME=lastmod></td> 97 108 </tr> 98 109 99 <tr class="row 1">110 <tr class="row0"> 100 111 <td class="heading">Circuit ID:</td> 101 112 <td class="regular"> … … 108 119 </tr> 109 120 110 <tr class="row 0">121 <tr class="row1"> 111 122 <td class="heading">Description/Name:</td> 112 123 <td class="regular"> … … 119 130 </tr> 120 131 121 <tr class="row 1">132 <tr class="row0"> 122 133 <td class="heading" valign="top">Notes:</td> 123 134 <td class="regular"> … … 130 141 131 142 <TMPL_IF nocling> 132 <tr class="row 0">143 <tr class="row1"> 133 144 <td class="heading" valign="top">Restricted data:</td> 134 145 <td class="regular"> … … 143 154 144 155 <TMPL_IF maychange> 145 <tr class="row<TMPL_IF nocling> 1<TMPL_ELSE>0</TMPL_IF>">156 <tr class="row<TMPL_IF nocling>0<TMPL_ELSE>1</TMPL_IF>"> 146 157 <td colspan="2" class="center"> 147 158 <input type="submit" value=" Update this block " class="regular"> … … 160 171 <form method="POST" action="main.cgi"> 161 172 <fieldset><legend class="noshow"> </legend> 162 <div class="row<TMPL_IF nocling><TMPL_IF maychange> 0<TMPL_ELSE>1</TMPL_IF><TMPL_ELSE><TMPL_IF maychange>1<TMPL_ELSE>0</TMPL_IF></TMPL_IF>">173 <div class="row<TMPL_IF nocling><TMPL_IF maychange>1<TMPL_ELSE>0</TMPL_IF><TMPL_ELSE><TMPL_IF maychange>0<TMPL_ELSE>1</TMPL_IF></TMPL_IF>"> 163 174 <input type="hidden" name="action" value="delete"> 164 175 <input type="hidden" name="block" value="<TMPL_VAR NAME=block>"> -
branches/stable/templates/update.tmpl
r594 r598 30 30 31 31 <tr class="row0"> 32 <td>VRF Instance:</td> 33 <td><TMPL_VAR NAME=vrf></td> 34 </tr> 35 36 <tr class="row1"> 32 37 <td>Customer ID:</td> 33 38 <td><TMPL_VAR NAME=custid></td> 34 39 </tr> 35 40 36 <tr class="row 1">41 <tr class="row0"> 37 42 <td>SWIPed?:</td> 38 43 <td><TMPL_VAR NAME=swip></td> 39 44 </tr> 40 45 41 <tr class="row 0">46 <tr class="row1"> 42 47 <td>Circuit ID:</td> 43 48 <td><TMPL_VAR ESCAPE=HTML NAME=circid></td> 44 49 </tr> 45 50 46 <tr class="row 1">51 <tr class="row0"> 47 52 <td valign="top">Description/Name:</td> 48 53 <td><TMPL_VAR ESCAPE=HTML NAME=desc></td> 49 54 </tr> 50 55 51 <tr class="row 0">56 <tr class="row1"> 52 57 <td valign="top">Notes:</td> 53 58 <td><TMPL_VAR NAME=notes></td> … … 55 60 56 61 <TMPL_IF privdata> 57 <tr class="row 1">62 <tr class="row0"> 58 63 <td valign="top">Restricted data:</td> 59 64 <td><TMPL_VAR NAME=privdata></td>
Note:
See TracChangeset
for help on using the changeset viewer.