<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<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]-->
</head>
<body lang="ZH-TW" link="#0563C1" vlink="#954F72" style="text-justify-trim:punctuation">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">refer to: </span><span lang="EN-US" style="font-size:11.0pt">glance client Python API v2<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="http://docs.openstack.org/developer/python-glanceclient/ref/v2/images.html">http://docs.openstack.org/developer/python-glanceclient/ref/v2/images.html</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 lang="EN-US" style="font-size:11.0pt;font-family:"Courier New";color:#222222">add_location</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#3E4349">(<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 lang="EN-US" style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#3E4349">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 lang="EN-US" style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#3E4349">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" border="0" cellspacing="0" cellpadding="0" style="margin-left:36.0pt;border-collapse:collapse">
<tbody>
<tr>
<td style="padding:.75pt 6.0pt .75pt 0cm">
<p class="MsoNormal" style="margin-bottom:7.5pt"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif">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 lang="EN-US" style="font-size:10.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><b><span lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif">image_id</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif"> </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 lang="EN-US" style="font-size:10.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><b><span lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif">url</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif"> </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 lang="EN-US" style="font-size:10.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><![endif]><b><span lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif">metadata</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif"> </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 lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif">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 lang="EN-US" style="font-size:11.0pt;font-family:"新細明體",serif">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 = 'http://xxxx/ubuntu1604.qcow2'<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.
</body>
</html>