I'm slowly working on a set of workflows that will integrate with a powershell module I have created.
For my first workflow, I'm in the process of figuring out all the information I need when a user executes an orchestrator workflow on a virtual machine.
So far i've figured out the cluster but i'm having trouble identifying the right scripting object that will provide me with the fqdn for a vcenter host corresponding to that VM.
Being new to vCO doesn't help a great deal either.
I figured it would be part of VcManagedEntity but for some reason, that page results in a big ol 404!
I thought maybe it would be part of vm.runtime.parent.parent but my script is leading to errors.
Any help would be greatly appreciated!
thank you.
I think now you are one the right path, the display name of the vCenter server will be localhost, so the response of vm.sdkConnection.setting.sdkConnection is localhost.
Maybe this will help:
var sdkConnection = vm.sdkConnection;
var optionManager = sdkConnection.optionManager;
var vCenterInstanceName = optionManager.queryOptions( "VirtualCenter.InstanceName" ).shift().value;
var vCenterFqdn = optionManager.queryOptions( "VirtualCenter.FQDN" ).shift().value;
System.log( "vCenter Instance Name: " + vCenterInstanceName );
System.log( "vCenter FQDN: " + vCenterFqdn );
Where I think your instance name will show localhost.
But FQDN should be the thing you are searching.
Cheers
Using the vc:virtualmachine object you can get what you need with something like this
vm = vc:virtualmachine
var vc = vm.sdkConnection.setting.sdkConnection
System.log(vc)
Hi sbeaver. Thanks for response. When i use
System.log("Vcenter: " + vc.name);
I get https://localhost:443/sdk
In my lab, my vcenter fqdn is serv-vc1.services.local
That's the value I'm trying to get.
thanks!
I am not sure you understood what I was posting so using the vc:virtualmachine object try the workflow in the package attached to this post
My mistake. Thank you for being so patient.
When I try to import the package into the orchestrator client, it reports an error
"Unable to extract package from raw data"
I simply unzipped the zip and then imported the package from the Packages tab in the vCO client.
Am i missing something?
thank you again. I hope "likes" are used like currency here.
If it helps, here's the scripting tab for my workflow.
The schema is very simple. It's just a single scriptable task
var cluster = ((vm.runtime).host.parent);
var vc = vm.sdkConnection.setting.sdkConnection;
Server.log("Hello, " + vm.displayName);
Server.log("VM ID: " + vm.id);
Server.log("VM Cluster: " + cluster.name);
Server.log("vCenter: " + vc.name);
not sure why the export is not working so lets go old school
Please create a new workflow. Create an input named vm that is a VC:VirtualMachine type. add a Scriptable Task. In the Visual Binding area drag the in Parameter vm over to the in of the scriptable task. and in the scripting are add this code please
var vc = vm.sdkConnection.setting.sdkConnection
System.log(vc.toString())
You will get the Virtual Center name in a string form in the log
If you need the variable vc in a string format and not the object you can use the code this way
var vc = vm.sdkConnection.setting.sdkConnection.toString();
System.log(vc)
Hi @sbeaver,
That's pretty much what I have plus some additional information as you can see in the javascript i posted earlier.
The result of System.log("vCenter: " + vc.toString()) is
"vCenter: localhost"
I guess something may be misconfigured on my esx host? or on my vcenter?
Can you ssh to the vCenter appliance and report the output of this command
hostname
yup. First thing i did
It's not a vcenter appliance. It's a VM in the environment running windows and vCenter Server 5.1.0,799731
not the latest and greatest but the hostname command returns with
"Serv-vc1"
What is that VM's display name in vCenter?
I think now you are one the right path, the display name of the vCenter server will be localhost, so the response of vm.sdkConnection.setting.sdkConnection is localhost.
Maybe this will help:
var sdkConnection = vm.sdkConnection;
var optionManager = sdkConnection.optionManager;
var vCenterInstanceName = optionManager.queryOptions( "VirtualCenter.InstanceName" ).shift().value;
var vCenterFqdn = optionManager.queryOptions( "VirtualCenter.FQDN" ).shift().value;
System.log( "vCenter Instance Name: " + vCenterInstanceName );
System.log( "vCenter FQDN: " + vCenterFqdn );
Where I think your instance name will show localhost.
But FQDN should be the thing you are searching.
Cheers
here's what i see in the web client.
In vcenter, it's listed as SERV-VC1.services.local
Try the following ('vm' is the name of your virtual machine scripting object)
var dnsConfig = vm.summary.runtime.host.configManager.networkSystem.networkInfo.dnsConfig;
System.log("host name -> " + dnsConfig.hostName);
System.log("domain name -> " + dnsConfig.domainName);
This did it!
Thank you very much. Where is the information you provided documented?
how did you know to look for VirtualCenter.InstanceName?
thanks!
Take a look into your vCenter Client and navigate to:
Administration --> vCenter Server Settings... --> Advanced Settings
There you can see vCenter settings and with the option manager you can read em off vCenter. Where it is documented? In my head, it's my practical knowledge 😉
One more thing you have to check out: https://<vcenterip>/mob this is the manages object browser where you can see the vCenter API and attributes and so on and where you can take a look by your own what is where provided 🙂
ChristianWehner Thanks so much! I completely forgot about the mob!
That is very useful information. The Advanced Settings isn't nearly as nice as the mob though.
thanks again!