<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 2014年06月27日 11:35, Royce Lv wrote:<br>
</div>
<blockquote cite="mid:53ACE665.9020209@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">On 2014年06月27日 04:57, Aline Manera
wrote:<br>
</div>
<blockquote cite="mid:53AC8957.7000206@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">On 06/26/2014 04:35 AM, <a
moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:lvroyce@linux.vnet.ibm.com">lvroyce@linux.vnet.ibm.com</a>
wrote:<br>
</div>
<blockquote
cite="mid:1403768132-9897-1-git-send-email-lvroyce@linux.vnet.ibm.com"
type="cite">
<pre wrap="">From: Royce Lv <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:lvroyce@linux.vnet.ibm.com"><lvroyce@linux.vnet.ibm.com></a>
When adding vm storage, volume and path cannot be specified
at the same time. Fix it.
Signed-off-by: Royce Lv <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:lvroyce@linux.vnet.ibm.com"><lvroyce@linux.vnet.ibm.com></a>
---
src/kimchi/model/vmstorages.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index 8c51716..093b9ee 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -154,6 +154,8 @@ class VMStoragesModel(object):
# Path will never be blank due to API.json verification.
# There is no need to cover this case here.
params['format'] = 'raw'
+ if 'vol' in params and 'path' in params:
+ raise InvalidParameter("KCHVMSTOR0012E")
if params.get('vol'):
try:
pool = params['pool']
</pre>
</blockquote>
<br>
<font face="DejaVu Sans Mono">This is one part of the solution
we should have for #382<br>
</font></blockquote>
<font face="DejaVu Sans Mono">ACK.</font><br>
<blockquote cite="mid:53AC8957.7000206@linux.vnet.ibm.com"
type="cite"><font face="DejaVu Sans Mono"> <br>
if type not in ['disk', 'cdrom']:<br>
raise InvalidParameter(Disk type not support)<br>
</font></blockquote>
<font face="DejaVu Sans Mono">This part is covered by jsonschema.
</font><font face="DejaVu Sans Mono"><br>
<br>
</font>
<blockquote cite="mid:53AC8957.7000206@linux.vnet.ibm.com"
type="cite"><font face="DejaVu Sans Mono"> <br>
path = params.get(path, None)<br>
if type == 'cdrom':<br>
if not path:<br>
raise MissingParameter()<br>
</font></blockquote>
<font face="DejaVu Sans Mono">I think we need to reserve
volume/pool for cdrom type,<br>
so that in the future, ui will be able to pick one iso from the
iso pool. What do you think?</font><br>
<blockquote cite="mid:53AC8957.7000206@linux.vnet.ibm.com"
type="cite"><font face="DejaVu Sans Mono"> <br>
# validate path and continue the logic<br>
<br>
elif type == 'disk':<br>
pool = params.get(pool, None)<br>
vol = params.get(vol, None)<br>
if not pool or not vol:<br>
raise MissingParameter()<br>
<br>
# validate values and continue the logic<br>
</font></blockquote>
We have 3 issues here:<br>
1. type needs to be in 'cdrom' and 'disk' -- already covered
by current json schema.<br>
2. For type 'disk', "pool" and "vol" need to be existed --
need to be covered by json schema 'dependencies' key word.<br>
3. For type 'cdrom', one of "path" or "pool"+"vol" needs to be
existed, but not at the same time -- need to be covered by json
schema 'dependencies' and "oneof" keywords. <br>
<br>
<font face="DejaVu Sans Mono">When I'm considering to introduce
jsonschema "oneOf" keyword,<br>
(<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://json-schema.org/latest/json-schema-validation.html#anchor88">http://json-schema.org/latest/json-schema-validation.html#anchor88</a>)<br>
jsonschema V4 support this, and this (python-jsonschema 2.3.0)
is only available on ubuntu 14.04 and above.<br>
</font></blockquote>
<font face="DejaVu Sans Mono">After integrated with jsonschema V4,
found it broke a lot of existed schema because of bug:
<a class="moz-txt-link-freetext" href="http://flexget.com/ticket/2268">http://flexget.com/ticket/2268</a><br>
So just work around with validate with python code.<br>
</font>
<blockquote cite="mid:53ACE665.9020209@linux.vnet.ibm.com"
type="cite"><font face="DejaVu Sans Mono"> Forturnately, 13.10
ends support in </font><font face="DejaVu Sans Mono">July 2014.<br>
So do you think we can add this now?<br>
REF:<br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://launchpad.net/ubuntu/+source/python-jsonschema">https://launchpad.net/ubuntu/+source/python-jsonschema</a><br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://wiki.ubuntu.com/Releases">https://wiki.ubuntu.com/Releases</a><br>
<br>
I will send patches using oneof and validate by python code. So
that you can merge it before release.<br>
</font>
<blockquote cite="mid:53AC8957.7000206@linux.vnet.ibm.com"
type="cite"><font face="DejaVu Sans Mono"> <br>
<br>
<br>
<br>
</font> </blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>