Files
doc-exports/docs/ims/dev/en-us_topic_0109822382.html
guoyanyan b3547b53d8 ims_dev_1109
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: guoyanyan <guoyanyan3@huawei.com>
Co-committed-by: guoyanyan <guoyanyan3@huawei.com>
2022-11-16 09:00:55 +00:00

41 lines
5.4 KiB
HTML

<a name="EN-US_TOPIC_0109822382"></a><a name="EN-US_TOPIC_0109822382"></a>
<h1 class="topictitle1">Creating an Image Using an External Image File</h1>
<div id="body48597379"><div class="section" id="EN-US_TOPIC_0109822382__en-us_topic_0040879985-chtext"><h4 class="sectiontitle">Scenario</h4><p id="EN-US_TOPIC_0109822382__p12792132515163">An external image file can also be used to create a private image.</p>
<div class="note" id="EN-US_TOPIC_0109822382__note177773191273"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0109822382__ul8147739131519"><li id="EN-US_TOPIC_0109822382__li5902812171111">The API used here is the same as the one for creating a private image from an ECS except for the parameters in the request body.</li><li id="EN-US_TOPIC_0109822382__li9147183901514">The token obtained from Identity and Access Management (IAM) is valid for only 24 hours. If you want to use a token for authentication, you can cache it to avoid frequently calling the IAM API.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0109822382__section31142810"><h4 class="sectiontitle">Involved APIs</h4><p class="litext" id="EN-US_TOPIC_0109822382__p23385131">If you use a token for authentication, you must obtain the token and add <strong id="EN-US_TOPIC_0109822382__en-us_topic_0109822381_b842352706134841">X-Auth-Token</strong> to the request header of the IMS API when making an API call.</p>
<ul id="EN-US_TOPIC_0109822382__ul45489722"><li id="EN-US_TOPIC_0109822382__li6754315">IAM API used to obtain the token<p id="EN-US_TOPIC_0109822382__en-us_topic_0109822381_p1833933634"><a name="EN-US_TOPIC_0109822382__li6754315"></a><a name="li6754315"></a>URI format: POST https://<em id="EN-US_TOPIC_0109822382__en-us_topic_0109822381_i15500165112426">IAM endpoint</em>/v3/auth/tokens</p>
</li><li id="EN-US_TOPIC_0109822382__li60788841">IMS API used to create a data disk image using an external image file<p id="EN-US_TOPIC_0109822382__p198241728192711"><a name="EN-US_TOPIC_0109822382__li60788841"></a><a name="li60788841"></a>URI format: POST https://<em id="EN-US_TOPIC_0109822382__i175004419487">IMS endpoint</em>/v1/cloudimages/dataimages/action</p>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0109822382__section11849838"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0109822382__ol115221350172119"><li id="EN-US_TOPIC_0109822382__li1837051910476">Obtain the token.</li><li class="msonormal" id="EN-US_TOPIC_0109822382__li89531824112417">Send <strong id="EN-US_TOPIC_0109822382__b014619718498">POST https://</strong><em id="EN-US_TOPIC_0109822382__i11460714497">IMS endpoint</em><strong id="EN-US_TOPIC_0109822382__b1114611719499">/v2/cloudimages/action</strong>.</li><li class="msonormal" id="EN-US_TOPIC_0109822382__li159534241246">Add <strong id="EN-US_TOPIC_0109822382__b84235270615255">X-Auth-Token</strong> to the request header.</li><li class="msonormal" id="EN-US_TOPIC_0109822382__li4953192411241">Specify the following parameters in the request body:<pre class="screen" id="EN-US_TOPIC_0109822382__screen1701742142517">{
"name": "ims_test_file", //Image name (mandatory, string)
"description": "Image creation using an image file uploaded to the OBS bucket", //Image description (optional, string)
"image_url": "ims-image:centos70.qcow2", //Image file address (mandatory, string)
"os_version": "CentOS 7.0 64bit", //OS version (optional, string)
"is_config_init":true, //Initialized or not (optional, boolean)
"min_disk": 40, //Minimum system disk size (mandatory, integer)
"is_config":true, //Whether to enable automatic configuration (optional, boolean)
"tags": [
"aaa.111",
"bbb.333",
"ccc.444"
] //Image tag list (optional, array of objects)
}</pre>
<div class="note" id="EN-US_TOPIC_0109822382__note18680101520526"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0109822382__p168081595220">For how to obtain the address of the image file in the OBS bucket, see "Operations on Buckets" in the <em id="EN-US_TOPIC_0109822382__i842352697161828">Object Storage Service API Reference</em>.</p>
</div></div>
<ul id="EN-US_TOPIC_0109822382__ul1080665150"><li id="EN-US_TOPIC_0109822382__li38061951558">If the request is successful, a job ID is returned.</li><li id="EN-US_TOPIC_0109822382__li145964817518">If the request fails, an error code and error details are returned. For details, see <a href="en-us_topic_0110943799.html">Error Codes</a>.</li></ul>
</li><li id="EN-US_TOPIC_0109822382__li514842411357">Query job details using the job ID by referring to <a href="en-us_topic_0109822371.html">Querying Job Details</a>.<p id="EN-US_TOPIC_0109822382__p411722533511">If the job status is <strong id="EN-US_TOPIC_0109822382__b8423527061586">SUCCESS</strong>, the private image is successfully created.</p>
<p id="EN-US_TOPIC_0109822382__p562815375571">For details about status codes for request errors, see <a href="en-us_topic_0124290300.html">Status Codes</a>.</p>
</li><li id="EN-US_TOPIC_0109822382__li17483254347">Obtain the image ID from the job body. You can query for image details based on the image ID. For details, see <a href="en-us_topic_0109822404.html">Queries Details About an Image</a>.</li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0219492328.html">Common Scenarios</a></div>
</div>
</div>