Changeset 642 for trunk


Ignore:
Timestamp:
10/17/14 16:55:34 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Commit really old work in admin.cgi adding rDNS

  • allocate block
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/admin.cgi

    r641 r642  
    140140
    141141  my $maskbits = $cidr->masklen;
    142   my $fbtmp = findAllocateFrom($ip_dbh, $maskbits, $webvar{alloctype}, '','',
     142  my ($fbid, $fb, $fbparent);
     143  ($fbid, $fb, $fbparent) = findAllocateFrom($ip_dbh, $maskbits, $webvar{alloctype}, '','',
    143144        (gimme => "$cidr", allowpriv => 1));
    144 
    145   if ($webvar{alloctype} eq 'rm') {
    146     if (!$fbtmp) {
     145  $page->param(fbid => $fbid);
     146  $page->param(parid => $fbparent);
     147  my $rdns = getBlockRDNS($ip_dbh, id => $fbparent, type => ($webvar{alloctype} =~ /^.i$/ ? 'i' : 'b'),
     148        user => $authuser);
     149  $page->param(rdns => $rdns);
     150  if ($webvar{alloctype} =~ /^(.)i$/) {
     151    my $iptype = $1;
     152    my $ptmp = getBlockData($ip_dbh, $fbparent);
     153    if ($ptmp->{type} =~ /^(.)[dp]$/) {
     154      my $newiptype = "$1i";
     155      if ($ptmp->{type} !~ /^$iptype./) {
     156        $page->param(warnmsg => "Warning:  Allocating IP as '".$disp_alloctypes{$newiptype}."' instead of '".
     157                $disp_alloctypes{$webvar{alloctype}}."' to match pool ".$ptmp->{block}."\n");
     158        $webvar{alloctype} = $newiptype;
     159      }
     160    }
     161    if (!$fbid) {
     162      $page->param(errmsg => "Can't allocate static IP from outside a pool!!");
     163      goto ERRJUMP;
     164    }
     165  } else {
     166    if (!$fbid) {
    147167      $page->param(errmsg => "Can't allocate from outside a free block!!");
    148168      goto ERRJUMP;
    149169    }
    150   } elsif ($webvar{alloctype} =~ /^(.)i$/) {
    151     my $iptype = $1;
    152     my $ptmp = ipParent($ip_dbh, "$cidr");
    153     if ($ptmp->{type} =~ /^(.)[dp]$/) {
    154       my $newiptype = "$1i";
    155       $fbtmp = $ptmp->{cidr};
    156       if ($ptmp->{type} !~ /^$iptype./) {
    157         $page->param(warnmsg => "Warning:  Allocating IP as '".$disp_alloctypes{$newiptype}."' instead of '".
    158                 $disp_alloctypes{$webvar{alloctype}}."' to match pool $fbtmp\n");
    159         $webvar{alloctype} = $newiptype;
    160       }
    161     }
    162     if (!$fbtmp) {
    163       $page->param(errmsg => "Can't allocate static IP from outside a pool!!");
    164       goto ERRJUMP;
    165     }
    166   } else {
    167     if (!$fbtmp) {
    168       $page->param(errmsg => "Can't allocate from outside a routed block!!");
    169       goto ERRJUMP;
    170     }
    171   }
    172 
    173   my $alloc_from = new NetAddr::IP $fbtmp;
     170  }
     171
     172  my $alloc_from = new NetAddr::IP $fb;
    174173
    175174  my @cities;
     
    201200  }
    202201
    203   my ($retcode,$msg) = allocateBlock($ip_dbh, $webvar{cidr}, $webvar{alloc_from},
    204         $webvar{custid}, $webvar{alloctype}, $webvar{city}, $webvar{desc}, $webvar{notes},
    205         $webvar{circid});
     202  my ($retcode,$msg) = allocateBlock($ip_dbh, cidr => $webvar{cidr}, fbid => $webvar{fbid},
     203        parent => $webvar{parent}, custid => $webvar{custid}, type => $webvar{alloctype}, city => $webvar{city},
     204        desc => $webvar{desc}, notes => $webvar{notes}, circid => $webvar{circid},
     205        privdata => $webvar{privdata}, nodeid => $webvar{node}, rdns => $webvar{rdns}, user => $authuser);
     206
    206207  if ($retcode eq 'OK') {
    207208    syslog "notice", "$authuser allocated '$webvar{cidr}' to '$webvar{custid}' as ".
  • trunk/templates/admin/alloc.tmpl

    r544 r642  
    55<form method="POST" action="admin.cgi">
    66<fieldset><legend class="noshow">&nbsp;</legend>
     7<input type="hidden" name="parent" value="<TMPL_VAR NAME=parid>">
     8<input type="hidden" name="fbid" value="<TMPL_VAR NAME=fbid>">
    79<table class="regular">
    810<tr class="row0">
     
    1921</tr>
    2022<tr class="row1">
     23<td>Reverse DNS pattern:</td>
     24<td><input type="text" name="rdns" value="<TMPL_VAR NAME=rdns>" size="40"><input type="button" value=" ? " onclick="helpRDNS()" class="regular"></td>
     25</tr>
     26<tr class="row0">
    2127<td>Customer ID:</td>
    2228<td><TMPL_VAR NAME=custid><input type="hidden" name="custid" value="<TMPL_VAR NAME=custid>"></td>
    2329</tr>
    24 <tr class="row0">
     30<tr class="row1">
    2531<td>Customer location:</td>
    2632<td>
     
    3137</td>
    3238</tr>
    33 <tr class="row1">
     39<tr class="row0">
    3440<td>Circuit ID:</td><td><input name="circid" size="40"></td>
    3541</tr>
    36 <tr class="row0">
     42<tr class="row1">
    3743<td>Description/Name:</td><td><input name="desc" size="40"></td>
    3844</tr>
    39 <tr class="row1">
     45<tr class="row0">
    4046<td>Notes:</td><td><textarea name="notes" rows="3" cols="40"></textarea></td>
    4147</tr>
     
    4349<td class="center" colspan="2">WARNING:  This will IMMEDIATELY assign this block!!</td>
    4450</tr>
    45 <tr class="row1">
     51<tr class="row0">
    4652<td class="center" colspan="2"><input type="submit" value="  Assign  "></td>
    4753</tr>
Note: See TracChangeset for help on using the changeset viewer.