Update Resource Configs via rhq-cli
Rafael Soares
rafaelcba at gmail.com
Tue May 31 23:56:33 UTC 2011
I put the script here: http://bit.ly/lgjSfD
Thanks.
---
Rafael
On Tue, May 31, 2011 at 19:18, Jay Shaughnessy <jshaughn at redhat.com> wrote:
>
> Nice job, Rafael. Other will find this useful, I'm sure.
>
> On 5/31/2011 12:10 AM, Rafael Soares wrote:
> > Hello Guys!
> >
> > I applyed more time in this issue and now I got the solution! o/
> >
> > A script like this solve my problem:
> >
> > var rgc = new ResourceGroupCriteria();
> > rgc.addFilterName("JBossAS5-Instances");
> > rgc.fetchExplicitResources(true);
> > var jbossGroupList =
> > ResourceGroupManager.findResourceGroupsByCriteria(rgc);
> > rgc.fetchExplicitResources(true);
> > var jbossGroup = jbossGroupList.get(0);
> > var jbossResourcesArray = jbossGroup.explicitResources.toArray();
> >
> > for( i in jbossResourcesArray ) {
> > var res = jbossResourcesArray[i];
> > var jboss = ProxyFactory.getResource(res.id <http://res.id>);
> > var avail =
> > AvailabilityManager.getCurrentAvailabilityForResource(jboss.id
> > <http://jboss.id>);
> >
> > println("");
> > println("");
> > println(" " + jboss.name <http://jboss.name> );
> > println(" - Availability: " + avail.availabilityType.getName());
> > println(" - Started : " + avail.startTime.toGMTString());
> > println("");
> >
> > var jbossConfig =
> > ConfigurationManager.getPluginConfiguration(jboss.id <http://jboss.id>);
> > var jbossConfigPropList = jbossConfig.getList("logEventSources");
> > var jbossConfigLogEventSourcesMap = jbossConfigPropList.list.get(0);
> >
> > var jbossConfigLogEventSourcesMapPropertySimpleEnabled =
> > jbossConfigLogEventSourcesMap.getSimple("enabled");
> >
> >
> jbossConfigLogEventSourcesMapPropertySimpleEnabled.setBooleanValue(true);
> >
> > var jbossConfigLogEventSourcesMapPropertySimpleIncludesPattern =
> > jbossConfigLogEventSourcesMap.getSimple("includesPattern");
> >
> >
> jbossConfigLogEventSourcesMapPropertySimpleIncludesPattern.setStringValue(".*SQLException.*");
> >
> > var jbossConfigLogEventSourcesMapPropertySimpleMinimumSeverity =
> > jbossConfigLogEventSourcesMap.getSimple("minimumSeverity");
> >
> >
> jbossConfigLogEventSourcesMapPropertySimpleMinimumSeverity.setStringValue("error");
> >
> > ConfigurationManager.updatePluginConfiguration(jboss.id
> > <http://jboss.id>, jbossConfig);
> >
> > var latestPluginConfigurations =
> > ConfigurationManager.getLatestPluginConfigurationUpdate(jboss.id
> > <http://jboss.id>);
> > println("latestPluginConfigurations: " +
> > latestPluginConfigurations.toString());
> > }
> >
> > Now I can automate the logEvents configuration for all my JBossAS
> > instances in the RHQ inventory - with a simple JS script and the power
> > of rhq-cli \o/.
> >
> > Thanks.
> > ____________________________
> > Rafael Torres Coelho Soares
> > rafaelcba at gmail.com <mailto:rafaelcba at gmail.com>
> > http://rafaeltuelho.wordpress.com
> > Brasília - DF - Brasil
> >
> >
> > On Mon, May 30, 2011 at 16:49, Rafael Soares <rafaelcba at gmail.com
> > <mailto:rafaelcba at gmail.com>> wrote:
> >
> > Hello!
> >
> > I need to enable the log events for a lot of JBossAS5 resources.
> > This task is boring and takes a long time to finish if you do it
> > manually through RHQ UI. So I'm trying to do this via rhq-cli. how
> > can I update a JBossAS5 resource's configuration using the RHQ
> > Remote/Domain API?
> >
> > I'm trying using a JS script like this:
> >
> > var serverJBoss = ProxyFactory.getResource(<resource ID>);
> > var mapJBossConfig =
> >
> serverJBoss.pluginConfiguration.getMap().get("logEventSources").getList().get(0).getMap();
> >
> > This return a java.util.Map holding the PropertySimple's objects
> > like this:
> >
> > {*enabled*=PropertySimple[id=345369, name=enabled, value=false,
> > override=null], *logFilePath*=PropertySimple[id=345368,
> > name=logFilePath,
> > value=/u01/app/jboss/jboss-4.2.2.GA/server/defaul/log/server.log
> > <http://jboss-4.2.2.GA/server/defaul/log/server.log>,
> > override=null], *includesPattern*=PropertySimple[id=345371,
> > name=includesPattern, value=null, override=null],
> > *minimumSeverity*=PropertySimple[id=345372, name=minimumSeverity,
> > value=null, override=null], *dateFormat*=PropertySimple[id=345370,
> > name=dateFormat, value=null, override=null]}
> >
> > After update these ProperySimple's objs how can I update the
> > Resource's Configuration on Server? Can someone help me?
> >
> > Thanks!
> > ____________________________
> > Rafael Torres Coelho Soares
> > rafaelcba at gmail.com <mailto:rafaelcba at gmail.com>
> > http://rafaeltuelho.wordpress.com
> > Brasília - DF - Brasil
> >
> >
> >
> > _______________________________________________
> > rhq-devel mailing list
> > rhq-devel at lists.fedorahosted.org
> > https://fedorahosted.org/mailman/listinfo/rhq-devel
> _______________________________________________
> rhq-devel mailing list
> rhq-devel at lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/rhq-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://fedorahosted.org/pipermail/rhq-devel/attachments/20110531/58ad023c/attachment.html
More information about the rhq-devel
mailing list