[Kimchi-devel] [PATCH] [Kimchi 2/3] Add support to create guests to netboot.
pvital at linux.vnet.ibm.com
pvital at linux.vnet.ibm.com
Mon Apr 18 19:21:54 UTC 2016
From: Paulo Vital <pvital at linux.vnet.ibm.com>
Add support to create guests without CD-ROM device information and setting the
second boot order option as 'netboot'.
This is part of solution to Issue #372.
Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
---
vmtemplate.py | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/vmtemplate.py b/vmtemplate.py
index a223beb..2639468 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -33,6 +33,7 @@ from wok.plugins.kimchi import imageinfo
from wok.plugins.kimchi import osinfo
from wok.plugins.kimchi.isoinfo import IsoImage
from wok.plugins.kimchi.utils import check_url_path, pool_name_from_uri
+from wok.plugins.kimchi.xmlutils.bootorder import get_bootorder_xml
from wok.plugins.kimchi.xmlutils.cpu import get_cpu_xml
from wok.plugins.kimchi.xmlutils.disk import get_disk_xml
from wok.plugins.kimchi.xmlutils.graphics import get_graphics_xml
@@ -146,9 +147,6 @@ class VMTemplate(object):
d_info = imageinfo.probe_img_info(d['base'])
d['size'] = d_info['virtual-size']
- if len(base_imgs) == 0:
- raise MissingParameter("KCHTMPL0016E")
-
return distro, version
def _gen_name(self, distro, version):
@@ -170,7 +168,7 @@ class VMTemplate(object):
def _get_cdrom_xml(self, libvirt_stream_protocols):
if 'cdrom' not in self.info:
- return ''
+ return None
params = {}
params['type'] = 'cdrom'
@@ -350,12 +348,15 @@ class VMTemplate(object):
libvirt_stream_protocols = kwargs.get('libvirt_stream_protocols', [])
cdrom_xml = self._get_cdrom_xml(libvirt_stream_protocols)
- if not urlparse.urlparse(self.info.get('cdrom', "")).scheme in \
- libvirt_stream_protocols and \
- params.get('iso_stream', False):
- params['qemu-stream-cmdline'] = cdrom_xml
- else:
- params['cdroms'] = cdrom_xml
+ # Add information of CD-ROM device only if template have info about it.
+ # Also, set up correct boot order.
+ if cdrom_xml is not None:
+ if not urlparse.urlparse(self.info.get('cdrom', "")).scheme in \
+ libvirt_stream_protocols and \
+ params.get('iso_stream', False):
+ params['qemu-stream-cmdline'] = cdrom_xml
+ else:
+ params['cdroms'] = cdrom_xml
# Setting maximum number of slots to avoid errors when hotplug memory
# Number of slots are the numbers of chunks of 1GB that fit inside
@@ -411,6 +412,7 @@ class VMTemplate(object):
<type arch='%(arch)s'>hvm</type>
<boot dev='hd'/>
<boot dev='cdrom'/>
+ <boot dev='network'/>
</os>
<features>
<acpi/>
--
2.5.5
More information about the Kimchi-devel
mailing list