use FS::part_svc;
use FS::part_export_option;
use FS::part_export_machine;
+use FS::svc_export_machine;
use FS::export_svc;
#for export modules, though they should probably just use it themselves
$self;
}
+=item svc_machine
+
+=cut
+
+sub svc_machine {
+ my( $self, $svc_x ) = @_;
+
+ return $self->machine unless $self->machine eq '_SVC_MACHINE';
+
+ my $svc_export_machine = qsearchs('svc_export_machine', {
+ 'svcnum' => $svc_x->svcnum,
+ 'exportnum' => $self->exportnum,
+ })
+ #would only happen if you add this export to existing services without a
+ #machine set then try to run exports without setting it... right?
+ or die "No hostname selected for ".($self->exportname || $self->exporttype);
+
+ return $svc_export_machine->part_export_machine->machine;
+}
+
#these should probably all go away, just let the subclasses define em
=item export_insert SVC_OBJECT
%info = (
'svc' => 'svc_acct',
- 'desc' =>
- 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
+ 'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
'options' => \%options,
'nodomain' => 'Y',
'svc_machine' => 1,
my @ssh_cmd_args = (
user => $self->option('user') || 'root',
- host => $self->machine,
+ host => $self->svc_machine($svc_acct),
command => $command_string,
stdin_string => $stdin_string,
ignored_errors => $self->option('ignored_errors') || '',
eval { ssh_cmd(@ssh_cmd_args) };
$error = $@;
$error = $error->full_message if ref $error; # Exception::Class::Base
- return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')'
+ return $error. ' ('. $self->exporttype. ' to '. $self->svc_machine($svc_acct). ')'
if $error;
}
else {
# $error ||= "can't change RADIUS groups";
#}
}
- return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')'
+ return $error. ' ('. $self->exporttype. ' to '. $self->svc_machine($new). ')'
if $error;
$new_agent_custid = $new_cust_main ? $new_cust_main->agent_custid : '';
my @ssh_cmd_args = (
user => $self->option('user') || 'root',
- host => $self->machine,
+ host => $self->svc_machine($new),
command => $command_string,
stdin_string => $stdin_string,
ignored_errors => $self->option('ignored_errors') || '',
eval { ssh_cmd(@ssh_cmd_args) };
$error = $@;
$error = $error->full_message if ref $error; # Exception::Class::Base
- return $error. ' ('. $self->exporttype. ' to '. $self->machine. ')'
+ return $error. ' ('. $self->exporttype. ' to '. $self->svc_machine($new). ')'
if $error;
}
else {
;
%info = (
- 'svc' => 'svc_acct',
- 'desc' => 'Real-time export via remote SSH (vpopmail, ISPMan)',
- 'options' => \%options,
- 'notes' => <<'END'
+ 'svc' => 'svc_acct',
+ 'desc' => 'Real-time export via remote SSH (vpopmail, ISPMan, MagicMail)',
+ 'options' => \%options,
+ 'svc_machine' => 1,
+ 'notes' => <<'END'
Run remote commands via SSH. username@domain (rather than just usernames) are
considered unique (also see shellcommands). You probably want this if the
commands you are running will accept a domain as a parameter, and will allow