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;
144 $settings{'TrailerText'} = $svc_domain->trailer
145 if $svc_domain->trailer;
147 my @options = ( $create, $svc_domain->domain, \%settings );
149 eval { $self->communigate_pro_runcommand( @options ) };
153 if ( $svc_domain->cgp_aliases ) {
154 my $alias_err = $self->communigate_pro_queue( $svc_domain->svcnum,
157 split(/\s*[,\s]\s*/, $svc_domain->cgp_aliases),
159 warn "WARNING: error queueing SetDomainAliases job: $alias_err"
164 my $def_err = $self->communigate_pro_queue( $svc_domain->svcnum,
165 'SetAccountDefaults',
167 'PWDAllowed' =>($svc_domain->acct_def_password_selfchange ? 'YES':'NO'),
168 'PasswordRecovery' => ($svc_domain->acct_def_password_recover ? 'YES':'NO'),
169 'AccessModes' => $svc_domain->acct_def_cgp_accessmodes,
170 'MaxAccountSize' => $svc_domain->acct_def_quota,
171 'MaxWebSize' => $svc_domain->acct_def_file_quota,
172 'MaxWebFile' => $svc_domain->acct_def_file_maxnum,
173 'MaxFileSize' => $svc_domain->acct_def_file_maxsize,
175 warn "WARNING: error queueing SetAccountDefaults job: $def_err"
178 #account defaults prefs
179 my $pref_err = $self->communigate_pro_queue( $svc_domain->svcnum,
180 'SetAccountDefaultPrefs',
182 'DeleteMode' => $svc_domain->acct_def_cgp_deletemode,
183 'EmptyTrash' => $svc_domain->acct_def_cgp_emptytrash,
185 warn "WARNING: error queueing SetAccountDefaultPrefs job: $pref_err"
192 sub _export_insert_svc_forward {
193 my( $self, $svc_forward ) = (shift, shift);
195 my $src = $svc_forward->src || $svc_forward->srcsvc_acct->email;
196 my $dst = $svc_forward->dst || $svc_forward->dstsvc_acct->email;
198 #real-time here, presuming CGP does some dup detection?
199 eval { $self->communigate_pro_runcommand( 'CreateForwarder', $src, $dst); };
205 sub _export_insert_svc_mailinglist {
206 my( $self, $svc_mlist ) = (shift, shift);
208 my @members = map $_->email_address,
209 $svc_mlist->mailinglist->mailinglistmember;
211 #real-time here, presuming CGP does some dup detection
212 eval { $self->communigate_pro_runcommand(
214 $svc_mlist->username.'@'.$svc_mlist->domain,
215 { 'RealName' => $svc_mlist->listname,
216 'SetReplyTo' => ( $svc_mlist->reply_to ? 'YES' : 'NO' ),
217 'RemoveAuthor' => ( $svc_mlist->remove_from ? 'YES' : 'NO' ),
218 'RejectAuto' => ( $svc_mlist->reject_auto ? 'YES' : 'NO' ),
219 'RemoveToAndCc' => ( $svc_mlist->remove_to_and_cc ? 'YES' : 'NO' ),
220 'Members' => \@members,
230 sub _export_replace {
231 my( $self, $new, $old ) = (shift, shift, shift);
233 my $table = $new->table;
234 my $method = "_export_replace_$table";
235 $self->$method($new, $old, @_);
238 sub _export_replace_svc_acct {
239 my( $self, $new, $old ) = (shift, shift, shift);
241 #let's just do the rename part realtime rather than trying to queue
242 #w/dependencies. we don't want FS winding up out-of-sync with the wrong
243 #username and a queued job anyway. right??
244 if ( $self->export_username($old) ne $self->export_username($new) ) {
245 eval { $self->communigate_pro_runcommand(
247 $self->export_username($old),
248 $self->export_username($new),
253 if ( $new->_password ne $old->_password
254 && '*SUSPENDED* '.$old->_password ne $new->_password
256 $self->communigate_pro_queue( $new->svcnum, 'SetAccountPassword',
257 $self->export_username($new), $new->_password
263 $settings{'RealName'} = $new->finger
264 if $old->finger ne $new->finger;
265 $settings{$quotas{$_}} = $new->$_()
266 foreach grep $old->$_() ne $new->$_(), keys %quotas;
267 $settings{'accountType'} = $new->cgp_type
268 if $old->cgp_type ne $new->cgp_type;
269 $settings{'AccessModes'} = $new->cgp_accessmodes
270 if $old->cgp_accessmodes ne $new->cgp_accessmodes
271 || $old->cgp_type ne $new->cgp_type;
273 #phase 2: pwdallowed, passwordrecovery, allowed mail rules,
274 # RPOP modifications, accepts mail to all, add trailer to sent mail
275 #phase 3: archive messages, mailing lists
277 if ( keys %settings ) {
278 my $error = $self->communigate_pro_queue(
280 'UpdateAccountSettings',
281 $self->export_username($new),
284 return $error if $error;
289 $prefs{'DeleteMode'} = $new->cgp_deletemode
290 if $old->cgp_deletemode ne $new->cgp_deletemode;
291 $prefs{'EmptyTrash'} = $new->cgp_emptytrash
292 if $old->cgp_emptytrash ne $new->cgp_emptytrash;
293 #phase 2: language, time zone, layout, pronto style, send read receipts
295 my $pref_err = $self->communigate_pro_queue( $new->svcnum,
296 'UpdateAccountPrefs',
297 $self->export_username($new),
300 warn "WARNING: error queueing UpdateAccountPrefs job: $pref_err"
304 if ( $old->cgp_aliases ne $new->cgp_aliases ) {
305 my $error = $self->communigate_pro_queue(
308 $self->export_username($new),
309 [ split(/\s*[,\s]\s*/, $new->cgp_aliases) ],
311 return $error if $error;
318 sub _export_replace_svc_domain {
319 my( $self, $new, $old ) = (shift, shift, shift);
321 if ( $old->domain ne $new->domain ) {
322 my $error = $self->communigate_pro_queue( $new->svcnum, 'RenameDomain',
323 $old->domain, $new->domain,
325 return $error if $error;
328 $settings{'AccountsLimit'} = $new->max_accounts
329 if $old->max_accounts ne $new->max_accounts;
330 $settings{'TrailerText'} = $new->trailer
331 if $old->trailer ne $new->trailer;
332 $settings{'DomainAccessModes'} = $new->cgp_accessmodes
333 if $old->cgp_accessmodes ne $new->cgp_accessmodes;
334 $settings{'AdminDomainName'} =
335 $new->parent_svcnum ? $new->parent_svc_x->domain : ''
336 if $old->parent_svcnum != $new->parent_svcnum;
338 if ( keys %settings ) {
339 my $error = $self->communigate_pro_queue( $new->svcnum,
340 'UpdateDomainSettings',
344 return $error if $error;
347 if ( $old->cgp_aliases ne $new->cgp_aliases ) {
348 my $error = $self->communigate_pro_queue( $new->svcnum,
351 split(/\s*[,\s]\s*/, $new->cgp_aliases),
353 return $error if $error;
356 #below this identical to insert... any value to doing an Update here?
357 #not seeing any big one... i guess it would be nice to avoid the update
358 #when things haven't changed
361 my $def_err = $self->communigate_pro_queue( $new->svcnum,
362 'SetAccountDefaults',
364 'PWDAllowed' => ( $new->acct_def_password_selfchange ? 'YES' : 'NO' ),
365 'PasswordRecovery' => ( $new->acct_def_password_recover ? 'YES' : 'NO' ),
366 'AccessModes' => $new->acct_def_cgp_accessmodes,
367 'MaxAccountSize' => $new->acct_def_quota,
368 'MaxWebSize' => $new->acct_def_file_quota,
369 'MaxWebFile' => $new->acct_def_file_maxnum,
370 'MaxFileSize' => $new->acct_def_file_maxsize,
372 warn "WARNING: error queueing SetAccountDefaults job: $def_err"
375 #account defaults prefs
376 my $pref_err = $self->communigate_pro_queue( $new->svcnum,
377 'SetAccountDefaultPrefs',
379 'DeleteMode' => $new->acct_def_cgp_deletemode,
380 'EmptyTrash' => $new->acct_def_cgp_emptytrash,
382 warn "WARNING: error queueing SetAccountDefaultPrefs job: $pref_err"
388 sub _export_replace_svc_forward {
389 my( $self, $new, $old ) = (shift, shift, shift);
391 my $osrc = $old->src || $old->srcsvc_acct->email;
392 my $nsrc = $new->src || $new->srcsvc_acct->email;
393 my $odst = $old->dst || $old->dstsvc_acct->email;
394 my $ndst = $new->dst || $new->dstsvc_acct->email;
396 if ( $odst ne $ndst ) {
398 #no change command, so delete and create (real-time)
399 eval { $self->communigate_pro_runcommand('DeleteForwarder', $osrc) };
401 eval { $self->communigate_pro_runcommand('CreateForwarder', $nsrc, $ndst)};
404 } elsif ( $osrc ne $nsrc ) {
406 #real-time here, presuming CGP does some dup detection?
407 eval { $self->communigate_pro_runcommand( 'RenameForwarder', $osrc, $nsrc)};
411 warn "communigate replace called for svc_forward with no changes\n";#confess
417 sub _export_replace_svc_mailinglist {
418 my( $self, $new, $old ) = (shift, shift, shift);
420 my $oldGroupName = $old->username.'@'.$old->domain;
421 my $newGroupName = $new->username.'@'.$new->domain;
423 if ( $oldGroupName ne $newGroupName ) {
424 eval { $self->communigate_pro_runcommand(
425 'RenameGroup', $oldGroupName, $newGroupName ); };
429 my @members = map $_->email_address,
430 $new->mailinglist->mailinglistmember;
432 #real-time here, presuming CGP does some dup detection
433 eval { $self->communigate_pro_runcommand(
434 'SetGroup', $newGroupName,
435 { 'RealName' => $new->listname,
436 'SetReplyTo' => ( $new->reply_to ? 'YES' : 'NO' ),
437 'RemoveAuthor' => ( $new->remove_from ? 'YES' : 'NO' ),
438 'RejectAuto' => ( $new->reject_auto ? 'YES' : 'NO' ),
439 'RemoveToAndCc' => ( $new->remove_to_and_cc ? 'YES' : 'NO' ),
440 'Members' => \@members,
451 my( $self, $svc_x ) = (shift, shift);
453 my $table = $svc_x->table;
454 my $method = "_export_delete_$table";
455 $self->$method($svc_x, @_);
458 sub _export_delete_svc_acct {
459 my( $self, $svc_acct ) = (shift, shift);
461 $self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
462 $self->export_username($svc_acct),
466 sub _export_delete_svc_domain {
467 my( $self, $svc_domain ) = (shift, shift);
469 $self->communigate_pro_queue( $svc_domain->svcnum, 'DeleteDomain',
471 #XXX turn on force option for domain deletion?
475 sub _export_delete_svc_forward {
476 my( $self, $svc_forward ) = (shift, shift);
478 $self->communigate_pro_queue( $svc_forward->svcnum, 'DeleteForwarder',
479 ($svc_forward->src || $svc_forward->srcsvc_acct->email),
483 sub _export_delete_svc_mailinglist {
484 my( $self, $svc_mailinglist ) = (shift, shift);
486 #real-time here, presuming CGP does some dup detection
487 eval { $self->communigate_pro_runcommand(
489 $svc_mailinglist->username.'@'.$svc_mailinglist->domain,
498 sub _export_suspend {
499 my( $self, $svc_x ) = (shift, shift);
501 my $table = $svc_x->table;
502 my $method = "_export_suspend_$table";
503 $self->$method($svc_x, @_);
507 sub _export_suspend_svc_acct {
508 my( $self, $svc_acct ) = (shift, shift);
510 #XXX is this the desired suspnsion action?
512 $self->communigate_pro_queue(
514 'UpdateAccountSettings',
515 $self->export_username($svc_acct),
516 'AccessModes' => 'Mail',
521 sub _export_suspend_svc_domain {
522 my( $self, $svc_domain) = (shift, shift);
524 #XXX domain operations
529 sub _export_unsuspend {
530 my( $self, $svc_x ) = (shift, shift);
532 my $table = $svc_x->table;
533 my $method = "_export_unsuspend_$table";
534 $self->$method($svc_x, @_);
538 sub _export_unsuspend_svc_acct {
539 my( $self, $svc_acct ) = (shift, shift);
541 $self->communigate_pro_queue(
543 'UpdateAccountSettings',
544 $self->export_username($svc_acct),
545 'AccessModes' => ( $svc_acct->cgp_accessmodes
546 || $self->option('AccessModes') ),
551 sub _export_unsuspend_svc_domain {
552 my( $self, $svc_domain) = (shift, shift);
554 #XXX domain operations
559 sub export_mailinglistmember_insert {
560 my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
561 $svc_mailinglist->replace();
564 sub export_mailinglistmember_replace {
565 my( $self, $svc_mailinglist, $new, $old ) = (shift, shift, shift, shift);
566 die "no way to do this from the UI right now";
569 sub export_mailinglistmember_delete {
570 my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
571 $svc_mailinglist->replace();
574 sub export_getsettings {
575 my($self, $svc_x) = (shift, shift);
577 my $table = $svc_x->table;
578 my $method = "export_getsettings_$table";
580 $self->can($method) ? $self->$method($svc_x, @_) : '';
584 sub export_getsettings_svc_domain {
585 my($self, $svc_domain, $settingsref, $defaultref ) = @_;
587 my $settings = eval { $self->communigate_pro_runcommand(
593 my $effective_settings = eval { $self->communigate_pro_runcommand(
594 'GetDomainEffectiveSettings',
599 my $acct_defaults = eval { $self->communigate_pro_runcommand(
600 'GetAccountDefaults',
605 my $acct_defaultprefs = eval { $self->communigate_pro_runcommand(
606 'GetAccountDefaultPrefs',
611 %$effective_settings = (
612 %$effective_settings,
613 ( map { ("Acct. Default $_" => $acct_defaults->{$_}); }
614 keys(%$acct_defaults)
616 ( map { ("Acct. Default $_" => $acct_defaultprefs->{$_}); } #diff label??
617 keys(%$acct_defaultprefs)
622 ( map { ("Acct. Default $_" => $acct_defaults->{$_}); }
623 keys(%$acct_defaults)
625 ( map { ("Acct. Default $_" => $acct_defaultprefs->{$_}); } #diff label??
626 keys(%$acct_defaultprefs)
631 my $aliases = eval { $self->communigate_pro_runcommand(
637 $effective_settings->{'Aliases'} = join(', ', @$aliases);
638 $settings->{'Aliases'} = join(', ', @$aliases);
641 #false laziness w/below
643 my %defaults = map { $_ => 1 }
644 grep !exists(${$settings}{$_}), keys %$effective_settings;
646 foreach my $key ( grep ref($effective_settings->{$_}),
647 keys %$effective_settings )
649 my $value = $effective_settings->{$key};
650 if ( ref($value) eq 'ARRAY' ) {
651 $effective_settings->{$key} = join(' ', @$value);
654 warn "serializing ". ref($value). " for table display not yet handled";
658 %{$settingsref} = %$effective_settings;
659 %{$defaultref} = %defaults;
664 sub export_getsettings_svc_acct {
665 my($self, $svc_acct, $settingsref, $defaultref ) = @_;
667 my $settings = eval { $self->communigate_pro_runcommand(
668 'GetAccountSettings',
673 delete($settings->{'Password'});
675 my $effective_settings = eval { $self->communigate_pro_runcommand(
676 'GetAccountEffectiveSettings',
681 delete($effective_settings->{'Password'});
683 #prefs/effectiveprefs too
685 my $prefs = eval { $self->communigate_pro_runcommand(
691 my $effective_prefs = eval { $self->communigate_pro_runcommand(
692 'GetAccountEffectivePrefs',
697 %$effective_settings = ( %$effective_settings,
698 map { ("Pref $_" => $effective_prefs->{$_}); }
699 keys(%$effective_prefs)
701 %$settings = ( %$settings,
702 map { ("Pref $_" => $prefs->{$_}); }
708 my $aliases = eval { $self->communigate_pro_runcommand(
714 $effective_settings->{'Aliases'} = join(', ', @$aliases);
715 $settings->{'Aliases'} = join(', ', @$aliases);
717 #false laziness w/above
719 my %defaults = map { $_ => 1 }
720 grep !exists(${$settings}{$_}), keys %$effective_settings;
722 foreach my $key ( grep ref($effective_settings->{$_}),
723 keys %$effective_settings )
725 my $value = $effective_settings->{$key};
726 if ( ref($value) eq 'ARRAY' ) {
727 $effective_settings->{$key} = join(' ', @$value);
730 warn "serializing ". ref($value). " for table display not yet handled";
734 %{$settingsref} = %$effective_settings;
735 %{$defaultref} = %defaults;
741 sub export_getsettings_svc_mailinglist {
742 my($self, $svc_mailinglist, $settingsref, $defaultref ) = @_;
744 my $settings = eval { $self->communigate_pro_runcommand(
746 $svc_mailinglist->username.'@'.$svc_mailinglist->domain,
750 $settings->{'Members'} = join(', ', @{ $settings->{'Members'} } );
752 %{$settingsref} = %$settings;
757 sub communigate_pro_queue {
758 my( $self, $svcnum, $method ) = (shift, shift, shift);
759 my $jobnum = ''; #don't actually care
760 $self->communigate_pro_queue_dep( \$jobnum, $svcnum, $method, @_);
763 sub communigate_pro_queue_dep {
764 my( $self, $jobnumref, $svcnum, $method ) = splice(@_,0,4);
766 my %kludge_methods = (
767 #'CreateAccount' => 'CreateAccount',
768 'UpdateAccountSettings' => 'UpdateAccountSettings',
769 'UpdateAccountPrefs' => 'cp_Scalar_Hash',
770 #'CreateDomain' => 'cp_Scalar_Hash',
771 #'CreateSharedDomain' => 'cp_Scalar_Hash',
772 'UpdateDomainSettings' => 'cp_Scalar_settingsHash',
773 'SetDomainAliases' => 'cp_Scalar_Array',
774 'SetAccountDefaults' => 'cp_Scalar_settingsHash',
775 'UpdateAccountDefaults' => 'cp_Scalar_settingsHash',
776 'SetAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
777 'UpdateAccountDefaultPrefs' => 'cp_Scalar_settingsHash',
779 my $sub = exists($kludge_methods{$method})
780 ? $kludge_methods{$method}
781 : 'communigate_pro_command';
783 my $queue = new FS::queue {
785 'job' => "FS::part_export::communigate_pro::$sub",
787 my $error = $queue->insert(
789 $self->option('port'),
790 $self->option('login'),
791 $self->option('password'),
795 $$jobnumref = $queue->jobnum unless $error;
800 sub communigate_pro_runcommand {
801 my( $self, $method ) = (shift, shift);
803 communigate_pro_command(
805 $self->option('port'),
806 $self->option('login'),
807 $self->option('password'),
814 #XXX one sub per arg prototype is lame. more magic? i suppose queue needs
815 # to store data strctures properly instead of just an arg list. right.
818 my( $machine, $port, $login, $password, $method, $scalar, %hash ) = @_;
819 my @args = ( $scalar, \%hash );
820 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
823 sub cp_Scalar_Array {
824 my( $machine, $port, $login, $password, $method, $scalar, @array ) = @_;
825 my @args = ( $scalar, \@array );
826 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
830 # my( $machine, $port, $login, $password, $method, %hash ) = @_;
831 # my @args = ( \%hash );
832 # communigate_pro_command( $machine, $port, $login, $password, $method, @args );
835 sub cp_Scalar_settingsHash {
836 my( $machine, $port, $login, $password, $method, $domain, %settings ) = @_;
837 for (qw( AccessModes DomainAccessModes )) {
838 $settings{$_} = [split(' ',$settings{$_})] if $settings{$_};
840 my @args = ( 'domain' => $domain, 'settings' => \%settings );
841 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
845 # my( $machine, $port, $login, $password, $method, %args ) = @_;
846 # my $accountName = delete $args{'accountName'};
847 # my $accountType = delete $args{'accountType'};
848 # my $externalFlag = delete $args{'externalFlag'};
849 # $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
850 # my @args = ( accountName => $accountName,
851 # accountType => $accountType,
852 # settings => \%args,
854 # #externalFlag => $externalFlag,
855 # push @args, externalFlag => $externalFlag if $externalFlag;
857 # communigate_pro_command( $machine, $port, $login, $password, $method, @args );
861 sub UpdateAccountSettings {
862 my( $machine, $port, $login, $password, $method, $accountName, %args ) = @_;
863 $args{'AccessModes'} = [ split(' ', $args{'AccessModes'}) ];
864 my @args = ( $accountName, \%args );
865 communigate_pro_command( $machine, $port, $login, $password, $method, @args );
868 sub communigate_pro_command { #subroutine, not method
869 my( $machine, $port, $login, $password, $method, @args ) = @_;
874 my $cli = new CGP::CLI( {
875 'PeerAddr' => $machine,
878 'password' => $password,
879 } ) or die "Can't login to CGPro: $CGP::ERR_STRING\n";
881 #warn "$method ". Dumper(@args) if $DEBUG;
883 my $return = $cli->$method(@args)
884 or die "Communigate Pro error: ". $cli->getErrMessage. "\n";
886 $cli->Logout; # or die "Can't logout of CGPro: $CGP::ERR_STRING\n";