16 |
|
|
17 |
my $limit = 0; |
my $limit = 0; |
18 |
my @models; |
my @models; |
19 |
|
my $strix; |
20 |
|
|
21 |
GetOptions( |
GetOptions( |
22 |
'limit=i', => \$limit, |
'limit=i', => \$limit, |
23 |
'model=s', => \@models, |
'model=s', => \@models, |
24 |
); |
'strix+', => \$strix, |
25 |
|
) or die "$0: $!"; |
26 |
|
|
27 |
my $ldap = A3C::LDAP->new; |
my $ldap = A3C::LDAP->new; |
28 |
|
|
29 |
|
sub sync_org { |
30 |
|
my $org_uid = shift; |
31 |
|
my $action = Jifty->web->new_action( |
32 |
|
class => 'SyncOrganization', |
33 |
|
moniker => 'sync', |
34 |
|
arguments => { |
35 |
|
org_uid => $org_uid, |
36 |
|
} |
37 |
|
); |
38 |
|
$action->run; |
39 |
|
if ( $action->result->success ) { |
40 |
|
Jifty->log->info( $action->result->message ); |
41 |
|
} else { |
42 |
|
Jifty->log->error( "Can't sync $org_uid" ); |
43 |
|
} |
44 |
|
} |
45 |
|
|
46 |
|
@models = 'hrEduOrg' if $strix; |
47 |
|
|
48 |
if ( @models ) { |
if ( @models ) { |
49 |
|
|
50 |
Jifty->log->info( 'syncing: ', join(',', @models) ); |
Jifty->log->info( 'syncing: ', join(',', @models) ); |
73 |
next; |
next; |
74 |
} |
} |
75 |
my $org_uid = $o->$value_from || warn "can't find org_uid in $value_from in ",dump( $o->as_hash ); |
my $org_uid = $o->$value_from || warn "can't find org_uid in $value_from in ",dump( $o->as_hash ); |
76 |
my $action = Jifty->web->new_action( |
sync_org( $org_uid ); |
77 |
class => 'SyncOrganization', |
} |
78 |
moniker => 'sync', |
} |
79 |
arguments => { |
|
80 |
org_uid => $org_uid, |
if ( $strix ) { |
81 |
} |
my $instances = A3C::Model::StrixInstanceCollection->new; |
82 |
); |
$instances->unlimit; |
83 |
$action->run; |
my $o_nr = 1; |
84 |
if ( $action->result->success ) { |
while ( my $instance = $instances->next ) { |
85 |
Jifty->log->info( $action->result->message ); |
Jifty->log->info( 'sync organization ', $o_nr++, '/', $instances->count, ' ', $instance->instance ); |
86 |
} else { |
sync_org( $instance->instance ); |
|
Jifty->log->error( "Can't sync ", $o->name ); |
|
|
} |
|
87 |
} |
} |
88 |
} |
} |
89 |
|
|