Changeset 1354 for trunk/LATMOS-Accounts
- Timestamp:
- 06/24/15 15:36:23 (9 years ago)
- Location:
- trunk/LATMOS-Accounts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts.pm
r1242 r1354 223 223 } 224 224 225 my $labfrom = $options{from} ? $self->base($options{from}) : $self-> default_base;225 my $labfrom = $options{from} ? $self->base($options{from}) : $self->base; 226 226 227 227 my @labto = -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
r1206 r1354 274 274 275 275 my %desterror; 276 my %existings;277 276 my $updated = 0; 278 277 foreach my $destbase ($self->to) { … … 281 280 $destbase->is_supported_object($otype) or next; 282 281 283 $existings{$otype} ||= { map { $_ => 1 } 282 my %existings; 283 my %filtering; 284 285 $existings{$otype} = { map { $_ => 1 } 284 286 $self->from->list_objects($otype) }; 285 287 288 # Is there a filter to apply: 289 my $filtername = 'filter.' . $destbase->label . '.' . $otype; 290 if (my $filter = $self->{options}->{$filtername}) { 291 la_log(LA_DEBUG, "Found %s param, using it: %s", $filtername, $filter); 292 $filtering{$otype} = { map { $_ => 1 } 293 $self->from->search_objects($otype, $filter) }; 294 } else { 295 $filtering{$otype} = $existings{$otype}; 296 } 297 298 286 299 # deleting non existing object in dest: 300 my $deletefiltered = 'deletefiltered.' . $destbase->label . '.' . $otype; 287 301 foreach ($destbase->list_objects($otype)) { 288 if(!$existings{$otype}{$_}) { 289 if (my $res = $destbase->sync_object_from($self->from, 290 $otype, $_, %options)) { 291 la_log(LA_NOTICE, "%s::%s::%s => %s %s", 292 $self->from->label, $otype, $_, $destbase->label, $res, 293 ); 294 if ($destbase->is_transactionnal) { 295 $destbase->commit; 296 } 297 $updated = 1; 298 } else { 299 if ($destbase->is_transactionnal) { 300 $destbase->rollback; 301 } 302 303 if ($filtering{$otype}{$_}) { 304 # the object must exists 305 next; 306 } elsif ($existings{$otype}{$_}) { 307 # object exists but is filtered 308 if (!$self->{options}->{$deletefiltered}) { 309 next; 310 } 311 } 312 313 if (my $res = $destbase->sync_object_from($self->from, 314 $otype, $_, %options)) { 315 la_log(LA_NOTICE, "%s::%s::%s => %s %s", 316 $self->from->label, $otype, $_, $destbase->label, $res, 317 ); 318 if ($destbase->is_transactionnal) { 319 $destbase->commit; 320 } 321 $updated = 1; 322 } else { 323 if ($destbase->is_transactionnal) { 324 $destbase->rollback; 302 325 } 303 326 } 304 327 } 305 328 306 @{$objlist{$otype}} = $self->from->list_objects_from_rev( 329 # Finding object to synchronize: 330 @{$objlist{$otype}} = grep { $filtering{$otype}{$_} } $self->from->list_objects_from_rev( 307 331 $otype, 308 332 $self->val($self->from->label, $destbase->label, 0), 309 333 ); 310 334 } 335 336 my %objectok; 311 337 foreach my $pass (1, 0) { 312 338 foreach my $otype ($destbase->ordered_objects) { 313 339 exists($objlist{$otype}) or next; 314 340 foreach (@{$objlist{$otype} || []}) { 341 342 # If first synchro is not ok, don't retry to sync the object 343 if ((!$pass) && (!$objectok{$otype}{$_})) { 344 next; 345 } 346 315 347 my $res = $destbase->sync_object_from($self->from, $otype, $_, 316 348 %options, firstpass => $pass); … … 325 357 } 326 358 $updated = 1; 359 $objectok{$otype}{$_} = 1; 327 360 } 328 361 } else { … … 336 369 } 337 370 } 338 339 371 } 340 372 } -
trunk/LATMOS-Accounts/man/man5/latmos-accounts.ini.pod
r1249 r1354 135 135 feature (SQL only at time) 136 136 137 =head3 filtering object propagation 138 139 It is possible to filter the objects you want to propagate into peer base. 140 141 The filter to apply must be set into the parameter named 142 C<filter.BASENAME.OTYPE>, where C<BASENAME> is the name of the destination 143 base and C<OTYPE> the object type to filter. 144 145 For example to push into C<ldap> base only user being into group C<unix>: 146 147 filter.ldap.user = memberOf=unix 148 149 =head3 Deleting filtered object 150 151 By default filtered object will not be deleted to the destination base, neither 152 touched. 153 154 Setting option in form C<deletefiltered.BASENAME.OTYPE> to true will allow 155 deletion. This option has effects only if filtering objects is enabled. 156 137 157 =head1 SEE ALSO 138 158
Note: See TracChangeset
for help on using the changeset viewer.