1 package FS::part_export::communigate_pro;
4 use vars qw(@ISA %info %options %quotas $DEBUG);
10 @ISA = qw(FS::part_export);
14 tie %options, 'Tie::IxHash',
15 'port' => { label =>'Port number', default=>'106', },
16 'login' => { label =>'The administrator account name. The name can contain a domain part.', },
17 'password' => { label =>'The administrator account password.', },
18 'accountType' => { label => 'Type for newly-created accounts (default when not specified in service)',
20 options => [qw(MultiMailbox TextMailbox MailDirMailbox AGrade BGrade CGrade)],
21 default => 'MultiMailbox',
23 'externalFlag' => { label => 'Create accounts with an external (visible for legacy mailers) INBOX.',
26 'AccessModes' => { label => 'Access modes (default when not specified in service)',
27 default => 'Mail POP IMAP PWD WebMail WebSite',
29 'create_domain' => { label => 'Domain creation API call',
31 options => [qw( CreateDomain CreateSharedDomain )],
36 'svc' => [qw( svc_acct svc_domain svc_forward svc_mailinglist )],
37 'desc' => 'Real-time export of accounts, domains, mail forwards and mailing lists to a CommuniGate Pro mail server',
38 'options' => \%options,
40 Real time export of accounts, domains, mail forwards and mailing lists to a
41 <a href="http://www.stalker.com/CommuniGatePro/">CommuniGate Pro</a>
43 <a href="http://www.stalker.com/CGPerl/">CommuniGate Pro Perl Interface</a>
44 must be installed as CGP::CLI.
49 'quota' => 'MaxAccountSize',
50 'file_quota' => 'MaxWebSize',
51 'file_maxnum' => 'MaxWebFiles',
52 'file_maxsize' => 'MaxFileSize',
55 sub rebless { shift; }
58 my($self, $svc_acct) = (shift, shift);
63 my( $self, $svc_x ) = (shift, shift);
65 my $table = $svc_x->table;
66 my $method = "_export_insert_$table";
67 $self->$method($svc_x, @_);
70 sub _export_insert_svc_acct {
71 my( $self, $svc_acct ) = (shift, shift);
74 'AccessModes' => [ split(' ', ( $svc_acct->cgp_accessmodes
75 || $self->option('AccessModes') )
78 'RealName' => $svc_acct->finger,
79 'Password' => $svc_acct->_password,
80 map { $quotas{$_} => $svc_acct->$_() }
81 grep $svc_acct->$_(), keys %quotas
83 #phase 2: pwdallowed, passwordrecovery, allowed mail rules,
84 # RPOP modifications, accepts mail to all, add trailer to sent mail
85 #phase 3: archive messages, mailing lists
87 my @options = ( 'CreateAccount',
88 'accountName' => $self->export_username($svc_acct),
89 'accountType' => ( $svc_acct->cgp_type
90 || $self->option('accountType') ),
91 'settings' => \%settings
94 push @options, 'externalFlag' => $self->option('externalFlag')
95 if $self->option('externalFlag');
97 #let's do the create realtime too, for much the same reasons, and to avoid
98 #pain of trying to queue w/dep the prefs & aliases
99 eval { $self->communigate_pro_runcommand( @options ) };
104 $prefs{'DeleteMode'} = $svc_acct->cgp_deletemode if $svc_acct->cgp_deletemode;
105 $prefs{'EmptyTrash'} = $svc_acct->cgp_emptytrash if $svc_acct->cgp_emptytrash;
106 #phase 2: language, time zone, layout, pronto style, send read receipts
108 my $pref_err = $self->communigate_pro_queue( $svc_acct->svcnum,
109 'UpdateAccountPrefs',
110 $self->export_username($svc_acct),
113 warn "WARNING: error queueing UpdateAccountPrefs job: $pref_err"
118 if ( $svc_acct->cgp_aliases ) {
119 my $alias_err = $self->communigate_pro_queue( $svc_acct->svcnum,
121 $self->export_username($svc_acct),
122 [ split(/\s*[,\s]\s*/, $svc_acct->cgp_aliases) ],
124 warn "WARNING: error queueing SetAccountAliases job: $alias_err"
132 sub _export_insert_svc_domain {
133 my( $self, $svc_domain ) = (shift, shift);
135 my $create = $self->option('create_domain') || 'CreateDomain';
138 'DomainAccessModes' => [ split(' ', $svc_domain->cgp_accessmodes ) ],
140 $settings{'AccountsLimit'} = $svc_domain->max_accounts
141 if $svc_domain->max_accounts;
142 $settings{'AdminDomainName'} = $svc_domain->parent_svc_x->domain
143 if $svc_domain->parent_svcnum;
145 my @options = ( $create, $svc_domain->domain, \%settings );
147 eval { $self->communigate_pro_runcommand( @options ) };
151 if ( $svc_domain->cgp_aliases ) {
152 my $alias_err = $self->communigate_pro_queue( $svc_domain->svcnum,
155 split(/\s*[,\s]\s*/, $svc_domain->cgp_aliases),
157 warn "WARNING: error queueing SetDomainAliases job: $alias_err"
162 my $def_err = $self->communigate_pro_queue( $svc_domain->svcnum,
163 'SetAccountDefaults',
165 'PWDAllowed' =>($svc_domain->acct_def_password_selfchange ? 'YES':'NO'),
166 'PasswordRecovery' => ($svc_domain->acct_def_password_recover ? 'YES':'NO'),
167 'AccessModes' => $svc_domain->acct_def_cgp_accessmodes,
168 'MaxAccountSize' => $svc_domain->acct_def_quota,
169 'MaxWebSize' => $svc_domain->acct_def_file_quota,
170 'MaxWebFile' => $svc_domain->acct_def_file_maxnum,
171 'MaxFileSize' => $svc_domain->acct_def_file_maxsize,
173 warn "WARNING: error queueing SetAccountDefaults job: $def_err"
176 #account defaults prefs
177 my $pref_err = $self->communigate_pro_queue( $svc_domain->svcnum,
178 'SetAccountDefaultPrefs',
180 'DeleteMode' => $svc_domain->acct_def_cgp_deletemode,
181 'EmptyTrash' => $svc_domain->acct_def_cgp_emptytrash,
183 warn "WARNING: error queueing SetAccountDefaultPrefs job: $pref_err"
190 sub _export_insert_svc_forward {
191 my( $self, $svc_forward ) = (shift, shift);
193 my $src = $svc_forward->src || $svc_forward->srcsvc_acct->email;
194 my $dst = $svc_forward->dst || $svc_forward->dstsvc_acct->email;
196 #real-time here, presuming CGP does some dup detection?
197 eval { $self->communigate_pro_runcommand( 'CreateForwarder', $src, $dst); };
203 sub _export_insert_svc_mailinglist {
204 my( $self, $svc_mlist ) = (shift, shift);
206 my @members = map $_->email_address,
207 $svc_mlist->mailinglist->mailinglistmember;
209 #real-time here, presuming CGP does some dup detection
210 eval { $self->communigate_pro_runcommand(
212 $svc_mlist->username.'@'.$svc_mlist->domain,
213 { 'RealName' => $svc_mlist->listname,
214 'SetReplyTo' => ( $svc_mlist->reply_to ? 'YES' : 'NO' ),
215 'RemoveAuthor' => ( $svc_mlist->remove_from ? 'YES' : 'NO' ),
216 'RejectAuto' => ( $svc_mlist->reject_auto ? 'YES' : 'NO' ),
217 'RemoveToAndCc' => ( $svc_mlist->remove_to_and_cc ? 'YES' : 'NO' ),
218 'Members' => \@members,
228 sub _export_replace {
229 my( $self, $new, $old ) = (shift, shift, shift);
231 my $table = $new->table;
232 my $method = "_export_replace_$table";
233 $self->$method($new, $old, @_);
236 sub _export_replace_svc_acct {
237 my( $self, $new, $old ) = (shift, shift, shift);
239 #let's just do the rename part realtime rather than trying to queue
240 #w/dependencies. we don't want FS winding up out-of-sync with the wrong
241 #username and a queued job anyway. right??
242 if ( $self->export_username($old) ne $self->export_username($new) ) {
243 eval { $self->communigate_pro_runcommand(
245 $self->export_username($old),
246 $self->export_username($new),
251 if ( $new->_password ne $old->_password
252 && '*SUSPENDED* '.$old->_password ne $new->_password
254 $self->communigate_pro_queue( $new->svcnum, 'SetAccountPassword',
255 $self->export_username($new), $new->_password
261 $settings{'RealName'} = $new->finger
262 if $old->finger ne $new->finger;
263 $settings{$quotas{$_}} = $new->$_()
264 foreach grep $old->$_() ne $new->$_(), keys %quotas;
265 $settings{'accountType'} = $new->cgp_type
266 if $old->cgp_type ne $new->cgp_type;
267 $settings{'AccessModes'} = $new->cgp_accessmodes
268 if $old->cgp_accessmodes ne $new->cgp_accessmodes
269 || $old->cgp_type ne $new->cgp_type;
271 #phase 2: pwdallowed, passwordrecovery, allowed mail rules,
272 # RPOP modifications, accepts mail to all, add trailer to sent mail
273 #phase 3: archive messages, mailing lists
275 if ( keys %settings ) {
276 my $error = $self->communigate_pro_queue(
278 'UpdateAccountSettings',
279 $self->export_username($new),
282 return $error if $error;
287 $prefs{'DeleteMode'} = $new->cgp_deletemode
288 if $old->cgp_deletemode ne $new->cgp_deletemode;
289 $prefs{'EmptyTrash'} = $new->cgp_emptytrash
290 if $old->cgp_emptytrash ne $new->cgp_emptytrash;
291 #phase 2: language, time zone, layout, pronto style, send read receipts
293 my $pref_err = $self->communigate_pro_queue( $new->svcnum,
294 'UpdateAccountPrefs',
295 $self->export_username($new),
298 warn "WARNING: error queueing UpdateAccountPrefs job: $pref_err"
302 if ( $old->cgp_aliases ne $new->cgp_aliases ) {
303 my $error = $self->communigate_pro_queue(
306 $self->export_username($new),
307 [ split(/\s*[,\s]\s*/, $new->cgp_aliases) ],
309 return $error if $error;
316 sub _export_replace_svc_domain {
317 my( $self, $new, $old ) = (shift, shift, shift);
319 if ( $old->domain ne $new->domain ) {
320 my $error = $self->communigate_pro_queue( $new->svcnum, 'RenameDomain',
321 $old->domain, $new->domain,
323 return $error if $error;
326 $settings{'AccountsLimit'} = $new->max_accounts
327 if $old->max_accounts ne $new->max_accounts;
328 $settings{'DomainAccessModes'} = $new->cgp_accessmodes
329 if $old->cgp_accessmodes ne $new->cgp_accessmodes;
330 $settings{'AdminDomainName'} =
331 $new->parent_svcnum ? $new->parent_svc_x->domain : ''
332 if $old->parent_svcnum != $new->parent_svcnum;
334 if ( keys %settings ) {
335 my $error = $self->communigate_pro_queue( $new->svcnum,
336 'UpdateDomainSettings',
340 return $error if $error;
343 if ( $old->cgp_aliases ne $new->cgp_aliases ) {
344 my $error = $self->communigate_pro_queue( $new->svcnum,
347 split(/\s*[,\s]\s*/, $new->cgp_aliases),
349 return $error if $error;
352 #below this identical to insert... any value to doing an Update here?
353 #not seeing any big one... i guess it would be nice to avoid the update
354 #when things haven't changed
357 my $def_err = $self->communigate_pro_queue( $new->svcnum,
358 'SetAccountDefaults',
360 'PWDAllowed' => ( $new->acct_def_password_selfchange ? 'YES' : 'NO' ),
361 'PasswordRecovery' => ( $new->acct_def_password_recover ? 'YES' : 'NO' ),
362 'AccessModes' => $new->acct_def_cgp_accessmodes,
363 'MaxAccountSize' => $new->acct_def_quota,
364 'MaxWebSize' => $new->acct_def_file_quota,
365 'MaxWebFile' => $new->acct_def_file_maxnum,
366 'MaxFileSize' => $new->acct_def_file_maxsize,
368 warn "WARNING: error queueing SetAccountDefaults job: $def_err"
371 #account defaults prefs
372 my $pref_err = $self->communigate_pro_queue( $new->svcnum,
373 'SetAccountDefaultPrefs',
375 'DeleteMode' => $new->acct_def_cgp_deletemode,
376 'EmptyTrash' => $new->acct_def_cgp_emptytrash,
378 warn "WARNING: error queueing SetAccountDefaultPrefs job: $pref_err"
384 sub _export_replace_svc_forward {
385 my( $self, $new, $old ) = (shift, shift, shift);
387 my $osrc = $old->src || $old->srcsvc_acct->email;
388 my $nsrc = $new->src || $new->srcsvc_acct->email;
389 my $odst = $old->dst || $old->dstsvc_acct->email;
390 my $ndst = $new->dst || $new->dstsvc_acct->email;
392 if ( $odst ne $ndst ) {
394 #no change command, so delete and create (real-time)
395 eval { $self->communigate_pro_runcommand('DeleteForwarder', $osrc) };
397 eval { $self->communigate_pro_runcommand('CreateForwarder', $nsrc, $ndst)};
400 } elsif ( $osrc ne $nsrc ) {
402 #real-time here, presuming CGP does some dup detection?
403 eval { $self->communigate_pro_runcommand( 'RenameForwarder', $osrc, $nsrc)};
407 warn "communigate replace called for svc_forward with no changes\n";#confess
413 sub _export_replace_svc_mailinglist {
414 my( $self, $new, $old ) = (shift, shift, shift);
416 my $oldGroupName = $old->username.'@'.$old->domain;
417 my $newGroupName = $new->username.'@'.$new->domain;
419 if ( $oldGroupName ne $newGroupName ) {
420 eval { $self->communigate_pro_runcommand(
421 'RenameGroup', $oldGroupName, $newGroupName ); };
425 my @members = map $_->email_address,
426 $new->mailinglist->mailinglistmember;
428 #real-time here, presuming CGP does some dup detection
429 eval { $self->communigate_pro_runcommand(
430 'SetGroup', $newGroupName,
431 { 'RealName' => $new->listname,
432 'SetReplyTo' => ( $new->reply_to ? 'YES' : 'NO' ),
433 'RemoveAuthor' => ( $new->remove_from ? 'YES' : 'NO' ),
434 'RejectAuto' => ( $new->reject_auto ? 'YES' : 'NO' ),
435 'RemoveToAndCc' => ( $new->remove_to_and_cc ? 'YES' : 'NO' ),
436 'Members' => \@members,
447 my( $self, $svc_x ) = (shift, shift);
449 my $table = $svc_x->table;
450 my $method = "_export_delete_$table";
451 $self->$method($svc_x, @_);
454 sub _export_delete_svc_acct {
455 my( $self, $svc_acct ) = (shift, shift);
457 $self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
458 $self->export_username($svc_acct),
462 sub _export_delete_svc_domain {
463 my( $self, $svc_domain ) = (shift, shift);
465 $self->communigate_pro_queue( $svc_domain->svcnum, 'DeleteDomain',
467 #XXX turn on force option for domain deletion?
471 sub _export_delete_svc_forward {
472 my( $self, $svc_forward ) = (shift, shift);
474 $self->communigate_pro_queue( $svc_forward->svcnum, 'DeleteForwarder',
475 ($svc_forward->src || $svc_forward->srcsvc_acct->email),
479 sub _export_delete_svc_mailinglist {
480 my( $self, $svc_mailinglist ) = (shift, shift);
482 #real-time here, presuming CGP does some dup detection
483 eval { $self->communigate_pro_runcommand(
485 $svc_mailinglist->username.'@'.$svc_mailinglist->domain,
494 sub _export_suspend {
495 my( $self, $svc_x ) = (shift, shift);
497 my $table = $svc_x->table;
498 my $method = "_export_suspend_$table";
499 $self->$method($svc_x, @_);
503 sub _export_suspend_svc_acct {
504 my( $self, $svc_acct ) = (shift, shift);
506 #XXX is this the desired suspnsion action?
508 $self->communigate_pro_queue(
510 'UpdateAccountSettings',
511 $self->export_username($svc_acct),
512 'AccessModes' => 'Mail',
517 sub _export_suspend_svc_domain {
518 my( $self, $svc_domain) = (shift, shift);
520 #XXX domain operations
525 sub _export_unsuspend {
526 my( $self, $svc_x ) = (shift, shift);
528 my $table = $svc_x->table;
529 my $method = "_export_unsuspend_$table";
530 $self->$method($svc_x, @_);
534 sub _export_unsuspend_svc_acct {
535 my( $self, $svc_acct ) = (shift, shift);
537 $self->communigate_pro_queue(
539 'UpdateAccountSettings',
540 $self->export_username($svc_acct),
541 'AccessModes' => ( $svc_acct->cgp_accessmodes
542 || $self->option('AccessModes') ),
547 sub _export_unsuspend_svc_domain {
548 my( $self, $svc_domain) = (shift, shift);
550 #XXX domain operations
555 sub export_mailinglistmember_insert {
556 my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
557 $svc_mailinglist->replace();
560 sub export_mailinglistmember_replace {
561 my( $self, $svc_mailinglist, $new, $old ) = (shift, shift, shift, shift);
562 die "no way to do this from the UI right now";
565 sub export_mailinglistmember_delete {
566 my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
567 $svc_mailinglist->replace();
570 sub export_getsettings {
571 my($self, $svc_x) = (shift, shift);
573 my $table = $svc_x->table;
574 my $method = "export_getsettings_$table";
576 $self->can($method) ? $self->$method($svc_x, @_) : '';
580 sub export_getsettings_svc_domain {
581 my($self, $svc_domain, $settingsref, $defaultref ) = @_;
583 my $settings = eval { $self->communigate_pro_runcommand(
589 my $effective_settings = eval { $self->communigate_pro_runcommand(
590 'GetDomainEffectiveSettings',
595 my $acct_defaults = eval { $self->communigate_pro_runcommand(
596 'GetAccountDefaults',
601 my $acct_defaultprefs = eval { $self->communigate_pro_runcommand(
602 'GetAccountDefaultPrefs',
607 %$effective_settings = (
608 %$effective_settings,
609 ( map { ("Acct. Default $_" => $acct_defaults->{$_}); }
610 keys(%$acct_defaults)
612 ( map { ("Acct. Default $_" => $acct_defaultprefs->{$_}); } #diff label??
613 keys(%$acct_defaultprefs)
618 ( map { ("Acct. Default $_" => $acct_defaults->{$_}); }
619 keys(%$acct_defaults)
621 ( map { ("Acct. Default $_" => $acct_defaultprefs->{$_}); } #diff label??
622 keys(%$acct_defaultprefs)
627 my $aliases = eval { $self->communigate_pro_runcommand(
633 $effective_settings->{'Aliases'} = join(', ', @$aliases);
634 $settings->{'Aliases'} = join(', ', @$aliases);
637 #false laziness w/below
639 my %defaults = map { $_ => 1 }
640 grep !exists(${$settings}{$_}), keys %$effective_settings;
642 foreach my $key ( grep ref($effective_settings->{$_}),
643 keys %$effective_settings )
645 my $value = $effective_settings->{$key};
646 if ( ref($value) eq 'ARRAY' ) {
647 $effective_settings->{$key} = join(' ', @$value);
650 warn "serializing ". ref($value). " for table display not yet handled";
654 %{$settingsref} = %$effective_settings;
655 %{$defaultref} = %defaults;
660 sub export_getsettings_svc_acct {
661 my($self, $svc_acct, $settingsref, $defaultref ) = @_;
663 my $settings = eval { $self->communigate_pro_runcommand(
664 'GetAccountSettings',
669 delete($settings->{'Password'});
671 my $effective_settings = eval { $self->communigate_pro_runcommand(
672 'GetAccountEffectiveSettings',
677 delete($effective_settings->{'Password'});
679 #prefs/effectiveprefs too
681 my $prefs = eval { $self->communigate_pro_runcommand(
687 my $effective_prefs = eval { $self->communigate_pro_runcommand(
688 'GetAccountEffectivePrefs',
693 %$effective_settings = ( %$effective_settings,
694 map { ("Pref $_" => $effective_prefs->{$_}); }
695 keys(%$effective_prefs)
697 %$settings = ( %$settings,
698 map { ("Pref $_" => $prefs->{$_}); }
704 my $aliases = eval { $self->communigate_pro_runcommand(
710 $effective_settings->{'Aliases'} = join(', ', @$aliases);
711 $settings->{'Aliases'} = join(', ', @$aliases);
713 #false laziness w/above
715 my %defaults = map { $_ => 1 }
716 grep !exists(${$settings}{$_}), keys %$effective_settings;
718 foreach my $key ( grep ref($effective_settings->{$_}),
719 keys %$effective_settings )
721 my $value = $effective_settings->{$key};
722 if ( ref($value) eq 'ARRAY' ) {
723 $effective_settings->{$key} = join(' ', @$value);
726 warn "serializing ". ref($value). " for table display not yet handled";
730 %{$settingsref} = %$effective_settings;
731 %{$defaultref} = %defaults;
737 sub export_getsettings_svc_mailinglist {
738 my($self, $svc_mailinglist, $settingsref, $defaultref ) = @_;
740 my $settings = eval { $self->communigate_pro_runcommand(
742 $svc_mailinglist->username.'@'.$svc_mailinglist->domain,
746 $settings->{'Members'} = join(', ', @{ $settings->{'Members'} } );
748 %{$settingsref} = %$settings;
753 sub communigate_pro_queue {
754 my( $self, $svcnum, $method ) = (shift, shift, shift);
755 my $jobnum = ''; #don't actually care
756 $self->communigate_pro_queue_dep( \$jobnum, $svcnum, $method, @_);
759 sub communigate_pro_queue_dep {
760 my( $self, $jobnumref, $svcnum, $method ) = splice(@_,0,4);
762 my %kludge_methods = (
763 #'CreateAccount' => 'CreateAccount',
764 'UpdateAccountSettings' => 'UpdateAccountSettings',
765 'UpdateAccountPrefs' => 'cp_Scalar_Hash',
766 #'CreateDomain' => 'cp_Scalar_Hash',
767 #'CreateSharedDomain' => 'cp_Scalar_Hash',
768 'UpdateDomainSettings' => 'cp_Scalar_settingsHash',
769 'SetDomainAliases' => 'cp_Scalar_Array',
770 'SetAccountDefaults' => 'cp_Scalar_settingsHash',
771 'UpdateAccountDefaults' => 'cp_Scalar_settingsHash',
772 'SetAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
773 'UpdateAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
775 my $sub = exists($kludge_methods{$method})
776 ? $kludge_methods{$method}
777 : 'communigate_pro_command';
779 my $queue = new FS::queue {
781 'job' => "FS::part_export::communigate_pro::$sub",
783 my $error = $queue->insert(
785 $self->option('port'),
786 $self->option('login'),
787 $self->option('password'),
791 $$jobnumref = $queue->jobnum unless $error;
796 sub communigate_pro_runcommand {
797 my( $self, $method ) = (shift, shift);
799 communigate_pro_command(
801 $self->option('port'),
802 $self->option('login'),
803 $self->option('password'),
810 #XXX one sub per arg prototype is lame. more magic? i suppose queue needs
811 # to store data strctures properly instead of just an arg list. right.
814 my( $machine, $port, $login, $password, $method, $scalar, %hash ) = @_;
815 my @args = ( $scalar, \%hash );
816 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
819 sub cp_Scalar_Array {
820 my( $machine, $port, $login, $password, $method, $scalar, @array ) = @_;
821 my @args = ( $scalar, \@array );
822 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
826 # my( $machine, $port, $login, $password, $method, %hash ) = @_;
827 # my @args = ( \%hash );
828 # communigate_pro_command( $machine, $port, $login, $password, $method, @args );
831 sub cp_Scalar_settingsHash {
832 my( $machine, $port, $login, $password, $method, $domain, %settings ) = @_;
833 for (qw( AccessModes DomainAccessModes )) {
834 $settings{$_} = [split(' ',$settings{$_})] if $settings{$_};
836 my @args = ( 'domain' => $domain, 'settings' => \%settings );
837 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
841 # my( $machine, $port, $login, $password, $method, %args ) = @_;
842 # my $accountName = delete $args{'accountName'};
843 # my $accountType = delete $args{'accountType'};
844 # my $externalFlag = delete $args{'externalFlag'};
845 # $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
846 # my @args = ( accountName => $accountName,
847 # accountType => $accountType,
848 # settings => \%args,
850 # #externalFlag => $externalFlag,
851 # push @args, externalFlag => $externalFlag if $externalFlag;
853 # communigate_pro_command( $machine, $port, $login, $password, $method, @args );
857 sub UpdateAccountSettings {
858 my( $machine, $port, $login, $password, $method, $accountName, %args ) = @_;
859 $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
860 my @args = ( $accountName, \%args );
861 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
864 sub communigate_pro_command { #subroutine, not method
865 my( $machine, $port, $login, $password, $method, @args ) = @_;
869 my $cli = new CGP::CLI( {
870 'PeerAddr' => $machine,
873 'password' => $password,
874 } ) or die "Can't login to CGPro: $CGP::ERR_STRING\n";
876 #warn "$method ". Dumper(@args) if $DEBUG;
878 my $return = $cli->$method(@args)
879 or die "Communigate Pro error: ". $cli->getErrMessage. "\n";
881 $cli->Logout; # or die "Can't logout of CGPro: $CGP::ERR_STRING\n";