Changeset 691 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
02/06/15 17:42:26 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Expose VRF field, and add a similar VLAN field (see #10).

File:
1 edited

Legend:

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

    r687 r691  
    345345    $page->param(cached => $cached);
    346346
     347    my $pinfo = getBlockData($ip_dbh, $webvar{parent});
     348    # seems reasonable that a new allocation would share a VRF with its parent
     349    $page->param(pvrf => $pinfo->{vrf});
     350
    347351    $webvar{fbtype} = '' if !$webvar{fbtype};
    348352    if ($webvar{fbtype} eq 'i') {
    349353      my $ipinfo = getBlockData($ip_dbh, $webvar{block}, 'i');
    350       my $pinfo = getBlockData($ip_dbh, $webvar{parent});
    351354      $page->param(
    352355        fbip => 1,
     
    529532  $page->param(cidr => $cidr);
    530533  $page->param(rdns => $webvar{rdns});
     534  $page->param(vrf => $webvar{vrf});
     535  $page->param(vlan => $webvar{vlan});
    531536  $page->param(city => $q->escapeHTML($webvar{city}));
    532537  $page->param(custid => $webvar{custid});
     
    583588  }
    584589
    585   my ($code,$msg) = allocateBlock($ip_dbh, cidr => $webvar{fullcidr}, fbid => $webvar{fbid},
    586         parent => $webvar{parent}, custid => $webvar{custid}, type => $webvar{alloctype}, city => $webvar{city},
    587         desc => $webvar{desc}, notes => $webvar{notes}, circid => $webvar{circid},
    588         privdata => $webvar{privdata}, nodeid => $webvar{node}, rdns => $webvar{rdns}, user => $authuser,
    589         iprev => \%iprev);
     590  # Easier to see and cosmetically fiddle the list like this
     591  my %insert_args = (
     592        cidr            => $webvar{fullcidr},
     593        fbid            => $webvar{fbid},
     594        parent          => $webvar{parent},
     595        custid          => $webvar{custid},
     596        type            => $webvar{alloctype},
     597        city            => $webvar{city},
     598        desc            => $webvar{desc},
     599        notes           => $webvar{notes},
     600        circid          => $webvar{circid},
     601        privdata        => $webvar{privdata},
     602        nodeid          => $webvar{node},
     603        rdns            => $webvar{rdns},
     604        vrf             => $webvar{vrf},
     605        vlan            => $webvar{vlan},
     606        user            => $authuser,
     607        );
     608
     609  my ($code,$msg) = allocateBlock($ip_dbh, %insert_args, iprev => \%iprev);
    590610
    591611  if ($code eq 'OK') {
     
    705725}
    706726
     727  # VRF.  Not a full validity check, just a basic sanity check.
     728  if ($webvar{vrf}) {
     729    # Trim leading and trailing whitespace first
     730    $webvar{vrf} =~ s/^\s+//;
     731    $webvar{vrf} =~ s/\s+$//;
     732    if ($webvar{vrf} !~ /^[\w\d_.-]{1,32}$/) {
     733      $page->param(err => "VRF values may only contain alphanumerics, and may not be more than 32 characters");
     734      return;
     735    }
     736  }
     737
     738  # VLAN.  Should we allow/use VLAN names, or just the numeric ID?
     739  if ($webvar{vlan}) {
     740    # Trim leading and trailing whitespace first
     741    $webvar{vlan} =~ s/^\s+//;
     742    $webvar{vlan} =~ s/\s+$//;
     743    # ...  ve make it ze configurable thingy!
     744    if ($IPDB::numeric_vlan) {
     745      if ($webvar{vlan} !~ /^\d+$/) {
     746        $page->param(err => "VLANs must be numeric");
     747        return;
     748      }
     749    } else {
     750      if ($webvar{vlan} !~ /^[\w\d_.-]+$/) {
     751        $page->param(err => "VLANs must be alphanumeric");
     752        return;
     753      }
     754    }
     755  }
     756
    707757  return 'OK';
    708758} # end validateInput
     
    716766  # snag block info from db
    717767  my $blockinfo = getBlockData($ip_dbh, $webvar{id}, $webvar{basetype});
    718   $page->param(id => $webvar{id});
     768  $page->param(id       => $webvar{id});
    719769  $page->param(basetype => $webvar{basetype});
    720770
     
    726776  ($blockinfo->{rdns},$cached) = getBlockRDNS($ip_dbh, id => $webvar{id}, type => $blockinfo->{type}, user => $authuser);
    727777  # visual flag that we're working IPDB-local, not off more authoritative data in dnsadmin
    728   $page->param(cached => $cached);
     778  $page->param(cached   => $cached);
    729779
    730780  my $cidr = new NetAddr::IP $blockinfo->{block};
     
    743793  }
    744794
    745   $page->param(block    => $blockinfo->{block});
    746   $page->param(rdns     => $blockinfo->{rdns});
    747 
    748   $page->param(custid   => $blockinfo->{custid});
    749   $page->param(city     => $blockinfo->{city});
    750   $page->param(circid   => $blockinfo->{circuitid});
    751   $page->param(desc     => $blockinfo->{description});
    752   $page->param(notes    => $blockinfo->{notes});
     795  # consider extending this to show time as well as date
     796  my ($lastmod,undef) = split /\s+/, $blockinfo->{lastmod};
     797  $page->param(lastmod  => $lastmod);
     798#  $page->param(lastmod  => $blockinfo->{lastmod});
     799
     800  $page->param(block    => $blockinfo->{block});
     801  $page->param(city     => $blockinfo->{city});
     802  $page->param(custid   => $blockinfo->{custid});
    753803
    754804##fixme The check here should be built from the database
     
    789839## end node hack
    790840
    791   my ($lastmod,undef) = split /\s+/, $blockinfo->{lastmod};
    792   $page->param(lastmod => $lastmod);
     841  $page->param(rdns     => $blockinfo->{rdns});
     842  $page->param(vrf      => $blockinfo->{vrf});
     843  $page->param(vlan     => $blockinfo->{vlan});
    793844
    794845  # not happy with the upside-down logic, but...
    795846  $page->param(swipable => $blockinfo->{type} !~ /.i/);
    796   $page->param(swip => $blockinfo->{swip} ne 'n') if $blockinfo->{swip};
     847  $page->param(swip     => $blockinfo->{swip} ne 'n') if $blockinfo->{swip};
     848
     849  $page->param(circid   => $blockinfo->{circuitid});
     850  $page->param(desc     => $blockinfo->{description});
     851  $page->param(notes    => $blockinfo->{notes});
    797852
    798853  # Check to see if we can display sensitive data
    799   $page->param(nocling => $IPDBacl{$authuser} =~ /s/);
     854  $page->param(nocling  => $IPDBacl{$authuser} =~ /s/);
    800855  $page->param(privdata => $blockinfo->{privdata});
    801856
     
    830885        swip            => $webvar{swip},
    831886        rdns            => $webvar{rdns},
     887        vrf             => $webvar{vrf},
     888        vlan            => $webvar{vlan},
    832889        user            => $authuser,
    833890        );
Note: See TracChangeset for help on using the changeset viewer.