You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Gareth <ga...@gmail.com> on 2014/05/27 23:39:10 UTC
Bulk Delete Configurations
Hello,
Any way to bulk delete configurations? I realize I have created 30000
instances of a factory pid which shouldn't be there. I know I can create a
script to delete the pids. Just wondering whether there may be another way.
thanks in advance,
Gareth
--
View this message in context: http://karaf.922171.n3.nabble.com/Bulk-Delete-Configurations-tp4033294.html
Sent from the Karaf - User mailing list archive at Nabble.com.
RE: Bulk Delete Configurations
Posted by Benjamin Debeerst <Be...@younicos.com>.
Hi Gareth,
In a programmatic way, that's relatively easy. You can use the Configuration Admin Service and call listConfigurations(String filter), with a filter like "(service.factoryPid=YouFactoryPid)". Then you can call delete() on all of the returned Configuration objects. Beware that the ConfigAdmin returns null rather than an empty array in case there is no configuration matching the filter. (See docs [1][2]).
I'm unaware of an easy possibility to do this with a script "from outside", i.e. the console or similar.
Regards,
Benjamin
[1] http://www.osgi.org/javadoc/r4v42/org/osgi/service/cm/ConfigurationAdmin.html#listConfigurations%28java.lang.String%29
[2] http://www.osgi.org/javadoc/r4v42/org/osgi/service/cm/Configuration.html#delete%28%29
-----Original Message-----
From: Gareth [mailto:gareth.o.collins@gmail.com]
Sent: Dienstag, 27. Mai 2014 23:39
To: user@karaf.apache.org
Subject: Bulk Delete Configurations
Hello,
Any way to bulk delete configurations? I realize I have created 30000 instances of a factory pid which shouldn't be there. I know I can create a script to delete the pids. Just wondering whether there may be another way.
thanks in advance,
Gareth
--
View this message in context: http://karaf.922171.n3.nabble.com/Bulk-Delete-Configurations-tp4033294.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Bulk Delete Configurations
Posted by Gareth <ga...@gmail.com>.
Thanks for all the answers! I actually tried something like this (the tee was
to put the output to file - is there a better way?):
karaf@root> config:list "(<my pid query>)" | grep service.pid | exec tee
/tmp/badconfigs.txt
Then this to create the commands (there were some weird characters in the
output):
sed --expression="s/.*=/config:delete/g;s/...$//g" badconfigs.txt
which I could then feed into karaf.
One thing I noted - when I tried to add the "sed" expression to the karaf
command line the execution became very slow (even the tee slowed down karaf
a lot). I guess that is just a limitation of the implementation? Also is
there any way to pipe the commands into karaf directly for execution without
using a temporary file?
thanks in advance,
Gareth
--
View this message in context: http://karaf.922171.n3.nabble.com/Bulk-Delete-Configurations-tp4033294p4033326.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Bulk Delete Configurations
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
By the way, I think config:delete accept wildcard (my.pid*) AFAIR.
If not, it could be a good addition ;)
Regards
JB
On 05/27/2014 11:39 PM, Gareth wrote:
> Hello,
>
> Any way to bulk delete configurations? I realize I have created 30000
> instances of a factory pid which shouldn't be there. I know I can create a
> script to delete the pids. Just wondering whether there may be another way.
>
> thanks in advance,
> Gareth
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Bulk-Delete-Configurations-tp4033294.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Bulk Delete Configurations
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Gareth,
You can do that:
- using the ConfigAdmin service programmatically
- using the ConfigMBean (remotely programmatically)
- using a script that use config:* commands (local or remote using ssh)
Regards
JB
On 05/27/2014 11:39 PM, Gareth wrote:
> Hello,
>
> Any way to bulk delete configurations? I realize I have created 30000
> instances of a factory pid which shouldn't be there. I know I can create a
> script to delete the pids. Just wondering whether there may be another way.
>
> thanks in advance,
> Gareth
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Bulk-Delete-Configurations-tp4033294.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com