forked from docs/doc-exports
Reviewed-by: Hajba, László Antal <laszlo-antal.hajba@t-systems.com> Co-authored-by: Qin Ying, Fan <fanqinying@huawei.com> Co-committed-by: Qin Ying, Fan <fanqinying@huawei.com>
106 lines
8.3 KiB
HTML
106 lines
8.3 KiB
HTML
<a name="eip_apieg_0002"></a><a name="eip_apieg_0002"></a>
|
|
|
|
<h1 class="topictitle1">Binding an EIP to an <span id="text4648152216508">ECS</span></h1>
|
|
<div id="body1598357202801"><div class="section" id="eip_apieg_0002__section7138121042816"><h4 class="sectiontitle">Scenarios</h4><p id="eip_apieg_0002__p2702101072812">This section describes how to bind an EIP to an <span id="eip_apieg_0002__text145051735155012">ECS</span> by calling APIs.</p>
|
|
</div>
|
|
<div class="section" id="eip_apieg_0002__section121461310112815"><h4 class="sectiontitle">Prerequisites</h4><ul id="eip_apieg_0002__ul11703191082816"><li id="eip_apieg_0002__li1970311012287">You have created an ECS. For details, see section "Purchasing an ECS with Customized Configurations" in the <em id="eip_apieg_0002__i186701211922">Elastic Cloud Server User Guide</em>.</li><li id="eip_apieg_0002__li37039105286">If you use a token for authentication, you must obtain the token and add <strong id="eip_apieg_0002__b12870184919531">X-Auth-Token</strong> to the request header when making an API call. <div class="note" id="eip_apieg_0002__note11614213151716"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="eip_apieg_0002__eip_apieg_0001_p530413530166">The token obtained from IAM is valid for only 24 hours. If you want to use a token for authentication, you can cache it to avoid frequent calling.</p>
|
|
</div></div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="eip_apieg_0002__section19170191052819"><h4 class="sectiontitle">Procedure</h4><ol id="eip_apieg_0002__ol6705151017288"><li id="eip_apieg_0002__li570561062812">Obtain the NIC information based on the <span id="eip_apieg_0002__text197589610596">ECS</span> ID. For details, see section "Querying a Port" in the <em id="eip_apieg_0002__i18176132343">Virtual Private Cloud API Reference</em>.<ol type="a" id="eip_apieg_0002__ol83611143183010"><li id="eip_apieg_0002__li19183935193018">Send <strong id="eip_apieg_0002__b10952152910427">GET https://</strong><em id="eip_apieg_0002__i10119136125610">VPC endpoint</em><strong id="eip_apieg_0002__b8868133312423">/v1/</strong><em id="eip_apieg_0002__i1888013393427">project_id</em><strong id="eip_apieg_0002__b19334245194216">/ports?device_id=</strong><em id="eip_apieg_0002__i1853275264218">ecs_id</em>. Parameter <strong id="eip_apieg_0002__b141256675611">project_id</strong> indicates the project ID.</li><li id="eip_apieg_0002__li830913398301">Add <strong id="eip_apieg_0002__b1374634013014">X-Auth-Token</strong> to the request header.</li><li id="eip_apieg_0002__li652144114308">Check the response message.<ul id="eip_apieg_0002__ul8705210172817"><li id="eip_apieg_0002__li97051010182820">The request is successful if the following response is displayed.<pre class="screen" id="eip_apieg_0002__screen1830283316">{
|
|
"ports": [{
|
|
"id": "02c72193-efec-42fb-853b-c33f2b802467",
|
|
"name": "",
|
|
"status": "ACTIVE",
|
|
"admin_state_up": true,
|
|
"fixed_ips": [{
|
|
"subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12",
|
|
"ip_address": "192.168.0.75"
|
|
}],
|
|
"mac_address": "fa:16:3e:47:5f:c1",
|
|
"network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d",
|
|
"tenant_id": "db82c9e1415a464ea68048baa8acc6b8",
|
|
"project_id": "db82c9e1415a464ea68048baa8acc6b8",
|
|
"device_id": "ea61f836-b52f-41bf-9d06-685644001d6f",
|
|
"device_owner": "compute:br-iaas-odin1a",
|
|
"security_groups": [
|
|
"e0598d96-9451-4f8a-8de0-b8b4d451d9e7"
|
|
],
|
|
"extra_dhcp_opts": [],
|
|
"allowed_address_pairs": [],
|
|
"binding:vnic_type": "normal",
|
|
"binding:vif_details": {
|
|
"primary_interface": true
|
|
},
|
|
"binding:profile": {},
|
|
"port_security_enabled": true,
|
|
"created_at": "2020-06-20T08:07:29",
|
|
"updated_at": "2020-06-20T08:07:29"
|
|
}]
|
|
}</pre>
|
|
</li><li id="eip_apieg_0002__li13710710182818">For details about the error codes when the request is abnormal, see <a href="ErrorCode.html">Error Codes</a>.</li></ul>
|
|
</li></ol>
|
|
</li><li id="eip_apieg_0002__li19710910192810">Assign an EIP.<ol type="a" id="eip_apieg_0002__ol16710810152814"><li id="eip_apieg_0002__li197105105282">Send <strong id="eip_apieg_0002__b22572061834">POST https://</strong><em id="eip_apieg_0002__i1214414617582">Endpoint</em><strong id="eip_apieg_0002__b17847301335">/v1/</strong><em id="eip_apieg_0002__i26232521928">project_id</em><strong id="eip_apieg_0002__b36873571211">/publicips</strong>. Parameter <strong id="eip_apieg_0002__b1314946165814">project_id</strong> indicates the project ID.</li><li id="eip_apieg_0002__li171091082816">Add <strong id="eip_apieg_0002__b7658115705812">X-Auth-Token</strong> to the request header.</li><li id="eip_apieg_0002__li7710410122817">Specify the following parameters in the request body:<pre class="screen" id="eip_apieg_0002__screen1697543293113">{
|
|
"publicip": {
|
|
"type": "5_bgp",
|
|
"ip_version": 6
|
|
},
|
|
"bandwidth": {
|
|
"name": "bandwidth123",
|
|
"size": 5,
|
|
"share_type": "WHOLE",
|
|
"id":"ebfa375c-3f93-465e-81a3-bd66e578ee9d"
|
|
},
|
|
"enterprise_project_id":"0"
|
|
}</pre>
|
|
</li><li id="eip_apieg_0002__li2711141092814">Check the response message.<ul id="eip_apieg_0002__ul147115109283"><li id="eip_apieg_0002__li1071151018288">The request is successful if the following response is displayed.<pre class="screen" id="eip_apieg_0002__screen162291142133118">{
|
|
"publicip": {
|
|
"id": "f588ccfa-8750-4d7c-bf5d-2ede24414706",
|
|
"status": "PENDING_CREATE",
|
|
"type": "5_bgp",
|
|
"public_ip_address": "161.xx.xx.7",
|
|
"tenant_id": "8b7e35ad379141fc9df3e178bd64f55c",
|
|
"ip_version": 4,
|
|
"create_time": "2015-07-16 04:10:52",
|
|
"bandwidth_size": 0,
|
|
"enterprise_project_id":"b261ac1f-2489-4bc7-b31b-c33c3346a439"
|
|
}
|
|
}</pre>
|
|
</li><li id="eip_apieg_0002__li15711121014289">For details about the error codes when the request is abnormal, see <a href="ErrorCode.html">Error Codes</a>.</li></ul>
|
|
</li></ol>
|
|
</li><li id="eip_apieg_0002__li671111092814">Bind the EIP to the <span id="eip_apieg_0002__text68061028205913">ECS</span> NIC.<ol type="a" id="eip_apieg_0002__ol15711121062812"><li id="eip_apieg_0002__li6711171012281">Send <strong id="eip_apieg_0002__b164853441632">PUT /v1/</strong><em id="eip_apieg_0002__i1085017253311">project_id</em><strong id="eip_apieg_0002__b7527939235">/publicips/</strong><em id="eip_apieg_0002__i19535112919318">publicip_id</em>. Parameter <strong id="eip_apieg_0002__b1625612411918">project_id</strong> indicates the project ID.</li><li id="eip_apieg_0002__li3711101014284">Add <strong id="eip_apieg_0002__b2059016313">X-Auth-Token</strong> to the request header.</li><li id="eip_apieg_0002__li20711171015281">Specify the following parameters in the request body:<pre class="screen" id="eip_apieg_0002__screen8163135043110">{
|
|
"publicip": {
|
|
"port_id": "02c72193-efec-42fb-853b-c33f2b802467"
|
|
}
|
|
}</pre>
|
|
</li><li id="eip_apieg_0002__li47111810192815">Check the response message.<ul id="eip_apieg_0002__ul19711131018281"><li id="eip_apieg_0002__li1271111101285">The request is successful if the following response is displayed.<pre class="screen" id="eip_apieg_0002__screen297135614312">{
|
|
"publicip": {
|
|
"id": "f588ccfa-8750-4d7c-bf5d-2ede24414706",
|
|
"status": "ACTIVE",
|
|
"type": "5_bgp",
|
|
"port_id": "02c72193-efec-42fb-853b-c33f2b802467",
|
|
"public_ip_address": "10.xx.xx.162",
|
|
"private_ip_address": "192.168.1.131",
|
|
"tenant_id": "26ae5181a416420998eb2093aaed84d9",
|
|
"create_time": "2019-03-27 01:33:18",
|
|
"bandwidth_id": "02da78da-4fb0-4880-b512-f516cdeb8ef3",
|
|
"bandwidth_name": "test",
|
|
"<u id="eip_apieg_0002__u97412814119">b</u>andwidth_share_type": "PER",
|
|
"bandwidth_size": 1,
|
|
"profile": {},
|
|
"enterprise_project_id": "0",
|
|
"ip_version": 4
|
|
}
|
|
}</pre>
|
|
</li><li id="eip_apieg_0002__li871241072818">For details about the error codes when the request is abnormal, see <a href="ErrorCode.html">Error Codes</a>.</li></ul>
|
|
</li></ol>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="eip_apieg_0000.html">Application Examples</a></div>
|
|
</div>
|
|
</div>
|
|
|