[Users] Fwd: Sample code for setting NIC - CloudInit

Hi, Can someone share me sample java code for assigning IP address for VM on eth0 through Java SDK via CloudInit ? *Something Like this but in Java:* <network_configuration> <nics> <nic> <name>eth0</name> <boot_protocol>STATIC</boot_protocol> <network> <ip address="192.168.2.11" netmask="255.255.0.0" gateway="192.168.2.1" /> </network> <on_boot>true</on_boot> </nic> <nic> <name>eth1</name> <boot_protocol>DHCP</boot_protocol> </nic> <nic> <name>eth2</name> <boot_protocol>NONE</boot_protocol> <on_boot>true</on_boot> </nic> </nics> <dns> <servers> <host> <address>1.1.2.2</address> </host> <host> <address>1.2.3.4</address> </host> </servers> <search_domains> <host> <address>qa.lab</address> </host> <host> <address>google.com</address> </host> </search_domains> </dns> </network_configuration> -- Thanks & Regards Tejesh

------=_Part_6226104_1412353006.1392849662491 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit ----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "users@oVirt.org" <users@ovirt.org> Sent: Wednesday, February 19, 2014 3:24:40 PM Subject: [Users] Fwd: Sample code for setting NIC - CloudInit
Hi,
Can someone share me sample java code for assigning IP address for VM on eth0 through Java SDK via CloudInit ?
Hi Tejesh, I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it. Thanks, Moti
Something Like this but in Java: <network_configuration> <nics> <nic> <name>eth0</name> <boot_protocol>STATIC</boot_protocol> <network> <ip address="192.168.2.11" netmask="255.255.0.0" gateway="192.168.2.1" /> </network> <on_boot>true</on_boot> </nic> <nic> <name>eth1</name> <boot_protocol>DHCP</boot_protocol> </nic> <nic> <name>eth2</name> <boot_protocol>NONE</boot_protocol> <on_boot>true</on_boot> </nic> </nics> <dns> <servers> <host> <address>1.1.2.2</address> </host> <host> <address>1.2.3.4</address> </host> </servers> <search_domains> <host> <address>qa.lab</address> </host> <host> <address> google.com </address> </host> </search_domains> </dns> </network_configuration>
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
------=_Part_6226104_1412353006.1392849662491 Content-Type: text/x-java; name=VmCloudInit.java Content-Disposition: attachment; filename=VmCloudInit.java Content-Transfer-Encoding: base64 cGFja2FnZSBvcmcub3ZpcnQudGVzdGRheTsKCmltcG9ydCBqYXZhLmlvLklPRXhjZXB0aW9uOwpp bXBvcnQgamF2YS51dGlsLkFycmF5czsKaW1wb3J0IGphdmEudXRpbC5MaXN0OwoKaW1wb3J0IG9y Zy5hcGFjaGUuaHR0cC5jbGllbnQuQ2xpZW50UHJvdG9jb2xFeGNlcHRpb247CmltcG9ydCBvcmcu b3ZpcnQuZW5naW5lLnNkay5BcGk7CmltcG9ydCBvcmcub3ZpcnQuZW5naW5lLnNkay5kZWNvcmF0 b3JzLlZNOwppbXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuQWN0aW9uOwppbXBv cnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuQ2xvdWRJbml0OwppbXBvcnQgb3JnLm92 aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuRE5TOwppbXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsu ZW50aXRpZXMuSG9zdDsKaW1wb3J0IG9yZy5vdmlydC5lbmdpbmUuc2RrLmVudGl0aWVzLkhvc3Rz OwppbXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuSVA7CmltcG9ydCBvcmcub3Zp cnQuZW5naW5lLnNkay5lbnRpdGllcy5Jbml0aWFsaXphdGlvbjsKaW1wb3J0IG9yZy5vdmlydC5l bmdpbmUuc2RrLmVudGl0aWVzLk5JQzsKaW1wb3J0IG9yZy5vdmlydC5lbmdpbmUuc2RrLmVudGl0 aWVzLk5ldHdvcms7CmltcG9ydCBvcmcub3ZpcnQuZW5naW5lLnNkay5lbnRpdGllcy5OZXR3b3Jr Q29uZmlndXJhdGlvbjsKaW1wb3J0IG9yZy5vdmlydC5lbmdpbmUuc2RrLmVudGl0aWVzLk5pY3M7 CmltcG9ydCBvcmcub3ZpcnQuZW5naW5lLnNkay5leGNlcHRpb25zLlNlcnZlckV4Y2VwdGlvbjsK aW1wb3J0IG9yZy5vdmlydC5lbmdpbmUuc2RrLmV4Y2VwdGlvbnMuVW5zZWN1cmVkQ29ubmVjdGlv bkF0dGVtcHRFcnJvcjsKCgovKioKICogU2FtcGxlIG5vbi1zZWN1cmVkIGNvZGUgZm9yIHNlbmRp bmcgdGhlIGZvbGxvd2luZyByZXF1ZXN0OgogKiAgICAgPG5ldHdvcmtfY29uZmlndXJhdGlvbj4K ICAgICAgICAgPG5pY3M+CiAgICAgICAgICAgPG5pYz4KICAgICAgICAgICAgIDxuYW1lPmV0aDA8 L25hbWU+CiAgICAgICAgICAgICA8Ym9vdF9wcm90b2NvbD5TVEFUSUM8L2Jvb3RfcHJvdG9jb2w+ CiAgICAgICAgICAgICA8bmV0d29yaz4KICAgICAgICAgICAgICAgPGlwIGFkZHJlc3M9IjE5Mi4x NjguMi4xMSIgbmV0bWFzaz0iMjU1LjI1NS4wLjAiIGdhdGV3YXk9IjE5Mi4xNjguMi4xIiAvPgog ICAgICAgICAgICAgPC9uZXR3b3JrPgogICAgICAgICAgICAgPG9uX2Jvb3Q+dHJ1ZTwvb25fYm9v dD4KICAgICAgICAgICA8L25pYz4KICAgICAgICAgICA8bmljPgogICAgICAgICAgICAgPG5hbWU+ ZXRoMTwvbmFtZT4KICAgICAgICAgICAgIDxib290X3Byb3RvY29sPkRIQ1A8L2Jvb3RfcHJvdG9j b2w+CiAgICAgICAgICAgPC9uaWM+CiAgICAgICAgICAgPG5pYz4KICAgICAgICAgICAgIDxuYW1l PmV0aDI8L25hbWU+CiAgICAgICAgICAgICA8Ym9vdF9wcm90b2NvbD5OT05FPC9ib290X3Byb3Rv Y29sPgogICAgICAgICAgICAgPG9uX2Jvb3Q+dHJ1ZTwvb25fYm9vdD4KICAgICAgICAgICA8L25p Yz4KICAgICAgICAgPC9uaWNzPgogICAgICAgICA8ZG5zPgogICAgICAgICAgIDxzZXJ2ZXJzPgog ICAgICAgICAgICAgPGhvc3Q+CiAgICAgICAgICAgICAgIDxhZGRyZXNzPjEuMS4yLjI8L2FkZHJl c3M+CiAgICAgICAgICAgICA8L2hvc3Q+CiAgICAgICAgICAgICA8aG9zdD4KICAgICAgICAgICAg ICAgPGFkZHJlc3M+MS4yLjMuNDwvYWRkcmVzcz4KICAgICAgICAgICAgIDwvaG9zdD4KICAgICAg ICAgICA8L3NlcnZlcnM+CiAgICAgICAgICAgPHNlYXJjaF9kb21haW5zPgogICAgICAgICAgICAg PGhvc3Q+CiAgICAgICAgICAgICAgIDxhZGRyZXNzPnFhLmxhYjwvYWRkcmVzcz4KICAgICAgICAg ICAgIDwvaG9zdD4KICAgICAgICAgICAgIDxob3N0PgogICAgICAgICAgICAgICA8YWRkcmVzcz5n b29nbGUuY29tPC9hZGRyZXNzPgogICAgICAgICAgICAgPC9ob3N0PgogICAgICAgICAgIDwvc2Vh cmNoX2RvbWFpbnM+CiAgICAgICAgIDwvZG5zPgogICAgICAgPC9uZXR3b3JrX2NvbmZpZ3VyYXRp b24+CiAqCiAqLwpwdWJsaWMgY2xhc3MgVm1DbG91ZEluaXQgewoKICAgIHB1YmxpYyBzdGF0aWMg dm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBDbGllbnRQcm90b2NvbEV4Y2VwdGlvbiwg U2VydmVyRXhjZXB0aW9uLAogICAgICAgICAgICBVbnNlY3VyZWRDb25uZWN0aW9uQXR0ZW1wdEVy cm9yLCBJT0V4Y2VwdGlvbiB7CgogICAgICAgIHRyeSAoQXBpIGFwaSA9IG5ldyBBcGkoImh0dHA6 Ly9sb2NhbGhvc3Q6ODA4MC9hcGkiLAogICAgICAgICAgICAgICAgImFkbWluQGludGVybmFsIiwK ICAgICAgICAgICAgICAgICIxIiwKICAgICAgICAgICAgICAgIG51bGwsIG51bGwsIG51bGwsIG51 bGwsIG51bGwsIG51bGwsIHRydWUpKXsKCiAgICAgICAgICAgIFZNIHZtID0gYXBpLmdldFZNcygp LmdldCgidm0xIik7CiAgICAgICAgICAgIE5ldHdvcmtDb25maWd1cmF0aW9uIG5ldHdvcmtDb25m aWd1cmF0aW9uID0gbmV3IE5ldHdvcmtDb25maWd1cmF0aW9uKCk7CiAgICAgICAgICAgIEROUyBk bnMgPSBuZXcgRE5TKCk7CiAgICAgICAgICAgIGRucy5zZXRTZXJ2ZXJzKGNyZWF0ZVNlcnZlcnNM aXN0KCIxLjEuMi4yIiwgIjEuMi4zLjQiKSk7CiAgICAgICAgICAgIGRucy5zZXRTZWFyY2hEb21h aW5zKGNyZWF0ZVNlcnZlcnNMaXN0KCJxYS5sYWIiLCAiZ29vZ2xlLmNvbSIpKTsKICAgICAgICAg ICAgbmV0d29ya0NvbmZpZ3VyYXRpb24uc2V0RG5zKGRucyk7CiAgICAgICAgICAgIG5ldHdvcmtD b25maWd1cmF0aW9uLnNldE5pY3MobmV3IE5pY3MoKSk7CiAgICAgICAgICAgIExpc3Q8TklDPiBu aWNzID0gbmV0d29ya0NvbmZpZ3VyYXRpb24uZ2V0TmljcygpLmdldE5pY3MoKTsKICAgICAgICAg ICAgbmljcy5hZGQoY3JlYXRlTmljKCJldGgwIiwgIlNUQVRJQyIsIGNyZWF0ZU5ldHdvcmsoIjE5 Mi4xNjguMi4xMSIsICIyNTUuMjU1LjAuMCIsICIxOTIuMTY4LjIuMSIpLCB0cnVlKSk7CiAgICAg ICAgICAgIG5pY3MuYWRkKGNyZWF0ZU5pYygiZXRoMSIsICJESENQIiwgbnVsbCwgZmFsc2UpKTsK ICAgICAgICAgICAgbmljcy5hZGQoY3JlYXRlTmljKCJldGgxIiwgIk5PTkUiLCBudWxsLCB0cnVl KSk7CiAgICAgICAgICAgIHZtLnNldEluaXRpYWxpemF0aW9uKG5ldyBJbml0aWFsaXphdGlvbigp KTsKICAgICAgICAgICAgdm0uZ2V0SW5pdGlhbGl6YXRpb24oKS5zZXRDbG91ZEluaXQobmV3IENs b3VkSW5pdCgpKTsKICAgICAgICAgICAgdm0uZ2V0SW5pdGlhbGl6YXRpb24oKS5nZXRDbG91ZElu aXQoKS5zZXROZXR3b3JrQ29uZmlndXJhdGlvbihuZXR3b3JrQ29uZmlndXJhdGlvbik7CiAgICAg ICAgICAgIEFjdGlvbiBhY3Rpb24gPSBuZXcgQWN0aW9uKCk7CiAgICAgICAgICAgIGFjdGlvbi5z ZXRWbSh2bSk7CiAgICAgICAgICAgIHZtLnN0YXJ0KGFjdGlvbik7CiAgICAgICAgfSBjYXRjaCAo RXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKICAgICAgICB9 CiAgICB9CgogICAgcHJpdmF0ZSBzdGF0aWMgTklDIGNyZWF0ZU5pYyhTdHJpbmcgbmFtZSwgU3Ry aW5nIGJvb3RQcm90b2NvbCwgTmV0d29yayBuZXR3b3JrLCBib29sZWFuIG9uQm9vdCkgewogICAg ICAgIE5JQyBuaWMgPSBuZXcgTklDKCk7CiAgICAgICAgbmljLnNldE5hbWUobmFtZSk7CiAgICAg ICAgbmljLnNldEJvb3RQcm90b2NvbChib290UHJvdG9jb2wpOwogICAgICAgIG5pYy5zZXROZXR3 b3JrKG5ldHdvcmspOwogICAgICAgIG5pYy5zZXRPbkJvb3Qob25Cb290KTsKICAgICAgICByZXR1 cm4gbmljOwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgSG9zdHMgY3JlYXRlU2VydmVyc0xpc3Qo U3RyaW5nLi4uIGFkZHJlc3NlcykgewogICAgICAgIExpc3Q8U3RyaW5nPiBob3N0QWRkcmVzc2Vz ID0gQXJyYXlzLmFzTGlzdChhZGRyZXNzZXMpOwogICAgICAgIEhvc3RzIHNlcnZlcnMgPSBuZXcg SG9zdHMoKTsKICAgICAgICBmb3IgKFN0cmluZyBhZGRyZXNzIDogaG9zdEFkZHJlc3Nlcykgewog ICAgICAgICAgICBIb3N0IGhvc3QgPSBuZXcgSG9zdCgpOwogICAgICAgICAgICBob3N0LnNldEFk ZHJlc3MoYWRkcmVzcyk7CiAgICAgICAgICAgIHNlcnZlcnMuZ2V0SG9zdHMoKS5hZGQoaG9zdCk7 CiAgICAgICAgfQoKICAgICAgICByZXR1cm4gc2VydmVyczsKICAgIH0KCiAgICBwdWJsaWMgc3Rh dGljIE5ldHdvcmsgY3JlYXRlTmV0d29yayhTdHJpbmcgYWRkcmVzcywgU3RyaW5nIG5ldG1hc2ss IFN0cmluZyBnYXRld2F5KSB7CiAgICAgICAgTmV0d29yayBuZXR3b3JrID0gbmV3IE5ldHdvcmso KTsKICAgICAgICBJUCBpcCA9IG5ldyBJUCgpOwogICAgICAgIGlwLnNldEFkZHJlc3MoYWRkcmVz cyk7CiAgICAgICAgaXAuc2V0TmV0bWFzayhuZXRtYXNrKTsKICAgICAgICBpcC5zZXRHYXRld2F5 KGdhdGV3YXkpOwogICAgICAgIG5ldHdvcmsuc2V0SXAoaXApOwogICAgICAgIHJldHVybiBuZXR3 b3JrOwogICAgfQoKfQo= ------=_Part_6226104_1412353006.1392849662491--

I'm not getting below class: import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "users@oVirt.org" <users@ovirt.org> Sent: Wednesday, February 19, 2014 3:24:40 PM Subject: [Users] Fwd: Sample code for setting NIC - CloudInit
Hi,
Can someone share me sample java code for assigning IP address for VM on eth0 through Java SDK via CloudInit ?
Hi Tejesh,
I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it.
Thanks, Moti
Something Like this but in Java: <network_configuration> <nics> <nic> <name>eth0</name> <boot_protocol>STATIC</boot_protocol> <network> <ip address="192.168.2.11" netmask="255.255.0.0" gateway="192.168.2.1" /> </network> <on_boot>true</on_boot> </nic> <nic> <name>eth1</name> <boot_protocol>DHCP</boot_protocol> </nic> <nic> <name>eth2</name> <boot_protocol>NONE</boot_protocol> <on_boot>true</on_boot> </nic> </nics> <dns> <servers> <host> <address>1.1.2.2</address> </host> <host> <address>1.2.3.4</address> </host> </servers> <search_domains> <host> <address>qa.lab</address> </host> <host> <address> google.com </address> </host> </search_domains> </dns> </network_configuration>
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Thanks & Regards Tejesh

----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com> Cc: "users@oVirt.org" <users@ovirt.org> Sent: Thursday, February 20, 2014 8:52:52 AM Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit
I'm not getting below class:
import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;
Which version of ovirt-engine-sdk-java are you using ? I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml: <dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.4.0.1-1</version> <type>jar</type> <scope>compile</scope> </dependency>
On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "users@oVirt.org" <users@ovirt.org> Sent: Wednesday, February 19, 2014 3:24:40 PM Subject: [Users] Fwd: Sample code for setting NIC - CloudInit
Hi,
Can someone share me sample java code for assigning IP address for VM on eth0 through Java SDK via CloudInit ?
Hi Tejesh,
I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it.
Thanks, Moti
Something Like this but in Java: <network_configuration> <nics> <nic> <name>eth0</name> <boot_protocol>STATIC</boot_protocol> <network> <ip address="192.168.2.11" netmask="255.255.0.0" gateway="192.168.2.1" /> </network> <on_boot>true</on_boot> </nic> <nic> <name>eth1</name> <boot_protocol>DHCP</boot_protocol> </nic> <nic> <name>eth2</name> <boot_protocol>NONE</boot_protocol> <on_boot>true</on_boot> </nic> </nics> <dns> <servers> <host> <address>1.1.2.2</address> </host> <host> <address>1.2.3.4</address> </host> </servers> <search_domains> <host> <address>qa.lab</address> </host> <host> <address> google.com </address> </host> </search_domains> </dns> </network_configuration>
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Thanks & Regards Tejesh

I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log. *Java Code:* org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit(); cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData); org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network(); DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics()); Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); networkConfiguration.setNics(nics); cloudData.setNetwork(networkConfiguration); Initialization initData = new Initialization(); initData.setCloudInit(cloudData); VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart); // Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData); On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com> Cc: "users@oVirt.org" <users@ovirt.org> Sent: Thursday, February 20, 2014 8:52:52 AM Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit
I'm not getting below class:
import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;
Which version of ovirt-engine-sdk-java are you using ?
I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.4.0.1-1</version> <type>jar</type> <scope>compile</scope> </dependency>
On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "users@oVirt.org" <users@ovirt.org> Sent: Wednesday, February 19, 2014 3:24:40 PM Subject: [Users] Fwd: Sample code for setting NIC - CloudInit
Hi,
Can someone share me sample java code for assigning IP address for
VM on
eth0
through Java SDK via CloudInit ?
Hi Tejesh,
I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it.
Thanks, Moti
Something Like this but in Java: <network_configuration> <nics> <nic> <name>eth0</name> <boot_protocol>STATIC</boot_protocol> <network> <ip address="192.168.2.11" netmask="255.255.0.0" gateway="192.168.2.1" /> </network> <on_boot>true</on_boot> </nic> <nic> <name>eth1</name> <boot_protocol>DHCP</boot_protocol> </nic> <nic> <name>eth2</name> <boot_protocol>NONE</boot_protocol> <on_boot>true</on_boot> </nic> </nics> <dns> <servers> <host> <address>1.1.2.2</address> </host> <host> <address>1.2.3.4</address> </host> </servers> <search_domains> <host> <address>qa.lab</address> </host> <host> <address> google.com </address> </host> </search_domains> </dns> </network_configuration>
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh

On 02/20/2014 10:40 AM, Tejesh M wrote:
I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log.
I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this: iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0 But we actually pass them outside of the network interface, like this: dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0 I need to check it.
_*Java Code:*_ org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit();
cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData);
org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network();
DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com <http://google.com>")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics());
Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true));
networkConfiguration.setNics(nics);
cloudData.setNetwork(networkConfiguration);
Initialization initData = new Initialization();
initData.setCloudInit(cloudData);
VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart);
// Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData);
On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote:
----- Original Message ----- > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > To: "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com>> > Cc: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > Sent: Thursday, February 20, 2014 8:52:52 AM > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > I'm not getting below class: > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;
Which version of ovirt-engine-sdk-java are you using ?
I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.4.0.1-1</version> <type>jar</type> <scope>compile</scope> </dependency>
> > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote: > > > > > > > ----- Original Message ----- > > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for VM on > > eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request (as the output > > is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a feedback for it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > <network_configuration> > > > <nics> > > > <nic> > > > <name>eth0</name> > > > <boot_protocol>STATIC</boot_protocol> > > > <network> > > > <ip address="192.168.2.11" netmask="255.255.0.0" > > > gateway="192.168.2.1" /> > > > </network> > > > <on_boot>true</on_boot> > > > </nic> > > > <nic> > > > <name>eth1</name> > > > <boot_protocol>DHCP</boot_protocol> > > > </nic> > > > <nic> > > > <name>eth2</name> > > > <boot_protocol>NONE</boot_protocol> > > > <on_boot>true</on_boot> > > > </nic> > > > </nics> > > > <dns> > > > <servers> > > > <host> > > > <address>1.1.2.2</address> > > > </host> > > > <host> > > > <address>1.2.3.4</address> > > > </host> > > > </servers> > > > <search_domains> > > > <host> > > > <address>qa.lab</address> > > > </host> > > > <host> > > > <address> google.com <http://google.com> </address> > > > </host> > > > </search_domains> > > > </dns> > > > </network_configuration>
-- 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'm using rhevm 3.3 java sdk,which doesn't have NetworkConfiguration class. On 20 Feb 2014 20:58, "Juan Hernandez" <jhernand@redhat.com> wrote:
On 02/20/2014 10:40 AM, Tejesh M wrote:
I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log.
I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this:
iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
But we actually pass them outside of the network interface, like this:
dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
I need to check it.
_*Java Code:*_ org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit();
cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData);
org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network();
DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com <http://google.com>")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics());
Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true));
networkConfiguration.setNics(nics);
cloudData.setNetwork(networkConfiguration);
Initialization initData = new Initialization();
initData.setCloudInit(cloudData);
VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart);
// Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData);
On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote:
----- Original Message ----- > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > To: "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com>> > Cc: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > Sent: Thursday, February 20, 2014 8:52:52 AM > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > I'm not getting below class: > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;
Which version of ovirt-engine-sdk-java are you using ?
I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.4.0.1-1</version> <type>jar</type> <scope>compile</scope> </dependency>
> > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote: > > > > > > > ----- Original Message ----- > > > From: "Tejesh M" <tejeshmk@gmail.com <mailto: tejeshmk@gmail.com>> > > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org
> > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for VM on > > eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request (as the output > > is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a feedback for it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > <network_configuration> > > > <nics> > > > <nic> > > > <name>eth0</name> > > > <boot_protocol>STATIC</boot_protocol> > > > <network> > > > <ip address="192.168.2.11" netmask="255.255.0.0" > > > gateway="192.168.2.1" /> > > > </network> > > > <on_boot>true</on_boot> > > > </nic> > > > <nic> > > > <name>eth1</name> > > > <boot_protocol>DHCP</boot_protocol> > > > </nic> > > > <nic> > > > <name>eth2</name> > > > <boot_protocol>NONE</boot_protocol> > > > <on_boot>true</on_boot> > > > </nic> > > > </nics> > > > <dns> > > > <servers> > > > <host> > > > <address>1.1.2.2</address> > > > </host> > > > <host> > > > <address>1.2.3.4</address> > > > </host> > > > </servers> > > > <search_domains> > > > <host> > > > <address>qa.lab</address> > > > </host> > > > <host> > > > <address> google.com <http://google.com> </address> > > > </host> > > > </search_domains> > > > </dns> > > > </network_configuration>
-- 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/20/2014 05:09 PM, Tejesh M wrote:
I'm using rhevm 3.3 java sdk,which doesn't have NetworkConfiguration class.
In that case you will have to use CloudInit.Network. That was an error in that version of the SDK, which will be fixed with the next release.
On 20 Feb 2014 20:58, "Juan Hernandez" <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/20/2014 10:40 AM, Tejesh M wrote: > I wrote this code to assign IP address to VM interface eth0, but not > luck. Also, have attached debug log. >
I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this:
iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com <http://google.com> address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
But we actually pass them outside of the network interface, like this:
dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com <http://google.com> iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
I need to check it.
> _*Java Code:*_ > org.ovirt.engine.sdk.entities.User userData = new User(); > userData.setUserName("root"); > userData.setPassword(password); > Users usersData = new Users(); > usersData.getUsers().add(userData); > CloudInit cloudData = new CloudInit(); > > > cloudData.setUsers(usersData); > Host hostData = new Host(); > hostData.setAddress(vmName); > cloudData.setHost(hostData); > > org.ovirt.engine.sdk.entities.CloudInit.Network > networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network(); > > DNS dns = new DNS(); > dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); > dns.setSearchDomains(createServersList("google.com <http://google.com> > <http://google.com>")); > networkConfiguration.setDns(dns); > networkConfiguration.setNics(new Nics()); > > Nics nics = networkConfiguration.getNics(); > nics.getNics().add(createNic("eth0", "STATIC", > createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); > > networkConfiguration.setNics(nics); > > cloudData.setNetwork(networkConfiguration); > > Initialization initData = new Initialization(); > > initData.setCloudInit(cloudData); > > VM vmDataForStart = new VM(); > vmDataForStart.setInitialization(initData); > Action actionData = new Action(); > actionData.setVm(vmDataForStart); > > // Send the request to start the VM to the server: > api.getVMs().get(vmName).start(actionData); > > > > > > > On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com> > <mailto:masayag@redhat.com <mailto:masayag@redhat.com>>> wrote: > > > > ----- Original Message ----- > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>> > > To: "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com> <mailto:masayag@redhat.com <mailto:masayag@redhat.com>>> > > Cc: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > > Sent: Thursday, February 20, 2014 8:52:52 AM > > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > I'm not getting below class: > > > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; > > Which version of ovirt-engine-sdk-java are you using ? > > I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml: > > <dependency> > <groupId>org.ovirt.engine.sdk</groupId> > <artifactId>ovirt-engine-sdk-java</artifactId> > <version>3.4.0.1-1</version> > <type>jar</type> > <scope>compile</scope> > </dependency> > > > > > > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com> > <mailto:masayag@redhat.com <mailto:masayag@redhat.com>>> wrote: > > > > > > > > > > > ----- Original Message ----- > > > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>> > > > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > > > Hi, > > > > > > > > Can someone share me sample java code for assigning IP address > for VM on > > > eth0 > > > > through Java SDK via CloudInit ? > > > > > > > > > > Hi Tejesh, > > > > > > I've attached a sample code that sends the required request (as > the output > > > is demonstrated in debug mode). > > > Note that the code is jdk-7 compliant. > > > I haven't configured cloud-init and haven't tested it end-to-end. > > > Please try to test it on your environment and provide a feedback > for it. > > > > > > Thanks, > > > Moti > > > > > > > Something Like this but in Java: > > > > <network_configuration> > > > > <nics> > > > > <nic> > > > > <name>eth0</name> > > > > <boot_protocol>STATIC</boot_protocol> > > > > <network> > > > > <ip address="192.168.2.11" netmask="255.255.0.0" > > > > gateway="192.168.2.1" /> > > > > </network> > > > > <on_boot>true</on_boot> > > > > </nic> > > > > <nic> > > > > <name>eth1</name> > > > > <boot_protocol>DHCP</boot_protocol> > > > > </nic> > > > > <nic> > > > > <name>eth2</name> > > > > <boot_protocol>NONE</boot_protocol> > > > > <on_boot>true</on_boot> > > > > </nic> > > > > </nics> > > > > <dns> > > > > <servers> > > > > <host> > > > > <address>1.1.2.2</address> > > > > </host> > > > > <host> > > > > <address>1.2.3.4</address> > > > > </host> > > > > </servers> > > > > <search_domains> > > > > <host> > > > > <address>qa.lab</address> > > > > </host> > > > > <host> > > > > <address> google.com <http://google.com> <http://google.com> </address> > > > > </host> > > > > </search_domains> > > > > </dns> > > > > </network_configuration>
-- 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.
-- 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/20/2014 04:28 PM, Juan Hernandez wrote:
On 02/20/2014 10:40 AM, Tejesh M wrote:
I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log.
I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this:
iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
But we actually pass them outside of the network interface, like this:
dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
I need to check it.
I have modified the code that generates the cloud-init files to put the DNS configuration inside the "iface" configuration, and then it works: http://gerrit.ovirt.org/24850 So this is probably a bug, either in our side or in cloud-init itself. Greg, Shahar, you know cloud-init better, what do you think?
_*Java Code:*_ org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit();
cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData);
org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network();
DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com <http://google.com>")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics());
Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true));
networkConfiguration.setNics(nics);
cloudData.setNetwork(networkConfiguration);
Initialization initData = new Initialization();
initData.setCloudInit(cloudData);
VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart);
// Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData);
On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote:
----- Original Message ----- > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > To: "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com>> > Cc: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > Sent: Thursday, February 20, 2014 8:52:52 AM > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > I'm not getting below class: > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;
Which version of ovirt-engine-sdk-java are you using ?
I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.4.0.1-1</version> <type>jar</type> <scope>compile</scope> </dependency>
> > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote: > > > > > > > ----- Original Message ----- > > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for VM on > > eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request (as the output > > is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a feedback for it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > <network_configuration> > > > <nics> > > > <nic> > > > <name>eth0</name> > > > <boot_protocol>STATIC</boot_protocol> > > > <network> > > > <ip address="192.168.2.11" netmask="255.255.0.0" > > > gateway="192.168.2.1" /> > > > </network> > > > <on_boot>true</on_boot> > > > </nic> > > > <nic> > > > <name>eth1</name> > > > <boot_protocol>DHCP</boot_protocol> > > > </nic> > > > <nic> > > > <name>eth2</name> > > > <boot_protocol>NONE</boot_protocol> > > > <on_boot>true</on_boot> > > > </nic> > > > </nics> > > > <dns> > > > <servers> > > > <host> > > > <address>1.1.2.2</address> > > > </host> > > > <host> > > > <address>1.2.3.4</address> > > > </host> > > > </servers> > > > <search_domains> > > > <host> > > > <address>qa.lab</address> > > > </host> > > > <host> > > > <address> google.com <http://google.com> </address> > > > </host> > > > </search_domains> > > > </dns> > > > </network_configuration>
-- 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/20/2014 02:26 PM, Juan Hernandez wrote:
On 02/20/2014 04:28 PM, Juan Hernandez wrote:
On 02/20/2014 10:40 AM, Tejesh M wrote:
I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log.
I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this:
iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
But we actually pass them outside of the network interface, like this:
dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
I need to check it.
I have modified the code that generates the cloud-init files to put the DNS configuration inside the "iface" configuration, and then it works:
So this is probably a bug, either in our side or in cloud-init itself. Greg, Shahar, you know cloud-init better, what do you think?
It looks like our bug. Cloud-init wants to see a standard debian/ubuntu style /etc/network/interfaces, and the documentation for that format supports your change. Thanks for posting the patch!
_*Java Code:*_ org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit();
cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData);
org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network();
DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com <http://google.com>")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics());
Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true));
networkConfiguration.setNics(nics);
cloudData.setNetwork(networkConfiguration);
Initialization initData = new Initialization();
initData.setCloudInit(cloudData);
VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart);
// Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData);
On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote:
----- Original Message ----- > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > To: "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com>> > Cc: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > Sent: Thursday, February 20, 2014 8:52:52 AM > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > I'm not getting below class: > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;
Which version of ovirt-engine-sdk-java are you using ?
I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.4.0.1-1</version> <type>jar</type> <scope>compile</scope> </dependency>
> > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote: > > > > > > > ----- Original Message ----- > > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for VM on > > eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request (as the output > > is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a feedback for it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > <network_configuration> > > > <nics> > > > <nic> > > > <name>eth0</name> > > > <boot_protocol>STATIC</boot_protocol> > > > <network> > > > <ip address="192.168.2.11" netmask="255.255.0.0" > > > gateway="192.168.2.1" /> > > > </network> > > > <on_boot>true</on_boot> > > > </nic> > > > <nic> > > > <name>eth1</name> > > > <boot_protocol>DHCP</boot_protocol> > > > </nic> > > > <nic> > > > <name>eth2</name> > > > <boot_protocol>NONE</boot_protocol> > > > <on_boot>true</on_boot> > > > </nic> > > > </nics> > > > <dns> > > > <servers> > > > <host> > > > <address>1.1.2.2</address> > > > </host> > > > <host> > > > <address>1.2.3.4</address> > > > </host> > > > </servers> > > > <search_domains> > > > <host> > > > <address>qa.lab</address> > > > </host> > > > <host> > > > <address> google.com <http://google.com> </address> > > > </host> > > > </search_domains> > > > </dns> > > > </network_configuration>

On 02/20/2014 08:42 PM, Greg Padgett wrote:
On 02/20/2014 02:26 PM, Juan Hernandez wrote:
On 02/20/2014 04:28 PM, Juan Hernandez wrote:
On 02/20/2014 10:40 AM, Tejesh M wrote:
I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log.
I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this:
iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
But we actually pass them outside of the network interface, like this:
dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0
I need to check it.
I have modified the code that generates the cloud-init files to put the DNS configuration inside the "iface" configuration, and then it works:
So this is probably a bug, either in our side or in cloud-init itself. Greg, Shahar, you know cloud-init better, what do you think?
I opened the following bug to track it: https://bugzilla.redhat.com/1067906
It looks like our bug. Cloud-init wants to see a standard debian/ubuntu style /etc/network/interfaces, and the documentation for that format supports your change. Thanks for posting the patch!
_*Java Code:*_ org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit();
cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData);
org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network();
DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com <http://google.com>")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics());
Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true));
networkConfiguration.setNics(nics);
cloudData.setNetwork(networkConfiguration);
Initialization initData = new Initialization();
initData.setCloudInit(cloudData);
VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart);
// Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData);
On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote:
----- Original Message ----- > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > To: "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com>> > Cc: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > Sent: Thursday, February 20, 2014 8:52:52 AM > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > I'm not getting below class: > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;
Which version of ovirt-engine-sdk-java are you using ?
I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.4.0.1-1</version> <type>jar</type> <scope>compile</scope> </dependency>
> > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <masayag@redhat.com <mailto:masayag@redhat.com>> wrote: > > > > > > > ----- Original Message ----- > > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for VM on > > eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request (as the output > > is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a feedback for it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > <network_configuration> > > > <nics> > > > <nic> > > > <name>eth0</name> > > > <boot_protocol>STATIC</boot_protocol> > > > <network> > > > <ip address="192.168.2.11" netmask="255.255.0.0" > > > gateway="192.168.2.1" /> > > > </network> > > > <on_boot>true</on_boot> > > > </nic> > > > <nic> > > > <name>eth1</name> > > > <boot_protocol>DHCP</boot_protocol> > > > </nic> > > > <nic> > > > <name>eth2</name> > > > <boot_protocol>NONE</boot_protocol> > > > <on_boot>true</on_boot> > > > </nic> > > > </nics> > > > <dns> > > > <servers> > > > <host> > > > <address>1.1.2.2</address> > > > </host> > > > <host> > > > <address>1.2.3.4</address> > > > </host> > > > </servers> > > > <search_domains> > > > <host> > > > <address>qa.lab</address> > > > </host> > > > <host> > > > <address> google.com <http://google.com> </address> > > > </host> > > > </search_domains> > > > </dns> > > > </network_configuration>
-- 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.

Ok. Will it take long time for that sdk to release? On 20 Feb 2014 04:11, "Moti Asayag" <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "users@oVirt.org" <users@ovirt.org> Sent: Wednesday, February 19, 2014 3:24:40 PM Subject: [Users] Fwd: Sample code for setting NIC - CloudInit
Hi,
Can someone share me sample java code for assigning IP address for VM on eth0 through Java SDK via CloudInit ?
Hi Tejesh,
I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it.
Thanks, Moti
Something Like this but in Java: <network_configuration> <nics> <nic> <name>eth0</name> <boot_protocol>STATIC</boot_protocol> <network> <ip address="192.168.2.11" netmask="255.255.0.0" gateway="192.168.2.1" /> </network> <on_boot>true</on_boot> </nic> <nic> <name>eth1</name> <boot_protocol>DHCP</boot_protocol> </nic> <nic> <name>eth2</name> <boot_protocol>NONE</boot_protocol> <on_boot>true</on_boot> </nic> </nics> <dns> <servers> <host> <address>1.1.2.2</address> </host> <host> <address>1.2.3.4</address> </host> </servers> <search_domains> <host> <address>qa.lab</address> </host> <host> <address> google.com </address> </host> </search_domains> </dns> </network_configuration>
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 02/20/2014 05:56 PM, Tejesh M wrote:
Ok. Will it take long time for that sdk to release?
No, it should be released soon. Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is almost identical to the RHEV-M Jaa SDK. If you are using maven these are the coordinates of the artifact: <dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.3.3.0</version> </dependency> If you aren't using maven you can still download the .jar file from here: http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar
On 20 Feb 2014 04:11, "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com>> wrote:
----- Original Message ----- > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > Sent: Wednesday, February 19, 2014 3:24:40 PM > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > Hi, > > Can someone share me sample java code for assigning IP address for VM on eth0 > through Java SDK via CloudInit ? >
Hi Tejesh,
I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it.
Thanks, Moti
> Something Like this but in Java: > <network_configuration> > <nics> > <nic> > <name>eth0</name> > <boot_protocol>STATIC</boot_protocol> > <network> > <ip address="192.168.2.11" netmask="255.255.0.0" > gateway="192.168.2.1" /> > </network> > <on_boot>true</on_boot> > </nic> > <nic> > <name>eth1</name> > <boot_protocol>DHCP</boot_protocol> > </nic> > <nic> > <name>eth2</name> > <boot_protocol>NONE</boot_protocol> > <on_boot>true</on_boot> > </nic> > </nics> > <dns> > <servers> > <host> > <address>1.1.2.2</address> > </host> > <host> > <address>1.2.3.4</address> > </host> > </servers> > <search_domains> > <host> > <address>qa.lab</address> > </host> > <host> > <address> google.com <http://google.com> </address> > </host> > </search_domains> > </dns> > </network_configuration> > > > > -- > Thanks & Regards > Tejesh > > _______________________________________________ > Users mailing list > Users@ovirt.org <mailto:Users@ovirt.org> > http://lists.ovirt.org/mailman/listinfo/users >
_______________________________________________ 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.

When i try to execute with the ovirt sdk 3.3.3 and do operations on RHEV-M 3.3, it fails with below error Exception in thread "main" java.lang.UnsupportedClassVersionError: org/ovirt/engine/sdk/Api at rhvm.callAPI(rhvm.java:238) at rhvm.main(rhvm.java:278) On Fri, Feb 21, 2014 at 12:19 AM, Juan Hernandez <jhernand@redhat.com>wrote:
On 02/20/2014 05:56 PM, Tejesh M wrote:
Ok. Will it take long time for that sdk to release?
No, it should be released soon.
Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is almost identical to the RHEV-M Jaa SDK.
If you are using maven these are the coordinates of the artifact:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.3.3.0</version> </dependency>
If you aren't using maven you can still download the .jar file from here:
http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar
On 20 Feb 2014 04:11, "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com>> wrote:
----- Original Message ----- > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>> > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org>> > Sent: Wednesday, February 19, 2014 3:24:40 PM > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > Hi, > > Can someone share me sample java code for assigning IP address for VM on eth0 > through Java SDK via CloudInit ? >
Hi Tejesh,
I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it.
Thanks, Moti
> Something Like this but in Java: > <network_configuration> > <nics> > <nic> > <name>eth0</name> > <boot_protocol>STATIC</boot_protocol> > <network> > <ip address="192.168.2.11" netmask="255.255.0.0" > gateway="192.168.2.1" /> > </network> > <on_boot>true</on_boot> > </nic> > <nic> > <name>eth1</name> > <boot_protocol>DHCP</boot_protocol> > </nic> > <nic> > <name>eth2</name> > <boot_protocol>NONE</boot_protocol> > <on_boot>true</on_boot> > </nic> > </nics> > <dns> > <servers> > <host> > <address>1.1.2.2</address> > </host> > <host> > <address>1.2.3.4</address> > </host> > </servers> > <search_domains> > <host> > <address>qa.lab</address> > </host> > <host> > <address> google.com <http://google.com> </address> > </host> > </search_domains> > </dns> > </network_configuration> > > > > -- > Thanks & Regards > Tejesh > > _______________________________________________ > Users mailing list > Users@ovirt.org <mailto:Users@ovirt.org> > http://lists.ovirt.org/mailman/listinfo/users >
_______________________________________________ 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/21/2014 08:13 AM, Tejesh M wrote:
When i try to execute with the ovirt sdk 3.3.3 and do operations on RHEV-M 3.3, it fails with below error
This happens because the oVirt SDK is compiled with Java 7, and you are probably using Java 6. I suggest to switch to Java 7, unless there is a very good reason to stick to Java 6. Java 6 "end of life" was declared by Oracle on Feb 1023. However, the OpenJDK community still support Java 6, so if you really need it please tell us, and we can try to make a version of the oVirt SDK compatible with Java 6.
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/ovirt/engine/sdk/Api at rhvm.callAPI(rhvm.java:238) at rhvm.main(rhvm.java:278)
On Fri, Feb 21, 2014 at 12:19 AM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/20/2014 05:56 PM, Tejesh M wrote: > Ok. Will it take long time for that sdk to release? >
No, it should be released soon.
Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is almost identical to the RHEV-M Jaa SDK.
If you are using maven these are the coordinates of the artifact:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.3.3.0</version> </dependency>
If you aren't using maven you can still download the .jar file from here:
http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar
> On 20 Feb 2014 04:11, "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com> > <mailto:masayag@redhat.com <mailto:masayag@redhat.com>>> wrote: > > > > ----- Original Message ----- > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>> > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > Hi, > > > > Can someone share me sample java code for assigning IP address for > VM on eth0 > > through Java SDK via CloudInit ? > > > > Hi Tejesh, > > I've attached a sample code that sends the required request (as the > output is demonstrated in debug mode). > Note that the code is jdk-7 compliant. > I haven't configured cloud-init and haven't tested it end-to-end. > Please try to test it on your environment and provide a feedback for it. > > Thanks, > Moti > > > Something Like this but in Java: > > <network_configuration> > > <nics> > > <nic> > > <name>eth0</name> > > <boot_protocol>STATIC</boot_protocol> > > <network> > > <ip address="192.168.2.11" netmask="255.255.0.0" > > gateway="192.168.2.1" /> > > </network> > > <on_boot>true</on_boot> > > </nic> > > <nic> > > <name>eth1</name> > > <boot_protocol>DHCP</boot_protocol> > > </nic> > > <nic> > > <name>eth2</name> > > <boot_protocol>NONE</boot_protocol> > > <on_boot>true</on_boot> > > </nic> > > </nics> > > <dns> > > <servers> > > <host> > > <address>1.1.2.2</address> > > </host> > > <host> > > <address>1.2.3.4</address> > > </host> > > </servers> > > <search_domains> > > <host> > > <address>qa.lab</address> > > </host> > > <host> > > <address> google.com <http://google.com> <http://google.com> </address> > > </host> > > </search_domains> > > </dns> > > </network_configuration> > > > >
-- 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. It worked. On Fri, Feb 21, 2014 at 4:25 PM, Juan Hernandez <jhernand@redhat.com> wrote:
On 02/21/2014 08:13 AM, Tejesh M wrote:
When i try to execute with the ovirt sdk 3.3.3 and do operations on RHEV-M 3.3, it fails with below error
This happens because the oVirt SDK is compiled with Java 7, and you are probably using Java 6.
I suggest to switch to Java 7, unless there is a very good reason to stick to Java 6. Java 6 "end of life" was declared by Oracle on Feb 1023.
However, the OpenJDK community still support Java 6, so if you really need it please tell us, and we can try to make a version of the oVirt SDK compatible with Java 6.
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/ovirt/engine/sdk/Api at rhvm.callAPI(rhvm.java:238) at rhvm.main(rhvm.java:278)
On Fri, Feb 21, 2014 at 12:19 AM, Juan Hernandez <jhernand@redhat.com <mailto:jhernand@redhat.com>> wrote:
On 02/20/2014 05:56 PM, Tejesh M wrote: > Ok. Will it take long time for that sdk to release? >
No, it should be released soon.
Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is almost identical to the RHEV-M Jaa SDK.
If you are using maven these are the coordinates of the artifact:
<dependency> <groupId>org.ovirt.engine.sdk</groupId> <artifactId>ovirt-engine-sdk-java</artifactId> <version>3.3.3.0</version> </dependency>
If you aren't using maven you can still download the .jar file from here:
http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar
> On 20 Feb 2014 04:11, "Moti Asayag" <masayag@redhat.com <mailto:masayag@redhat.com> > <mailto:masayag@redhat.com <mailto:masayag@redhat.com>>> wrote: > > > > ----- Original Message ----- > > From: "Tejesh M" <tejeshmk@gmail.com <mailto:tejeshmk@gmail.com> <mailto:tejeshmk@gmail.com <mailto:tejeshmk@gmail.com>>> > > To: "users@oVirt.org" <users@ovirt.org <mailto:users@ovirt.org> <mailto:users@ovirt.org <mailto:users@ovirt.org>>> > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > Hi, > > > > Can someone share me sample java code for assigning IP address for > VM on eth0 > > through Java SDK via CloudInit ? > > > > Hi Tejesh, > > I've attached a sample code that sends the required request (as the > output is demonstrated in debug mode). > Note that the code is jdk-7 compliant. > I haven't configured cloud-init and haven't tested it
end-to-end.
> Please try to test it on your environment and provide a feedback for it. > > Thanks, > Moti > > > Something Like this but in Java: > > <network_configuration> > > <nics> > > <nic> > > <name>eth0</name> > > <boot_protocol>STATIC</boot_protocol> > > <network> > > <ip address="192.168.2.11"
netmask="255.255.0.0"
> > gateway="192.168.2.1" /> > > </network> > > <on_boot>true</on_boot> > > </nic> > > <nic> > > <name>eth1</name> > > <boot_protocol>DHCP</boot_protocol> > > </nic> > > <nic> > > <name>eth2</name> > > <boot_protocol>NONE</boot_protocol> > > <on_boot>true</on_boot> > > </nic> > > </nics> > > <dns> > > <servers> > > <host> > > <address>1.1.2.2</address> > > </host> > > <host> > > <address>1.2.3.4</address> > > </host> > > </servers> > > <search_domains> > > <host> > > <address>qa.lab</address> > > </host> > > <host> > > <address> google.com <http://google.com> <http://google.com> </address> > > </host> > > </search_domains> > > </dns> > > </network_configuration> > > > >
-- 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

Also, any workaround to assign ip? On 20 Feb 2014 04:11, "Moti Asayag" <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "users@oVirt.org" <users@ovirt.org> Sent: Wednesday, February 19, 2014 3:24:40 PM Subject: [Users] Fwd: Sample code for setting NIC - CloudInit
Hi,
Can someone share me sample java code for assigning IP address for VM on eth0 through Java SDK via CloudInit ?
Hi Tejesh,
I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it.
Thanks, Moti
Something Like this but in Java: <network_configuration> <nics> <nic> <name>eth0</name> <boot_protocol>STATIC</boot_protocol> <network> <ip address="192.168.2.11" netmask="255.255.0.0" gateway="192.168.2.1" /> </network> <on_boot>true</on_boot> </nic> <nic> <name>eth1</name> <boot_protocol>DHCP</boot_protocol> </nic> <nic> <name>eth2</name> <boot_protocol>NONE</boot_protocol> <on_boot>true</on_boot> </nic> </nics> <dns> <servers> <host> <address>1.1.2.2</address> </host> <host> <address>1.2.3.4</address> </host> </servers> <search_domains> <host> <address>qa.lab</address> </host> <host> <address> google.com </address> </host> </search_domains> </dns> </network_configuration>
-- Thanks & Regards Tejesh
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (4)
-
Greg Padgett
-
Juan Hernandez
-
Moti Asayag
-
Tejesh M