Using OpenStack Client Tool
ใช้งาน Python SDK สำหรับ OpenStack เพื่อใช้งาน NCS Public API
Prerequisite
มี account ใช้งานบน NIPA Cloud Space
มี access เข้า project ที่มี wallet status เป็น Normal
ดาวน์โหลด RC file (วิธีการ download RC file)
Instructions
1. เตรียม dependency สำหรับใช้งาน
สำหรับ 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
ผลที่ควรจะเป็น

2. Setup RC File
ตั้งค่า RC file โดยใช้ command source
source <openrc.sh file>
ผลที่ควรจะเป็น

กรอก password ที่ใช้ในการ login เข้า NIPA Cloud Space
3. ดูรายการ command ที่ใช้งานได้
ดูรายการ command ที่ใช้งานได้ โดยการใช้ command ดังนี้
openstack command list
ผลที่ควรจะได้รับ

หรือสามารถ filter command ที่ต้องการได้ โดยการระบุ group
openstack command list --group compute
ผลที่ควรจะได้รับ

หรือใช้ 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
list รายการ Machine Type (Flavor) โดยใช้ command
openstack flavor list
ผลที่ได้ควรจะเป็น

2. ดูรายการของ VPC Network และ Subnet
list รายการ VPC Network (Network) โดยใช้ command
openstack network list
ผลที่ได้ควรจะเป็น

list รายการ Subnet โดยใช้ command
openstack subnet list
ผลที่ได้ควรจะเป็น

3. ดูรายการของ Security Group
list รายการ Security Group โดยใช้ command
openstack security group list
ผลที่ได้ควรจะเป็น

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
ผลที่ได้ควรจะเป็น

ตรวจสอบ Compute Instance ที่ถูกสร้างผ่าน command
openstack server list
ผลที่ได้ควรจะเป็น

Last updated
Was this helpful?