[freeside-commits] branch FREESIDE_2_3_BRANCH updated. c84159b64f322a6c32a9ec77e7e63beb4a5f6c19
Ivan
ivan at 420.am
Thu Oct 18 12:59:47 PDT 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via c84159b64f322a6c32a9ec77e7e63beb4a5f6c19 (commit)
from 6a181d2c63c16c16640576095d54381a343d6c32 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c84159b64f322a6c32a9ec77e7e63beb4a5f6c19
Author: Ivan Kohler <ivan at freeside.biz>
Date: Thu Oct 18 12:59:45 2012 -0700
add modification command to broadband_shellcommands export, RT#19897
diff --git a/FS/FS/part_export/broadband_shellcommands.pm b/FS/FS/part_export/broadband_shellcommands.pm
index c7f0fbb..c5fa5de 100644
--- a/FS/FS/part_export/broadband_shellcommands.pm
+++ b/FS/FS/part_export/broadband_shellcommands.pm
@@ -8,21 +8,26 @@ use FS::part_export;
@ISA = qw(FS::part_export);
tie my %options, 'Tie::IxHash',
- 'user' => { label=>'Remote username', default=>'freeside' },
- 'insert' => { label=>'Insert command',
- default=>'php provision.php --mac=$mac_addr --plan=$plan_id --account=active',
- },
- 'delete' => { label=>'Delete command',
- default=>'',
- },
- 'suspend' => { label=>'Suspension command',
- default=>'php provision.php --mac=$mac_addr --plan=$plan_id --account=suspend',
- },
- 'unsuspend'=> { label=>'Unsuspension command',
- default=>'',
- },
- 'uppercase_mac' => { label => 'Force MACs to uppercase',
- type => 'checkbox', }
+ 'user' => { label => 'Remote username',
+ default => 'freeside' },
+ 'insert' => { label => 'Insert command',
+ default => 'php provision.php --mac=$mac_addr --plan=$plan_id --account=active',
+ },
+ 'delete' => { label => 'Delete command',
+ default => '',
+ },
+ 'replace' => { label => 'Modification command',
+ default => '',
+ },
+ 'suspend' => { label => 'Suspension command',
+ default => 'php provision.php --mac=$mac_addr --plan=$plan_id --account=suspend',
+ },
+ 'unsuspend' => { label => 'Unsuspension command',
+ default => '',
+ },
+ 'uppercase_mac' => { label => 'Force MACs to uppercase',
+ type => 'checkbox',
+ }
;
%info = (
@@ -30,6 +35,10 @@ tie my %options, 'Tie::IxHash',
'desc' => 'Run remote commands via SSH, for svc_broadband services',
'options' => \%options,
'notes' => <<'END'
+Run remote commands via SSH, for broadband services.
+<BR><BR>
+All fields in svc_broadband are available for interpolation (prefixed with
+<code>new_</code> or <code>old_</code> for replace operations).
END
);
@@ -61,28 +70,49 @@ sub _export_command {
my $command = $self->option($action);
return '' if $command =~ /^\s*$/;
- #set variable for the command
+ #set variables for the command
no strict 'vars';
{
no strict 'refs';
${$_} = $svc_broadband->getfield($_) foreach $svc_broadband->fields;
}
- if ( $self->option('uppercase_mac') ) {
- $mac_addr = uc $mac_addr;
- }
+ $mac_addr = uc $mac_addr
+ if $self->option('uppercase_mac');
#done setting variables for the command
$self->shellcommands_queue( $svc_broadband->svcnum,
- user => $self->option('user')||'root',
- host => $self->machine,
- command => eval(qq("$command")),
+ user => $self->option('user')||'root',
+ host => $self->machine,
+ command => eval(qq("$command")),
);
}
sub _export_replace {
- '';
+ my($self, $new, $old ) = (shift, shift, shift);
+ my $command = $self->option('replace');
+
+ #set variable for the command
+ no strict 'vars';
+ {
+ no strict 'refs';
+ ${"old_$_"} = $old->getfield($_) foreach $old->fields;
+ ${"new_$_"} = $new->getfield($_) foreach $new->fields;
+ }
+
+ if ( $self->option('uppercase_mac') ) {
+ $old_mac_addr = uc $old_mac_addr;
+ $new_mac_addr = uc $new_mac_addr;
+ }
+
+ #done setting variables for the command
+
+ $self->shellcommands_queue( $new->svcnum,
+ user => $self->option('user')||'root',
+ host => $self->machine,
+ command => eval(qq("$command")),
+ );
}
#a good idea to queue anything that could fail or take any time
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_export/broadband_shellcommands.pm | 76 ++++++++++++++++++--------
1 files changed, 53 insertions(+), 23 deletions(-)
More information about the freeside-commits
mailing list