<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
As the error said, you need to see the disk_format and
container_format. I haven't digged the code, but I think you should
try to set the container_format and disk_format when you create the
image like this:<br>
<br>
<span lang="EN-US">image =
self.glance.images.create(name="myNewImage",<br>
container_format='bare',<br>
disk_format='raw',)</span><br>
<br>
<div class="moz-cite-prefix">On 03/08/16 13:27, <a class="moz-txt-link-abbreviated" href="mailto:kristen@itri.org.tw">kristen@itri.org.tw</a>
wrote:<br>
</div>
<blockquote
cite="mid:2f0005c9227043c0a63923dcd0ac77c8@EXMB01.ITRI.DS"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:新細明體;
panose-1:2 2 5 0 0 0 0 0 0 0;}
@font-face
{font-family:細明體;
panose-1:2 2 5 9 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@新細明體";
panose-1:2 2 5 0 0 0 0 0 0 0;}
@font-face
{font-family:"\@細明體";
panose-1:2 2 5 9 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"新細明體",serif;}
tt
{mso-style-priority:99;
font-family:細明體;}
p.first, li.first, div.first
{mso-style-name:first;
mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"新細明體",serif;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:338971564;
mso-list-template-ids:-1947300766;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">refer to: </span><span
style="font-size:11.0pt" lang="EN-US">glance client Python
API v2<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><a
moz-do-not-send="true"
href="http://docs.openstack.org/developer/python-glanceclient/ref/v2/images.html"><a class="moz-txt-link-freetext" href="http://docs.openstack.org/developer/python-glanceclient/ref/v2/images.html">http://docs.openstack.org/developer/python-glanceclient/ref/v2/images.html</a></a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:16.2pt;background:white"><b><span
style="font-size:11.0pt;font-family:"Courier
New";color:#222222" lang="EN-US">add_location</span></b><span
style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#3E4349"
lang="EN-US">(<i>image_id</i>, <i>url</i>, <i>metadata</i>)<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-bottom-alt:auto;margin-left:36.0pt;line-height:18.0pt;background:white"><span
style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#3E4349"
lang="EN-US">Add a new location entry to an image’s list of
locations.<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-bottom-alt:auto;margin-left:36.0pt;line-height:18.0pt;background:white"><span
style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#3E4349"
lang="EN-US">It is an error to add a URL that is already
present in the list of locations.<o:p></o:p></span></p>
<table class="MsoNormalTable"
style="margin-left:36.0pt;border-collapse:collapse" border="0"
cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="padding:.75pt 6.0pt .75pt 0cm">
<p class="MsoNormal" style="margin-bottom:7.5pt"><b><span
style="font-size:11.0pt;font-family:"新細明體&
quot;,serif" lang="EN-US">Parameters:<o:p></o:p></span></b></p>
</td>
<td style="padding:.75pt 6.0pt .75pt 0cm">
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:0cm;text-indent:-18.0pt;line-height:18.0pt;mso-list:l0
level1 lfo2">
<!--[if !supportLists]--><span
style="font-size:10.0pt;font-family:Symbol"
lang="EN-US"><span style="mso-list:Ignore">·<span
style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><b><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US">image_id</span></b><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US"> </span><span
style="font-size:11.0pt;font-family:"新細明體",serif">–<span
lang="EN-US"> ID of image to which the location is
to be added.<o:p></o:p></span></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:0cm;text-indent:-18.0pt;line-height:18.0pt;mso-list:l0
level1 lfo2">
<!--[if !supportLists]--><span
style="font-size:10.0pt;font-family:Symbol"
lang="EN-US"><span style="mso-list:Ignore">·<span
style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><b><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US">url</span></b><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US"> </span><span
style="font-size:11.0pt;font-family:"新細明體",serif">–<span
lang="EN-US"> URL of the location to add.<o:p></o:p></span></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:0cm;text-indent:-18.0pt;line-height:18.0pt;mso-list:l0
level1 lfo2">
<!--[if !supportLists]--><span
style="font-size:10.0pt;font-family:Symbol"
lang="EN-US"><span style="mso-list:Ignore">·<span
style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><b><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US">metadata</span></b><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US"> </span><span
style="font-size:11.0pt;font-family:"新細明體",serif">–<span
lang="EN-US"> Metadata associated with the
location.<o:p></o:p></span></span></p>
</td>
</tr>
<tr>
<td style="padding:.75pt 6.0pt .75pt 0cm">
<p class="MsoNormal"><b><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US">Returns:<o:p></o:p></span></b></p>
</td>
<td style="padding:.75pt 6.0pt .75pt 0cm">
<p class="MsoNormal" style="line-height:18.0pt"><span
style="font-size:11.0pt;font-family:"新細明體",serif"
lang="EN-US">The updated image<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span lang="EN-US">-------------------------------------------------------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#--source code--<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">from
glanceclient.v2.client import Client<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">……<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">url =
'<a class="moz-txt-link-freetext" href="http://xxxx/ubuntu1604.qcow2">http://xxxx/ubuntu1604.qcow2</a>'<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">image =
self.glance.images.create(name="myNewImage")<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">self.glance.images.add_location(image.id,
url, {})<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#--end<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">-------------------------------------------------------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I am sure the
images.create is work.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I got image .id
‘be416e4a-f266-4ad5-a62f-979242d23633’.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I don’t Know which data
should be assign to metadata.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Then I got :<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">
self.glance.images.add_location(image.id, url, {})<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> File
"/usr/lib/python2.7/dist-packages/glanceclient/v2/images.py",
line 311, in add_location<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">
self._send_image_update_request(image_id, add_patch)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> File
"/usr/lib/python2.7/dist-packages/glanceclient/v2/images.py",
line 296, in _send_image_update_request<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">
self.http_client.patch(url, headers=hdrs,
data=json.dumps(patch_body))<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> File
"/usr/lib/python2.7/dist-packages/glanceclient/common/http.py",
line 284, in patch<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> return
self._request('PATCH', url, **kwargs)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> File
"/usr/lib/python2.7/dist-packages/glanceclient/common/http.py",
line 267, in _request<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> resp, body_iter =
self._handle_response(resp)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> File
"/usr/lib/python2.7/dist-packages/glanceclient/common/http.py",
line 83, in _handle_response<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> raise
exc.from_response(resp, resp.content)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">HTTPBadRequest: 400 Bad
Request: Properties disk_format, container_format must be
set prior to saving data. (HTTP 400)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Best Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Kristen<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<br>
<br>
--<br>
本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 This email may
contain confidential information. Please do not use or disclose it
in any way and delete it if you are not the intended recipient.
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: <a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev-request@lists.openstack.org?subject:unsubscribe">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>
<a class="moz-txt-link-freetext" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Cheers & Best regards,
Fei Long Wang (王飞龙)
--------------------------------------------------------------------------
Senior Cloud Software Engineer
Tel: +64-48032246
Email: <a class="moz-txt-link-abbreviated" href="mailto:flwang@catalyst.net.nz">flwang@catalyst.net.nz</a>
Catalyst IT Limited
Level 6, Catalyst House, 150 Willis Street, Wellington
-------------------------------------------------------------------------- </pre>
</body>
</html>