X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fsqlradius.pm;h=926e36fdb9c4d3ef9dec40d25e07faa83a16337f;hb=9427fea032c131bc2c000515853d4f1462b7deff;hp=048a244853355d2bb7b40a409438b23b98632563;hpb=9aee669886202be7035e6c6049fc71bc99dd3013;p=freeside.git diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm index 048a24485..926e36fdb 100644 --- a/FS/FS/part_export/sqlradius.pm +++ b/FS/FS/part_export/sqlradius.pm @@ -8,7 +8,7 @@ use FS::Record qw( dbh qsearch qsearchs str2time_sql str2time_sql_closing ); use FS::part_export; use FS::svc_acct; use FS::export_svc; -use Carp qw( cluck ); +use Carp qw( carp cluck ); use NEXT; use Net::OpenSSH; @@ -26,6 +26,10 @@ tie %options, 'Tie::IxHash', type => 'select', options => [qw( usergroup radusergroup ) ], }, + 'skip_provisioning' => { + type => 'checkbox', + label => 'Skip provisioning records to this database' + }, 'ignore_accounting' => { type => 'checkbox', label => 'Ignore accounting records from this database' @@ -80,10 +84,6 @@ tie %options, 'Tie::IxHash', 'disconnect_port' => { label => 'Port to send disconnection requests to, default 1700', }, - 'disconnect_ignore_error' => { - label => 'Ignore disconnection request errors', - type => 'checkbox', - }, ; $notes1 = <<'END'; @@ -158,6 +158,8 @@ sub radius_check { #override for other svcdb sub _export_insert { my($self, $svc_x) = (shift, shift); + return '' if $self->option('skip_provisioning'); + foreach my $table (qw(reply check)) { my $method = "radius_$table"; my %attrib = $self->$method($svc_x); @@ -183,6 +185,8 @@ sub _export_insert { sub _export_replace { my( $self, $new, $old ) = (shift, shift, shift); + return '' if $self->option('skip_provisioning'); + local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -270,7 +274,6 @@ sub _export_replace { 'disconnect_ssh' => $self->option('disconnect_ssh'), 'svc_acct_username' => $old->username, 'disconnect_port' => $self->option('disconnect_port'), - 'ignore_error' => $self->option('disconnect_ignore_error'), ); unless ( ref($err_or_queue) ) { $dbh->rollback if $oldAutoCommit; @@ -294,6 +297,8 @@ sub _export_replace { sub _export_suspend { my( $self, $svc_acct ) = (shift, shift); + return '' if $self->option('skip_provisioning'); + my $new = $svc_acct->clone_suspended; local $SIG{HUP} = 'IGNORE'; @@ -365,6 +370,8 @@ sub _export_suspend { sub _export_unsuspend { my( $self, $svc_x ) = (shift, shift); + return '' if $self->option('skip_provisioning'); + local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -404,6 +411,8 @@ sub _export_unsuspend { sub _export_delete { my( $self, $svc_x ) = (shift, shift); + return '' if $self->option('skip_provisioning'); + my $jobnum = ''; my $usergroup = $self->option('usergroup') || 'usergroup'; @@ -418,7 +427,6 @@ sub _export_delete { 'disconnect_ssh' => $self->option('disconnect_ssh'), 'svc_acct_username' => $svc_x->username, 'disconnect_port' => $self->option('disconnect_port'), - 'ignore_error' => $self->option('disconnect_ignore_error'), ); return $err_or_queue unless ref($err_or_queue); if ( $jobnum ) { @@ -481,6 +489,12 @@ sub suspended_usergroups { } sub sqlradius_insert { #subroutine, not method + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_insert() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my( $table, $username, %attributes ) = @_; @@ -519,6 +533,12 @@ sub sqlradius_insert { #subroutine, not method } sub sqlradius_usergroup_insert { #subroutine, not method + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_usergroup_insert() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my $username = shift; my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup'; @@ -557,6 +577,12 @@ sub sqlradius_usergroup_insert { #subroutine, not method } sub sqlradius_usergroup_delete { #subroutine, not method + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_usergroup_delete() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my $username = shift; my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup'; @@ -574,6 +600,12 @@ sub sqlradius_usergroup_delete { #subroutine, not method } sub sqlradius_rename { #subroutine, not method + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_rename() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my($new_username, $old_username) = (shift, shift); my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup'; @@ -587,6 +619,12 @@ sub sqlradius_rename { #subroutine, not method } sub sqlradius_attrib_delete { #subroutine, not method + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_attrib_delete() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my( $table, $username, @attrib ) = @_; @@ -601,6 +639,12 @@ sub sqlradius_attrib_delete { #subroutine, not method } sub sqlradius_delete { #subroutine, not method + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_delete() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my $username = shift; my $usergroup = ( $_[0] =~ /^(rad)?usergroup/i ) ? shift : 'usergroup'; @@ -875,6 +919,12 @@ sub usage_sessions { sub update_svc { my $self = shift; + if ( $FS::svc_Common::noexport_hack ) { + carp 'update_svc() suppressed by noexport_hack' + if $self->option('debug') || $DEBUG; + return; + } + my $conf = new FS::Conf; my $fdbh = dbh; @@ -1040,6 +1090,13 @@ sub export_nas_replace { shift->export_nas_action('replace', @_); } sub export_nas_action { my $self = shift; my ($action, $new, $old) = @_; + + if ( $FS::svc_Common::noexport_hack ) { + carp "export_nas_action($action) suppressed by noexport_hack" + if $self->option('debug') || $DEBUG; + return; + } + # find the NAS in the target table by its name my $nasname = ($action eq 'replace') ? $old->nasname : $new->nasname; my $nasnum = $new->nasnum; @@ -1053,6 +1110,12 @@ sub export_nas_action { } sub sqlradius_nas_insert { + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_nas_insert() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my %opt = @_; my $nas = qsearchs('nas', { nasnum => $opt{'nasnum'} }) @@ -1067,6 +1130,12 @@ VALUES (?, ?, ?, ?, ?, ?, ?)'); } sub sqlradius_nas_delete { + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_nas_delete() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my %opt = @_; my $sth = $dbh->prepare('DELETE FROM nas WHERE nasname = ?'); @@ -1074,6 +1143,12 @@ sub sqlradius_nas_delete { } sub sqlradius_nas_replace { + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_nas_replace() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my %opt = @_; my $nas = qsearchs('nas', { nasnum => $opt{'nasnum'} }) @@ -1149,6 +1224,12 @@ sub export_attr_action { } sub sqlradius_attr_insert { + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_attr_insert() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my %opt = @_; @@ -1172,6 +1253,12 @@ sub sqlradius_attr_insert { } sub sqlradius_attr_delete { + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_attr_delete() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my %opt = @_; @@ -1223,6 +1310,12 @@ sub export_group_replace { } sub sqlradius_group_replace { + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_group_replace() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my $usergroup = shift; $usergroup =~ /^(rad)?usergroup$/ @@ -1258,13 +1351,17 @@ I - the user to be disconnected (required) I - the port (on the nas) to send disconnect requests to (defaults to 1700) -I - do not die on error with the disconnect request - Note this is NOT the opposite of sqlradius_connect. =cut sub sqlradius_user_disconnect { + + if ( $FS::svc_Common::noexport_hack ) { + carp 'sqlradius_user_disconnect() suppressed by noexport_hack' if $DEBUG; + return; + } + my $dbh = sqlradius_connect(shift, shift, shift); my %opt = @_; # get list of nas @@ -1294,7 +1391,7 @@ sub sqlradius_user_disconnect { if $error && (@$nas > 1); $error = "No clients found" unless @$nas; - die $error if $error && !$opt{'ignore_error'}; + die $error if $error; return ''; }