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 'template' => { label=>'Domain Template' },
14 'web' => { label=>'Host Website',
16 'debug' => { label=>'Enable debugging',
22 'desc' => 'Real-time export to Plesk managed hosting service',
23 'options' => \%options,
27 <a href="http://www.swsoft.com/">Plesk</a> managed server.
28 Requires installation of
29 <a href="http://search.cpan.org/dist/Net-Plesk">Net::Plesk</a>
30 from CPAN and proper <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.7:Documentation:Administration:www_plesk.pm">configuration</a>.
34 sub rebless { shift; }
36 # experiment: want the status of these right away (don't want account to
37 # create or whatever and then get error in the queue from dup username or
38 # something), so no queueing
41 my( $self, $www ) = ( shift, shift );
43 eval "use Net::Plesk;";
46 my $plesk = new Net::Plesk (
47 'POST' => $self->option('URL'),
48 ':HTTP_AUTH_LOGIN' => $self->option('login'),
49 ':HTTP_AUTH_PASSWD' => $self->option('password'),
52 my $gcresp = $plesk->client_get( $www->svc_acct->username );
53 return $gcresp->errortext
54 unless $gcresp->is_success;
56 unless ($gcresp->id) {
57 my $cust_main = $www->cust_svc->cust_pkg->cust_main;
58 $gcresp = $plesk->client_add( $cust_main->name,
59 $www->svc_acct->username,
60 $www->svc_acct->_password,
63 $cust_main->invoicing_list->[0],
64 $cust_main->address1 . $cust_main->address2,
70 return $gcresp->errortext
71 unless $gcresp->is_success;
74 $plesk->client_ippool_add_ip ( $gcresp->id,
75 $www->domain_record->recdata,
78 if ($self->option('web')) {
79 $self->_plesk_command( 'domain_add',
80 $www->domain_record->svc_domain->domain,
82 $www->domain_record->recdata,
83 $self->option('template')?$self->option('template'):'',
84 $www->svc_acct->username,
85 $www->svc_acct->_password,
88 $self->_plesk_command( 'domain_add',
89 $www->domain_record->svc_domain->domain,
91 $www->domain_record->recdata,
92 $self->option('template')?$self->option('template'):'',
98 my( $self, $method, @args ) = @_;
100 eval "use Net::Plesk;";
103 local($Net::Plesk::DEBUG) = 1
104 if $self->option('debug');
106 my $plesk = new Net::Plesk (
107 'POST' => $self->option('URL'),
108 ':HTTP_AUTH_LOGIN' => $self->option('login'),
109 ':HTTP_AUTH_PASSWD' => $self->option('password'),
112 my $response = $plesk->$method(@args);
113 return $response->errortext unless $response->is_success;
118 sub _export_replace {
119 my( $self, $new, $old ) = (shift, shift, shift);
121 return "can't change domain with Plesk"
122 if $old->domain_record->svc_domain->domain ne
123 $new->domain_record->svc_domain->domain;
125 return "can't change client with Plesk"
126 if $old->svc_acct->username ne
127 $new->svc_acct->username;
134 my( $self, $www ) = ( shift, shift );
135 $self->_plesk_command( 'domain_del', $www->domain_record->svc_domain->domain);