VMware Cloud Community
koushik_vmware
Enthusiast
Enthusiast
Jump to solution

"Commad" is not executed properly in vro7 workflow...no error is showing in the workflow....

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 ?

nsupdate command.png

Thanks,

Koushik

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

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

View solution in original post

0 Kudos
9 Replies
tschoergez
Leadership
Leadership
Jump to solution

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

0 Kudos
koushik_vmware
Enthusiast
Enthusiast
Jump to solution

Thanks Joerg, I checked the file js-io-rights.conf file (below is the content) and it seems fine to me..

js-io-rights.png

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

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

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?

0 Kudos
koushik_vmware
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

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:

  • add some debug log statements to print values of interesting variables like nsupdStr, tmpFilePath, etc
  • the line var resultOutput = command.result; is not correct way to get command output; it should be var resultOutput = command.output;
  • try to execute a simpler command; like var command = new Command("cat " + tmpFilePath); to figure out if it is failing only for nsupdate or also for other Linux commands.
0 Kudos
koushik_vmware
Enthusiast
Enthusiast
Jump to solution

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';

  1. System.log("nsupdStr>>>" + nsupdStr);

  1. tmpFile.write(nsupdStr);

var nsUpdCmd = 'nsupdate -k /etc/vco/app-server/security/ddns-update.key ' + tmpFilePath;

var catCmd = 'cat ' + tmpFilePath;

  1. System.log("executing cat command : "+catCmd);

var command = new Command(catCmd);

  1. command.execute(true);
  2. System.log("cat command result : "+ command.result);
  3. System.log("cat command output : "+ command.output);

  1. System.log("executing nsupdate cmd: " + nsUpdCmd);

var command = new Command(nsUpdCmd);

try{

  1. command.execute(true);

var resultNumber = command.result;

  1. System.log("nsupdate cmd resultNumber: " + resultNumber);

var resultOutput = command.output;

  1. System.log("nsupdate resultOutput: " + resultOutput);

}catch(err){

  1. System.log("Exception: " + err);

throw ("Exception nsupdate .#####" + err);

}

finally{

var tmpFile = new File(tmpFilePath);

  1. 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:

_________________________________________________________

0 Kudos
koushik_vmware
Enthusiast
Enthusiast
Jump to solution

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:

_________________________________________________________

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

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

0 Kudos
koushik_vmware
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos