> For the complete documentation index, see [llms.txt](https://docs-epc.gitbook.io/ncs-documents/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-epc.gitbook.io/ncs-documents/public-api/getting-start-with-ncs-public-api/using-openstack-client-tool-with-rc-file.md).

# Using OpenStack Client Tool With RC File

## Prerequisite

* มี account ใช้งานบน NIPA Cloud Space
* มี access เข้า project ที่มี wallet status เป็น Normal
* ดาวน์โหลด RC file ( [Manage Application Credentials](/ncs-documents/public-api/getting-start-with-ncs-public-api/using-openstack-client-tool-with-rc-file/manage-application-credentials.md), [Manage Application Credentials](/ncs-documents/public-api/getting-start-with-ncs-public-api/using-openstack-client-tool-with-rc-file/manage-application-credentials.md))

## Instructions

### 1. เตรียม dependency สำหรับใช้งาน&#x20;

#### สำหรับ Ubuntu

update package cache

```
sudo apt update && sudo apt upgrade -y
```

ติดตั้ง Python3

```
sudo apt install python3-dev python3-pip
```

ติดตั้ง OpenStack Client

```
sudo apt install python3-openstackclient 
```

ตรวจสอบความพร้อม

```
openstack --help
```

ผลที่ควรจะเป็น

<figure><img src="/files/3NIjob2Ml43wq0FEUqjw" alt=""><figcaption></figcaption></figure>

### 2. Setup RC File

ตั้งค่า RC file โดยใช้ command source

```
source <openrc.sh file>
```

หากใช้ User RC File จะมีขั้นตอนในการกรอก Password หรือ TOTP เพิ่มขึ้นมา

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

กรอก password ที่ใช้ในการ login เข้า NIPA Cloud Space

### 3. ดูรายการ command ที่ใช้งานได้

ดูรายการ command ที่ใช้งานได้ โดยการใช้ command ดังนี้

```
openstack command list
```

ผลที่ควรจะได้รับ

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

หรือสามารถ filter command ที่ต้องการได้ โดยการระบุ group

```
openstack command list --group compute
```

ผลที่ควรจะได้รับ

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

หรือใช้ help เพื่อดู command เพิ่มเติม เช่น

```
codeopenstack help flavor list 
usage: openstack flavor list [-h] [-f {csv,json,table,value,yaml}] [-c COLUMN][--quote {all,minimal,none,nonnumeric}] [--noindent][--max-width <integer>] [--fit-width] [--print-empty][--sort-column SORT_COLUMN][--sort-ascending | --sort-descending] [--public | --private | --all][--min-disk <min-disk>] [--min-ram <min-ram>] [--long][--marker <flavor-id>] [--limit <num-flavors>]
```

***

## ตัวอย่างการสร้าง Compute Instance โดยใช้ OpenStack Client

สร้าง Compute Instance ที่มี specification ดังนี้

* Name: Instance-2001
* Machine Type: csa.large.v2
* Volume: Standard-SSD 40 GB
* VPC : default

### 1. ดูรายการของ Machine Type&#x20;

list รายการ Machine Type (Flavor) โดยใช้ command

```
openstack flavor list
```

ผลที่ได้ควรจะเป็น

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

### 2. ดูรายการของ VPC Network และ Subnet

list รายการ VPC Network (Network) โดยใช้ command

```
openstack network list
```

ผลที่ได้ควรจะเป็น

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

list รายการ Subnet โดยใช้ command

```
openstack subnet list
```

ผลที่ได้ควรจะเป็น

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

### 3. ดูรายการของ Security Group

list รายการ Security Group โดยใช้ command

```
openstack security group list
```

ผลที่ได้ควรจะเป็น

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

### 4. สั่ง launch Compute Instance

สั่ง launch Compute Instance (Server) โดยใช้ข้อมูลที่ list ไว้ก่อนหน้า

```
openstack server create ..........
```

ตัวอย่าง

```
openstack server create \
  --flavor 3d7f13f6-11df-45a0-a78b-fb20a64c2849 \
  --image 6a0e2c93-682d-4d3b-a473-5251faefb8fc \
  --boot-from-volume 20 \
  --nic net-id=2aa7a98d-ae38-4844-82d6-9ab5c2460b69 \
  Instance-2001
```

ผลที่ได้ควรจะเป็น

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

ตรวจสอบ Compute Instance ที่ถูกสร้างผ่าน command

```
openstack server list 
```

ผลที่ได้ควรจะเป็น

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