summaryrefslogtreecommitdiffstats
path: root/install/ui/association.js
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2011-08-25 14:57:44 +0200
committerEndi S. Dewata <edewata@redhat.com>2011-08-25 15:57:00 +0000
commit50a898855c044d88d069c69dfe5d2659e4eceed9 (patch)
treef0cff85a8d5bb37cfeaf5e87118e5a49fbdc8d99 /install/ui/association.js
parentfcd927a126ebcee2b38e8f8bb05ea38cf018b1e2 (diff)
downloadfreeipa-50a898855c044d88d069c69dfe5d2659e4eceed9.tar.gz
freeipa-50a898855c044d88d069c69dfe5d2659e4eceed9.tar.xz
freeipa-50a898855c044d88d069c69dfe5d2659e4eceed9.zip
Modify serial associator to use batch
https://fedorahosted.org/freeipa/ticket/1688 The serial associator is used to execute a command multiple times with different parameters. This is used for adding/removing a user into/from multiple groups. It has some issues: Each command is executed one-by-one, so it could be slow. * If there's a failure the rest of the commands will not be executed. * This can be fixed by putting the commands into a batch and execute them at once.
Diffstat (limited to 'install/ui/association.js')
-rw-r--r--install/ui/association.js36
1 files changed, 19 insertions, 17 deletions
diff --git a/install/ui/association.js b/install/ui/association.js
index b79a18f06..1c9776b0e 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -64,28 +64,30 @@ IPA.serial_associator = function(spec) {
return;
}
- var value = that.values.shift();
- if (!value) {
- that.on_success();
- return;
- }
-
- var args = [value];
- var options = {};
- options[that.entity.name] = that.pkey;
-
- var command = IPA.command({
- entity: that.other_entity,
- method: that.method,
- args: args,
- options: options,
- on_success: that.execute,
+ var batch = IPA.batch_command({
+ on_success: that.on_success,
on_error: that.on_error
});
+ var args, options, command;
+
+ for(var i=0; i < that.values.length; i++) {
+ args = [that.values[i]];
+ options = {};
+ options[that.entity.name] = that.pkey;
+
+ command = IPA.command({
+ entity: that.other_entity,
+ method: that.method,
+ args: args,
+ options: options
+ });
+
+ batch.add_command(command);
+ }
//alert(JSON.stringify(command.to_json()));
- command.execute();
+ batch.execute();
};
return that;