Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK

On 02/12/2014 03:14 PM, Tejesh M wrote:
Hi,
Can anyone share sample code on how to assign IP address to guest os & changing the root password while creating VM from Template using Java SDK?
-- Thanks & Regards Lucky
_______________________________________________ rhevm-api mailing list rhevm-api@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/rhevm-api
this list isn't used any more, moving to users@ovirt.org

On 12.02.14 22:55, Itamar Heim wrote:
On 02/12/2014 03:14 PM, Tejesh M wrote:
Hi,
Can anyone share sample code on how to assign IP address to guest os & changing the root password while creating VM from Template using Java SDK? Hi Tejesh, You should start here: http://www.ovirt.org/Api This link will explain the basics for fetching VM via the API using HTTP via curl command line.
Every VM have a collection of networks and manipulating them can be seeing here with the REST API examples: http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST the section for you is "Attaching a network to a NIC" under the REST category. Shahar Havivi.
-- Thanks & Regards Lucky
_______________________________________________ rhevm-api mailing list rhevm-api@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/rhevm-api
this list isn't used any more, moving to users@ovirt.org

----- Original Message -----
From: "Shahar Havivi" <shaharh@redhat.com> To: users@ovirt.org Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com>, rhevm-api@lists.fedorahosted.org, "Tejesh M" <tejeshmk@gmail.com> Sent: Wednesday, February 12, 2014 11:22:20 PM Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK
On 12.02.14 22:55, Itamar Heim wrote:
On 02/12/2014 03:14 PM, Tejesh M wrote:
Hi,
Can anyone share sample code on how to assign IP address to guest os & changing the root password while creating VM from Template using Java SDK? Hi Tejesh, You should start here: http://www.ovirt.org/Api This link will explain the basics for fetching VM via the API using HTTP via curl command line.
Every VM have a collection of networks and manipulating them can be seeing here with the REST API examples: http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST the section for you is "Attaching a network to a NIC" under the REST category.
Shahar Havivi.
Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. See more in "http://www.ovirt.org/Features/Cloud-Init_Integration". If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog. Omer - we have REST API support for cloud-init, right?
-- Thanks & Regards Lucky
_______________________________________________ rhevm-api mailing list rhevm-api@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/rhevm-api
this list isn't used any more, moving to users@ovirt.org
Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

Yes, there is REST support, but for ovirt < 3.4 the JSON submitted data format is incomplete, this is just documented in a BZ somewhere. So in order to pass all data successfully, you need to use XML. (especially for the root password) JSON should be supported from 3.4 but I didn't test this myself yet. PS: Be aware: IPv6 is not supported as well, you might want to write your own cloud-init parser script and pass additional info via the "attach text file" method. HTH Am 13.02.2014 06:59, schrieb Oved Ourfalli:
Omer - we have REST API support for cloud-init, right?--
Mit freundlichen Grüßen / Regards Sven Kieske Systemadministrator Mittwald CM Service GmbH & Co. KG Königsberger Straße 6 32339 Espelkamp T: +49-5772-293-100 F: +49-5772-293-333 https://www.mittwald.de Geschäftsführer: Robert Meyer St.Nr.: 331/5721/1033, USt-IdNr.: DE814773217, HRA 6640, AG Bad Oeynhausen Komplementärin: Robert Meyer Verwaltungs GmbH, HRB 13260, AG Bad Oeynhausen

On 13.02.14 00:59, Oved Ourfalli wrote:
----- Original Message -----
From: "Shahar Havivi" <shaharh@redhat.com> To: users@ovirt.org Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com>, rhevm-api@lists.fedorahosted.org, "Tejesh M" <tejeshmk@gmail.com> Sent: Wednesday, February 12, 2014 11:22:20 PM Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK
On 12.02.14 22:55, Itamar Heim wrote:
On 02/12/2014 03:14 PM, Tejesh M wrote:
Hi,
Can anyone share sample code on how to assign IP address to guest os & changing the root password while creating VM from Template using Java SDK? Hi Tejesh, You should start here: http://www.ovirt.org/Api This link will explain the basics for fetching VM via the API using HTTP via curl command line.
Every VM have a collection of networks and manipulating them can be seeing here with the REST API examples: http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST the section for you is "Attaching a network to a NIC" under the REST category.
Shahar Havivi.
Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. See more in "http://www.ovirt.org/Features/Cloud-Init_Integration". If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog.
Omer - we have REST API support for cloud-init, right?
Yes, more on that can be found here: http://www.ovirt.org/Features/vm-init-persistent
-- Thanks & Regards Lucky
_______________________________________________ rhevm-api mailing list rhevm-api@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/rhevm-api
this list isn't used any more, moving to users@ovirt.org
Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 02/13/2014 09:29 AM, Shahar Havivi wrote:
On 13.02.14 00:59, Oved Ourfalli wrote:
----- Original Message -----
From: "Shahar Havivi" <shaharh@redhat.com> To: users@ovirt.org Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com>, rhevm-api@lists.fedorahosted.org, "Tejesh M" <tejeshmk@gmail.com> Sent: Wednesday, February 12, 2014 11:22:20 PM Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK
On 12.02.14 22:55, Itamar Heim wrote:
On 02/12/2014 03:14 PM, Tejesh M wrote:
Hi,
Can anyone share sample code on how to assign IP address to guest os & changing the root password while creating VM from Template using Java SDK? Hi Tejesh, You should start here: http://www.ovirt.org/Api This link will explain the basics for fetching VM via the API using HTTP via curl command line.
Every VM have a collection of networks and manipulating them can be seeing here with the REST API examples: http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST the section for you is "Attaching a network to a NIC" under the REST category.
Shahar Havivi.
Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. See more in "http://www.ovirt.org/Features/Cloud-Init_Integration". If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog.
Omer - we have REST API support for cloud-init, right?
Yes, more on that can be found here: http://www.ovirt.org/Features/vm-init-persistent
Tajesh, you have a detailed example of how to set the password in the following message: http://lists.ovirt.org/pipermail/users/2014-February/021302.html Setting the IP address is similar. -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

Hi All, Thanks alot. I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but no luck, the code is not setting root password. Also, there is no option to set *Hostname *for the VM. *Code:* /*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/"; // You need to know the name of the template, the cluster and // the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm"; // 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); // Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a while): for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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); 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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/ Thanks & Regards, Tejesh On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote:
On 13.02.14 00:59, Oved Ourfalli wrote:
----- Original Message -----
From: "Shahar Havivi" <shaharh@redhat.com> To: users@ovirt.org Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com>,
rhevm-api@lists.fedorahosted.org, "Tejesh M"
<tejeshmk@gmail.com> Sent: Wednesday, February 12, 2014 11:22:20 PM Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK
On 12.02.14 22:55, Itamar Heim wrote:
On 02/12/2014 03:14 PM, Tejesh M wrote:
Hi,
Can anyone share sample code on how to assign IP address to guest os & changing the root password while creating VM from Template using Java SDK? Hi Tejesh, You should start here: http://www.ovirt.org/Api This link will explain the basics for fetching VM via the API using HTTP via curl command line.
Every VM have a collection of networks and manipulating them can be seeing here with the REST API examples: http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST the section for you is "Attaching a network to a NIC" under the REST category.
Shahar Havivi.
Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. See more in "http://www.ovirt.org/Features/Cloud-Init_Integration". If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog.
Omer - we have REST API support for cloud-init, right? Yes, more on that can be found here: http://www.ovirt.org/Features/vm-init-persistent
Tajesh, you have a detailed example of how to set the password in the following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh

Hi, what cloud-init version and which OS do you run inside the vm? background: the ovirt-payload function generates an iso file from your cloud-init data and attaches this to the vm. this feature is just working if you got cloud-init >= 0.7.2 inside the vm, which is not available e.g. in centos < 6.5 and ubuntu 12.04. I don't know which data format the java sdk uses as default, so make sure you are passing XML, not JSON. HTH Am 13.02.2014 14:39, schrieb Tejesh M:
Hi All,
Thanks alot.
I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but no luck, the code is not setting root password.
Also, there is no option to set *Hostname *for the VM.
*Code:*
/*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/";
// You need to know the name of the template, the cluster and // the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm";
// 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);
// Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a while): for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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);
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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/
Thanks & Regards, Tejesh
On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote:
On 13.02.14 00:59, Oved Ourfalli wrote:
----- Original Message -----
From: "Shahar Havivi" <shaharh@redhat.com> To: users@ovirt.org Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com>,
rhevm-api@lists.fedorahosted.org, "Tejesh M"
<tejeshmk@gmail.com> Sent: Wednesday, February 12, 2014 11:22:20 PM Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK
On 12.02.14 22:55, Itamar Heim wrote:
On 02/12/2014 03:14 PM, Tejesh M wrote: > Hi, > > Can anyone share sample code on how to assign IP address to guest os & > changing the root password while creating VM from Template using Java SDK? Hi Tejesh, You should start here: http://www.ovirt.org/Api This link will explain the basics for fetching VM via the API using HTTP via curl command line.
Every VM have a collection of networks and manipulating them can be seeing here with the REST API examples: http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST the section for you is "Attaching a network to a NIC" under the REST category.
Shahar Havivi.
Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. See more in "http://www.ovirt.org/Features/Cloud-Init_Integration". If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog.
Omer - we have REST API support for cloud-init, right? Yes, more on that can be found here: http://www.ovirt.org/Features/vm-init-persistent
Tajesh, you have a detailed example of how to set the password in the following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Mit freundlichen Grüßen / Regards Sven Kieske Systemadministrator Mittwald CM Service GmbH & Co. KG Königsberger Straße 6 32339 Espelkamp T: +49-5772-293-100 F: +49-5772-293-333 https://www.mittwald.de Geschäftsführer: Robert Meyer St.Nr.: 331/5721/1033, USt-IdNr.: DE814773217, HRA 6640, AG Bad Oeynhausen Komplementärin: Robert Meyer Verwaltungs GmbH, HRB 13260, AG Bad Oeynhausen

On 02/13/2014 02:58 PM, Sven Kieske wrote:
Hi,
what cloud-init version and which OS do you run inside the vm?
background: the ovirt-payload function generates an iso file from your cloud-init data and attaches this to the vm. this feature is just working if you got cloud-init >= 0.7.2 inside the vm, which is not available e.g. in centos < 6.5 and ubuntu 12.04.
I don't know which data format the java sdk uses as default, so make sure you are passing XML, not JSON.
The Java SDK always uses XML.
HTH
Am 13.02.2014 14:39, schrieb Tejesh M:
Hi All,
Thanks alot.
I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but no luck, the code is not setting root password.
Also, there is no option to set *Hostname *for the VM.
*Code:*
/*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/";
// You need to know the name of the template, the cluster and // the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm";
// 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);
// Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a while): for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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);
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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/
Thanks & Regards, Tejesh
On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote:
On 13.02.14 00:59, Oved Ourfalli wrote:
----- Original Message -----
From: "Shahar Havivi" <shaharh@redhat.com> To: users@ovirt.org Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com>,
rhevm-api@lists.fedorahosted.org, "Tejesh M"
<tejeshmk@gmail.com> Sent: Wednesday, February 12, 2014 11:22:20 PM Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK
On 12.02.14 22:55, Itamar Heim wrote: > On 02/12/2014 03:14 PM, Tejesh M wrote: >> Hi, >> >> Can anyone share sample code on how to assign IP address to guest os & >> changing the root password while creating VM from Template using Java SDK? Hi Tejesh, You should start here: http://www.ovirt.org/Api This link will explain the basics for fetching VM via the API using HTTP via curl command line.
Every VM have a collection of networks and manipulating them can be seeing here with the REST API examples: http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST the section for you is "Attaching a network to a NIC" under the REST category.
Shahar Havivi.
Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. See more in "http://www.ovirt.org/Features/Cloud-Init_Integration". If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog.
Omer - we have REST API support for cloud-init, right? Yes, more on that can be found here: http://www.ovirt.org/Features/vm-init-persistent
Tajesh, you have a detailed example of how to set the password in the following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

I have several questions as I have ZERO experience with oVirt and I'm hoping to save myself any headaches before diving in. For the sake of argument, I have a Centos 6.5 box running KVM with several VMs already active. The storage is local, hardware RAID 5 and is set to libvirt default /var/lib/libvirt/images. I would make ISO storage something like /home/iso as that's where I have available space for 20-30 gigs of ISOs. 1. Is this proper in the first place or should I be using freshly installed Virtualization enabled machine? Otherwise: 2. For storage type should I say POSIXFS, ie ext4? 3. Is there any issue with just pointing storage to the libvirt default /var/lib/libvirt/images where my VMs currently live? Thank you for your time.

On 02/13/2014 02:39 PM, Tejesh M wrote:
Hi All,
Thanks alot.
I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but no luck, the code is not setting root password.
What version of the engine are you running? I may not have the required cloud-init support. Try to run the application in debug mode: Api api = new Api( "https://whatever/api", "user@domain", "password", null, null, null, null, true, null, true // <- This is to enable debug mode ); It will send to the log the actual XML documents sent to the server. We can use it to see if the request is generated correctly. It may also happen that cloud-init support isn't working correctly. To verify this try to use the cloud-init support manually from webadmin. Does it work from there?
Also, there is no option to set *Hostname *for the VM.
To set the host name you need to add something like this: Host hostData = new Host(); hostData.setAddress("the.host.name"); cloudData.setHost(hostData);
_*Code:*_
/*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/";
// You need to know the name of the template, the cluster and // the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm";
// 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);
// Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a while): for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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);
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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/
Thanks & Regards, Tejesh
On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote: > On 13.02.14 00:59, Oved Ourfalli wrote: >> >> >> ----- Original Message ----- >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com>> >>> To: users@ovirt.org <mailto:users@ovirt.org> >>> Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>>, rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>, "Tejesh M" >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK >>> >>> On 12.02.14 22:55, Itamar Heim wrote: >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: >>>>> Hi, >>>>> >>>>> Can anyone share sample code on how to assign IP address to guest os & >>>>> changing the root password while creating VM from Template using Java SDK? >>> Hi Tejesh, >>> You should start here: >>> http://www.ovirt.org/Api >>> This link will explain the basics for fetching VM via the API using HTTP via >>> curl command line. >>> >>> Every VM have a collection of networks and manipulating them can be seeing >>> here with the REST API examples: >>> http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST >>> the section for you is "Attaching a network to a NIC" under the REST >>> category. >>> >>> Shahar Havivi. >>> >> >> Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. >> See more in "http://www.ovirt.org/Features/Cloud-Init_Integration". >> If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog. >> >> Omer - we have REST API support for cloud-init, right? > Yes, more on that can be found here: > http://www.ovirt.org/Features/vm-init-persistent >>
Tajesh, you have a detailed example of how to set the password in the following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

1. The Version is RHEV-M 3.3 & Cloud-init is cloud-init-0.6.3-0.12.bzr532.el6.noarch 2. In Webadmin, i don't find any option to set Cloud-init data's. I checked under New VM->Initial Run.. Am i looking at the right place? How to enable cloud-init support in engine? I have installed cloud-init package in RHEV-M & also in Template. Please suggest. On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/13/2014 02:39 PM, Tejesh M wrote:
Hi All,
Thanks alot.
I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but no luck, the code is not setting root password.
What version of the engine are you running? I may not have the required cloud-init support.
Try to run the application in debug mode:
Api api = new Api( "https://whatever/api", "user@domain", "password", null, null, null, null, true, null, true // <- This is to enable debug mode );
It will send to the log the actual XML documents sent to the server. We can use it to see if the request is generated correctly.
It may also happen that cloud-init support isn't working correctly. To verify this try to use the cloud-init support manually from webadmin. Does it work from there?
Also, there is no option to set *Hostname *for the VM.
To set the host name you need to add something like this:
Host hostData = new Host(); hostData.setAddress("the.host.name"); cloudData.setHost(hostData);
_*Code:*_
/*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/";
// You need to know the name of the template, the cluster and // the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm";
// 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);
// Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a while): for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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);
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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/
Thanks & Regards, Tejesh
On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote: > On 13.02.14 00:59, Oved Ourfalli wrote: >> >> >> ----- Original Message ----- >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com>> >>> To: users@ovirt.org <mailto:users@ovirt.org> >>> Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>>, rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>, "Tejesh M" >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK >>> >>> On 12.02.14 22:55, Itamar Heim wrote: >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: >>>>> Hi, >>>>> >>>>> Can anyone share sample code on how to assign IP address to guest os & >>>>> changing the root password while creating VM from Template using Java SDK? >>> Hi Tejesh, >>> You should start here: >>> http://www.ovirt.org/Api >>> This link will explain the basics for fetching VM via the API using HTTP via >>> curl command line. >>> >>> Every VM have a collection of networks and manipulating them can be seeing >>> here with the REST API examples: >>> http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST >>> the section for you is "Attaching a network to a NIC" under the
REST
>>> category. >>> >>> Shahar Havivi. >>> >> >> Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. >> See more in "http://www.ovirt.org/Features/Cloud-Init_Integration
".
>> If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog. >> >> Omer - we have REST API support for cloud-init, right? > Yes, more on that can be found here: > http://www.ovirt.org/Features/vm-init-persistent >>
Tajesh, you have a detailed example of how to set the password in the following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh

On 13.02.14 20:17, Tejesh M wrote:
1. The Version is RHEV-M 3.3 & Cloud-init is cloud-init-0.6.3-0.12.bzr532.el6.noarch
2. In Webadmin, i don't find any option to set Cloud-init data's. I checked under New VM->Initial Run.. Am i looking at the right place? How to enable cloud-init support in engine? You will not found it since you are working in 3.3 and this feature presented in 3.4. In 3.3 you can try to set the Cloud-Init via the Run-Once button.
I have installed cloud-init package in RHEV-M & also in Template.
Please suggest.
On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/13/2014 02:39 PM, Tejesh M wrote:
Hi All,
Thanks alot.
I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but no luck, the code is not setting root password.
What version of the engine are you running? I may not have the required cloud-init support.
Try to run the application in debug mode:
Api api = new Api( "https://whatever/api", "user@domain", "password", null, null, null, null, true, null, true // <- This is to enable debug mode );
It will send to the log the actual XML documents sent to the server. We can use it to see if the request is generated correctly.
It may also happen that cloud-init support isn't working correctly. To verify this try to use the cloud-init support manually from webadmin. Does it work from there?
Also, there is no option to set *Hostname *for the VM.
To set the host name you need to add something like this:
Host hostData = new Host(); hostData.setAddress("the.host.name"); cloudData.setHost(hostData);
_*Code:*_
/*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/";
// You need to know the name of the template, the cluster and // the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm";
// 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);
// Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a while): for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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);
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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/
Thanks & Regards, Tejesh
On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote: > On 13.02.14 00:59, Oved Ourfalli wrote: >> >> >> ----- Original Message ----- >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com>> >>> To: users@ovirt.org <mailto:users@ovirt.org> >>> Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>>, rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>, "Tejesh M" >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK >>> >>> On 12.02.14 22:55, Itamar Heim wrote: >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: >>>>> Hi, >>>>> >>>>> Can anyone share sample code on how to assign IP address to guest os & >>>>> changing the root password while creating VM from Template using Java SDK? >>> Hi Tejesh, >>> You should start here: >>> http://www.ovirt.org/Api >>> This link will explain the basics for fetching VM via the API using HTTP via >>> curl command line. >>> >>> Every VM have a collection of networks and manipulating them can be seeing >>> here with the REST API examples: >>> http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST >>> the section for you is "Attaching a network to a NIC" under the
REST
>>> category. >>> >>> Shahar Havivi. >>> >> >> Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. >> See more in "http://www.ovirt.org/Features/Cloud-Init_Integration
".
>> If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog. >> >> Omer - we have REST API support for cloud-init, right? > Yes, more on that can be found here: > http://www.ovirt.org/Features/vm-init-persistent >>
Tajesh, you have a detailed example of how to set the password in the following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh

On 02/13/2014 03:59 PM, Shahar Havivi wrote:
On 13.02.14 20:17, Tejesh M wrote:
1. The Version is RHEV-M 3.3 & Cloud-init is cloud-init-0.6.3-0.12.bzr532.el6.noarch
2. In Webadmin, i don't find any option to set Cloud-init data's. I checked under New VM->Initial Run.. Am i looking at the right place? How to enable cloud-init support in engine? You will not found it since you are working in 3.3 and this feature presented in 3.4. In 3.3 you can try to set the Cloud-Init via the Run-Once button.
In 3.3 you need first to create the VM. Once it is created select it, click the "Run Once" button, then click on the plus sign next to "Initial Run", check the "Cloud-Init" box, and populate the fields you want.
I have installed cloud-init package in RHEV-M & also in Template.
Please suggest.
On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/13/2014 02:39 PM, Tejesh M wrote:
Hi All,
Thanks alot.
I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but no luck, the code is not setting root password.
What version of the engine are you running? I may not have the required cloud-init support.
Try to run the application in debug mode:
Api api = new Api( "https://whatever/api", "user@domain", "password", null, null, null, null, true, null, true // <- This is to enable debug mode );
It will send to the log the actual XML documents sent to the server. We can use it to see if the request is generated correctly.
It may also happen that cloud-init support isn't working correctly. To verify this try to use the cloud-init support manually from webadmin. Does it work from there?
Also, there is no option to set *Hostname *for the VM.
To set the host name you need to add something like this:
Host hostData = new Host(); hostData.setAddress("the.host.name"); cloudData.setHost(hostData);
_*Code:*_
/*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/";
// You need to know the name of the template, the cluster and // the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm";
// 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);
// Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a while): for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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);
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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/
Thanks & Regards, Tejesh
On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote: > On 13.02.14 00:59, Oved Ourfalli wrote: >> >> >> ----- Original Message ----- >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com>> >>> To: users@ovirt.org <mailto:users@ovirt.org> >>> Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>>, rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>, "Tejesh M" >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK >>> >>> On 12.02.14 22:55, Itamar Heim wrote: >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: >>>>> Hi, >>>>> >>>>> Can anyone share sample code on how to assign IP address to guest os & >>>>> changing the root password while creating VM from Template using Java SDK? >>> Hi Tejesh, >>> You should start here: >>> http://www.ovirt.org/Api >>> This link will explain the basics for fetching VM via the API using HTTP via >>> curl command line. >>> >>> Every VM have a collection of networks and manipulating them can be seeing >>> here with the REST API examples: >>> http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST >>> the section for you is "Attaching a network to a NIC" under the
REST
>>> category. >>> >>> Shahar Havivi. >>> >> >> Actually it looks like Tejesh is referring to the Guests and not the hosts, so you can use cloud-init in order to do that. >> See more in "http://www.ovirt.org/Features/Cloud-Init_Integration
".
>> If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog. >> >> Omer - we have REST API support for cloud-init, right? > Yes, more on that can be found here: > http://www.ovirt.org/Features/vm-init-persistent >>
Tajesh, you have a detailed example of how to set the password in the following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

Actually, i want to automate the vm provisioning through java sdk. and this urgent requirement. Is it possible to automate setting hostname, root password n nic info by any means in 3.3? Also in windows administration password as similar to linux.. kindly help as im new to this.. On 13 Feb 2014 20:32, "Juan Hernandez" <jhernand@redhat.com> wrote:
On 13.02.14 20:17, Tejesh M wrote:
1. The Version is RHEV-M 3.3 & Cloud-init is cloud-init-0.6.3-0.12.bzr532.el6.noarch
2. In Webadmin, i don't find any option to set Cloud-init data's. I checked under New VM->Initial Run.. Am i looking at the right place? How to enable cloud-init support in engine? You will not found it since you are working in 3.3 and this feature
On 02/13/2014 03:59 PM, Shahar Havivi wrote: presented
in 3.4. In 3.3 you can try to set the Cloud-Init via the Run-Once button.
In 3.3 you need first to create the VM. Once it is created select it, click the "Run Once" button, then click on the plus sign next to "Initial Run", check the "Cloud-Init" box, and populate the fields you want.
I have installed cloud-init package in RHEV-M & also in Template.
Please suggest.
On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez <jhernand@redhat.com>
wrote:
On 02/13/2014 02:39 PM, Tejesh M wrote:
Hi All,
Thanks alot.
I have created one VM with minimal installation & installed cloud-init package. And, converted that VM into Template. Then executed the code given in http://lists.ovirt.org/pipermail/users/2014-February/021302.html ,
no luck, the code is not setting root password.
What version of the engine are you running? I may not have the required cloud-init support.
Try to run the application in debug mode:
Api api = new Api( "https://whatever/api", "user@domain", "password", null, null, null, null, true, null, true // <- This is to enable debug mode );
It will send to the log the actual XML documents sent to the server. We can use it to see if the request is generated correctly.
It may also happen that cloud-init support isn't working correctly. To verify this try to use the cloud-init support manually from webadmin. Does it work from there?
Also, there is no option to set *Hostname *for the VM.
To set the host name you need to add something like this:
Host hostData = new Host(); hostData.setAddress("the.host.name"); cloudData.setHost(hostData);
_*Code:*_
/*********************Begin Customize VM*********************/ // Generate the random password, using whatever mechanism you // prefer: String password = "cJql3P9XLQG4drCYVG/6Q/";
// You need to know the name of the template, the cluster
and
// the VM you are going to create: String templateName = "rhel2_temp"; String clusterName = "testCluster"; String vmName = "myvm";
// 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);
// Send the request to create the VM to the server: api.getVMs().add(vmDataForCreate); String state; // White till the VM is down (it will be locked for a
while):
for (;;) { state = api.getVMs().get(vmName).getStatus().getState(); if ("down".equals(state)) { break; } Thread.sleep(1000); } System.out.println("System Status:"+state); // Populate parameters for the action to start the VM with cloud-init: 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);
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); System.out.println("After : "+api.getVMs().get(vmName).getStatus()); /*********************End Customize VM*********************/
Thanks & Regards, Tejesh
On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 09:29 AM, Shahar Havivi wrote: > On 13.02.14 00:59, Oved Ourfalli wrote: >> >> >> ----- Original Message ----- >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com>> >>> To: users@ovirt.org <mailto:users@ovirt.org> >>> Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>>, rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>, "Tejesh M" >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using Java SDK >>> >>> On 12.02.14 22:55, Itamar Heim wrote: >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: >>>>> Hi, >>>>> >>>>> Can anyone share sample code on how to assign IP address to guest os & >>>>> changing the root password while creating VM from Template using Java SDK? >>> Hi Tejesh, >>> You should start here: >>> http://www.ovirt.org/Api >>> This link will explain the basics for fetching VM via the API using HTTP via >>> curl command line. >>> >>> Every VM have a collection of networks and manipulating them
can
be seeing >>> here with the REST API examples: >>>
http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST
>>> the section for you is "Attaching a network to a NIC" under
REST
>>> category. >>> >>> Shahar Havivi. >>> >> >> Actually it looks like Tejesh is referring to the Guests and
not
the hosts, so you can use cloud-init in order to do that. >> See more in "
http://www.ovirt.org/Features/Cloud-Init_Integration ".
>> If the VM's operating system is defined as some kind of Linux, then you'll be able to set some stuff using cloud-init, either via the Run-Once Dialog, or in the regular VM properties dialog. >> >> Omer - we have REST API support for cloud-init, right? > Yes, more on that can be found here: > http://www.ovirt.org/Features/vm-init-persistent >>
Tajesh, you have a detailed example of how to set the password in
but the the
following message:
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
Setting the IP address is similar.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh
Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.

On 02/13/2014 05:15 PM, Tejesh M wrote:
Actually, i want to automate the vm provisioning through java sdk. and this urgent requirement. Is it possible to automate setting hostname, root password n nic info by any means in 3.3? Also in windows administration password as similar to linux.. kindly help as im new to this..
Yes, setting the hostname, root password and NIC info is possible in 3.3, using cloud-init and the Java SDK. I tested this with 3.3 and it works correctly. As you are having problems I suggest to try it manually, from the GUI, if it doesn't work then please report the details, so that we can diagnose and fix it. Once it works manually from the GUI, we can see why it doesn't work with the SDK, but we will need the output generated when running in debug mode.
On 13 Feb 2014 20:32, "Juan Hernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 03:59 PM, Shahar Havivi wrote: > On 13.02.14 20:17, Tejesh M wrote: >> 1. The Version is RHEV-M 3.3 & Cloud-init is >> cloud-init-0.6.3-0.12.bzr532.el6.noarch >> >> 2. In Webadmin, i don't find any option to set Cloud-init data's. I checked >> under New VM->Initial Run.. Am i looking at the right place? >> How to enable cloud-init support in engine? > You will not found it since you are working in 3.3 and this feature presented > in 3.4. > In 3.3 you can try to set the Cloud-Init via the Run-Once button. >
In 3.3 you need first to create the VM. Once it is created select it, click the "Run Once" button, then click on the plus sign next to "Initial Run", check the "Cloud-Init" box, and populate the fields you want.
>> >> I have installed cloud-init package in RHEV-M & also in Template. >> >> Please suggest. >> >> >> On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote: >> >>> On 02/13/2014 02:39 PM, Tejesh M wrote: >>>> Hi All, >>>> >>>> Thanks alot. >>>> >>>> I have created one VM with minimal installation & installed cloud-init >>>> package. And, converted that VM into Template. Then executed the code >>>> given in >>>> http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but >>>> no luck, the code is not setting root password. >>>> >>> >>> What version of the engine are you running? I may not have the required >>> cloud-init support. >>> >>> Try to run the application in debug mode: >>> >>> Api api = new Api( >>> "https://whatever/api", >>> "user@domain", >>> "password", >>> null, >>> null, >>> null, >>> null, >>> true, >>> null, >>> true // <- This is to enable debug mode >>> ); >>> >>> It will send to the log the actual XML documents sent to the server. We >>> can use it to see if the request is generated correctly. >>> >>> It may also happen that cloud-init support isn't working correctly. To >>> verify this try to use the cloud-init support manually from webadmin. >>> Does it work from there? >>> >>>> Also, there is no option to set *Hostname *for the VM. >>>> >>> >>> To set the host name you need to add something like this: >>> >>> Host hostData = new Host(); >>> hostData.setAddress("the.host.name <http://the.host.name>"); >>> cloudData.setHost(hostData); >>> >>>> >>>> >>>> _*Code:*_ >>>> >>>> /*********************Begin Customize VM*********************/ >>>> // Generate the random password, using whatever mechanism you >>>> // prefer: >>>> String password = "cJql3P9XLQG4drCYVG/6Q/"; >>>> >>>> // You need to know the name of the template, the cluster and >>>> // the VM you are going to create: >>>> String templateName = "rhel2_temp"; >>>> String clusterName = "testCluster"; >>>> String vmName = "myvm"; >>>> >>>> // 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); >>>> >>>> // Send the request to create the VM to the server: >>>> api.getVMs().add(vmDataForCreate); >>>> String state; >>>> // White till the VM is down (it will be locked for a while): >>>> for (;;) { >>>> state = api.getVMs().get(vmName).getStatus().getState(); >>>> if ("down".equals(state)) { >>>> break; >>>> } >>>> Thread.sleep(1000); >>>> } >>>> System.out.println("System Status:"+state); >>>> // Populate parameters for the action to start the VM with >>>> cloud-init: >>>> 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); >>>> >>>> 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); >>>> System.out.println("After : >>>> "+api.getVMs().get(vmName).getStatus()); >>>> /*********************End Customize VM*********************/ >>>> >>>> >>>> >>>> Thanks & Regards, >>>> Tejesh >>>> >>>> >>>> >>>> On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com> >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: >>>> >>>> On 02/13/2014 09:29 AM, Shahar Havivi wrote: >>>> > On 13.02.14 00:59, Oved Ourfalli wrote: >>>> >> >>>> >> >>>> >> ----- Original Message ----- >>>> >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com> >>>> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>>> >>>> >>> To: users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>> >>>> >>> Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com> >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>, rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> >>>> <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>>, "Tejesh M" >>>> >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>> >>>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM >>>> >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using >>>> Java SDK >>>> >>> >>>> >>> On 12.02.14 22:55, Itamar Heim wrote: >>>> >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: >>>> >>>>> Hi, >>>> >>>>> >>>> >>>>> Can anyone share sample code on how to assign IP address to >>>> guest os & >>>> >>>>> changing the root password while creating VM from Template >>>> using Java SDK? >>>> >>> Hi Tejesh, >>>> >>> You should start here: >>>> >>> http://www.ovirt.org/Api >>>> >>> This link will explain the basics for fetching VM via the API >>>> using HTTP via >>>> >>> curl command line. >>>> >>> >>>> >>> Every VM have a collection of networks and manipulating them can >>>> be seeing >>>> >>> here with the REST API examples: >>>> >>> http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST >>>> >>> the section for you is "Attaching a network to a NIC" under the >>> REST >>>> >>> category. >>>> >>> >>>> >>> Shahar Havivi. >>>> >>> >>>> >> >>>> >> Actually it looks like Tejesh is referring to the Guests and not >>>> the hosts, so you can use cloud-init in order to do that. >>>> >> See more in "http://www.ovirt.org/Features/Cloud-Init_Integration >>> ". >>>> >> If the VM's operating system is defined as some kind of Linux, >>>> then you'll be able to set some stuff using cloud-init, either via >>>> the Run-Once Dialog, or in the regular VM properties dialog. >>>> >> >>>> >> Omer - we have REST API support for cloud-init, right? >>>> > Yes, more on that can be found here: >>>> > http://www.ovirt.org/Features/vm-init-persistent >>>> >> >>>> >>>> Tajesh, you have a detailed example of how to set the password in the >>>> following message: >>>> >>>> http://lists.ovirt.org/pipermail/users/2014-February/021302.html >>>> >>>> Setting the IP address is similar. >>>> >>> >>> -- >>> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta >>> 3ºD, 28016 Madrid, Spain >>> Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L. >>> >> >> >> >> -- >> Thanks & Regards >> Tejesh > _______________________________________________ > Users mailing list > Users@ovirt.org <mailto:Users@ovirt.org> > http://lists.ovirt.org/mailman/listinfo/users >
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

Hi, There is no option in "Initial Run" to set root password & other stuff. Have attached screenshots & debug output. Is there any configuration needs to be done? or any cloud-init service needs to be started? How do integrate cloud-init with RHEV-M? Thanks & Regards, Tejesh On Thu, Feb 13, 2014 at 9:50 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/13/2014 05:15 PM, Tejesh M wrote:
Actually, i want to automate the vm provisioning through java sdk. and this urgent requirement. Is it possible to automate setting hostname, root password n nic info by any means in 3.3? Also in windows administration password as similar to linux.. kindly help as im new to this..
Yes, setting the hostname, root password and NIC info is possible in 3.3, using cloud-init and the Java SDK. I tested this with 3.3 and it works correctly.
As you are having problems I suggest to try it manually, from the GUI, if it doesn't work then please report the details, so that we can diagnose and fix it.
Once it works manually from the GUI, we can see why it doesn't work with the SDK, but we will need the output generated when running in debug mode.
On 13 Feb 2014 20:32, "Juan Hernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 03:59 PM, Shahar Havivi wrote: > On 13.02.14 20:17, Tejesh M wrote: >> 1. The Version is RHEV-M 3.3 & Cloud-init is >> cloud-init-0.6.3-0.12.bzr532.el6.noarch >> >> 2. In Webadmin, i don't find any option to set Cloud-init data's. I checked >> under New VM->Initial Run.. Am i looking at the right place? >> How to enable cloud-init support in engine? > You will not found it since you are working in 3.3 and this feature presented > in 3.4. > In 3.3 you can try to set the Cloud-Init via the Run-Once button. >
In 3.3 you need first to create the VM. Once it is created select it, click the "Run Once" button, then click on the plus sign next to "Initial Run", check the "Cloud-Init" box, and populate the fields you want.
>> >> I have installed cloud-init package in RHEV-M & also in Template. >> >> Please suggest. >> >> >> On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote: >> >>> On 02/13/2014 02:39 PM, Tejesh M wrote: >>>> Hi All, >>>> >>>> Thanks alot. >>>> >>>> I have created one VM with minimal installation & installed cloud-init >>>> package. And, converted that VM into Template. Then executed the code >>>> given in >>>> http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but >>>> no luck, the code is not setting root password. >>>> >>> >>> What version of the engine are you running? I may not have the required >>> cloud-init support. >>> >>> Try to run the application in debug mode: >>> >>> Api api = new Api( >>> "https://whatever/api", >>> "user@domain", >>> "password", >>> null, >>> null, >>> null, >>> null, >>> true, >>> null, >>> true // <- This is to enable debug mode >>> ); >>> >>> It will send to the log the actual XML documents sent to the server. We >>> can use it to see if the request is generated correctly. >>> >>> It may also happen that cloud-init support isn't working correctly. To >>> verify this try to use the cloud-init support manually from webadmin. >>> Does it work from there? >>> >>>> Also, there is no option to set *Hostname *for the VM. >>>> >>> >>> To set the host name you need to add something like this: >>> >>> Host hostData = new Host(); >>> hostData.setAddress("the.host.name <http://the.host.name>"); >>> cloudData.setHost(hostData); >>> >>>> >>>> >>>> _*Code:*_ >>>> >>>> /*********************Begin Customize VM*********************/ >>>> // Generate the random password, using whatever mechanism you >>>> // prefer: >>>> String password = "cJql3P9XLQG4drCYVG/6Q/"; >>>> >>>> // You need to know the name of the template, the cluster and >>>> // the VM you are going to create: >>>> String templateName = "rhel2_temp"; >>>> String clusterName = "testCluster"; >>>> String vmName = "myvm"; >>>> >>>> // 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); >>>> >>>> // Send the request to create the VM to the server: >>>> api.getVMs().add(vmDataForCreate); >>>> String state; >>>> // White till the VM is down (it will be locked for a while): >>>> for (;;) { >>>> state = api.getVMs().get(vmName).getStatus().getState(); >>>> if ("down".equals(state)) { >>>> break; >>>> } >>>> Thread.sleep(1000); >>>> } >>>> System.out.println("System Status:"+state); >>>> // Populate parameters for the action to start the VM with >>>> cloud-init: >>>> 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); >>>> >>>> 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); >>>> System.out.println("After : >>>> "+api.getVMs().get(vmName).getStatus()); >>>> /*********************End Customize VM*********************/ >>>> >>>> >>>> >>>> Thanks & Regards, >>>> Tejesh >>>> >>>> >>>> >>>> On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com> >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: >>>> >>>> On 02/13/2014 09:29 AM, Shahar Havivi wrote: >>>> > On 13.02.14 00:59, Oved Ourfalli wrote: >>>> >> >>>> >> >>>> >> ----- Original Message ----- >>>> >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com> >>>> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>>> >>>> >>> To: users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>> >>>> >>> Cc: "Juan Antonio Hernandez Fernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com> >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>, rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> >>>> <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>>, "Tejesh M" >>>> >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>> >>>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM >>>> >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using >>>> Java SDK >>>> >>> >>>> >>> On 12.02.14 22:55, Itamar Heim wrote: >>>> >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: >>>> >>>>> Hi, >>>> >>>>> >>>> >>>>> Can anyone share sample code on how to assign IP address to >>>> guest os & >>>> >>>>> changing the root password while creating VM from Template >>>> using Java SDK? >>>> >>> Hi Tejesh, >>>> >>> You should start here: >>>> >>> http://www.ovirt.org/Api >>>> >>> This link will explain the basics for fetching VM via the API >>>> using HTTP via >>>> >>> curl command line. >>>> >>> >>>> >>> Every VM have a collection of networks and manipulating them can >>>> be seeing >>>> >>> here with the REST API examples: >>>> >>> http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST >>>> >>> the section for you is "Attaching a network to a NIC" under the >>> REST >>>> >>> category. >>>> >>> >>>> >>> Shahar Havivi. >>>> >>> >>>> >> >>>> >> Actually it looks like Tejesh is referring to the Guests and not >>>> the hosts, so you can use cloud-init in order to do that. >>>> >> See more in "http://www.ovirt.org/Features/Cloud-Init_Integration >>> ". >>>> >> If the VM's operating system is defined as some kind of Linux, >>>> then you'll be able to set some stuff using cloud-init, either via >>>> the Run-Once Dialog, or in the regular VM properties dialog. >>>> >> >>>> >> Omer - we have REST API support for cloud-init, right? >>>> > Yes, more on that can be found here: >>>> > http://www.ovirt.org/Features/vm-init-persistent >>>> >> >>>> >>>> Tajesh, you have a detailed example of how to set the password in the >>>> following message: >>>> >>>> http://lists.ovirt.org/pipermail/users/2014-February/021302.html >>>> >>>> Setting the IP address is similar. >>>> >>> >>> -- >>> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta >>> 3ºD, 28016 Madrid, Spain >>> Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L. >>> >> >> >> >> -- >> Thanks & Regards >> Tejesh > _______________________________________________ > Users mailing list > Users@ovirt.org <mailto:Users@ovirt.org> > http://lists.ovirt.org/mailman/listinfo/users >
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh

On 02/14/2014 10:30 AM, Tejesh M wrote:
Hi,
There is no option in "Initial Run" to set root password & other stuff. Have attached screenshots & debug output. Is there any configuration needs to be done? or any cloud-init service needs to be started? How do integrate cloud-init with RHEV-M?
Thanks & Regards, Tejesh
You are using the "Run" and "New" options, but you have to use the "Run Once" option. There, in "Run Once" is where we have cloud-init support in 3.3.
On Thu, Feb 13, 2014 at 9:50 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 05:15 PM, Tejesh M wrote: > Actually, i want to automate the vm provisioning through java sdk. and > this urgent requirement. Is it possible to automate setting hostname, > root password n nic info by any means in 3.3? Also in windows > administration password as similar to linux.. kindly help as im new to > this.. >
Yes, setting the hostname, root password and NIC info is possible in 3.3, using cloud-init and the Java SDK. I tested this with 3.3 and it works correctly.
As you are having problems I suggest to try it manually, from the GUI, if it doesn't work then please report the details, so that we can diagnose and fix it.
Once it works manually from the GUI, we can see why it doesn't work with the SDK, but we will need the output generated when running in debug mode.
> On 13 Feb 2014 20:32, "Juan Hernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: > > On 02/13/2014 03:59 PM, Shahar Havivi wrote: > > On 13.02.14 20:17, Tejesh M wrote: > >> 1. The Version is RHEV-M 3.3 & Cloud-init is > >> cloud-init-0.6.3-0.12.bzr532.el6.noarch > >> > >> 2. In Webadmin, i don't find any option to set Cloud-init data's. > I checked > >> under New VM->Initial Run.. Am i looking at the right place? > >> How to enable cloud-init support in engine? > > You will not found it since you are working in 3.3 and this > feature presented > > in 3.4. > > In 3.3 you can try to set the Cloud-Init via the Run-Once button. > > > > In 3.3 you need first to create the VM. Once it is created select it, > click the "Run Once" button, then click on the plus sign next to > "Initial Run", check the "Cloud-Init" box, and populate the fields > you want. > > >> > >> I have installed cloud-init package in RHEV-M & also in Template. > >> > >> Please suggest. > >> > >> > >> On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: > >> > >>> On 02/13/2014 02:39 PM, Tejesh M wrote: > >>>> Hi All, > >>>> > >>>> Thanks alot. > >>>> > >>>> I have created one VM with minimal installation & installed > cloud-init > >>>> package. And, converted that VM into Template. Then executed > the code > >>>> given in > >>>> > http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but > >>>> no luck, the code is not setting root password. > >>>> > >>> > >>> What version of the engine are you running? I may not have the > required > >>> cloud-init support. > >>> > >>> Try to run the application in debug mode: > >>> > >>> Api api = new Api( > >>> "https://whatever/api", > >>> "user@domain", > >>> "password", > >>> null, > >>> null, > >>> null, > >>> null, > >>> true, > >>> null, > >>> true // <- This is to enable debug mode > >>> ); > >>> > >>> It will send to the log the actual XML documents sent to the > server. We > >>> can use it to see if the request is generated correctly. > >>> > >>> It may also happen that cloud-init support isn't working > correctly. To > >>> verify this try to use the cloud-init support manually from > webadmin. > >>> Does it work from there? > >>> > >>>> Also, there is no option to set *Hostname *for the VM. > >>>> > >>> > >>> To set the host name you need to add something like this: > >>> > >>> Host hostData = new Host(); > >>> hostData.setAddress("the.host.name <http://the.host.name> <http://the.host.name>"); > >>> cloudData.setHost(hostData); > >>> > >>>> > >>>> > >>>> _*Code:*_ > >>>> > >>>> /*********************Begin Customize > VM*********************/ > >>>> // Generate the random password, using whatever > mechanism you > >>>> // prefer: > >>>> String password = "cJql3P9XLQG4drCYVG/6Q/"; > >>>> > >>>> // You need to know the name of the template, the > cluster and > >>>> // the VM you are going to create: > >>>> String templateName = "rhel2_temp"; > >>>> String clusterName = "testCluster"; > >>>> String vmName = "myvm"; > >>>> > >>>> // 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); > >>>> > >>>> // Send the request to create the VM to the server: > >>>> api.getVMs().add(vmDataForCreate); > >>>> String state; > >>>> // White till the VM is down (it will be locked for a > while): > >>>> for (;;) { > >>>> state = > api.getVMs().get(vmName).getStatus().getState(); > >>>> if ("down".equals(state)) { > >>>> break; > >>>> } > >>>> Thread.sleep(1000); > >>>> } > >>>> System.out.println("System Status:"+state); > >>>> // Populate parameters for the action to start the VM > with > >>>> cloud-init: > >>>> 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); > >>>> > >>>> 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); > >>>> System.out.println("After : > >>>> "+api.getVMs().get(vmName).getStatus()); > >>>> /*********************End Customize > VM*********************/ > >>>> > >>>> > >>>> > >>>> Thanks & Regards, > >>>> Tejesh > >>>> > >>>> > >>>> > >>>> On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>> wrote: > >>>> > >>>> On 02/13/2014 09:29 AM, Shahar Havivi wrote: > >>>> > On 13.02.14 00:59, Oved Ourfalli wrote: > >>>> >> > >>>> >> > >>>> >> ----- Original Message ----- > >>>> >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com> > <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>> > >>>> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>>>> > >>>> >>> To: users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>> > <mailto:users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > >>>> >>> Cc: "Juan Antonio Hernandez Fernandez" > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>>, > rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>> > >>>> <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>>>, "Tejesh M" > >>>> >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>>> > >>>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM > >>>> >>> Subject: Re: [Users] [rhevm-api] Assign IP address to > VM using > >>>> Java SDK > >>>> >>> > >>>> >>> On 12.02.14 22:55, Itamar Heim wrote: > >>>> >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: > >>>> >>>>> Hi, > >>>> >>>>> > >>>> >>>>> Can anyone share sample code on how to assign IP > address to > >>>> guest os & > >>>> >>>>> changing the root password while creating VM from > Template > >>>> using Java SDK? > >>>> >>> Hi Tejesh, > >>>> >>> You should start here: > >>>> >>> http://www.ovirt.org/Api > >>>> >>> This link will explain the basics for fetching VM via > the API > >>>> using HTTP via > >>>> >>> curl command line. > >>>> >>> > >>>> >>> Every VM have a collection of networks and manipulating > them can > >>>> be seeing > >>>> >>> here with the REST API examples: > >>>> >>> > http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST > >>>> >>> the section for you is "Attaching a network to a NIC" > under the > >>> REST > >>>> >>> category. > >>>> >>> > >>>> >>> Shahar Havivi. > >>>> >>> > >>>> >> > >>>> >> Actually it looks like Tejesh is referring to the Guests > and not > >>>> the hosts, so you can use cloud-init in order to do that. > >>>> >> See more in > "http://www.ovirt.org/Features/Cloud-Init_Integration > >>> ". > >>>> >> If the VM's operating system is defined as some kind of > Linux, > >>>> then you'll be able to set some stuff using cloud-init, > either via > >>>> the Run-Once Dialog, or in the regular VM properties dialog. > >>>> >> > >>>> >> Omer - we have REST API support for cloud-init, right? > >>>> > Yes, more on that can be found here: > >>>> > http://www.ovirt.org/Features/vm-init-persistent > >>>> >> > >>>> > >>>> Tajesh, you have a detailed example of how to set the > password in the > >>>> following message: > >>>> > >>>> > http://lists.ovirt.org/pipermail/users/2014-February/021302.html > >>>> > >>>> Setting the IP address is similar. > >>>> > >>>
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

In the two screenshots which i shared earlier, in that "No Cloud-Init 2.png" is "Run Once" screenshot, it has only 4 options, i. Boot Options ii. Host iii. Display Protocol iv. Custom Properties After selecting VM, when i click Run Once, that screen is getting appears as in screenshot, no option for cloud-init. Do i need to update the RHEV-M? On Fri, Feb 14, 2014 at 3:06 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/14/2014 10:30 AM, Tejesh M wrote:
Hi,
There is no option in "Initial Run" to set root password & other stuff. Have attached screenshots & debug output. Is there any configuration needs to be done? or any cloud-init service needs to be started? How do integrate cloud-init with RHEV-M?
Thanks & Regards, Tejesh
You are using the "Run" and "New" options, but you have to use the "Run Once" option. There, in "Run Once" is where we have cloud-init support in 3.3.
On Thu, Feb 13, 2014 at 9:50 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 05:15 PM, Tejesh M wrote: > Actually, i want to automate the vm provisioning through java sdk.
and
> this urgent requirement. Is it possible to automate setting
hostname,
> root password n nic info by any means in 3.3? Also in windows > administration password as similar to linux.. kindly help as im
new to
> this.. >
Yes, setting the hostname, root password and NIC info is possible in 3.3, using cloud-init and the Java SDK. I tested this with 3.3 and it works correctly.
As you are having problems I suggest to try it manually, from the
GUI,
if it doesn't work then please report the details, so that we can diagnose and fix it.
Once it works manually from the GUI, we can see why it doesn't work
with
the SDK, but we will need the output generated when running in debug mode.
> On 13 Feb 2014 20:32, "Juan Hernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: > > On 02/13/2014 03:59 PM, Shahar Havivi wrote: > > On 13.02.14 20:17, Tejesh M wrote: > >> 1. The Version is RHEV-M 3.3 & Cloud-init is > >> cloud-init-0.6.3-0.12.bzr532.el6.noarch > >> > >> 2. In Webadmin, i don't find any option to set Cloud-init data's. > I checked > >> under New VM->Initial Run.. Am i looking at the right place? > >> How to enable cloud-init support in engine? > > You will not found it since you are working in 3.3 and this > feature presented > > in 3.4. > > In 3.3 you can try to set the Cloud-Init via the Run-Once button. > > > > In 3.3 you need first to create the VM. Once it is created select it, > click the "Run Once" button, then click on the plus sign next
to
> "Initial Run", check the "Cloud-Init" box, and populate the
fields
> you want. > > >> > >> I have installed cloud-init package in RHEV-M & also in Template. > >> > >> Please suggest. > >> > >> > >> On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: > >> > >>> On 02/13/2014 02:39 PM, Tejesh M wrote: > >>>> Hi All, > >>>> > >>>> Thanks alot. > >>>> > >>>> I have created one VM with minimal installation &
installed
> cloud-init > >>>> package. And, converted that VM into Template. Then
executed
> the code > >>>> given in > >>>> > http://lists.ovirt.org/pipermail/users/2014-February/021302.html ,
but
> >>>> no luck, the code is not setting root password. > >>>> > >>> > >>> What version of the engine are you running? I may not have
the
> required > >>> cloud-init support. > >>> > >>> Try to run the application in debug mode: > >>> > >>> Api api = new Api( > >>> "https://whatever/api", > >>> "user@domain", > >>> "password", > >>> null, > >>> null, > >>> null, > >>> null, > >>> true, > >>> null, > >>> true // <- This is to enable debug mode > >>> ); > >>> > >>> It will send to the log the actual XML documents sent to
the
> server. We > >>> can use it to see if the request is generated correctly. > >>> > >>> It may also happen that cloud-init support isn't working > correctly. To > >>> verify this try to use the cloud-init support manually from > webadmin. > >>> Does it work from there? > >>> > >>>> Also, there is no option to set *Hostname *for the VM. > >>>> > >>> > >>> To set the host name you need to add something like this: > >>> > >>> Host hostData = new Host(); > >>> hostData.setAddress("the.host.name <http://the.host.name> <http://the.host.name>"); > >>> cloudData.setHost(hostData); > >>> > >>>> > >>>> > >>>> _*Code:*_ > >>>> > >>>> /*********************Begin Customize > VM*********************/ > >>>> // Generate the random password, using whatever > mechanism you > >>>> // prefer: > >>>> String password = "cJql3P9XLQG4drCYVG/6Q/"; > >>>> > >>>> // You need to know the name of the template,
the
> cluster and > >>>> // the VM you are going to create: > >>>> String templateName = "rhel2_temp"; > >>>> String clusterName = "testCluster"; > >>>> String vmName = "myvm"; > >>>> > >>>> // 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); > >>>> > >>>> // Send the request to create the VM to the
server:
> >>>> api.getVMs().add(vmDataForCreate); > >>>> String state; > >>>> // White till the VM is down (it will be locked for a > while): > >>>> for (;;) { > >>>> state = > api.getVMs().get(vmName).getStatus().getState(); > >>>> if ("down".equals(state)) { > >>>> break; > >>>> } > >>>> Thread.sleep(1000); > >>>> } > >>>> System.out.println("System Status:"+state); > >>>> // Populate parameters for the action to start the VM > with > >>>> cloud-init: > >>>> 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); > >>>> > >>>> 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); > >>>> System.out.println("After : > >>>> "+api.getVMs().get(vmName).getStatus()); > >>>> /*********************End Customize > VM*********************/ > >>>> > >>>> > >>>> > >>>> Thanks & Regards, > >>>> Tejesh > >>>> > >>>> > >>>> > >>>> On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>> wrote: > >>>> > >>>> On 02/13/2014 09:29 AM, Shahar Havivi wrote: > >>>> > On 13.02.14 00:59, Oved Ourfalli wrote: > >>>> >> > >>>> >> > >>>> >> ----- Original Message ----- > >>>> >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com> > <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>> > >>>> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>>>> > >>>> >>> To: users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>> > <mailto:users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > >>>> >>> Cc: "Juan Antonio Hernandez Fernandez" > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>>, > rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>> > >>>> <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>>>, "Tejesh M" > >>>> >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>>> > >>>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM > >>>> >>> Subject: Re: [Users] [rhevm-api] Assign IP
address to
> VM using > >>>> Java SDK > >>>> >>> > >>>> >>> On 12.02.14 22:55, Itamar Heim wrote: > >>>> >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: > >>>> >>>>> Hi, > >>>> >>>>> > >>>> >>>>> Can anyone share sample code on how to assign IP > address to > >>>> guest os & > >>>> >>>>> changing the root password while creating VM
from
> Template > >>>> using Java SDK? > >>>> >>> Hi Tejesh, > >>>> >>> You should start here: > >>>> >>> http://www.ovirt.org/Api > >>>> >>> This link will explain the basics for fetching VM
via
> the API > >>>> using HTTP via > >>>> >>> curl command line. > >>>> >>> > >>>> >>> Every VM have a collection of networks and manipulating > them can > >>>> be seeing > >>>> >>> here with the REST API examples: > >>>> >>> >
http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST
> >>>> >>> the section for you is "Attaching a network to a
NIC"
> under the > >>> REST > >>>> >>> category. > >>>> >>> > >>>> >>> Shahar Havivi. > >>>> >>> > >>>> >> > >>>> >> Actually it looks like Tejesh is referring to the Guests > and not > >>>> the hosts, so you can use cloud-init in order to do
that.
> >>>> >> See more in > "http://www.ovirt.org/Features/Cloud-Init_Integration > >>> ". > >>>> >> If the VM's operating system is defined as some kind of > Linux, > >>>> then you'll be able to set some stuff using
cloud-init,
> either via > >>>> the Run-Once Dialog, or in the regular VM properties dialog. > >>>> >> > >>>> >> Omer - we have REST API support for cloud-init,
right?
> >>>> > Yes, more on that can be found here: > >>>> > http://www.ovirt.org/Features/vm-init-persistent > >>>> >> > >>>> > >>>> Tajesh, you have a detailed example of how to set the > password in the > >>>> following message: > >>>> > >>>> >
http://lists.ovirt.org/pipermail/users/2014-February/021302.html
> >>>> > >>>> Setting the IP address is similar. > >>>> > >>>
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh

On 02/14/2014 11:03 AM, Tejesh M wrote:
In the two screenshots which i shared earlier, in that "No Cloud-Init 2.png" is "Run Once" screenshot, it has only 4 options,
i. Boot Options ii. Host iii. Display Protocol iv. Custom Properties
After selecting VM, when i click Run Once, that screen is getting appears as in screenshot, no option for cloud-init.
Do i need to update the RHEV-M?
Ok, I thought you were using RHEV-M 3.3, but apparently you are using 3.2. Can you verify? # rpm -qa 'rhevm*' If you are using 3.2 then you will need to update to 3.3 in order to have cloud-init support.
On Fri, Feb 14, 2014 at 3:06 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/14/2014 10:30 AM, Tejesh M wrote: > Hi, > > There is no option in "Initial Run" to set root password & other stuff. > Have attached screenshots & debug output. Is there any configuration > needs to be done? or any cloud-init service needs to be started? How do > integrate cloud-init with RHEV-M? > > Thanks & Regards, > Tejesh >
You are using the "Run" and "New" options, but you have to use the "Run Once" option. There, in "Run Once" is where we have cloud-init support in 3.3.
> > On Thu, Feb 13, 2014 at 9:50 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: > > On 02/13/2014 05:15 PM, Tejesh M wrote: > > Actually, i want to automate the vm provisioning through java sdk. and > > this urgent requirement. Is it possible to automate setting hostname, > > root password n nic info by any means in 3.3? Also in windows > > administration password as similar to linux.. kindly help as im new to > > this.. > > > > Yes, setting the hostname, root password and NIC info is possible in > 3.3, using cloud-init and the Java SDK. I tested this with 3.3 and it > works correctly. > > As you are having problems I suggest to try it manually, from the GUI, > if it doesn't work then please report the details, so that we can > diagnose and fix it. > > Once it works manually from the GUI, we can see why it doesn't work with > the SDK, but we will need the output generated when running in debug > mode. > > > On 13 Feb 2014 20:32, "Juan Hernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>> wrote: > > > > On 02/13/2014 03:59 PM, Shahar Havivi wrote: > > > On 13.02.14 20:17, Tejesh M wrote: > > >> 1. The Version is RHEV-M 3.3 & Cloud-init is > > >> cloud-init-0.6.3-0.12.bzr532.el6.noarch > > >> > > >> 2. In Webadmin, i don't find any option to set Cloud-init > data's. > > I checked > > >> under New VM->Initial Run.. Am i looking at the right place? > > >> How to enable cloud-init support in engine? > > > You will not found it since you are working in 3.3 and this > > feature presented > > > in 3.4. > > > In 3.3 you can try to set the Cloud-Init via the Run-Once > button. > > > > > > > In 3.3 you need first to create the VM. Once it is created > select it, > > click the "Run Once" button, then click on the plus sign next to > > "Initial Run", check the "Cloud-Init" box, and populate the fields > > you want. > > > > >> > > >> I have installed cloud-init package in RHEV-M & also in > Template. > > >> > > >> Please suggest. > > >> > > >> > > >> On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez > > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>> wrote: > > >> > > >>> On 02/13/2014 02:39 PM, Tejesh M wrote: > > >>>> Hi All, > > >>>> > > >>>> Thanks alot. > > >>>> > > >>>> I have created one VM with minimal installation & installed > > cloud-init > > >>>> package. And, converted that VM into Template. Then executed > > the code > > >>>> given in > > >>>> > > > http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but > > >>>> no luck, the code is not setting root password. > > >>>> > > >>> > > >>> What version of the engine are you running? I may not have the > > required > > >>> cloud-init support. > > >>> > > >>> Try to run the application in debug mode: > > >>> > > >>> Api api = new Api( > > >>> "https://whatever/api", > > >>> "user@domain", > > >>> "password", > > >>> null, > > >>> null, > > >>> null, > > >>> null, > > >>> true, > > >>> null, > > >>> true // <- This is to enable debug mode > > >>> ); > > >>> > > >>> It will send to the log the actual XML documents sent to the > > server. We > > >>> can use it to see if the request is generated correctly. > > >>> > > >>> It may also happen that cloud-init support isn't working > > correctly. To > > >>> verify this try to use the cloud-init support manually from > > webadmin. > > >>> Does it work from there? > > >>> > > >>>> Also, there is no option to set *Hostname *for the VM. > > >>>> > > >>> > > >>> To set the host name you need to add something like this: > > >>> > > >>> Host hostData = new Host(); > > >>> hostData.setAddress("the.host.name <http://the.host.name> > <http://the.host.name> <http://the.host.name>"); > > >>> cloudData.setHost(hostData); > > >>> > > >>>> > > >>>> > > >>>> _*Code:*_ > > >>>> > > >>>> /*********************Begin Customize > > VM*********************/ > > >>>> // Generate the random password, using whatever > > mechanism you > > >>>> // prefer: > > >>>> String password = "cJql3P9XLQG4drCYVG/6Q/"; > > >>>> > > >>>> // You need to know the name of the template, the > > cluster and > > >>>> // the VM you are going to create: > > >>>> String templateName = "rhel2_temp"; > > >>>> String clusterName = "testCluster"; > > >>>> String vmName = "myvm"; > > >>>> > > >>>> // 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); > > >>>> > > >>>> // Send the request to create the VM to the server: > > >>>> api.getVMs().add(vmDataForCreate); > > >>>> String state; > > >>>> // White till the VM is down (it will be locked > for a > > while): > > >>>> for (;;) { > > >>>> state = > > api.getVMs().get(vmName).getStatus().getState(); > > >>>> if ("down".equals(state)) { > > >>>> break; > > >>>> } > > >>>> Thread.sleep(1000); > > >>>> } > > >>>> System.out.println("System Status:"+state); > > >>>> // Populate parameters for the action to start > the VM > > with > > >>>> cloud-init: > > >>>> 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); > > >>>> > > >>>> 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); > > >>>> System.out.println("After : > > >>>> "+api.getVMs().get(vmName).getStatus()); > > >>>> /*********************End Customize > > VM*********************/ > > >>>> > > >>>> > > >>>> > > >>>> Thanks & Regards, > > >>>> Tejesh > > >>>> > > >>>> > > >>>> > > >>>> On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez > > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> > > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>>> wrote: > > >>>> > > >>>> On 02/13/2014 09:29 AM, Shahar Havivi wrote: > > >>>> > On 13.02.14 00:59, Oved Ourfalli wrote: > > >>>> >> > > >>>> >> > > >>>> >> ----- Original Message ----- > > >>>> >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com> > <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>> > > <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>>> > > >>>> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com> > <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com> > <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>>>>> > > >>>> >>> To: users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>> > <mailto:users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > > <mailto:users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>> > <mailto:users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>>> > > >>>> >>> Cc: "Juan Antonio Hernandez Fernandez" > > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> > > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>>>, > > rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>> > > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>>> > > >>>> <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>> > > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>>>>, "Tejesh M" > > >>>> >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>> > > <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>>>> > > >>>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM > > >>>> >>> Subject: Re: [Users] [rhevm-api] Assign IP address to > > VM using > > >>>> Java SDK > > >>>> >>> > > >>>> >>> On 12.02.14 22:55, Itamar Heim wrote: > > >>>> >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: > > >>>> >>>>> Hi, > > >>>> >>>>> > > >>>> >>>>> Can anyone share sample code on how to assign IP > > address to > > >>>> guest os & > > >>>> >>>>> changing the root password while creating VM from > > Template > > >>>> using Java SDK? > > >>>> >>> Hi Tejesh, > > >>>> >>> You should start here: > > >>>> >>> http://www.ovirt.org/Api > > >>>> >>> This link will explain the basics for fetching VM via > > the API > > >>>> using HTTP via > > >>>> >>> curl command line. > > >>>> >>> > > >>>> >>> Every VM have a collection of networks and > manipulating > > them can > > >>>> be seeing > > >>>> >>> here with the REST API examples: > > >>>> >>> > > http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST > > >>>> >>> the section for you is "Attaching a network to a NIC" > > under the > > >>> REST > > >>>> >>> category. > > >>>> >>> > > >>>> >>> Shahar Havivi. > > >>>> >>> > > >>>> >> > > >>>> >> Actually it looks like Tejesh is referring to the > Guests > > and not > > >>>> the hosts, so you can use cloud-init in order to do that. > > >>>> >> See more in > > "http://www.ovirt.org/Features/Cloud-Init_Integration > > >>> ". > > >>>> >> If the VM's operating system is defined as some > kind of > > Linux, > > >>>> then you'll be able to set some stuff using cloud-init, > > either via > > >>>> the Run-Once Dialog, or in the regular VM properties > dialog. > > >>>> >> > > >>>> >> Omer - we have REST API support for cloud-init, right? > > >>>> > Yes, more on that can be found here: > > >>>> > http://www.ovirt.org/Features/vm-init-persistent > > >>>> >> > > >>>> > > >>>> Tajesh, you have a detailed example of how to set the > > password in the > > >>>> following message: > > >>>> > > >>>> > > http://lists.ovirt.org/pipermail/users/2014-February/021302.html > > >>>> > > >>>> Setting the IP address is similar. > > >>>> > > >>>
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

On Fri, Feb 14, 2014 at 11:22 AM, Juan Hernandez wrote:
On 02/14/2014 11:03 AM, Tejesh M wrote:
In the two screenshots which i shared earlier, in that "No Cloud-Init 2.png" is "Run Once" screenshot, it has only 4 options,
i. Boot Options ii. Host iii. Display Protocol iv. Custom Properties
After selecting VM, when i click Run Once, that screen is getting appears as in screenshot, no option for cloud-init.
Do i need to update the RHEV-M?
Ok, I thought you were using RHEV-M 3.3, but apparently you are using 3.2. Can you verify?
You are using the "Run" and "New" options, but you have to use the "Run Once" option. There, in "Run Once" is where we have cloud-init support in 3.3.
>
And in fact in my oVirt 3.3.3 run once options I have this kind of output: https://drive.google.com/file/d/0BwoPbcrMv8mvTlphZWJyV1ZOdmc/edit?usp=sharin... HIH, Gianluca

On 02/14/2014 10:36 AM, Juan Hernandez wrote:
On 02/14/2014 10:30 AM, Tejesh M wrote:
Hi,
There is no option in "Initial Run" to set root password & other stuff. Have attached screenshots & debug output. Is there any configuration needs to be done? or any cloud-init service needs to be started? How do integrate cloud-init with RHEV-M?
Thanks & Regards, Tejesh
You are using the "Run" and "New" options, but you have to use the "Run Once" option. There, in "Run Once" is where we have cloud-init support in 3.3.
From your debug.txt file this is the request that you the Java SDK is sending to the server:
<action> <vm> <initialization> <cloud_init> <host> <address>myvm</address> </host> <users> <user> <user_name>root</user_name> <password>cJql3P9XLQG4drCYVG/6Q/</password> </user> </users> </cloud_init> </initialization> </vm> </action> That is correct. I just tested it in my environment and it works well, and it assigns the host name and root password to the machine. To check if cloud-init is working correctly you will have to check if has a CDROM attached as expected. Remember that we dynamically generate an ISO file and connect it to the VM as a CDROM. The cloud-init scripts take the information from that CDROM. To verify that this is working start the VM (manually or using the Java SDK) and then login to the hypervisor and check what arguments have been passed to the qemu-kvm process corresponding to that VM: # ps -ef | grep 'qemu-kvm -name myvm' That should give a very long command line. Look for an option like the following: -drive file=/var/run/vdsm/payload/c46bf225-4e58-48b8-bfac-112351b00619.34ac58704f7df0efab99cf4bd14a1696.img,if=none,media=cdrom,id=drive-ide0-1-1,readonly=on,format=raw,serial= If you don't see an option similar to this one then the CDROM isn't being attached to the VM correctly. If you do see this option, then make a copy of the file, and inspect its content. For example, I did this in my environment: # cp /var/run/vdsm/payload/c46bf225-4e58-48b8-bfac-112351b00619.34ac58704f7df0efab99cf4bd14a1696.img /tmp/cloud-init.iso # mount -o loop,ro /tmp/cloud-init.iso /mnt # find /mnt /mnt/ /mnt/openstack /mnt/openstack/latest /mnt/openstack/latest/meta_data.json /mnt/openstack/latest/user_data # cat /mnt/openstack/latest/meta_data.json { "launch_index" : "0", "availability_zone" : "nova", "name" : "myvm", "hostname" : "myvm", "uuid" : "39cea046-e8ce-4e3d-bb9b-d2a449434066", "meta" : { "essential" : "false", "role" : "server", "dsmode" : "local" } } # cat /mnt/openstack/latest/user_data #cloud-config output: all: '>> /var/log/cloud-init-output.log' user: root password: cJql3P9XLQG4drCYVG runcmd: - 'sed -i ''/^datasource_list: /d'' /etc/cloud/cloud.cfg; echo ''datasource_list: ["NoCloud", "ConfigDrive"]'' >> /etc/cloud/cloud.cfg' Please report your results.
On Thu, Feb 13, 2014 at 9:50 PM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/13/2014 05:15 PM, Tejesh M wrote: > Actually, i want to automate the vm provisioning through java sdk. and > this urgent requirement. Is it possible to automate setting hostname, > root password n nic info by any means in 3.3? Also in windows > administration password as similar to linux.. kindly help as im new to > this.. >
Yes, setting the hostname, root password and NIC info is possible in 3.3, using cloud-init and the Java SDK. I tested this with 3.3 and it works correctly.
As you are having problems I suggest to try it manually, from the GUI, if it doesn't work then please report the details, so that we can diagnose and fix it.
Once it works manually from the GUI, we can see why it doesn't work with the SDK, but we will need the output generated when running in debug mode.
> On 13 Feb 2014 20:32, "Juan Hernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com> > <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: > > On 02/13/2014 03:59 PM, Shahar Havivi wrote: > > On 13.02.14 20:17, Tejesh M wrote: > >> 1. The Version is RHEV-M 3.3 & Cloud-init is > >> cloud-init-0.6.3-0.12.bzr532.el6.noarch > >> > >> 2. In Webadmin, i don't find any option to set Cloud-init data's. > I checked > >> under New VM->Initial Run.. Am i looking at the right place? > >> How to enable cloud-init support in engine? > > You will not found it since you are working in 3.3 and this > feature presented > > in 3.4. > > In 3.3 you can try to set the Cloud-Init via the Run-Once button. > > > > In 3.3 you need first to create the VM. Once it is created select it, > click the "Run Once" button, then click on the plus sign next to > "Initial Run", check the "Cloud-Init" box, and populate the fields > you want. > > >> > >> I have installed cloud-init package in RHEV-M & also in Template. > >> > >> Please suggest. > >> > >> > >> On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>> wrote: > >> > >>> On 02/13/2014 02:39 PM, Tejesh M wrote: > >>>> Hi All, > >>>> > >>>> Thanks alot. > >>>> > >>>> I have created one VM with minimal installation & installed > cloud-init > >>>> package. And, converted that VM into Template. Then executed > the code > >>>> given in > >>>> > http://lists.ovirt.org/pipermail/users/2014-February/021302.html , but > >>>> no luck, the code is not setting root password. > >>>> > >>> > >>> What version of the engine are you running? I may not have the > required > >>> cloud-init support. > >>> > >>> Try to run the application in debug mode: > >>> > >>> Api api = new Api( > >>> "https://whatever/api", > >>> "user@domain", > >>> "password", > >>> null, > >>> null, > >>> null, > >>> null, > >>> true, > >>> null, > >>> true // <- This is to enable debug mode > >>> ); > >>> > >>> It will send to the log the actual XML documents sent to the > server. We > >>> can use it to see if the request is generated correctly. > >>> > >>> It may also happen that cloud-init support isn't working > correctly. To > >>> verify this try to use the cloud-init support manually from > webadmin. > >>> Does it work from there? > >>> > >>>> Also, there is no option to set *Hostname *for the VM. > >>>> > >>> > >>> To set the host name you need to add something like this: > >>> > >>> Host hostData = new Host(); > >>> hostData.setAddress("the.host.name <http://the.host.name> <http://the.host.name>"); > >>> cloudData.setHost(hostData); > >>> > >>>> > >>>> > >>>> _*Code:*_ > >>>> > >>>> /*********************Begin Customize > VM*********************/ > >>>> // Generate the random password, using whatever > mechanism you > >>>> // prefer: > >>>> String password = "cJql3P9XLQG4drCYVG/6Q/"; > >>>> > >>>> // You need to know the name of the template, the > cluster and > >>>> // the VM you are going to create: > >>>> String templateName = "rhel2_temp"; > >>>> String clusterName = "testCluster"; > >>>> String vmName = "myvm"; > >>>> > >>>> // 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); > >>>> > >>>> // Send the request to create the VM to the server: > >>>> api.getVMs().add(vmDataForCreate); > >>>> String state; > >>>> // White till the VM is down (it will be locked for a > while): > >>>> for (;;) { > >>>> state = > api.getVMs().get(vmName).getStatus().getState(); > >>>> if ("down".equals(state)) { > >>>> break; > >>>> } > >>>> Thread.sleep(1000); > >>>> } > >>>> System.out.println("System Status:"+state); > >>>> // Populate parameters for the action to start the VM > with > >>>> cloud-init: > >>>> 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); > >>>> > >>>> 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); > >>>> System.out.println("After : > >>>> "+api.getVMs().get(vmName).getStatus()); > >>>> /*********************End Customize > VM*********************/ > >>>> > >>>> > >>>> > >>>> Thanks & Regards, > >>>> Tejesh > >>>> > >>>> > >>>> > >>>> On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>> wrote: > >>>> > >>>> On 02/13/2014 09:29 AM, Shahar Havivi wrote: > >>>> > On 13.02.14 00:59, Oved Ourfalli wrote: > >>>> >> > >>>> >> > >>>> >> ----- Original Message ----- > >>>> >>> From: "Shahar Havivi" <shaharh@redhat.com <mailto:shaharh@redhat.com> > <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>> > >>>> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com> <mailto:shaharh@redhat.com <mailto:shaharh@redhat.com>>>> > >>>> >>> To: users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>> > <mailto:users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > >>>> >>> Cc: "Juan Antonio Hernandez Fernandez" > <jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>> > >>>> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com> <mailto:jhernand@redhat.com <mailto:jhernand@redhat.com>>>>, > rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>> > >>>> <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org> > <mailto:rhevm-api@lists.fedorahosted.org <mailto:rhevm-api@lists.fedorahosted.org>>>, "Tejesh M" > >>>> >>> <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>>> > >>>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM > >>>> >>> Subject: Re: [Users] [rhevm-api] Assign IP address to > VM using > >>>> Java SDK > >>>> >>> > >>>> >>> On 12.02.14 22:55, Itamar Heim wrote: > >>>> >>>> On 02/12/2014 03:14 PM, Tejesh M wrote: > >>>> >>>>> Hi, > >>>> >>>>> > >>>> >>>>> Can anyone share sample code on how to assign IP > address to > >>>> guest os & > >>>> >>>>> changing the root password while creating VM from > Template > >>>> using Java SDK? > >>>> >>> Hi Tejesh, > >>>> >>> You should start here: > >>>> >>> http://www.ovirt.org/Api > >>>> >>> This link will explain the basics for fetching VM via > the API > >>>> using HTTP via > >>>> >>> curl command line. > >>>> >>> > >>>> >>> Every VM have a collection of networks and manipulating > them can > >>>> be seeing > >>>> >>> here with the REST API examples: > >>>> >>> > http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST > >>>> >>> the section for you is "Attaching a network to a NIC" > under the > >>> REST > >>>> >>> category. > >>>> >>> > >>>> >>> Shahar Havivi. > >>>> >>> > >>>> >> > >>>> >> Actually it looks like Tejesh is referring to the Guests > and not > >>>> the hosts, so you can use cloud-init in order to do that. > >>>> >> See more in > "http://www.ovirt.org/Features/Cloud-Init_Integration > >>> ". > >>>> >> If the VM's operating system is defined as some kind of > Linux, > >>>> then you'll be able to set some stuff using cloud-init, > either via > >>>> the Run-Once Dialog, or in the regular VM properties dialog. > >>>> >> > >>>> >> Omer - we have REST API support for cloud-init, right? > >>>> > Yes, more on that can be found here: > >>>> > http://www.ovirt.org/Features/vm-init-persistent > >>>> >> > >>>> > >>>> Tajesh, you have a detailed example of how to set the > password in the > >>>> following message: > >>>> > >>>> > http://lists.ovirt.org/pipermail/users/2014-February/021302.html > >>>> > >>>> Setting the IP address is similar. > >>>> > >>>
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
participants (8)
-
Gianluca Cecchi
-
Gordon Thagard
-
Itamar Heim
-
Juan Hernandez
-
Oved Ourfalli
-
Shahar Havivi
-
Sven Kieske
-
Tejesh M