Changeset 923 for trunk/cgi-bin


Ignore:
Timestamp:
06/18/19 18:15:33 (5 years ago)
Author:
Kris Deugau
Message:

/trunk

Refine selection handling in static IP section of allocateBlock().

  • properly accept an IP ID or IP
  • properly accept either the pool ID (parent) or VRF to uniquely identify the pool
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r920 r923  
    16221622##fixme:  IP pools across VRFs, need to use the IP ID instead of the CIDR
    16231623# ...  or the VRF itself?
    1624       if ($args{cidr}) {        # IP specified
    1625         my ($isavail) = $dbh->selectrow_array(
    1626           "SELECT available FROM poolips WHERE ip=?".($args{vrf} ? " AND vrf=?" : ''),
    1627           undef, ($args{vrf} ? ($args{cidr},$args{vrf}) : $args{cidr}) );
     1624      if ($args{cidr}) {
     1625        # IP specified
     1626        my $availsql = "SELECT available FROM poolips WHERE ";
     1627        my @availargs;
     1628        if ($args{cidr} =~ /^\d+$/) {
     1629          # IP passed as ID
     1630          $availsql .= "id = ?";
     1631          push @availargs, $args{cidr};
     1632        } else {
     1633          # IP passed as IP address
     1634          $availsql .= "ip = ?";
     1635          push @availargs, $args{cidr};
     1636        }
     1637        if ($args{parent}) {
     1638          # Limit by parent ID
     1639          $availsql .= " AND parent_id = ?";
     1640          push @availargs, $args{parent};
     1641        } elsif ($args{vfr}) {
     1642          # Limit by VRF, but only if the parent ID isn't available
     1643          $availsql .= " AND vrf = ?";
     1644          push @availargs, $args{vrf};
     1645        } else {
     1646          # Fail if we don't have a handle for the pool
     1647          die "Missing parent ID or VRF.\n";
     1648        }
     1649        my ($isavail) = $dbh->selectrow_array($availsql, undef, @availargs);
    16281650        die "IP is not in an IP pool.\n"
    16291651          if !$isavail;
Note: See TracChangeset for help on using the changeset viewer.