VMware {code} Community
sasama1997
Contributor
Contributor

IP of a virtual machine is changed with the CloneVM_Task(SDK for JAVA)

Hello.

I am making the clone of a virtual machine from the template now.

At that time, I want to change IP.

It tries to set IP that wants to change to VirtualMachineCloneSpec.

customization.nicSettingMap.adapter.ip.

However, what you set to CustomizationIpGenerator is not understood.

First of all, should I acquire DynamicData?

How can I acquire it?

//***********************************************************

//***********************************************************

CustomizationIpGenerator genIP = new CustomizationIpGenerator();

CustomizationIPSettings customIP = new CustomizationIPSettings();

     //Is DynamicData acquired?

customIP.setIp(genIP);

     //Is IP newly set?

     String clonedName = cloneName;

System.out.println("Launching clone task to create a clone: "

+ clonedName);

try {

ManagedObjectReference cloneTask

= service.cloneVM_Task(vmRef, vmFolderRef, clonedName, cloneSpec);

String status = cb.getServiceUtil().waitForTask(cloneTask);

if(status.equalsIgnoreCase("failure")) {

System.out.println("Failure -: Virtual Machine cannot be cloned");

}

if(status.equalsIgnoreCase("sucess")) {

System.out.println("Virtual Machine Cloned successfully.");

}

//************************************************************

I survive terribly when I understand this.

My best regards.

Reply
0 Kudos
1 Reply
njain
Expert
Expert

Hi,

The "CustomizationIpGenerator" class is further extended by four classes, that is, "CustomizationCustomIpGenerator", "CustomizationDhcpIpGenerator", "CustomizationFixedIp" and "CustomizationUnknownIpGenerator". This in order to set "customization.nicSettingMap.adapter.ip" property, you need to implement either of these classes that suits your needs. For example, if you need to provide a static IP address, you can implement the CustomizationFixedIp by setting the "ipAddress" property.

Another thread that might be of interest to you:

http://communities.vmware.com/message/987752

Regards,

Neha

Reply
0 Kudos