From 351c9f0e23d1b66d7b62b72afa31e14575722ba0 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Wed, 30 Dec 2015 18:51:09 -0800 Subject: [PATCH] add option for exports to avoid suspending services, #20739 --- FS/FS/Schema.pm | 2 ++ FS/FS/part_export.pm | 7 +++++++ FS/FS/svc_Common.pm | 3 +++ httemplate/browse/part_export.cgi | 5 +++++ httemplate/edit/part_export.cgi | 5 +++++ 5 files changed, 22 insertions(+) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 4d931b4d2..c855b1fba 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -3059,6 +3059,8 @@ sub tables_hashref { 'exporttype', 'varchar', '', $char_d, '', '', 'nodomain', 'char', 'NULL', 1, '', '', 'default_machine','int', 'NULL', '', '', '', + 'no_suspend', 'char', 'NULL', 1, '', '', + # could also have 'no_insert', 'no_replace', etc. ], 'primary_key' => 'exportnum', 'unique' => [], diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index bdbecff97..803325f12 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -59,6 +59,12 @@ fields are currently supported: =item nodomain - blank or "Y" : usernames are exported to this service with no domain +=item default_machine - For exports that require a machine to be selected for +each service (see L), the one to use as the default. + +=item no_suspend - Don't export service suspensions. In the future there may +be "no_*" options for the other service actions. + =back =head1 METHODS @@ -334,6 +340,7 @@ sub check { || $self->ut_textn('exportname') || $self->ut_domainn('machine') || $self->ut_alpha('exporttype') + || $self->ut_flag('no_suspend') ; if ( $self->machine eq '_SVC_MACHINE' ) { diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm index faae79d0a..dea31ea85 100644 --- a/FS/FS/svc_Common.pm +++ b/FS/FS/svc_Common.pm @@ -1163,7 +1163,9 @@ Runs the provided export hook (i.e. "suspend", "unsuspend") for this service. sub export { my( $self, $method ) = ( shift, shift ); + # $method must start with export_, $action must be the part after that $method = "export_$method" unless $method =~ /^export_/; + my ($action) = $method =~ /^export_(\w+)/; local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -1180,6 +1182,7 @@ sub export { unless ( $noexport_hack ) { foreach my $part_export ( $self->cust_svc->part_svc->part_export ) { next unless $part_export->can($method); + next if $part_export->get("no_$action"); # currently only 'no_suspend' my $error = $part_export->$method($self, @_); if ( $error ) { $dbh->rollback if $oldAutoCommit; diff --git a/httemplate/browse/part_export.cgi b/httemplate/browse/part_export.cgi index af988d37b..bbb723dbf 100755 --- a/httemplate/browse/part_export.cgi +++ b/httemplate/browse/part_export.cgi @@ -38,6 +38,11 @@ function part_export_areyousure(href) { <% $part_export->label_html %> (edit | delete) +% if ( $part_export->no_suspend ) { +

+ This export will not suspend services. +

+% } % if ( my @actions = $part_export->actions ) {

Management: diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi index 382093116..5411feb5f 100644 --- a/httemplate/edit/part_export.cgi +++ b/httemplate/edit/part_export.cgi @@ -285,6 +285,11 @@ my $widget = new HTML::Widgets::SelectLayers( $html .= ''; } + $html .= 'Do not suspend services' . + 'no_suspend eq 'Y'; + $html .= '>'; + $html .= ''; # false laziness with config_element above -- 2.11.0