doc-exports/docs/ims/api-ref/en-us_topic_0037131984.html
Zaoxu, Li c236478734 IMS API DOC
Reviewed-by: Pristromskaia, Margarita <margarita.pristromskaia@t-systems.com>
Co-authored-by: Zaoxu, Li <lizaoxu@huawei.com>
Co-committed-by: Zaoxu, Li <lizaoxu@huawei.com>
2024-06-05 07:22:50 +00:00

149 lines
14 KiB
HTML

<a name="EN-US_TOPIC_0037131984"></a><a name="EN-US_TOPIC_0037131984"></a>
<h1 class="topictitle1">Registering an Image</h1>
<div id="body1473061546628"><div class="section" id="EN-US_TOPIC_0037131984__section11046056154747"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0037131984__p4464523163517">This API is used to register an image file as an uninitialized private image on the cloud platform.</p>
<p id="EN-US_TOPIC_0037131984__p34229512164319">The following describes how to use this API:</p>
<ol id="EN-US_TOPIC_0037131984__ol48948360"><li id="EN-US_TOPIC_0037131984__li34280961">Upload the image file to an OBS bucket. For details, see "Object Storage Service User Guide".</li><li id="EN-US_TOPIC_0037131984__li40093194"><a name="EN-US_TOPIC_0037131984__li40093194"></a><a name="li40093194"></a>Use the image metadata creation API to create image metadata. After the API is invoked successfully, save the image ID. For how to create image metadata, see <a href="en-us_topic_0031615565.html">Creating Image Metadata (Native OpenStack API)</a>.</li><li id="EN-US_TOPIC_0037131984__li25294426">Use the API for registering images and the image ID obtained in <a href="#EN-US_TOPIC_0037131984__li40093194">2</a> to register the image file as a private image.</li><li id="EN-US_TOPIC_0037131984__li26323242">After the API is successfully invoked as an asynchronous one, the cloud service system receives a request. Query the image status using the image ID and check whether the image file is successfully registered. When the image status changes to <strong id="EN-US_TOPIC_0037131984__b842352706152426">active</strong>, the image file is successfully registered as a private image.<p id="EN-US_TOPIC_0037131984__p1971816274148">For details about how to query the status of an asynchronous task, see <a href="en-us_topic_0022473688.html">Querying the Status of an Asynchronous Job</a>.</p>
</li></ol>
<div class="note" id="EN-US_TOPIC_0037131984__note666119145185"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0037131984__p26613144183">Before registering an image file, ensure that you have the Tenant Administrator permission for OBS.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0037131984__section66620681154747"><h4 class="sectiontitle">URI</h4><p id="EN-US_TOPIC_0037131984__p1631075693910">PUT /v1/cloudimages/{image_id}/upload</p>
<div class="p" id="EN-US_TOPIC_0037131984__p811194505911"><a href="#EN-US_TOPIC_0037131984__table23910047154747">Table 1</a> lists the parameters in the URI.
<div class="tablenoborder"><a name="EN-US_TOPIC_0037131984__table23910047154747"></a><a name="table23910047154747"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0037131984__table23910047154747" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="EN-US_TOPIC_0037131984__row24965460154747"><th align="left" class="cellrowborder" valign="top" width="19.168083191680832%" id="mcps1.3.2.3.2.2.5.1.1"><p id="EN-US_TOPIC_0037131984__p8936346154747">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="22.17778222177782%" id="mcps1.3.2.3.2.2.5.1.2"><p id="EN-US_TOPIC_0037131984__p4072498116916">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="18.228177182281772%" id="mcps1.3.2.3.2.2.5.1.3"><p id="EN-US_TOPIC_0037131984__p52755425154747">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40.42595740425957%" id="mcps1.3.2.3.2.2.5.1.4"><p id="EN-US_TOPIC_0037131984__p57477321154747">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0037131984__row25151394154747"><td class="cellrowborder" valign="top" width="19.168083191680832%" headers="mcps1.3.2.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0037131984__p23996995154747">image_id</p>
</td>
<td class="cellrowborder" valign="top" width="22.17778222177782%" headers="mcps1.3.2.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0037131984__p1038913616916">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="18.228177182281772%" headers="mcps1.3.2.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0037131984__p64708437154747">String</p>
</td>
<td class="cellrowborder" valign="top" width="40.42595740425957%" headers="mcps1.3.2.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0037131984__p54354750154747">Specifies the image ID.</p>
<ul id="EN-US_TOPIC_0037131984__ul2091361694"><li id="EN-US_TOPIC_0037131984__li243224961694"><strong id="EN-US_TOPIC_0037131984__b842352706151612">image_id</strong> is the ID of the image you created by invoking the API for creating image metadata. Registration may fail if you use other image IDs.</li><li id="EN-US_TOPIC_0037131984__li621310511694">After this API is invoked, you can check the image status with the image ID. When the image status changes to <strong id="EN-US_TOPIC_0037131984__b1284633427">active</strong>, the image file is successfully registered. For details, see <a href="en-us_topic_0020091566.html">Querying Image Details (Native OpenStack API)</a>.</li></ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0037131984__section29704853154747"><h4 class="sectiontitle">Request</h4><ul id="EN-US_TOPIC_0037131984__ul48754330102731"><li id="EN-US_TOPIC_0037131984__li60272794102731">Request parameters
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0037131984__table57282886154747" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0037131984__row33194661154747"><th align="left" class="cellrowborder" valign="top" width="20.95%" id="mcps1.3.3.2.1.1.1.5.1.1"><p id="EN-US_TOPIC_0037131984__p4413036154747">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.75%" id="mcps1.3.3.2.1.1.1.5.1.2"><p id="EN-US_TOPIC_0037131984__p15244109154747">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.830000000000002%" id="mcps1.3.3.2.1.1.1.5.1.3"><p id="EN-US_TOPIC_0037131984__p4364817210345">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="41.47%" id="mcps1.3.3.2.1.1.1.5.1.4"><p id="EN-US_TOPIC_0037131984__p26813302154747">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0037131984__row24393852154747"><td class="cellrowborder" valign="top" width="20.95%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="EN-US_TOPIC_0037131984__p29744966154747">image_url</p>
</td>
<td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="EN-US_TOPIC_0037131984__p384719154747">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="16.830000000000002%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="EN-US_TOPIC_0037131984__p2213925010345">String</p>
</td>
<td class="cellrowborder" valign="top" width="41.47%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="EN-US_TOPIC_0037131984__p31162299154747">Specifies the URL of the image file in the format of <em id="EN-US_TOPIC_0037131984__i84235269795423">Bucket name</em>:<em id="EN-US_TOPIC_0037131984__i84235269795427">File name</em>.</p>
<p id="EN-US_TOPIC_0037131984__p129047121673">Image files in the bucket can be in ZVHD, QCOW2, VHD, RAW, VHDX, QED, VDI, QCOW, ZVHD2, or VMDK format.</p>
<div class="note" id="EN-US_TOPIC_0037131984__note53614241491"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0037131984__p3361152417920">The storage class of the OBS bucket must be <strong id="EN-US_TOPIC_0037131984__b1397811178183">Standard</strong>.</p>
</div></div>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0037131984__section12698161123216"><h4 class="sectiontitle">Example Request</h4><p id="EN-US_TOPIC_0037131984__p68441783214">Registering an image (URL of the image file: bucketname:Centos6.5-disk1.vmdk)</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0037131984__screen25548375214125"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">PUT</span><span class="w"> </span><span class="n">https</span><span class="p">:</span><span class="c1">//{Endpoint}/v1/cloudimages/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba86/upload</span>
<span class="p">{</span>
<span class="w"> </span><span class="s">&quot;image_url&quot;</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;bucketname:Centos6.5-disk1.vmdk&quot;</span><span class="w"> </span>
<span class="p">}</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0037131984__section42338041154747"><h4 class="sectiontitle">Response</h4><ul id="EN-US_TOPIC_0037131984__ul832416471306"><li id="EN-US_TOPIC_0037131984__li9157132272020">Response parameters
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0037131984__table1337332211159" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0037131984__row1133156911159"><th align="left" class="cellrowborder" valign="top" width="23.84%" id="mcps1.3.5.2.1.1.1.4.1.1"><p id="EN-US_TOPIC_0037131984__p4544189211159">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.97%" id="mcps1.3.5.2.1.1.1.4.1.2"><p id="EN-US_TOPIC_0037131984__p556206921988">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="56.19%" id="mcps1.3.5.2.1.1.1.4.1.3"><p id="EN-US_TOPIC_0037131984__p5691464411159">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0037131984__row4668343211159"><td class="cellrowborder" valign="top" width="23.84%" headers="mcps1.3.5.2.1.1.1.4.1.1 "><p id="EN-US_TOPIC_0037131984__p2326164111159">job_id</p>
</td>
<td class="cellrowborder" valign="top" width="19.97%" headers="mcps1.3.5.2.1.1.1.4.1.2 "><p id="EN-US_TOPIC_0037131984__p89821791988">String</p>
</td>
<td class="cellrowborder" valign="top" width="56.19%" headers="mcps1.3.5.2.1.1.1.4.1.3 "><p id="EN-US_TOPIC_0037131984__p514473411159">Specifies the asynchronous job ID.</p>
<p id="EN-US_TOPIC_0037131984__p99354261311">For details, see <a href="en-us_topic_0022473688.html">Querying the Status of an Asynchronous Job</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li><li id="EN-US_TOPIC_0037131984__li1432417471019">Example response<pre class="codeblock" id="EN-US_TOPIC_0037131984__codeblock3406888294514">HTTP/1.1 200</pre>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0037131984__screen18896349469"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span></pre></div></td><td class="code"><div><pre><span></span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;job_id&quot;</span><span class="p">:</span><span class="s">&quot; b912fb4a4c464b568ecfca1071b21b10&quot;</span>
<span class="p">}</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0037131984__section61463701154747"><h4 class="sectiontitle">Returned Values</h4><ul id="EN-US_TOPIC_0037131984__ul11464716"><li id="EN-US_TOPIC_0037131984__li36073588">Normal<p id="EN-US_TOPIC_0037131984__p56226836"><a name="EN-US_TOPIC_0037131984__li36073588"></a><a name="li36073588"></a>200</p>
</li><li id="EN-US_TOPIC_0037131984__li36279478">Abnormal</li></ul>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0037131984__table61689654164325" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0037131984__row43263384164325"><th align="left" class="cellrowborder" valign="top" width="38.080000000000005%" id="mcps1.3.6.3.1.3.1.1"><p id="EN-US_TOPIC_0037131984__p14673233164325">Returned Value</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="61.919999999999995%" id="mcps1.3.6.3.1.3.1.2"><p id="EN-US_TOPIC_0037131984__p47681194164325">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0037131984__row36971467164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.3.1.3.1.1 "><p id="EN-US_TOPIC_0037131984__p41898845164325">400 Bad Request</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.3.1.3.1.2 "><p id="EN-US_TOPIC_0037131984__p38363271164325">Request error. For details about the returned error code, see <a href="en-us_topic_0022473689.html">Error Codes</a>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0037131984__row20417266164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.3.1.3.1.1 "><p id="EN-US_TOPIC_0037131984__p43185862164325">401 Unauthorized</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.3.1.3.1.2 "><p id="EN-US_TOPIC_0037131984__p8393897164325">Authentication failed.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0037131984__row8436217164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.3.1.3.1.1 "><p id="EN-US_TOPIC_0037131984__p12244985164325">403 Forbidden</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.3.1.3.1.2 "><p id="EN-US_TOPIC_0037131984__p52319709164325">You do not have the rights to perform the operation.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0037131984__row1115336164325"><td class="cellrowborder" valign="top" width="38.080000000000005%" headers="mcps1.3.6.3.1.3.1.1 "><p id="EN-US_TOPIC_0037131984__p23233406164325">404 Not Found</p>
</td>
<td class="cellrowborder" valign="top" width="61.919999999999995%" headers="mcps1.3.6.3.1.3.1.2 "><p id="EN-US_TOPIC_0037131984__p2857740164325">The requested resource was not found.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0135460761.html">Image</a></div>
</div>
</div>