Hello, I am working on modifying the vcenter clone workflow to automate network related information assignment, such as: ip, network address, gateway, DNS server, DomainName etc. I need to get it directly from vCenter API, not vCloud API; assuming that customer who is going to use this workflow, has no vCloud Director, just vCenter.
The only way I found out so far is to pre-create a customization spec with these default network information using vSphere Customization Manager, and using these during clone workflow. Please see my scripts below.
My question is: Is there any other way to get these network information directly from VC:VirtualMachine?
Thanks,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var custspec = new VcCustomizationSpec();
var con = vm.sdkConnection;
var cms = con.customizationSpecManager;
var customSpecExists = cms.doesCustomizationSpecExist(specName);
if (customSpecExists) {
var customSpecItem = cms.getCustomizationSpec(specName);
custspec = customSpecItem.spec;
var name = customSpecItem.info.name;
} else throw "customspec not found";
var ip = custspec.nicSettingMap[0].adapter.ip.ipAddress;
var dnsServerList = custspec.nicSettingMap[0].adapter.dnsServerList;
dnsDomain = custspec.nicSettingMap[0].adapter.dnsDomain;
netmask = custspec.nicSettingMap[0].adapter.subnetMask;
gateway = custspec.nicSettingMap[0].adapter.gateway;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jjang84,
VC:VirtualMachine should have an "guest" attribute of type VcGuestInfo which should contain the guest's hostname, IP address as well as a property of type VcGuestStackInfo which should contain DNS information. Offhand, I'm not sure how you'd grab the default gateway or netmask although I would say it would be part of the "ipRouteConfig" property of the VcGuestStackInfo.
Below are links to the API information:
http://www.vmware.com/support/orchestrator/doc/vco_vsphere51_api/html/VcVirtualMachine.html
http://www.vmware.com/support/orchestrator/doc/vco_vsphere51_api/html/VcGuestInfo.html
http://www.vmware.com/support/orchestrator/doc/vco_vsphere51_api/html/VcGuestStackInfo.html