doc-exports/docs/ecs/api-ref/en-us_topic_0022472987.html
Zaoxu, Li 4edaa4a4cc ECS API 20231016 version
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-04-29 11:04:13 +00:00

166 lines
17 KiB
HTML

<a name="EN-US_TOPIC_0022472987"></a><a name="EN-US_TOPIC_0022472987"></a>
<h1 class="topictitle1">Attaching a Disk to an <span id="text1320923105110">ECS</span></h1>
<div id="body1449024938540"><div class="section" id="EN-US_TOPIC_0022472987__section48627224105553"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0022472987__p46491051105553">This API is used to attach a disk to an <span id="EN-US_TOPIC_0022472987__text7169173225117">ECS</span>.</p>
<p id="EN-US_TOPIC_0022472987__p109912312314">This API is an asynchronous API. After the attachment request is successfully delivered, a job ID is returned. This does not mean the attachment is complete. You need to call the API by referring to <a href="en-us_topic_0022225398.html">Querying Task Execution Status</a> to query the job status. The SUCCESS status indicates that the attachment is successful.</p>
</div>
<div class="section" id="EN-US_TOPIC_0022472987__section15766276105553"><h4 class="sectiontitle">URI</h4><p id="EN-US_TOPIC_0022472987__p27779270105553">POST /v1/{project_id}/cloudservers/{server_id}/attachvolume</p>
<div class="p" id="EN-US_TOPIC_0022472987__p343712912316"><a href="#EN-US_TOPIC_0022472987__table35528365105553">Table 1</a> describes the parameters in the URI.
<div class="tablenoborder"><a name="EN-US_TOPIC_0022472987__table35528365105553"></a><a name="table35528365105553"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0022472987__table35528365105553" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="EN-US_TOPIC_0022472987__row17119455105553"><th align="left" class="cellrowborder" valign="top" width="16.42%" id="mcps1.3.2.3.2.2.4.1.1"><p id="EN-US_TOPIC_0022472987__p37105578">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="17.36%" id="mcps1.3.2.3.2.2.4.1.2"><p id="EN-US_TOPIC_0022472987__p52761866">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="66.22%" id="mcps1.3.2.3.2.2.4.1.3"><p id="EN-US_TOPIC_0022472987__p45852771">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0022472987__row39853249105553"><td class="cellrowborder" valign="top" width="16.42%" headers="mcps1.3.2.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0022472987__p6887725105553">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="17.36%" headers="mcps1.3.2.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0022472987__p21034813105553">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="66.22%" headers="mcps1.3.2.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0022472987__p37593705">Specifies the project ID.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0022472987__row670727210579"><td class="cellrowborder" valign="top" width="16.42%" headers="mcps1.3.2.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0022472987__p41505172105731">server_id</p>
</td>
<td class="cellrowborder" valign="top" width="17.36%" headers="mcps1.3.2.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0022472987__p6475762105731">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="66.22%" headers="mcps1.3.2.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0022472987__p54774717105731">Specifies the <span id="EN-US_TOPIC_0022472987__text88451273318">ECS</span> ID.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0022472987__section33557800105553"><h4 class="sectiontitle">Request</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0022472987__table55654045105553" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0022472987__row38118604105553"><th align="left" class="cellrowborder" valign="top" width="16.368363163683632%" id="mcps1.3.3.2.2.5.1.1"><p id="EN-US_TOPIC_0022472987__p599200105553">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="17.33826617338266%" id="mcps1.3.3.2.2.5.1.2"><p id="EN-US_TOPIC_0022472987__p48535233105553">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="12.75872412758724%" id="mcps1.3.3.2.2.5.1.3"><p id="EN-US_TOPIC_0022472987__p39039766105553">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="53.53464653534646%" id="mcps1.3.3.2.2.5.1.4"><p id="EN-US_TOPIC_0022472987__p8104455105553">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0022472987__row650913578526"><td class="cellrowborder" valign="top" width="16.368363163683632%" headers="mcps1.3.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0022472987__p351017572527">volumeAttachment</p>
</td>
<td class="cellrowborder" valign="top" width="17.33826617338266%" headers="mcps1.3.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0022472987__p1510125710524">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="12.75872412758724%" headers="mcps1.3.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0022472987__p55101657165213">Object</p>
</td>
<td class="cellrowborder" valign="top" width="53.53464653534646%" headers="mcps1.3.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0022472987__p1051017579521">Specifies the <span id="EN-US_TOPIC_0022472987__text8383155215364">ECS</span> attachment information. For details, see <a href="#EN-US_TOPIC_0022472987__table40707503151632">Table 3</a>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0022472987__row17917955151619"><td class="cellrowborder" valign="top" width="16.368363163683632%" headers="mcps1.3.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0022472987__p191745517165">dry_run</p>
</td>
<td class="cellrowborder" valign="top" width="17.33826617338266%" headers="mcps1.3.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0022472987__p199173556163">No</p>
</td>
<td class="cellrowborder" valign="top" width="12.75872412758724%" headers="mcps1.3.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0022472987__p18917105591610">Boolean</p>
</td>
<td class="cellrowborder" valign="top" width="53.53464653534646%" headers="mcps1.3.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0022472987__p16988497198">Specifies whether to check the request and attach the disk.</p>
<ul id="EN-US_TOPIC_0022472987__ul1769834914198"><li id="EN-US_TOPIC_0022472987__li12698144981918"><strong id="EN-US_TOPIC_0022472987__b14411753367">true</strong>: indicates that only the request is sent, and no disk will be attached. Check items include mandatory parameters, request format, and service restrictions. If the check fails, the system returns an error. If the check result is as expected, the system properly responds.</li><li id="EN-US_TOPIC_0022472987__li7698164918199"><strong id="EN-US_TOPIC_0022472987__b84235270611483">false</strong>: indicates that only the request is sent and the disk will be attached if the check result is as expected.</li></ul>
<p id="EN-US_TOPIC_0022472987__p169834901914">The default value is <strong id="EN-US_TOPIC_0022472987__b99122245816">false</strong>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><a name="EN-US_TOPIC_0022472987__table40707503151632"></a><a name="table40707503151632"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0022472987__table40707503151632" frame="border" border="1" rules="all"><caption><b>Table 3 </b><strong id="EN-US_TOPIC_0022472987__b28932169510">volumeAttachment</strong> field description</caption><thead align="left"><tr id="EN-US_TOPIC_0022472987__row46910609151632"><th align="left" class="cellrowborder" valign="top" width="17.849999999999998%" id="mcps1.3.3.3.2.5.1.1"><p id="EN-US_TOPIC_0022472987__p41663005151632">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="17.26%" id="mcps1.3.3.3.2.5.1.2"><p id="EN-US_TOPIC_0022472987__p1090831092414">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="11.41%" id="mcps1.3.3.3.2.5.1.3"><p id="EN-US_TOPIC_0022472987__p19260278151632">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="53.480000000000004%" id="mcps1.3.3.3.2.5.1.4"><p id="EN-US_TOPIC_0022472987__p696749151632">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0022472987__row56436699151632"><td class="cellrowborder" valign="top" width="17.849999999999998%" headers="mcps1.3.3.3.2.5.1.1 "><p id="EN-US_TOPIC_0022472987__p7969910151632">volumeId</p>
</td>
<td class="cellrowborder" valign="top" width="17.26%" headers="mcps1.3.3.3.2.5.1.2 "><p id="EN-US_TOPIC_0022472987__p149565197249">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.3.3.3.2.5.1.3 "><p id="EN-US_TOPIC_0022472987__p9972164210362">String</p>
</td>
<td class="cellrowborder" valign="top" width="53.480000000000004%" headers="mcps1.3.3.3.2.5.1.4 "><p id="EN-US_TOPIC_0022472987__p28198497151632">Specifies the ID of the disk to be attached. The value is in UUID format.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0022472987__row52459882151632"><td class="cellrowborder" valign="top" width="17.849999999999998%" headers="mcps1.3.3.3.2.5.1.1 "><p id="EN-US_TOPIC_0022472987__p21392044151632">device</p>
</td>
<td class="cellrowborder" valign="top" width="17.26%" headers="mcps1.3.3.3.2.5.1.2 "><p id="EN-US_TOPIC_0022472987__p16956171918245">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.3.3.3.2.5.1.3 "><p id="EN-US_TOPIC_0022472987__p55033990151632">String</p>
</td>
<td class="cellrowborder" valign="top" width="53.480000000000004%" headers="mcps1.3.3.3.2.5.1.4 "><p id="EN-US_TOPIC_0022472987__p179035435915">Indicates the disk device name.</p>
<div class="note" id="EN-US_TOPIC_0022472987__note1755312117111"><span class="notetitle"> NOTE: </span><div class="notebody"><ul id="EN-US_TOPIC_0022472987__ul1580711965"><li id="EN-US_TOPIC_0022472987__li1758019120619">The new disk device name cannot be the same as an existing one.</li><li id="EN-US_TOPIC_0022472987__li058081761">For KVM <span id="EN-US_TOPIC_0022472987__text98491751985">ECS</span>s, set the parameter value to <strong id="EN-US_TOPIC_0022472987__b1449143511497">/dev/vda</strong> for system disks. The device names for data disks of KVM <span id="EN-US_TOPIC_0022472987__text1770614689">ECS</span>s are optional. If the device names of data disks are required, set them in alphabetical order. For example, if there are two data disks, set the device names of the two data disks to <strong id="EN-US_TOPIC_0022472987__b15013554917">/dev/vdb</strong> and <strong id="EN-US_TOPIC_0022472987__b25173594918">/dev/vdc</strong>, respectively. If you set a device name starting with <strong id="EN-US_TOPIC_0022472987__b15223594918">/dev/sd</strong>, the system uses <strong id="EN-US_TOPIC_0022472987__b1859235144914">/dev/vd</strong> by default.</li><li id="EN-US_TOPIC_0022472987__li111172528272">For <span id="EN-US_TOPIC_0022472987__text151115552587">ECS</span>s that only support SCSI disks, set the device name of the system disk to <strong id="EN-US_TOPIC_0022472987__b149531269572">/dev/sda</strong> and the device names of data disks in alphabetical order, for example, <strong id="EN-US_TOPIC_0022472987__b489617349560">/dev/sdb</strong> and <strong id="EN-US_TOPIC_0022472987__b195518363567">/dev/sdc</strong>. The system will not change the default device names.</li></ul>
</div></div>
</td>
</tr>
<tr id="EN-US_TOPIC_0022472987__row454615315168"><td class="cellrowborder" valign="top" width="17.849999999999998%" headers="mcps1.3.3.3.2.5.1.1 "><p id="EN-US_TOPIC_0022472987__p2546173101613">volume_type</p>
</td>
<td class="cellrowborder" valign="top" width="17.26%" headers="mcps1.3.3.3.2.5.1.2 "><p id="EN-US_TOPIC_0022472987__p35463310168">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.3.3.3.2.5.1.3 "><p id="EN-US_TOPIC_0022472987__p454613191611">String</p>
</td>
<td class="cellrowborder" valign="top" width="53.480000000000004%" headers="mcps1.3.3.3.2.5.1.4 "><p id="EN-US_TOPIC_0022472987__p12516143417247">Specifies the disk type.</p>
<p id="EN-US_TOPIC_0022472987__p1768895191319">If <strong id="EN-US_TOPIC_0022472987__b143551051396">volumeId</strong> is unavailable and <strong id="EN-US_TOPIC_0022472987__b987116222920">dry_run</strong> is set to <strong id="EN-US_TOPIC_0022472987__b919915297910">true</strong>, <strong id="EN-US_TOPIC_0022472987__b1699274118920">volume_type</strong> is available and must be specified.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0022472987__row2312133414219"><td class="cellrowborder" valign="top" width="17.849999999999998%" headers="mcps1.3.3.3.2.5.1.1 "><p id="EN-US_TOPIC_0022472987__p73128341217">count</p>
</td>
<td class="cellrowborder" valign="top" width="17.26%" headers="mcps1.3.3.3.2.5.1.2 "><p id="EN-US_TOPIC_0022472987__p7312234172114">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.3.3.3.2.5.1.3 "><p id="EN-US_TOPIC_0022472987__p203131834172116">Integer</p>
</td>
<td class="cellrowborder" valign="top" width="53.480000000000004%" headers="mcps1.3.3.3.2.5.1.4 "><p id="EN-US_TOPIC_0022472987__p1431343432115">Specifies the number of disks.</p>
<p id="EN-US_TOPIC_0022472987__p11482441131217">If <strong id="EN-US_TOPIC_0022472987__b1507130101017">volumeId</strong> is unavailable and <strong id="EN-US_TOPIC_0022472987__b155082011015">dry_run</strong> is set to <strong id="EN-US_TOPIC_0022472987__b1850814020102">true</strong>, <strong id="EN-US_TOPIC_0022472987__b55085014105">count</strong> is available. If <strong id="EN-US_TOPIC_0022472987__b1362412216150">count</strong> is unavailable, the number of disks is <strong id="EN-US_TOPIC_0022472987__b1544119432109">1</strong> by default.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0022472987__row676311400224"><td class="cellrowborder" valign="top" width="17.849999999999998%" headers="mcps1.3.3.3.2.5.1.1 "><p id="EN-US_TOPIC_0022472987__p14763740162211">hw:passthrough</p>
</td>
<td class="cellrowborder" valign="top" width="17.26%" headers="mcps1.3.3.3.2.5.1.2 "><p id="EN-US_TOPIC_0022472987__p1376394016227">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.3.3.3.2.5.1.3 "><p id="EN-US_TOPIC_0022472987__p5763164082216">String</p>
</td>
<td class="cellrowborder" valign="top" width="53.480000000000004%" headers="mcps1.3.3.3.2.5.1.4 "><ul id="EN-US_TOPIC_0022472987__ul151413913619"><li id="EN-US_TOPIC_0022472987__li165147943618">If this parameter is set to <strong id="EN-US_TOPIC_0022472987__b84235270620365">true</strong>, the disk device type is SCSI, which allows ECS OSs to directly access the underlying storage media. SCSI reservation commands are supported.</li><li id="EN-US_TOPIC_0022472987__li1751512910362">If this parameter is set to <strong id="EN-US_TOPIC_0022472987__b203367810216">false</strong>, the disk device type is VBD, which supports only simple SCSI read/write commands.</li></ul>
<p id="EN-US_TOPIC_0022472987__p162351242102412">If <strong id="EN-US_TOPIC_0022472987__b1477917518161">volumeId</strong> is unavailable and <strong id="EN-US_TOPIC_0022472987__b177944561610">dry_run</strong> is set to <strong id="EN-US_TOPIC_0022472987__b198024517161">true</strong>, <strong id="EN-US_TOPIC_0022472987__b2081212571615">hw:passthrough</strong> is available and must be specified.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0022472987__section5883164105553"><h4 class="sectiontitle">Response</h4><p id="EN-US_TOPIC_0022472987__p6774315105553">See <a href="en-us_topic_0022067714.html">Responses (Task)</a>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0022472987__section812710371403"><h4 class="sectiontitle">Example Request</h4><p id="EN-US_TOPIC_0022472987__p495591125520">Attach a SCSI EVS disk to the device <strong id="EN-US_TOPIC_0022472987__b672882295913">/dev/sda</strong>.</p>
<pre class="screen" id="EN-US_TOPIC_0022472987__screen111411737104016">POST https://{endpoint}/v1/{project_id}/cloudservers/{server_id}/attachvolume
{
"volumeAttachment": {
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
"device": "/dev/sda",
"volume_type": "SSD",
"count": 5,
"hw:passthrough": "true"
},
"dry_run": false
}</pre>
</div>
<div class="section" id="EN-US_TOPIC_0022472987__section7250113841316"><h4 class="sectiontitle">Example Response</h4><pre class="screen" id="EN-US_TOPIC_0022472987__screen4283641172510">{
"job_id": "ff80808288d41e1b018990260955686a"
}</pre>
</div>
<div class="section" id="EN-US_TOPIC_0022472987__en-us_topic_0092803065_en-us_topic_0020212692_section22960139"><h4 class="sectiontitle">Returned Values</h4><p id="EN-US_TOPIC_0022472987__en-us_topic_0092803065_en-us_topic_0020212692_p23670760">See <a href="en-us_topic_0022067716.html">Returned Values for General Requests</a>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0022472987__en-us_topic_0092803065_en-us_topic_0067161469_en-us_topic_0057973179_section23611955"><h4 class="sectiontitle">Error Codes</h4><p id="EN-US_TOPIC_0022472987__p4242151919297">See <a href="en-us_topic_0022067717.html">Error Codes</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0111860831.html">Disk Management</a></div>
</div>
</div>