Hi All,
Can I use SDK API to assign static IP address to VM when cloning a new VM? I used VI Client to do it but it failed. Therefore, I am wondering if SDK API can do this. Can anyone give me a sample code?
Thank you very much.
Jeff
Jeff,
I thought we had some sample code posted on Code Central but now I cant find it,,;( What language were you needing this in.. ?
regards,
Pablo
http://communities.vmware.com/community/developer/codecentral
Hi Pablo,
Thanks for your response. I need java example for assigning IP address to VM and I did not find any sample code yet.
Can you give me a sample code for that?
regards,
Jeff
I asked our SDK Dev Support to lend a hand,,, Java it is,, anyone for C# ?
-P
Thank you very much!!!
Jeff
Hello Jeff,
Please find the attached sample code that our dev team cooked up.
Note:
In this class, look for “deployVMFromTemplate” method. That
method contains “CustomizationIPSettings” object, and we are setting the IP of
that object to DHCP IP. To make it static instead of setting its IP to
“CustomizationDhcpIpGenerator”, the user needs to set it to
“CustomizationFixedIp” which has “ipAddress” as its property.
Thank you,
Nava
Hi,
There's only one field named ipAddress in CustomizationFixedIp, and how to specify netmask and gateway? Thanks.
Hi,
Have you got the exact code to assign static IP?
Thanks,
Here's some sample code leveraging vSphere Management SDK for Java to assign static IP to a VM as part of cloning an existing template to create the new VM.
The code samples from above link are not from me. Besides, ensure that VMware tools are installed in your template (i.e. in the VM you use for template creation). Since assigning an IP to a VM is an operation on the guest OS, you need VMware tools to be able to pass the values to the guest OS.