VMware Cloud Community
Eichenbaum
Contributor
Contributor
Jump to solution

Run Command in Guest: : dnscmd

I am using Run Command in Guest to execute the below commands on a windows host. The account running the command has authorizations to run these command.

cmd.exe /c dnscmd xx.xx.xx.xx /recorddelete some.dns.host hostName1 A xx.xx.xx.xx /f

cmd.exe /c dnscmd xx.xx.xx.xx /recorddelete some.dns.host hostname1 PTR  /f

(actual IP info and hostnames are concealed to protect the innocent)

Both run successfully (and as intended) if run interactively from a CMD prompt, I get the expected result and a nslookup on the hostname indicates '...can't find <hostname>: Non-existend domain' as expected. (img1 attached)

If run via the Run Command in Guest, the first command executes (to remove the A record, however, while the second command seems to run, the PTR record isn't removed and nslookup on the hostname returns 'Name: <hostname>" (img2 attached)

Thoughts?


Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

Here's a snippet of "command" object processing from one of the articles on my blog: How to run a PERL Script from a vCenter Orchestrator Workflow


// Prepare Command line and parameters to execute:

cmd = scriptName + " " + scriptParams;

System.debug("executing cmd: " + cmd);


// Create and execute the command:

var command = new Command(cmd);

command.execute(true);


// Display command results and output

var scriptResult = command.result;

System.debug("Script Result: " + scriptResult);



var scriptOutput = command.output;

System.debug("Script Output: " + scriptOutput);

As you can see from the above code, you'll want to take a look at the results and output of your cmd object's execution. Hopefully that output will contain some clue as to why your second command is failing...

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
7 Replies
jcp0wermac
Enthusiast
Enthusiast
Jump to solution

Does the account that you are logging in with on your workflow have access to change DNS records?

0 Kudos
Eichenbaum
Contributor
Contributor
Jump to solution

I am advised the service account associated with running the vCO flows has full permissions to change DNS records. Do note the first command to delete the A record does execute successfully via the same vCO flow.

0 Kudos
jcp0wermac
Enthusiast
Enthusiast
Jump to solution

I assume you are using Command object to execute this right?  From execute are you getting 0 and an result from output on both?  Maybe put a sleep in between both running commands?  I don't usually use this object, for my AD/DNS operations in Orchestrator I use the PowerShell plug-in.

Burke-
VMware Employee
VMware Employee
Jump to solution

Okay, Run Command In Guest implies that you are running Guest Operations so this is not using the "command" object to run these commands locally on the vCO host, right?

These two commands... are you attempting to run them with a single call to the remote machine or two sequential calls? I've only attempted single calls.  Have you tried putting a short delay between the two calls?

If the first command is running, that does seem to indicate that the credentials being used are sufficient. You might want to try piping the output of your command into a log text file to see what is happening...

Something along the lines of:

cmd.exe /c dnscmd xx.xx.xx.xx /recorddelete some.dns.host hostname1 PTR  /f >> c:\dnscmndResults.txt

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
Eichenbaum
Contributor
Contributor
Jump to solution

OK... my mistake. I mis-recalled how I was doing this. Just checked the flow... I'm doing this within scriptable task with the below code. Each of the values within the first two lines are attributes from the flow.

var cmd0 = "cmd.exe /c dnscmd" + " " + hostDNS + " " + recordRemoveCmd + " " + zoneName + " " + nodeName + " " + typeA + " " + vmIP + " /f";

var cmd1 = "cmd.exe /c dnscmd" + " " + hostDNS + " " + recordRemoveCmd + " " + zoneName + " " + nodeName + " " + typePTR + " /f";

var command0 = new Command(cmd0);

var command1 = new Command(cmd1);

command0.execute (true);

System.sleep(10000);

command1.execute (true);

System.sleep(10000);

Server.log(cmd0);

System.log(cmd0);

Server.log(cmd1);

System.log(cmd1);

0 Kudos
jcp0wermac
Enthusiast
Enthusiast
Jump to solution

Check the return value from the execute method.  It should be 0 for both commands, non-zero is an error.

Burke-
VMware Employee
VMware Employee
Jump to solution

Here's a snippet of "command" object processing from one of the articles on my blog: How to run a PERL Script from a vCenter Orchestrator Workflow


// Prepare Command line and parameters to execute:

cmd = scriptName + " " + scriptParams;

System.debug("executing cmd: " + cmd);


// Create and execute the command:

var command = new Command(cmd);

command.execute(true);


// Display command results and output

var scriptResult = command.result;

System.debug("Script Result: " + scriptResult);



var scriptOutput = command.output;

System.debug("Script Output: " + scriptOutput);

As you can see from the above code, you'll want to take a look at the results and output of your cmd object's execution. Hopefully that output will contain some clue as to why your second command is failing...

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos