On Fri, 6 Sep 2013 03:09:46 -0400, Sebastien Goasguen wrote:
On Aug 28, 2013, at 11:16 PM, "Han,Meng" <meng...@ufl.edu> wrote:
Hi Sebasiten,
This type of error happens even when I define a very simple api,
e.g. output the whirr version.
2013-08-27 17:56:48,662 - requester.py:45 - [DEBUG] ======== START
Request ========
2013-08-27 17:56:48,662 - requester.py:45 - [DEBUG] Requesting
command=launchCluster, args={'config': '1'}
2013-08-27 17:56:48,663 - requester.py:45 - [DEBUG] Request sent:
http://localhost:8080/client/api?apiKey=3lwqSg6E1yS4vvF37mz7HshOp_3N9rHoDoXMoWsRcbaisMz5-_WnnwgzHaAeUi49cMMtb8GbzkPzvBA3WEqzMw&command=launchCluster&config=1&response=json&signature=xCb%2BX06aGT5%2Bd0iDQR3BbIBdYhM%3D
2013-08-27 17:56:52,254 - requester.py:45 - [DEBUG] Response
received: { "launchCluster" : { "launchCluster" : {"output":"Apache
Whirr ${project.version}jclouds 1.6.1-incubatingnull"} } }
2013-08-27 17:56:52,254 - requester.py:45 - [DEBUG] ======== END
Request ========
The following is the response object:
public class LaunchClusterResponse extends BaseResponse {
@SerializedName(ApiConstants.IS_ASYNC) @Param(description = "true
if api is asynchronous")
private Boolean isAsync;
@SerializedName("output") @Param(description = "whirr output")
private String output;
public LaunchClusterResponse(){
}
public void setAsync(Boolean isAsync) {
this.isAsync = isAsync;
}
public boolean getAsync() {
return isAsync;
}
public void setOutPut(String output) {
this.output = output;
}
public String getOutput(){
return output;
}
}
The following is the execute method of the command object.
public void execute() {
LaunchClusterResponse response = new LaunchClusterResponse();
response.setObjectName("launchCluster");
response.setResponseName(getCommandName());
String cmdToExec;
cmdToExec = "whirr version ";
try {
Process proc = Runtime.getRuntime().exec(cmdToExec);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
String stdout = "",stderr = "",s;
while ((s = stdInput.readLine()) != null) {
stdout=stdout+s;
}
while ((s = stdInput.readLine()) != null) {
stderr=stderr+s;
}
output = stdout+stderr;
} catch (IOException ex) {
Logger.getLogger(LaunchClusterCmd.class.getName()).log(Level.SEVERE,
null, ex);
}
response.setOutPut(output);
this.setResponseObject(response);
}
Thanks!
So what do you get in cloudmonkey, can you send the json ?
Sebastien, below is what I get in CloudMonkey:
2013-08-27 17:56:48,662 - requester.py:45 - [DEBUG] ======== START
Request ========
2013-08-27 17:56:48,662 - requester.py:45 - [DEBUG] Requesting
command=launchCluster, args={'config': '1'}
2013-08-27 17:56:48,663 - requester.py:45 - [DEBUG] Request sent:
http://localhost:8080/client/api?apiKey=3lwqSg6E1yS4vvF37mz7HshOp_3N9rHoDoXMoWsRcbaisMz5-_WnnwgzHaAeUi49cMMtb8GbzkPzvBA3WEqzMw&command=launchCluster&config=1&response=json&signature=xCb%2BX06aGT5%2Bd0iDQR3BbIBdYhM%3D
2013-08-27 17:56:52,254 - requester.py:45 - [DEBUG] Response received:
{ "launchCluster" : { "launchCluster" : {"output":"Apache Whirr
${project.version}jclouds 1.6.1-incubatingnull"} } }
2013-08-27 17:56:52,254 - requester.py:45 - [DEBUG] ======== END
Request ========
Thank you!
On Wed, 28 Aug 2013 03:10:31 -0400, Sebastien Goasguen wrote:
On Aug 27, 2013, at 6:08 PM, "Han,Meng" <meng...@ufl.edu> wrote:
Hi folks,
I am adding an api (launch cluster) to CloudStack and using
CloudMonkey to test the api.
From the CloudMonkey log file I can see that the request was
executed on the server side and return correct response, however,
CloudMonkey was forced to quit because the following error:
launchCluster config=hadoop.properties
Traceback (most recent call last):
File "/usr/bin/cloudmonkey", line 9, in <module>
load_entry_point('cloudmonkey==5.0.0', 'console_scripts',
'cloudmonkey')()
File
"/usr/lib/python2.6/site-packages/cloudmonkey/cloudmonkey.py", line
536, in main
shell.cmdloop()
File
"/usr/lib/python2.6/site-packages/cloudmonkey/cloudmonkey.py", line
106, in cmdloop
super(CloudMonkeyShell, self).cmdloop(intro="")
File "/usr/lib64/python2.6/cmd.py", line 142, in cmdloop
stop = self.onecmd(line)
File "/usr/lib64/python2.6/cmd.py", line 218, in onecmd
return self.default(line)
File
"/usr/lib/python2.6/site-packages/cloudmonkey/cloudmonkey.py", line
303, in default
result = self.make_request(apiname, args_dict, isasync)
File
"/usr/lib/python2.6/site-packages/cloudmonkey/cloudmonkey.py", line
257, in make_request
self.timeout, self.protocol, self.path)
File "/usr/lib/python2.6/site-packages/cloudmonkey/requester.py",
line 121, in monkeyrequest
responsekey = filter(lambda x: 'response' in x,
response.keys())[0]
IndexError: list index out of range
Meng, this actually might be an issue with your response object in
java, make sure that it is properly defined.
You can also send us the json that's returned via cloudmonkey
Could someone give me a pointer why this is happening?
Thanks!
Cheers,
Meng