# Multiple PXE Server On Cloud

### Mô hình :

<figure><img src="/files/MJP7YMoPT3m03zr8ijdL" alt=""><figcaption><p>Mô hình triển khai multiple pxe server</p></figcaption></figure>

* Tất cả VM đều được cấp MAC và IP theo router mà Host đã được cắm vào
* Lúc này tất cả máy trong dải IP đều có thể truy cập vào PXE server nằm trên các VM

<figure><img src="/files/Kcifyb4AWU02fgW2UxLv" alt=""><figcaption><p>Mô hình triển khai API</p></figcaption></figure>

### Các bước triển khai :&#x20;

1. Cài đặt Cockpit
2. Tạo template\_volumes
3. Nhân bản template thành nhiều volume
4. Khởi tạo VM từ các volume
5. Cấu hình interface network để được cấp phát IP của router trên các VM ( không dùng Virtual Network )
6. Cài đặt API

### Cài đặt Cockpit

```bash
apt update -y

apt install cockpit -y

apt install cockpit-machines -y

apt install libosinfo-bin -y

apt upgrade osinfo-db -y

apt install osinfo-db-tools -y

curl -O https://releases.pagure.org/libosinfo/osinfo-db-20230518.tar.xz

osinfo-db-import --local  osinfo-db-20230518.tar.xz

systemctl restart cockpit

systemctl status cockpit
```

### Tạo folder chứa dữ liệu :&#x20;

```bash
mkdir /vm-data

mkdir /vm-data/templates

mkdir /vm-data/volumes
```

### Tạo Storage Pool :&#x20;

```bash
virsh pool-define-as "VM Storage" dir --target /vm-data/volumes

virsh pool-start "VM Storage"

virsh pool-autostart "VM Storage"

virsh pool-list --all
```

### Tải template VM :&#x20;

```bash
wget -P /vm-data/templates/ https://example.com/template.qcow2
```

### Sau khi cài đặt thành công :

Truy cập <https://localhost:9090>

### Thực hiện đăng nhập :

Sử dụng chính user của OS để đăng nhập&#x20;

<figure><img src="/files/8v7ONxps4NVdY0vJ262O" alt=""><figcaption></figcaption></figure>

### Truy cập Terminal ở navbar phía bên trái :&#x20;

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

### Thực hiện tạo volumes từ template :&#x20;

<figure><img src="/files/9GFsmWh61lmrZwyoRib2" alt=""><figcaption></figcaption></figure>

### Truy cập mục Virtual Machines ở navbar phía bên trái :&#x20;

<figure><img src="/files/6nHkCoKeTJTEbXL1Vqhl" alt=""><figcaption></figcaption></figure>

### Chọn import VM ở góc bên phải và truyền path volume :&#x20;

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

### Mở detail VM và cấu hình network interface:

Type : Direct attachment

Source : enp3s0 (Interface dải mạng chính)

Model : e1000e (PCI)

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

### Truy cập vào VM check interface đã được cấp mạng theo đúng dải mạng mình cần dùng chưa :&#x20;

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

### Thực hiện truy cập Iventoy theo IP của VM :&#x20;

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

### Thực hiện cài đặt API ở thiết bị trên cùng dải mạng :

```bash
apt update -y

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

apt install nodejs -y

npm install -g pm2

git clone <Link>

cd api-handle-iventoy

npm install

pm2 start "node index.js" --name api
```

### API list :&#x20;

<table><thead><tr><th width="159">Path</th><th width="126">Method</th><th width="341">Body</th><th>Feature</th></tr></thead><tbody><tr><td>/os</td><td>GET</td><td></td><td>Danh sách OS</td></tr><tr><td>/os</td><td>POST</td><td><p></p><pre class="language-postman_json"><code class="lang-postman_json">{
    "name": "Windows 10"
}
</code></pre></td><td>Khai báo OS </td></tr><tr><td>/devices</td><td>GET</td><td></td><td>Danh sách PXE Server</td></tr><tr><td>/devices</td><td>POST</td><td><p></p><pre class="language-postman_json"><code class="lang-postman_json">{
    "ip": "192.168.1.112",
    "os": "Windows 10",
    "portIventoy": 26000
}
</code></pre></td><td></td></tr><tr><td>/devices/mac</td><td>POST</td><td><p></p><pre class="language-postman_json"><code class="lang-postman_json">{
    "os": "Windows 10",
    "mac": "00-0C-29-85-05-3D"
}
</code></pre></td><td>Khai báo mac được chấp nhận cho OS</td></tr><tr><td>/devices/mac</td><td>DELETE</td><td><p></p><pre class="language-postman_json"><code class="lang-postman_json">{
    "os": "Windows 10",
    "mac": "00-0C-29-85-05-3D"
}
</code></pre></td><td>Loại bỏ mac được chấp nhận cho OS</td></tr></tbody></table>


---

# 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.x-or.cloud/tutorials/multiple-pxe-server-on-cloud.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.
