Hi All,

I'm facing an issue in invoking Cloudinit while customization in RHEV 3.6 using RHEV Java SDK 3.6.

Below link says we need to explicitly call use_cloud_init=True, but i'm not sure how to pass this value as parameter while creating VM.

http://users.ovirt.narkive.com/BGUkanAk/ovirt-users-cloud-init-not-apply-when-v-create-from-api


My Code:
String password = "password"; //"password"

String templateName = "centos6.7-final";
String clusterName = "Default";
String vmName = "testVM3";

//Prepare the data to create the VM from the template:
org.ovirt.engine.sdk.entities.Template templateData = new Template();
templateData.setName(templateName);
org.ovirt.engine.sdk.entities.Cluster clusterData = new Cluster();
clusterData.setName(clusterName);
org.ovirt.engine.sdk.entities.VM vmDataForCreate = new VM();
vmDataForCreate.setName(vmName);
vmDataForCreate.setCluster(clusterData);
vmDataForCreate.setTemplate(templateData);

api.getVMs().add(vmDataForCreate);
String state;
for (;;) {
 state = api.getVMs().get(vmName).getStatus().getState();
if ("down".equals(state)) {
  break;
}
Thread.sleep(1000);
}
System.out.println("System Status:"+state); 
org.ovirt.engine.sdk.entities.User userData = new User();
userData.setUserName("root");
userData.setPassword(password);
Users usersData = new Users();
usersData.getUsers().add(userData);
CloudInit cloudData = new CloudInit();


cloudData.setUsers(usersData);
Host hostData = new Host();
hostData.setAddress(vmName);
cloudData.setHost(hostData);

org.ovirt.engine.sdk.entities.NetworkConfiguration networkConfiguration=new NetworkConfiguration();

networkConfiguration.setNics(new Nics());

Nics nics = networkConfiguration.getNics();
nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true));

networkConfiguration.setNics(nics);

cloudData.setNetworkConfiguration(networkConfiguration);

Initialization initData = new Initialization();

initData.setCloudInit(cloudData);

VM vmDataForStart = new VM();
vmDataForStart.setInitialization(initData);
Action actionData = new Action();

actionData.setVm(vmDataForStart);

// Send the request to start the VM to the server:
api.getVMs().get(vmName).start(actionData);

--
Thanks & Regards
Tejesh