# API cấu hình lại Network của VM

## <mark style="color:green;">**Tổng quan**</mark> <a href="#overview" id="overview"></a>

Trong tài liệu này, bạn sẽ tìm thấy thông tin chi tiết về cách chuẩn bị thông tin, lấy thông tin mạng của VM và cấu hình lại mạng của VM.

## <mark style="color:green;">Quy trình</mark>

{% stepper %}
{% step %}
**Bước 1**: Chuẩn bị thông tin

Đăng nhập vào IAM portal -> vCD portal: thu thập thông tin

**{{vcd\_url}}**

<figure><img src="/files/Y7kJzy5K5HCTTlGa9ERf" alt=""><figcaption></figcaption></figure>

**{{vm-uuid}}:** chọn VM -> kiểm tra vm **uuid** trên URL<br>

<figure><img src="/files/2T3sqUULPV3iCdXa1JK6" alt=""><figcaption></figcaption></figure>

**{{network\_name}}**: Chọn Networking -> Networks -> Sao chép tên mạng<br>

<figure><img src="/files/xfBlpjNpWuVyXjmNyDn0" alt=""><figcaption></figcaption></figure>

**{{Bearer Token}}:** Vui lòng tham khảo tài liệu “API token login”
{% endstep %}

{% step %}
**Bước 2:** **Lấy thông tin mạng của VM**

* GET https\://{{vcd\_url}}/api/vApp/{{vm-uuid}}/virtualHardwareSection/networkCards
* Authorization: {{Bearer Token}}
* Headers:

\- ‘Accept’: \*/\*;version=37.2

\- ‘Content-type’: application/vnd.vmware.vcloud.rasdItem+xml

<figure><img src="/files/guaxnTqbXVbZkFFDhOfZ" alt=""><figcaption></figcaption></figure>

* SEND request.

Copy **Response Body**
{% endstep %}

{% step %}
**Bước 3: Cấu hình lại mạng của VM**

* PUT https//{{vcd\_url}}/api/vApp/{{vm-uuid}}/virtualHardwareSection/networkCards
* Authorization: {{Bearer Token }}
* Headers:

\- 'Accept’: \*/\*;version=37.2

\- ‘Content-type’: application/vnd.vmware.vcloud.rasdItemsList+xml; charset=ISO-8859-1

Body: *{{select raw -> copy and paste* *response body from Get VM’s networks information }}*

Ex:

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RasdItemsList xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
…………………………………..
………………………………….
    <Link rel="edit" href="https://iaas-hcmc02.higiocloud.vn/api/vApp/vm-6cc0d2ef-6823-421a-bed5-8bb0f92a7bca/virtualHardwareSection/networkCards" type="application/vnd.vmware.vcloud.rasdItemsList+json"/>
    <Item>
        <rasd:Address>00:50:56:02:10:2c</rasd:Address>
        <rasd:AddressOnParent>0</rasd:AddressOnParent>
        <rasd:AllocationUnits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
        <rasd:AutomaticDeallocation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <rasd:ConfigurationName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <rasd:Connection xmlns:ns10="http://www.vmware.com/vcloud/v1.5" ns10:ipAddressingMode="Manual" ns10:ipAddress="10.10.11.20" ns10:primaryNetworkConnection="true">10.10.11.0/24</rasd:Connection>
        <rasd:ConsumerVisibility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        …………………………………………………………………….
        <rasd:ResourceSubType>VMXNET3</rasd:ResourceSubType>
        <rasd:ResourceType>10</rasd:ResourceType>
        <rasd:VirtualQuantity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
        <rasd:Weight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
    </Item>
</RasdItemsList>
```

\=====================================================================

Tìm từ :

<mark style="color:red;">ns10:ipAddressingMode</mark> và chỉnh sửa giá trị trong “ ” (network mode: “DHCP”, “Pool”, “Manual”)

\+ DHCP: Vui lòng thiết lập DHCP pool trên mạng của bạn -> The IP Management

\+ Pool: Vui lòng thiết lập Static IP pools trên mạng của bạn-> IP Management

<mark style="color:red;">ns10:ipAddress</mark> và chỉnh sửa giá trị trong “ ” (“VM ipv4 address”) – **không cần nếu sử dụng DHCP hoặc Pool**

<mark style="color:red;">ns10:primaryNetworkConnection</mark> và chỉnh sửa giá trị trong “ ” (dán tên mạng <mark style="color:green;">{{netwok\_name}}</mark> )

* SEND request.
  {% endstep %}

{% step %}
**Bước 4:** **Xác minh**

* **Lấy thông tin mạng của VM**

GET https\://{{vcd\_url}}/api/vApp/{{vm-uuid}}/virtualHardwareSection/networkCards

* **Kiểm tra trên vCD portal:**

Login IAM -> vCD portal-> select VM-> NICs
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.higiocloud.vn/hi-gio-user-guide-vn/compute/4.-hi-gio-api/api-cau-hinh-lai-network-cua-vm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
