Changeset 837
- Timestamp:
- 04/11/16 17:52:49 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/ipdb-rpc.cgi
r668 r837 4 4 # $Id$ 5 5 ### 6 # Copyright (C) 2013 Kris Deugau <kdeugau@deepnet.cx>6 # Copyright (C) 2013,2014,2016 Kris Deugau <kdeugau@deepnet.cx> 7 7 8 8 use strict; … … 148 148 my $argref = shift; 149 149 150 die "Block/IP is required\n" if !$argref->{block}; 150 if (!$argref->{block}) { 151 $argref->{block} = $argref->{cidr} if $argref->{cidr}; 152 die "Block/IP is required\n" if !$argref->{block}; 153 } 151 154 152 155 # Alloctype check. 153 chomp $argref->{ alloctype};154 155 die "Invalid allocation type\n" if (!grep /$argref->{ alloctype}/, keys %disp_alloctypes);156 chomp $argref->{type}; 157 158 die "Invalid allocation type\n" if (!grep /$argref->{type}/, keys %disp_alloctypes); 156 159 157 160 # Arguably not quite correct, as the custID won't be checked for 158 161 # validity if there's a default on the type. 159 if ($def_custids{$argref->{ alloctype}} eq '') {162 if ($def_custids{$argref->{type}} eq '') { 160 163 # Types without a default custID must have one passed in 161 164 die "Customer ID is required\n" if !$argref->{custid}; … … 167 170 # Types that have a default will use it unless one is specified. 168 171 if ((!$argref->{custid}) || ($argref->{custid} ne 'STAFF')) { 169 $argref->{custid} = $def_custids{$argref->{ alloctype}};172 $argref->{custid} = $def_custids{$argref->{type}}; 170 173 } 171 174 } … … 214 217 # Not required for update, delete 215 218 die "City is required\n" if !$args{city}; 216 die "Block/pool to allocate from is required\n" if !$args{alloc_from}; 217 218 # Desc, notes, circid, privdata, node, and vrf are all optional and handled in allocateBlock() 219 my ($code,$msg) = allocateBlock($ip_dbh, $args{block}, $args{alloc_from}, 220 $args{custid}, $args{alloctype}, $args{city}, $args{desc}, $args{notes}, 221 $args{circid}, $args{privdata}, $args{node}, $args{vrf}); 219 die "Customer ID is required\n" if !$args{custid}; 220 die "Allocation type is required\n" if !$args{type}; 221 222 if ($args{type} =~ /^.i$/) { 223 die "Pool ID or VRF to allocate from is required\n" if !$args{parent} && !$args{vrf}; 224 } else { 225 die "Free block to allocate from is required\n" if !$args{fbid}; 226 } 227 228 my ($code,$msg) = allocateBlock($ip_dbh, %args); 222 229 223 230 if ($code eq 'OK' || $code eq 'WARN') { 224 if ($args{ alloctype} =~ /^.i$/) {231 if ($args{type} =~ /^.i$/) { 225 232 $msg =~ s|/32||; 226 mailNotify($ip_dbh, "a$args{ alloctype}", "ADDED: $disp_alloctypes{$args{alloctype}} allocation",227 "$disp_alloctypes{$args{ alloctype}} $msg allocated to customer $args{custid}\n".233 mailNotify($ip_dbh, "a$args{type}", "ADDED: $disp_alloctypes{$args{type}} allocation", 234 "$disp_alloctypes{$args{type}} $msg allocated to customer $args{custid}\n". 228 235 "Description: $args{desc}\n\nAllocated by: $args{rpcsystem}/$args{rpcuser}\n"); 229 236 } else { 230 237 my $netblock = new NetAddr::IP $args{block}; 231 mailNotify($ip_dbh, "a$args{ alloctype}", "ADDED: $disp_alloctypes{$args{alloctype}} allocation",232 "$disp_alloctypes{$args{ alloctype}} $args{block} allocated to customer $args{custid}\n".238 mailNotify($ip_dbh, "a$args{type}", "ADDED: $disp_alloctypes{$args{type}} allocation", 239 "$disp_alloctypes{$args{type}} $args{block} allocated to customer $args{custid}\n". 233 240 "Description: $args{desc}\n\nAllocated by: $args{rpcsystem}/$args{rpcuser}\n"); 234 241 } 235 242 syslog "notice", "$args{rpcsystem}/$args{rpcuser} allocated '$args{block}' to '$args{custid}' as ". 236 "'$args{ alloctype}' ($msg)";243 "'$args{type}' ($msg)"; 237 244 } else { 238 245 syslog "err", "Allocation of '$args{block}' to '$args{custid}' as ". 239 "'$args{ alloctype}' by $args{rpcsystem}/$args{rpcuser} failed: '$msg'";246 "'$args{type}' by $args{rpcsystem}/$args{rpcuser} failed: '$msg'"; 240 247 die "$msg\n"; 241 248 }
Note:
See TracChangeset
for help on using the changeset viewer.