Files
doc-exports/docs/ims/dev/en-us_topic_0109822381.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

36 lines
4.5 KiB
HTML

<a name="EN-US_TOPIC_0109822381"></a><a name="EN-US_TOPIC_0109822381"></a>
<h1 class="topictitle1">Creating an Image Using an ECS</h1>
<div id="body23462052"><div class="section" id="EN-US_TOPIC_0109822381__section10781336"><h4 class="sectiontitle">Scenario</h4><p id="EN-US_TOPIC_0109822381__p7923645314">A Windows or Linux ECS can be used to create a private image.</p>
<div class="note" id="EN-US_TOPIC_0109822381__note44222521746"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0109822381__ul550713253156"><li id="EN-US_TOPIC_0109822381__li3714320">Before creating an image, ensure that the ECS is stopped.</li><li id="EN-US_TOPIC_0109822381__li850719256151">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_0109822381__section872994"><h4 class="sectiontitle">Involved APIs</h4><p class="litext" id="EN-US_TOPIC_0109822381__p23385131">If you use a token for authentication, you must obtain the token and add <strong id="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_0109822381__ul15147458"><li id="EN-US_TOPIC_0109822381__li2109397">IAM API used to obtain the token<p id="EN-US_TOPIC_0109822381__p1833933634"><a name="EN-US_TOPIC_0109822381__li2109397"></a><a name="li2109397"></a>URI format: POST https://<em id="EN-US_TOPIC_0109822381__i15500165112426">IAM endpoint</em>/v3/auth/tokens</p>
</li><li id="EN-US_TOPIC_0109822381__li18984577">IMS API used to create an image<p id="EN-US_TOPIC_0109822381__p327712359248"><a name="EN-US_TOPIC_0109822381__li18984577"></a><a name="li18984577"></a>URI format: POST https://<em id="EN-US_TOPIC_0109822381__i4702192218436">IMS endpoint</em>/v2/cloudimages/action</p>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0109822381__section7856948"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0109822381__ol61355793"><li id="EN-US_TOPIC_0109822381__li1837051910476">Obtain the token.</li><li class="msonormal" id="EN-US_TOPIC_0109822381__li8863205171315">Send <strong id="EN-US_TOPIC_0109822381__b1823914109442">POST https://</strong><em id="EN-US_TOPIC_0109822381__i46825420446">IMS endpoint</em><strong id="EN-US_TOPIC_0109822381__b56499143448">/v2/cloudimages/action</strong>.</li><li class="msonormal" id="EN-US_TOPIC_0109822381__li108635517130">Add <strong id="EN-US_TOPIC_0109822381__b84235270615255">X-Auth-Token</strong> to the request header.</li><li class="msonormal" id="EN-US_TOPIC_0109822381__li1586314581311">Specify the following parameters in the request body:<pre class="screen" id="EN-US_TOPIC_0109822381__screen1324171612164">{
"name": "ims_test", //Image name (mandatory, string)
"description": "Image creation from an ECS", //Image description (optional, string)
"instance_id": "877a2cda-ba63-4e1e-b95f-e67e48b6129a", //ECS ID (mandatory, string)
"tags": [
"aaa.111",
"bbb.333",
"ccc.444"
] //Image tag list (optional, array of objects)
} </pre>
<p id="EN-US_TOPIC_0109822381__p146904541437"></p>
<ul id="EN-US_TOPIC_0109822381__ul18271195810316"><li id="EN-US_TOPIC_0109822381__li172708581238">If the request is successful, a job ID is returned.</li><li id="EN-US_TOPIC_0109822381__li7597170542">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></ol><ol start="5" id="EN-US_TOPIC_0109822381__ol31495913310"><li id="EN-US_TOPIC_0109822381__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_0109822381__p411722533511">If the job status is <strong id="EN-US_TOPIC_0109822381__b8423527061586">SUCCESS</strong>, the private image is successfully created.</p>
<p id="EN-US_TOPIC_0109822381__p1126722819573">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_0109822381__li17483254347">Obtain the image ID from the job body and query, delete, and export the private image using the image ID.</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>