Hello All,
I am trying to execute the below nsupdate command via "Command" class in vRO7 workflow. The workflow is executed properly but when I checked i found that nsupdate command is not executed properly. I am not getting any error in the Workflow. the resultOutput is showing "2"... I am confused ..no idea how to execute the command using "Command" properly.....please help me out ..
Here "tmpFilePath" is the name of sh file which contents valid script. Is anything more needs to be configured ?
Thanks,
Koushik
Could you check the ownership/permissions of the file /etc/vco/app-server/security/ddns-update.key ?
You can do it eg. executing the following command in a Linux terminal
ll /etc/vco/app-server/security/
If the owner/group is set to root (perhaps set to root when you copied the file), then could you change owner/group to vco with the following command and try again to execute the workflow?
chown vco:vco /etc/vco/app-server/security/ddns-update.key
Make sure that the js-io-rights.conf file is configured properly, so that vRO has access to all the files needed. Also check filesystem permissions.
I assume you have activated the config parameter to allow execution of local scripts?
Check this section of the documentation for both... Setting System Properties
Regards,
Joerg
Thanks Joerg, I checked the file js-io-rights.conf file (below is the content) and it seems fine to me..
Also I checked the vmo.properties file and the local process is true there. If it is not true then I will get the an-authorized error during script execution. But this is not the case here.
com.vmware.js.allow-local-process = true
So, I am pretty much sure there is some issue with the permission. But strange thing is that there is no error in the script.
Can you please let me know any other way to check the same ? Thanks once again for your help.
Thanks,
Koushik
command.result is the status code of the command. In your case, it returns 2 which by *nix convention should be an error (0 - success, >0 - errors).
What happens if you manually execute the same 'nsupdate ...' command in a terminal?
Hello llian,
Thanks for your suggestion.
Yes, you are correct. when I executed manually the same nsupdate command in terminal it was executed successfully. I can see the correct output in the terminal.
That means there is something mistake during executing the same from workflow. Not sure where is the mistake. Waiting for your suggestion.
thanks,
koushik
Could you provide the whole workflow? From the snippet, it is not clear how tmpFile is opened, how tmpFilePath is set, etc.
Also, I'd suggest to:
Thanks llian.
please see below full script and the output. (I have put some dummy values for nameServer, natIPAddr and publishURL)
The debug statement is added.
Output is handled correct way.
Simple 'cat' command is working fine.
So, issue with the nsupdate command execution. Is there anything configured/permission for key file located at "/etc/vco/app-server/security/ddns-update.key"?
Please check and let me know.
Thanks,
Koushik
******************** scripting code **************************************
var publishURL = 'vrava7.xxxx.xxxx.com';
var nameServer = 'xxx.xx.xxx.xx';
var ttlInSeconds = '38400';
var natIPAddr ='xxx.xx.xxx.xx';
var tmpFile = System.createTempFile(".sh");
var tmpFilePath = tmpFile.path;
var nsupdStr = 'server ' + nameServer + "\n";
nsupdStr += 'update add ' + publishURL + ' ' + ttlInSeconds
+ ' A ' + natIPAddr;
nsupdStr += '\nsend\n';
var nsUpdCmd = 'nsupdate -k /etc/vco/app-server/security/ddns-update.key ' + tmpFilePath;
var catCmd = 'cat ' + tmpFilePath;
var command = new Command(catCmd);
var command = new Command(nsUpdCmd);
try{
var resultNumber = command.result;
var resultOutput = command.output;
}catch(err){
throw ("Exception nsupdate .#####" + err);
}
finally{
var tmpFile = new File(tmpFilePath);
}
**************************************************************************
Output :
____________________________________________
[2016-06-16 13:57:13.081] [I] nsupdStr>>>server xxx.xx.xxx.xx
update add vrava7.xxxx.xxxx.com 38400 A xxx.xx.xxx.xx
send
[2016-06-16 13:57:13.083] [I] executing cat command : cat /var/lib/vco/app-server/temp/vco-2082763454758528673.sh
[2016-06-16 13:57:13.090] [I] cat command result : 0
[2016-06-16 13:57:13.091] [I] cat command output : server xxx.xx.xxx.xx
update add vrava7.xxxx.xxxx.com 38400 A xxx.xx.xxx.xx
send
[2016-06-16 13:57:13.091] [I] executing nsupdate cmd: nsupdate -k /etc/vco/app-server/security/ddns-update.key /var/lib/vco/app-server/temp/vco-2082763454758528673.sh
[2016-06-16 13:57:13.150] [I] nsupdate cmd resultNumber: 1
[2016-06-16 13:57:13.151] [I] nsupdate resultOutput:
_________________________________________________________
Thanks llian.
please see below full script and the output. (I have put some dummy values for nameServer, natIPAddr and publishURL)
The debug statement is added.
Output is handled correct way.
Simple 'cat' command is working fine.
So, issue with the nsupdate command execution. Is there anything configured/permission for key file located at "/etc/vco/app-server/security/ddns-update.key"?
Please check and let me know.
Thanks,
Koushik
******************** scripting code **************************************
var publishURL = 'vrava7.xxxx.xxxx.com';
var nameServer = 'xxx.xx.xxx.xx';
var ttlInSeconds = '38400';
var natIPAddr ='xxx.xx.xxx.xx';
var tmpFile = System.createTempFile(".sh");
var tmpFilePath = tmpFile.path;
var nsupdStr = 'server ' + nameServer + "\n";
nsupdStr += 'update add ' + publishURL + ' ' + ttlInSeconds
+ ' A ' + natIPAddr;
nsupdStr += '\nsend\n';
System.log("nsupdStr>>>" + nsupdStr);
tmpFile.write(nsupdStr);
var nsUpdCmd = 'nsupdate -k /etc/vco/app-server/security/ddns-update.key ' + tmpFilePath;
var catCmd = 'cat ' + tmpFilePath;
System.log("executing cat command : "+catCmd);
var command = new Command(catCmd);
command.execute(true);
System.log("cat command result : "+ command.result);
System.log("cat command output : "+ command.output);
System.log("executing nsupdate cmd: " + nsUpdCmd);
var command = new Command(nsUpdCmd);
try{
command.execute(true);
var resultNumber = command.result;
System.log("nsupdate cmd resultNumber: " + resultNumber);
var resultOutput = command.output;
System.log("nsupdate resultOutput: " + resultOutput);
}catch(err){
System.log("Exception: " + err);
throw ("Exception nsupdate .#####" + err);
}
finally{
var tmpFile = new File(tmpFilePath);
tmpFile.deleteFile();
}
**************************************************************************
Output :
____________________________________________
[2016-06-16 13:57:13.081] [I] nsupdStr>>>server xxx.xx.xxx.xx
update add vrava7.xxxx.xxxx.com 38400 A xxx.xx.xxx.xx
send
[2016-06-16 13:57:13.083] [I] executing cat command : cat /var/lib/vco/app-server/temp/vco-2082763454758528673.sh
[2016-06-16 13:57:13.090] [I] cat command result : 0
[2016-06-16 13:57:13.091] [I] cat command output : server xxx.xx.xxx.xx
update add vrava7.xxxx.xxxx.com 38400 A xxx.xx.xxx.xx
send
[2016-06-16 13:57:13.091] [I] executing nsupdate cmd: nsupdate -k /etc/vco/app-server/security/ddns-update.key /var/lib/vco/app-server/temp/vco-2082763454758528673.sh
[2016-06-16 13:57:13.150] [I] nsupdate cmd resultNumber: 1
[2016-06-16 13:57:13.151] [I] nsupdate resultOutput:
_________________________________________________________
Could you check the ownership/permissions of the file /etc/vco/app-server/security/ddns-update.key ?
You can do it eg. executing the following command in a Linux terminal
ll /etc/vco/app-server/security/
If the owner/group is set to root (perhaps set to root when you copied the file), then could you change owner/group to vco with the following command and try again to execute the workflow?
chown vco:vco /etc/vco/app-server/security/ddns-update.key
Thanks llian for your support and assistance. You are absolutely correct. I got resolved the issue after changing the owner of the key/private files to vco:vco.
Now, everything is working as expected. Thanks once again.
Koushik