Discussion:
[ovirt-users] cloud_init not apply when v create from API
(too old to reply)
Arpit Makhiyaviya
2016-03-29 12:03:32 UTC
Permalink
Hello,
we are using ovirt api with json data format.
we have create vm from template and i want to set ip,macaddress,user and
password for that we are using cloud_init for that we it can't set any
options.


Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
Renout Gerrits
2016-03-29 12:54:12 UTC
Permalink
In the more recent versions you have to use 'use_cloud_init=True' in the
api, which isn't described in most documentation yet. Maybe thats the
reason it isn't working?

Here's a working snippet:

vm = api.vms.get(name=vm_name)

action = params.Action(
use_cloud_init=True,
vm=params.VM(
initialization=params.Initialization(
regenerate_ssh_keys=True,
host_name=vm_fqdn,
nic_configurations=params.GuestNicsConfiguration(
nic_configuration=[
params.GuestNicConfiguration(
name="eth0",
boot_protocol="static",
on_boot=True,
ip=params.IP(
address=vm_address,
netmask=vm_netmask,
gateway=vm_gateway,
),
),
],
),
),
),
)

vm.start(action)
Post by Arpit Makhiyaviya
Hello,
we are using ovirt api with json data format.
we have create vm from template and i want to set ip,macaddress,user and
password for that we are using cloud_init for that we it can't set any
options.
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
_______________________________________________
Users mailing list
http://lists.ovirt.org/mailman/listinfo/users
Arpit Makhiyaviya
2016-03-29 13:07:46 UTC
Permalink
Thanks for quick response.
we already knew this and we are passing following xml when calling Start
action.

<action>
<vm>
<initialization>
<cloud_init>
<host>
<address>vm-cloud-init-restapi</address>
</host>
<authorized_keys>
<authorized_key>
<user>
<user_name>root</user_name>
</user>
<key>ssh-rsa restapi-cloud-init-ssh-key ***@localdomain</key>
</authorized_key>
</authorized_keys>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
<password>SuperSecretPassword!</password>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth0</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="192.168.2.11" netmask="255.255.255.0"
gateway="192.168.2.254" />
</network>
<on_boot>true</on_boot>
</nic>
<nic>
<name>eth1</name>
<boot_protocol>DHCP</boot_protocol>
<on_boot>true</on_boot>
</nic>
</nics>
<dns>
<servers>
<host>
<address>10.20.30.100</address>
</host>
</servers>
<search_domains>
<host>
<address>domain.your.rhevm.com</address>
</host>
</search_domains>
</dns>
</network_configuration>
<files>
<file>
<name>/tmp/file1.txt</name>
<content>line 1
line 2
and now something special
!@#$%^&amp;*()_+</content>
<type>PLAINTEXT</type>
</file>
</files>
</cloud_init>
</initialization>
</vm>
</action>

we also found following link . is this related to my issue?

https://gerrit.ovirt.org/#/c/50240/2

Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
Post by Renout Gerrits
In the more recent versions you have to use 'use_cloud_init=True' in the
api, which isn't described in most documentation yet. Maybe thats the
reason it isn't working?
vm = api.vms.get(name=vm_name)
action = params.Action(
use_cloud_init=True,
vm=params.VM(
initialization=params.Initialization(
regenerate_ssh_keys=True,
host_name=vm_fqdn,
nic_configurations=params.GuestNicsConfiguration(
nic_configuration=[
params.GuestNicConfiguration(
name="eth0",
boot_protocol="static",
on_boot=True,
ip=params.IP(
address=vm_address,
netmask=vm_netmask,
gateway=vm_gateway,
),
),
],
),
),
),
)
vm.start(action)
On Tue, Mar 29, 2016 at 2:03 PM, Arpit Makhiyaviya <
Post by Arpit Makhiyaviya
Hello,
we are using ovirt api with json data format.
we have create vm from template and i want to set ip,macaddress,user and
password for that we are using cloud_init for that we it can't set any
options.
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
_______________________________________________
Users mailing list
http://lists.ovirt.org/mailman/listinfo/users
Juan Hernández
2016-03-29 18:57:18 UTC
Permalink
Post by Arpit Makhiyaviya
Thanks for quick response.
we already knew this and we are passing following xml when calling Start
action.
What version of the engine are you using exactly? This is a known bug.
The "cloud_init" element is ignored. See here for details:

Cloud-Init payload not passed into VM via python SDK
https://bugzilla.redhat.com/1305904

That will be fixed in version 3.6.5. If you have a version 3.6.2 or
newer then you can use the workaround described there, using the
"initailization" element directly.
Post by Arpit Makhiyaviya
<action>
<vm>
<initialization>
<cloud_init>
<host>
<address>vm-cloud-init-restapi</address>
</host>
<authorized_keys>
<authorized_key>
<user>
<user_name>root</user_name>
</user>
</authorized_key>
</authorized_keys>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
<password>SuperSecretPassword!</password>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth0</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="192.168.2.11" netmask="255.255.255.0"
gateway="192.168.2.254" />
</network>
<on_boot>true</on_boot>
</nic>
<nic>
<name>eth1</name>
<boot_protocol>DHCP</boot_protocol>
<on_boot>true</on_boot>
</nic>
</nics>
<dns>
<servers>
<host>
<address>10.20.30.100</address>
</host>
</servers>
<search_domains>
<host>
<address>domain.your.rhevm.com
<http://domain.your.rhevm.com></address>
</host>
</search_domains>
</dns>
</network_configuration>
<files>
<file>
<name>/tmp/file1.txt</name>
<content>line 1
line 2
and now something special
<type>PLAINTEXT</type>
</file>
</files>
</cloud_init>
</initialization>
</vm>
</action>
we also found following link . is this related to my issue?
https://gerrit.ovirt.org/#/c/50240/2
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
In the more recent versions you have to use 'use_cloud_init=True' in
the api, which isn't described in most documentation yet. Maybe
thats the reason it isn't working?
vm = api.vms.get(name=vm_name)
action = params.Action(
use_cloud_init=True,
vm=params.VM(
initialization=params.Initialization(
regenerate_ssh_keys=True,
host_name=vm_fqdn,
nic_configurations=params.GuestNicsConfiguration(
nic_configuration=[
params.GuestNicConfiguration(
name="eth0",
boot_protocol="static",
on_boot=True,
ip=params.IP(
address=vm_address,
netmask=vm_netmask,
gateway=vm_gateway,
),
),
],
),
),
),
)
vm.start(action)
On Tue, Mar 29, 2016 at 2:03 PM, Arpit Makhiyaviya
Hello,
we are using ovirt api with json data format.
we have create vm from template and i want to set
ip,macaddress,user and password for that we are using cloud_init
for that we it can't set any options.
--
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.
Arpit Makhiyaviya
2016-03-30 06:44:05 UTC
Permalink
I used *Version: 3.6.3.4-1.el7.centos* of ovirt engine.I already tried
following xml request with run VM but still its not working.
From admin panel of oVirt Its completely working but I found issue only
with oVirt API (VM start but cloudinit data not accepted).

*XML Request : *

<action>
<async>false</async>
<use_cloud_init>true</use_cloud_init>
<vm>
<initialization>
<cloud_init>
<host>
<address>vishal.123456</address>
</host>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
<password>***@131</password>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth1</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="51.254.56.84" netmask="255.255.255.255"
gateway="149.202.85.254" />
</network>
<on_boot>false</on_boot>
</nic>

</nics>
<dns>
<servers>
<host>
<address>8.8.8.8</address>
</host>
</servers>
<search_domains>
<host>
<address>8.8.4.4</address>
</host>
</search_domains>
</dns>
</network_configuration>


</cloud_init>
</initialization>
</vm>

</action>

Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
Post by Juan Hernández
Post by Arpit Makhiyaviya
Thanks for quick response.
we already knew this and we are passing following xml when calling Start
action.
What version of the engine are you using exactly? This is a known bug.
Cloud-Init payload not passed into VM via python SDK
https://bugzilla.redhat.com/1305904
That will be fixed in version 3.6.5. If you have a version 3.6.2 or
newer then you can use the workaround described there, using the
"initailization" element directly.
Post by Arpit Makhiyaviya
<action>
<vm>
<initialization>
<cloud_init>
<host>
<address>vm-cloud-init-restapi</address>
</host>
<authorized_keys>
<authorized_key>
<user>
<user_name>root</user_name>
</user>
</key>
Post by Arpit Makhiyaviya
</authorized_key>
</authorized_keys>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
<password>SuperSecretPassword!</password>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth0</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="192.168.2.11" netmask="255.255.255.0"
gateway="192.168.2.254" />
</network>
<on_boot>true</on_boot>
</nic>
<nic>
<name>eth1</name>
<boot_protocol>DHCP</boot_protocol>
<on_boot>true</on_boot>
</nic>
</nics>
<dns>
<servers>
<host>
<address>10.20.30.100</address>
</host>
</servers>
<search_domains>
<host>
<address>domain.your.rhevm.com
<http://domain.your.rhevm.com></address>
</host>
</search_domains>
</dns>
</network_configuration>
<files>
<file>
<name>/tmp/file1.txt</name>
<content>line 1
line 2
and now something special
<type>PLAINTEXT</type>
</file>
</files>
</cloud_init>
</initialization>
</vm>
</action>
we also found following link . is this related to my issue?
https://gerrit.ovirt.org/#/c/50240/2
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
In the more recent versions you have to use 'use_cloud_init=True' in
the api, which isn't described in most documentation yet. Maybe
thats the reason it isn't working?
vm = api.vms.get(name=vm_name)
action = params.Action(
use_cloud_init=True,
vm=params.VM(
initialization=params.Initialization(
regenerate_ssh_keys=True,
host_name=vm_fqdn,
nic_configurations=params.GuestNicsConfiguration(
nic_configuration=[
params.GuestNicConfiguration(
name="eth0",
boot_protocol="static",
on_boot=True,
ip=params.IP(
address=vm_address,
netmask=vm_netmask,
gateway=vm_gateway,
),
),
],
),
),
),
)
vm.start(action)
On Tue, Mar 29, 2016 at 2:03 PM, Arpit Makhiyaviya
Hello,
we are using ovirt api with json data format.
we have create vm from template and i want to set
ip,macaddress,user and password for that we are using cloud_init
for that we it can't set any options.
--
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.
Juan Hernández
2016-03-30 08:51:57 UTC
Permalink
Post by Arpit Makhiyaviya
I used *Version: 3.6.3.4-1.el7.centos* of ovirt engine.I already tried
following xml request with run VM but still its not working.
From admin panel of oVirt Its completely working but I found issue only
with oVirt API (VM start but cloudinit data not accepted).
Version 3.6.3.4 is affected by the bug that I mentioned. The result is
that the "cloud_init" element is just ignored. That will be fixed in
version 3.6.5. Meanwhile you can use the workaround suggested in comment
1 of the bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1305904#c1

Translated to XML it should look like described by Karim Boumedhel in
comment 7:

https://bugzilla.redhat.com/show_bug.cgi?id=1305904#c7
Post by Arpit Makhiyaviya
*XML Request : *
<action>
<async>false</async>
<use_cloud_init>true</use_cloud_init>
<vm>
<initialization>
<cloud_init>
<host>
<address>vishal.123456</address>
</host>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth1</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="51.254.56.84" netmask="255.255.255.255"
gateway="149.202.85.254" />
</network>
<on_boot>false</on_boot>
</nic>
</nics>
<dns>
<servers>
<host>
<address>8.8.8.8</address>
</host>
</servers>
<search_domains>
<host>
<address>8.8.4.4</address>
</host>
</search_domains>
</dns>
</network_configuration>
</cloud_init>
</initialization>
</vm>
</action>
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
Post by Arpit Makhiyaviya
Thanks for quick response.
we already knew this and we are passing following xml when calling
Start
Post by Arpit Makhiyaviya
action.
What version of the engine are you using exactly? This is a known bug.
Cloud-Init payload not passed into VM via python SDK
https://bugzilla.redhat.com/1305904
That will be fixed in version 3.6.5. If you have a version 3.6.2 or
newer then you can use the workaround described there, using the
"initailization" element directly.
Post by Arpit Makhiyaviya
<action>
<vm>
<initialization>
<cloud_init>
<host>
<address>vm-cloud-init-restapi</address>
</host>
<authorized_keys>
<authorized_key>
<user>
<user_name>root</user_name>
</user>
<key>ssh-rsa restapi-cloud-init-ssh-key
</authorized_key>
</authorized_keys>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
<password>SuperSecretPassword!</password>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth0</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="192.168.2.11" netmask="255.255.255.0"
gateway="192.168.2.254" />
</network>
<on_boot>true</on_boot>
</nic>
<nic>
<name>eth1</name>
<boot_protocol>DHCP</boot_protocol>
<on_boot>true</on_boot>
</nic>
</nics>
<dns>
<servers>
<host>
<address>10.20.30.100</address>
</host>
</servers>
<search_domains>
<host>
<address>domain.your.rhevm.com
<http://domain.your.rhevm.com>
Post by Arpit Makhiyaviya
<http://domain.your.rhevm.com></address>
</host>
</search_domains>
</dns>
</network_configuration>
<files>
<file>
<name>/tmp/file1.txt</name>
<content>line 1
line 2
and now something special
<type>PLAINTEXT</type>
</file>
</files>
</cloud_init>
</initialization>
</vm>
</action>
we also found following link . is this related to my issue?
https://gerrit.ovirt.org/#/c/50240/2
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
In the more recent versions you have to use
'use_cloud_init=True' in
Post by Arpit Makhiyaviya
the api, which isn't described in most documentation yet. Maybe
thats the reason it isn't working?
vm = api.vms.get(name=vm_name)
action = params.Action(
use_cloud_init=True,
vm=params.VM(
initialization=params.Initialization(
regenerate_ssh_keys=True,
host_name=vm_fqdn,
nic_configurations=params.GuestNicsConfiguration(
nic_configuration=[
params.GuestNicConfiguration(
name="eth0",
boot_protocol="static",
on_boot=True,
ip=params.IP(
address=vm_address,
netmask=vm_netmask,
gateway=vm_gateway,
),
),
],
),
),
),
)
vm.start(action)
On Tue, Mar 29, 2016 at 2:03 PM, Arpit Makhiyaviya
Hello,
we are using ovirt api with json data format.
we have create vm from template and i want to set
ip,macaddress,user and password for that we are using
cloud_init
Post by Arpit Makhiyaviya
for that we it can't set any options.
--
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.
Arpit Makhiyaviya
2016-03-30 10:14:07 UTC
Permalink
Thanks, that's works for me .
Post by Juan Hernández
Post by Arpit Makhiyaviya
I used *Version: 3.6.3.4-1.el7.centos* of ovirt engine.I already tried
following xml request with run VM but still its not working.
From admin panel of oVirt Its completely working but I found issue only
with oVirt API (VM start but cloudinit data not accepted).
Version 3.6.3.4 is affected by the bug that I mentioned. The result is
that the "cloud_init" element is just ignored. That will be fixed in
version 3.6.5. Meanwhile you can use the workaround suggested in comment
https://bugzilla.redhat.com/show_bug.cgi?id=1305904#c1
Translated to XML it should look like described by Karim Boumedhel in
https://bugzilla.redhat.com/show_bug.cgi?id=1305904#c7
Post by Arpit Makhiyaviya
*XML Request : *
<action>
<async>false</async>
<use_cloud_init>true</use_cloud_init>
<vm>
<initialization>
<cloud_init>
<host>
<address>vishal.123456</address>
</host>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth1</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="51.254.56.84" netmask="255.255.255.255"
gateway="149.202.85.254" />
</network>
<on_boot>false</on_boot>
</nic>
</nics>
<dns>
<servers>
<host>
<address>8.8.8.8</address>
</host>
</servers>
<search_domains>
<host>
<address>8.8.4.4</address>
</host>
</search_domains>
</dns>
</network_configuration>
</cloud_init>
</initialization>
</vm>
</action>
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
Post by Arpit Makhiyaviya
Thanks for quick response.
we already knew this and we are passing following xml when calling
Start
Post by Arpit Makhiyaviya
action.
What version of the engine are you using exactly? This is a known
bug.
Post by Arpit Makhiyaviya
Cloud-Init payload not passed into VM via python SDK
https://bugzilla.redhat.com/1305904
That will be fixed in version 3.6.5. If you have a version 3.6.2 or
newer then you can use the workaround described there, using the
"initailization" element directly.
Post by Arpit Makhiyaviya
<action>
<vm>
<initialization>
<cloud_init>
<host>
<address>vm-cloud-init-restapi</address>
</host>
<authorized_keys>
<authorized_key>
<user>
<user_name>root</user_name>
</user>
<key>ssh-rsa restapi-cloud-init-ssh-key
</authorized_key>
</authorized_keys>
<regenerate_ssh_keys>true</regenerate_ssh_keys>
<timezone>Atlantic/Reykjavik</timezone>
<users>
<user>
<user_name>root</user_name>
<password>SuperSecretPassword!</password>
</user>
</users>
<network_configuration>
<nics>
<nic>
<name>eth0</name>
<boot_protocol>STATIC</boot_protocol>
<network>
<ip address="192.168.2.11" netmask="255.255.255.0"
gateway="192.168.2.254" />
</network>
<on_boot>true</on_boot>
</nic>
<nic>
<name>eth1</name>
<boot_protocol>DHCP</boot_protocol>
<on_boot>true</on_boot>
</nic>
</nics>
<dns>
<servers>
<host>
<address>10.20.30.100</address>
</host>
</servers>
<search_domains>
<host>
<address>domain.your.rhevm.com
<http://domain.your.rhevm.com>
Post by Arpit Makhiyaviya
<http://domain.your.rhevm.com></address>
</host>
</search_domains>
</dns>
</network_configuration>
<files>
<file>
<name>/tmp/file1.txt</name>
<content>line 1
line 2
and now something special
<type>PLAINTEXT</type>
</file>
</files>
</cloud_init>
</initialization>
</vm>
</action>
we also found following link . is this related to my issue?
https://gerrit.ovirt.org/#/c/50240/2
Regards,
*Arpit Makhiyaviya*
Software Engineer
+91-79-40038284
+91-971-437-6669
<http://www.sculptsoft.com>
In the more recent versions you have to use
'use_cloud_init=True' in
Post by Arpit Makhiyaviya
the api, which isn't described in most documentation yet. Maybe
thats the reason it isn't working?
vm = api.vms.get(name=vm_name)
action = params.Action(
use_cloud_init=True,
vm=params.VM(
initialization=params.Initialization(
regenerate_ssh_keys=True,
host_name=vm_fqdn,
nic_configurations=params.GuestNicsConfiguration(
nic_configuration=[
params.GuestNicConfiguration(
name="eth0",
boot_protocol="static",
on_boot=True,
ip=params.IP(
address=vm_address,
netmask=vm_netmask,
gateway=vm_gateway,
),
),
],
),
),
),
)
vm.start(action)
On Tue, Mar 29, 2016 at 2:03 PM, Arpit Makhiyaviya
Hello,
we are using ovirt api with json data format.
we have create vm from template and i want to set
ip,macaddress,user and password for that we are using
cloud_init
Post by Arpit Makhiyaviya
for that we it can't set any options.
--
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.
Loading...