Hi Paulo,
As you are changing the source_media object, you need to update the
current API requests from UI to do not break anything there.
Otherwise, I will need to wait to the UI patch to merge this one to do
not break the current Template creation via UI.
Regards,
Aline Manera
On 04/20/2016 05:22 PM, pvital(a)linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
V4:
* Changed API of source_media to be a dictionary with type and path
* Adapted source code to the new API
V3:
* set network as third default option to boot order
V2:
* Adapted patch to new template API (automatic detection of cdrom)
V1:
This patchset adds support in backend to create templates and guests to netboot
without setting a cdrom path or URL as image to install. Once created a guest
to boot via network, the guest will request DHCP/TFTP/(NFS/HTTP/FTP) network
installation servers to download the configured images and start the install.
Reference:
http://miud.in/1Ht3
To test, use the curl commands (look the parameters used):
$ curl -k -u test -H "Content-Type: application/json" -H \
"Accept: application/json"
'https://localhost:8001/plugins/kimchi/templates' \
-X POST -d '{"name": "test-netboot", "source_media":
{"type": "netboot", "path":
"/var/lib/libvirt/images/netboot"}}'
Enter host password for user 'test':
{
"cpu_info":{
"maxvcpus":1,
"vcpus":1
},
"graphics":{
"type":"vnc",
"listen":"127.0.0.1"
},
"cdrom":null,
"networks":[
"default"
],
"icon":"plugins/kimchi/images/icon-vm.png",
"os_distro":"unknown",
"name":"test-netboot",
"disks":[
{
"index":0,
"format":"qcow2",
"pool":{
"type":"dir",
"name":"/plugins/kimchi/storagepools/default"
},
"size":10
}
],
"invalid":{},
"os_version":"unknown",
"memory":{
"current":1024,
"maxmemory":1024
},
"folder":[]
}
$ curl -k -u test -H "Content-Type: application/json" -H \
"Accept: application/json" 'https://localhost:8001/plugins/kimchi/vms'
-X POST \
-d
'{"name":"1netboot-test","template":"/plugins/kimchi/templates/test-netboot"}'
Enter host password for user 'test':
{
"status":"running",
"message":"Provisioning storages for new VM",
"id":"1",
"target_uri":"/plugins/kimchi/vms/1netboot-test"
}
$ sudo virsh dumpxml 1netboot-test
<domain type='kvm'>
<name>1netboot-test</name>
<uuid>5c9fa5b3-3203-4c93-92d6-2b4103fe7b40</uuid>
<metadata>
<kimchi:metadata
xmlns:kimchi="https://github.com/kimchi-project/kimchi">
<kimchi:os version="unknown" distro="unknown"/>
</kimchi:metadata>
</metadata>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<memtune>
<hard_limit unit='KiB'>2097152</hard_limit>
</memtune>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-2.4'>hvm</type>
<boot dev='hd'/>
<boot dev='cdrom'/>
<boot dev='network'/>
</os>
<acpi/>
<apic/>
<pae/>
</features>
<cpu>
<numa>
<cell id='0' cpus='0' memory='1048576'
unit='KiB'/>
</numa>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source
file='/var/lib/libvirt/images/5c9fa5b3-3203-4c93-92d6-2b4103fe7b40-0.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0'
target='0' unit='0'/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='52:54:00:ea:7e:ad'/>
<source network='default'/>
<model type='e1000'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'
listen='127.0.0.1'>
<listen type='address' address='127.0.0.1'/>
</graphics>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='16384' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>
Paulo Vital (3):
Add support to create netboot templates.
Add support to create guests to netboot.
Update test cases to support netboot.
API.json | 18 +++++++++++----
i18n.py | 1 +
model/templates.py | 27 ++++++++++++++++++++---
tests/test_authorization.py | 4 +++-
tests/test_mockmodel.py | 15 ++++++++-----
tests/test_model.py | 43 +++++++++++++++++++++---------------
tests/test_rest.py | 37 +++++++++++++++++++++----------
tests/test_template.py | 53 ++++++++++++++++++++++++++++++++++-----------
tests/test_vmtemplate.py | 18 +++++++++++++++
vmtemplate.py | 28 ++++++++++++++++--------
xmlutils/bootorder.py | 39 +++++++++++++++++++++++++++++++++
11 files changed, 219 insertions(+), 64 deletions(-)
create mode 100644 xmlutils/bootorder.py
--
2.5.5