X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fispconfig3.pm;h=9d22d1995c32691b9a74c092c810ae304e238c3c;hb=ffa18709ee8a4d05e18d2d406cf73afe79e52524;hp=2878c51f23676e000f6487ba98c0f6f95d7d5932;hpb=a472d8ff6bf5c87d7181c4a3f1757bae487a6ddf;p=freeside.git diff --git a/FS/FS/part_export/ispconfig3.pm b/FS/FS/part_export/ispconfig3.pm index 2878c51f2..9d22d1995 100644 --- a/FS/FS/part_export/ispconfig3.pm +++ b/FS/FS/part_export/ispconfig3.pm @@ -6,6 +6,7 @@ use base qw( FS::part_export ); use Data::Dumper; use SOAP::Lite; +use IO::Socket::SSL; =pod @@ -141,21 +142,22 @@ sub _mail_user_params { sub _export_insert { my ($self, $svc_acct) = @_; + return $self->api_error || 'Error logging in' + unless $self->api_login; my $params = $self->_mail_user_params($svc_acct); - $self->api_login; my $remoteid = $self->api_call('mail_user_add',$self->option('client_id'),$params); return $self->api_error_logout if $self->api_error; my $error = $self->set_remoteid($svc_acct,$remoteid); $error = "Remote system updated, but error setting remoteid ($remoteid): $error" if $error; $self->api_logout; - $error ||= "Systems updated, but error logging out: ".$self->api_error - if $self->api_error; return $error; } sub _export_replace { my ($self, $svc_acct, $svc_acct_old) = @_; + return $self->api_error || 'Error logging in' + unless $self->api_login; my $remoteid = $self->get_remoteid($svc_acct_old); return "Could not load remoteid for old service" unless $remoteid; my $params = $self->_mail_user_params($svc_acct); @@ -170,23 +172,32 @@ sub _export_replace { if $error; } $self->api_logout; - $error ||= "Systems updated, but error logging out: ".$self->api_error - if $self->api_error; return $error; } sub _export_delete { my ($self, $svc_acct) = @_; + return $self->api_error || 'Error logging in' + unless $self->api_login; my $remoteid = $self->get_remoteid($svc_acct); - return "Could not load remoteid for old service" unless $remoteid; + #don't abort deletion-- + # might have been provisioned before export was implemented, + # still need to be able to delete from freeside + unless ($remoteid) { + warn "Could not load remoteid for svcnum ".$svc_acct->svcnum.", unprovisioning anyway"; + return ''; + } #API docs claim "Returns the number of deleted records" my $success = $self->api_call('mail_user_delete',$remoteid); return $self->api_error_logout if $self->api_error; - my $error = $success ? '' : "Server returned no records deleted"; + #don't abort deletion-- + # if it's already been deleted remotely, + # still need to be able to delete from freeside + warn "Server returned no records deleted for svcnum ".$svc_acct->svcnum. + " remoteid $remoteid, unprovisioning anyway" + unless $success; $self->api_logout; - $error ||= "Systems updated, but error logging out: ".$self->api_error - if $self->api_error; - return $error; + return ''; } sub _export_suspend { @@ -219,7 +230,6 @@ automatically. Must run L first. sub api_call { my ($self,$method,@params) = @_; - $self->{'__ispconfig_response'} = undef; # This does get used by api_login, # to retrieve the session id after it sets the client, # so we only check for existence of client, @@ -244,7 +254,6 @@ sub api_call { $self->{'__ispconfig_error'} = $response->fault ? "Error from server: " . $response->faultstring : ''; - $self->{'__ispconfig_response'} = $response; return $response->result; } @@ -291,7 +300,12 @@ sub api_login { } $self->{'__ispconfig_session'} = undef; $self->{'__ispconfig_client'} = - SOAP::Lite->proxy($self->option('soap_location'), ssl_opts => [ verify_hostname => 0 ] ) + SOAP::Lite->proxy( $self->option('soap_location'), + ssl_opts => [ + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + ] + ) || undef; unless ($self->{'__ispconfig_client'}) { $self->{'__ispconfig_error'} = 'Error creating SOAP client';