X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Faddr_block.pm;h=be42cb50b3204d562faef37c549644aa9d32cee7;hp=5815f1abd5e9c7eeab9e79662defc7c0ea41bb07;hb=395cc72629d31c8dcd138acf423e66d2d73d89d2;hpb=a1871d3d13c1dafa93b956762c0d23728d261da7 diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm index 5815f1abd..be42cb50b 100755 --- a/FS/FS/addr_block.pm +++ b/FS/FS/addr_block.pm @@ -48,6 +48,8 @@ block is assigned. =item ip_netmask - the netmask of the block, expressed as an integer. +=item manual_flag - prohibit automatic ip assignment from this block when true. + =item agentnum - optional agent number (see L) =back @@ -74,14 +76,35 @@ otherwise returns false. Deletes this record from the database. If there is an error, returns the error, otherwise returns false. +=cut + sub delete { my $self = shift; - return 'Block must be deallocated before deletion' - if $self->router; - - $self->SUPER::delete; + return 'Block must be deallocated and have no services before deletion' + if $self->router || $self->svc_broadband; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + my $error = $self->SUPER::delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; } + =item replace OLD_RECORD Replaces OLD_RECORD with this one in the database. If there is an error, @@ -124,7 +147,8 @@ sub check { $self->ut_number('routernum') || $self->ut_ip('ip_gateway') || $self->ut_number('ip_netmask') - || $self->ut_agentnum_acl('agentnum', 'Engineering global configuration') + || $self->ut_enum('manual_flag', [ '', 'Y' ]) + || $self->ut_agentnum_acl('agentnum', 'Broadband global configuration') ; return $error if $error; @@ -202,13 +226,16 @@ sub cidr { Returns a NetAddr::IP object corresponding to the first unassigned address in the block (other than the network, broadcast, or gateway address). If -there are no free addresses, returns false. +there are no free addresses, returns false. There are never free addresses +when manual_flag is true. =cut sub next_free_addr { my $self = shift; + return '' if $self->manual_flag; + my $conf = new FS::Conf; my @excludeaddr = $conf->config('exclude_ip_addr');