1 package FS::part_export::www_plesk;
3 use vars qw(@ISA %info);
7 use Net::Plesk::Response;
9 @ISA = qw(FS::part_export);
11 tie my %options, 'Tie::IxHash',
12 'URL' => { label=>'URL' },
13 'login' => { label=>'Login' },
14 'password' => { label=>'Password' },
15 'debug' => { label=>'Enable debugging',
21 'desc' => 'Real-time export to Plesk managed hosting service',
22 'options'=> \%options,
25 <a href="http://www.swsoft.com/">Plesk</a> managed server.
26 Requires installation of
27 <a href="http://search.cpan.org/dist/Net-Plesk">Net::Plesk</a>
32 sub rebless { shift; }
34 # experiment: want the status of these right away (don't want account to
35 # create or whatever and then get error in the queue from dup username or
36 # something), so no queueing
39 my( $self, $www ) = ( shift, shift );
41 my $plesk = new Net::Plesk (
42 'POST' => $self->option('URL'),
43 ':HTTP_AUTH_LOGIN' => $self->option('login'),
44 ':HTTP_AUTH_PASSWD' => $self->option('password'),
47 my $gcresp = $plesk->client_get( $www->svc_acct->username );
48 return $gcresp->errortext
49 unless $gcresp->is_success;
51 unless ($gcresp->id) {
52 my $cust_main = $www->cust_svc->cust_pkg->cust_main;
53 $gcresp = $plesk->client_add( $cust_main->name,
54 $www->svc_acct->username,
55 $www->svc_acct->_password,
58 $cust_main->invoicing_list->[0],
59 $cust_main->address1 . $cust_main->address2,
65 return $gcresp->errortext
66 unless $gcresp->is_success;
69 $plesk->client_ippool_add_ip ( $gcresp->id,
70 $www->domain_record->recdata,
73 $self->_plesk_command( 'domain_add',
74 $www->domain_record->svc_domain->domain,
76 $www->domain_record->recdata,
81 my( $self, $method, @args ) = @_;
83 local($Net::Plesk::DEBUG) = 1
84 if $self->option('debug');
86 my $plesk = new Net::Plesk (
87 'POST' => $self->option('URL'),
88 ':HTTP_AUTH_LOGIN' => $self->option('login'),
89 ':HTTP_AUTH_PASSWD' => $self->option('password'),
92 my $response = $plesk->$method(@args);
93 return $response->errortext unless $response->is_success;
99 my( $self, $new, $old ) = (shift, shift, shift);
101 return "can't change domain with Plesk"
102 if $old->domain_record->svc_domain->domain ne
103 $new->domain_record->svc_domain->domain;
105 return "can't change client with Plesk"
106 if $old->svc_acct->username ne
107 $new->svc_acct->username;
114 my( $self, $www ) = ( shift, shift );
115 $self->_plesk_command( 'domain_del', $www->domain_record->svc_domain->domain);