[freeside-commits] freeside/FS/FS/part_export shellcommands.pm, 1.45, 1.46 shellcommands_withdomain.pm, 1.8, 1.9

Mark Wells mark at wavetail.420.am
Mon Jul 27 19:12:52 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail.420.am:/tmp/cvs-serv7089/part_export

Modified Files:
	shellcommands.pm shellcommands_withdomain.pm 
Log Message:
Add no_queue option to shellcommands exports

Index: shellcommands.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/shellcommands.pm,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- shellcommands.pm	1 Jul 2008 05:03:38 -0000	1.45
+++ shellcommands.pm	28 Jul 2009 02:12:50 -0000	1.46
@@ -65,6 +65,9 @@
                              'Radius group mapping to reason (via template user)',
 			    type  => 'textarea',
 			  },
+  'no_queue' => { label => 'Run command immediately',
+                   type  => 'checkbox',
+                },
 ;
 
 %info = (
@@ -367,12 +370,23 @@
 
   my $command_string = eval(qq("$command"));
 
-  $self->shellcommands_queue( $new->svcnum,
-    user         => $self->option('user')||'root',
-    host         => $self->machine,
-    command      => $command_string,
-    stdin_string => $stdin_string,
+  my @ssh_cmd_args = (
+    user          => $self->option('user') || 'root',
+    host          => $self->machine,
+    command       => $command_string,
+    stdin_string  => $stdin_string,
   );
+
+  if($self->options('no_queue')) {
+    # discard return value just like freeside-queued.
+    eval { ssh_cmd(@ssh_cmd_args) };
+    $error = $@;
+    return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')'
+      if $error;
+  }
+  else {
+    $self->shellcommands_queue( $new->svcnum, @ssh_cmd_args );
+  }
 }
 
 #a good idea to queue anything that could fail or take any time

Index: shellcommands_withdomain.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/shellcommands_withdomain.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- shellcommands_withdomain.pm	21 Nov 2005 14:26:01 -0000	1.8
+++ shellcommands_withdomain.pm	28 Jul 2009 02:12:50 -0000	1.9
@@ -51,6 +51,9 @@
                type=>'select', options=>[qw(crypt md5)],
                default => 'crypt',
              },
+  'no_queue' => { label => 'Run command immediately',
+                 type  => 'checkbox',
+           },
 ;
 
 %info = (



More information about the freeside-commits mailing list