1 package FS::part_export::www_plesk;
3 use vars qw(@ISA %info);
7 @ISA = qw(FS::part_export);
9 tie my %options, 'Tie::IxHash',
10 'URL' => { label=>'URL' },
11 'login' => { label=>'Login' },
12 'password' => { label=>'Password' },
13 'debug' => { label=>'Enable debugging',
19 'desc' => 'Real-time export to Plesk managed hosting service',
20 'options'=> \%options,
23 <a href="http://www.swsoft.com/">Plesk</a> managed server.
24 Requires installation of
25 <a href="http://search.cpan.org/dist/Net-Plesk">Net::Plesk</a>
30 sub rebless { shift; }
32 # experiment: want the status of these right away (don't want account to
33 # create or whatever and then get error in the queue from dup username or
34 # something), so no queueing
37 my( $self, $www ) = ( shift, shift );
39 eval "use Net::Plesk;";
42 my $plesk = new Net::Plesk (
43 'POST' => $self->option('URL'),
44 ':HTTP_AUTH_LOGIN' => $self->option('login'),
45 ':HTTP_AUTH_PASSWD' => $self->option('password'),
48 my $gcresp = $plesk->client_get( $www->svc_acct->username );
49 return $gcresp->errortext
50 unless $gcresp->is_success;
52 unless ($gcresp->id) {
53 my $cust_main = $www->cust_svc->cust_pkg->cust_main;
54 $gcresp = $plesk->client_add( $cust_main->name,
55 $www->svc_acct->username,
56 $www->svc_acct->_password,
59 $cust_main->invoicing_list->[0],
60 $cust_main->address1 . $cust_main->address2,
66 return $gcresp->errortext
67 unless $gcresp->is_success;
70 $plesk->client_ippool_add_ip ( $gcresp->id,
71 $www->domain_record->recdata,
74 $self->_plesk_command( 'domain_add',
75 $www->domain_record->svc_domain->domain,
77 $www->domain_record->recdata,
82 my( $self, $method, @args ) = @_;
84 eval "use Net::Plesk;";
87 local($Net::Plesk::DEBUG) = 1
88 if $self->option('debug');
90 my $plesk = new Net::Plesk (
91 'POST' => $self->option('URL'),
92 ':HTTP_AUTH_LOGIN' => $self->option('login'),
93 ':HTTP_AUTH_PASSWD' => $self->option('password'),
96 my $response = $plesk->$method(@args);
97 return $response->errortext unless $response->is_success;
102 sub _export_replace {
103 my( $self, $new, $old ) = (shift, shift, shift);
105 return "can't change domain with Plesk"
106 if $old->domain_record->svc_domain->domain ne
107 $new->domain_record->svc_domain->domain;
109 return "can't change client with Plesk"
110 if $old->svc_acct->username ne
111 $new->svc_acct->username;
118 my( $self, $www ) = ( shift, shift );
119 $self->_plesk_command( 'domain_del', $www->domain_record->svc_domain->domain);