<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
Hi Ramon,<br>
<br>
I just want to send you some tips on how to do that feature.<br>
<br>
1. You are changing the way the template is created. Now
source_media is a required parameter and need to be properly added
on API.json<br>
<br>
2. source_media will replace cdrom and disk[base], so, please update
API.json to reflect it.<br>
<br>
3. Following the Template creation flow, the request will first
touch on model/templates.py in create() function.<br>
<br>
The code below needs to be moved around as at this point you will
not know if source_media is an ISO or an Image file.<br>
<br>
...<br>
iso =
params.get('cdrom') <br>
# check search
permission <br>
if iso and iso.startswith('/') and
os.path.exists(iso): <br>
st_mode =
os.stat(iso).st_mode <br>
if stat.S_ISREG(st_mode) or
stat.S_ISBLK(st_mode): <br>
user =
UserTests().probe_user() <br>
run_setfacl_set_attr(iso,
user=user) <br>
ret, excp = probe_file_permission_as_user(iso,
user) <br>
if ret is
False: <br>
raise
InvalidParameter('KCHISO0008E', <br>
{'filename': iso, 'user':
user, <br>
'err': excp}) <br>
<br>
4. The second step is vmtemplate.py.<br>
As you can see you will need to change the function
_get_os_info() to something like:<br>
<b><br>
</b><b> source_media = args.get('source_media)</b><b><br>
</b><b> if source_media is not None:</b><b><br>
</b><b> if source_media.startswith('http|https|ftp|...')
or <use python magic to identify it is an ISO> :</b><b><br>
</b><b> args[cdrom] = source_media</b><b><br>
</b><b> else:</b><b><br>
</b><b> # assume it is an image</b><b><br>
</b><b> args[disks] = {base: source_media}</b><small><br>
</small><br>
# the code below keeps the same<br>
<br>
Does all that make sense for you?<br>
<br>
Regards,<br>
Aline Manera<br>
<br>
<div class="moz-cite-prefix">On 03/31/2016 10:47 AM, Ramon Medeiros
wrote:<br>
</div>
<blockquote
cite="mid:1459432076-27272-1-git-send-email-ramonn@linux.vnet.ibm.com"
type="cite">
<pre wrap="">Instead of specify if the media is cdrom or disk, use source_media to create a template
Changes:
v2:
Remove libvirt connection from VMtemplate
Fix incorrect changes on tests
Fix return status when source_media not passed
v3:
Fix pep8 issues
Remove/add some constants
Rewrite API message
Ramon Medeiros (4):
Create a single field to pass the installation media
Fix checking duplicate template before creating it
Identify installation media while creating template
Update tests
API.json | 5 ++
i18n.py | 2 +-
model/templates.py | 15 ++++--
tests/test_authorization.py | 4 +-
tests/test_livemigration.py | 7 +--
tests/test_mockmodel.py | 13 +++---
tests/test_model.py | 94 ++++++++++++++++++++-----------------
tests/test_rest.py | 36 +++++++--------
tests/test_template.py | 47 +++++++++----------
tests/test_vmtemplate.py | 40 ++++++++--------
vmtemplate.py | 110 +++++++++++++++++++++++++++++++++++++-------
11 files changed, 235 insertions(+), 138 deletions(-)
</pre>
</blockquote>
<br>
</body>
</html>