RHQ CLI alert scripts

Lukas Krejci lkrejci at redhat.com
Fri Mar 29 12:45:55 UTC 2013


What version of RHQ are you seeing this in?

If it is 4.6.0, I think you have discovered a regression due to our move to 
AS7 that slipped through our fingers.

If it is prior to 4.6.0 then this is even more serious bug.

In either case, I've created 
https://bugzilla.redhat.com/show_bug.cgi?id=928971 and will take a look at it 
soon.

It seems that there currently isn't any workaround. The server-side scripting 
is currently mightily broken in RHQ 4.6.0 - or rather, one cannot use any of 
the standard APIs we provide to access RHQ server's functionality from the 
scripts.

Thanks for reporting this,

Lukas

On Thursday, March 28, 2013 11:17:31 Ken Rumer wrote:
> I'm seeing different results in CLI scripts depending on if I run them from
> the CLI or the alert kicks them off.  A simple example is here:
> 
> ---CLI---------------------
> var tomcatServer = ProxyFactory.getResource(14008);
> tomcatServer;
> #ResourceClientProxy_$$_javassist_0:
> #                         availability: ?
> #                             children:
> #                         contentTypes: {}
> #                          createdDate: Mon Mar 18 13:42:11 PDT 2013
> #                          description: Tomcat Web Application Server
> (tstcdemo3)
> #                              handler:
> org.rhq.bindings.client.ResourceClientProxy$ClientProxyMethodHandler at d751189
> #                                   id: 14008
> #                         measurements: [Server Identifier, Availability]
> #                         modifiedDate: Mon Mar 18 13:42:11 PDT 2013
> #                                 name: Tomcat (8080)
> #                           operations: [restart, start,
> storeConfiguration, shutdown]
> #                  pluginConfiguration:
> #        pluginConfigurationDefinition: ConfigurationDefinition[id=10314,
> name=Tomcat Server]
> #                         resourceType: Tomcat Server
> #                     serverIdentifier: ?
> #                              version: 7.0.37.0
> tomcatServer.restart(); // This works like a charm
> ---CLI Alert--(tomcat.restart.js)---
>   var myResource = ProxyFactory.getResource(
> alert.alertDefinition.resource.id);
>   var e = exporter;
>   e.setTarget('raw', '/local/mnt/workspace/tomcat.restart.out');
>   e.write(myResource);
>   myResource.restart();
> ---CLI Alert output----------
> Ran script tomcat.restart.js in version rhqadmin: 1.0 from repo
> cli.remediation as user rhqadmin.
> javax.script.ScriptException:org.mozilla.javascript.EcmaError: TypeError:
> Cannot find function restart in object [14008] Tomcat (8080) (Tomcat
> Server::Tomcat). (#9) in at line number 9 in script tomcat.restart.js
> (rhqadmin: 1.0) in repo cli.remediation at line number 9
> ---exporter output-----------
> cat tomcat.restart.out
> #ResourceClientProxy:
> #                  id: 14008
> #                name: Tomcat (8080)
> #             version: 7.0.37.0
> #        resourceType: Tomcat Server
> #            children:
> #        contentTypes: {}
> #         createdDate: Mon Mar 18 13:42:11 PDT 2013
> #         description: Tomcat Web Application Server (tstcdemo3)
> #        measurements: [Server Identifier, Availability]
> #        modifiedDate: Mon Mar 18 13:42:11 PDT 2013
> #          operations: [restart, start, storeConfiguration, shutdown]
> 
> 
> 
> 
> Why is the object different in CLI vs export output?
> "ResourceClientProxy_$$_javassist_0" vs "ResourceClientProxy"
> 
> If there's a better way to do this, let me know!


More information about the rhq-devel mailing list