This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / part_export / cardfortress.pm
1 package FS::part_export::cardfortress;
2
3 use strict;
4 use base 'FS::part_export';
5 use vars qw( %info );
6 use String::ShellQuote;
7
8 #tie my %options, 'Tie::IxHash';
9 #;
10
11 %info = (
12   'svc'      => 'svc_acct',
13   'desc'     => 'CardFortress',
14   'options'  => {}, #\%options,
15   'nodomain' => 'Y',
16   'notes'    => '',
17 );
18
19 sub rebless { shift; }
20
21 sub _export_insert {
22   my($self, $svc_acct) = (shift, shift);
23
24   eval "use Net::OpenSSH;";
25   return $@ if $@;
26
27   open my $def_in, '<', '/dev/null' or die "unable to open /dev/null";
28   my $ssh = Net::OpenSSH->new( $self->machine,
29                                default_stdin_fh => $def_in );
30
31   my $private_key = $ssh->capture(
32     { 'stdin_data' => $svc_acct->_password. "\n" },
33     '/usr/local/bin/merchant_create', map $svc_acct->$_, qw( username finger )
34   );
35   return $ssh->error if $ssh->error;
36
37   $svc_acct->cf_privatekey($private_key);
38
39   $svc_acct->replace;
40
41 }
42
43 sub _export_replace {
44   my( $self, $new, $old ) = (shift, shift, shift);
45
46   return 'username changes not yet supported'
47     if $old->username ne $new->username;
48
49   return 'password changes not yet supported'
50     if $old->_password ne $new->_password;
51
52   return 'Real name changes not yet supported'
53     if $old->finger ne $new->finger;
54
55   '';
56 }
57
58 sub _export_delete {
59   #my( $self, $svc_x ) = (shift, shift);
60
61   return 'deletion not yet supproted';
62 }
63
64 1;