Guide: OpenStack CLI – Basic Usage

From bwCloud-OS
Revision as of 21:54, 24 April 2026 by Sia (talk | contribs) (Created page with " = Guide: OpenStack CLI – Basic Usage = This guide provides a quick introduction to managing your bwCloud-OS project using the OpenStack CLI. It covers the most common operations for instances, storage, networking, and security. == General Information about Cloud, Project, and User == Before working with resources, you can inspect your current configuration and context:<pre> openstack configuration show openstack project list openstack token issue openstack region lis...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Guide: OpenStack CLI – Basic Usage

This guide provides a quick introduction to managing your bwCloud-OS project using the OpenStack CLI. It covers the most common operations for instances, storage, networking, and security.

General Information about Cloud, Project, and User

Before working with resources, you can inspect your current configuration and context:

openstack configuration show
openstack project list
openstack token issue
openstack region list

Instances (Compute)

Create an instance:

openstack server create \
  --image ubuntu-24.04 \
  --flavor m1.small \
  --network myNet \
  --key-name myKey \
  myVM

List instances:

openstack server list

Show details of an instance:

openstack server show myVM

Delete an instance:

openstack server delete myVM

Storage (Volumes)

Create a volume:

openstack volume create --size 10 myVolume

List volumes:

openstack volume list

Attach a volume to an instance:

openstack server add volume myVM myVolume

Detach a volume:

openstack server remove volume myVM myVolume

Delete a volume:

openstack volume delete myVolume

Networking

Create a network:

openstack network create myNet

Create a subnet:

openstack subnet create mySubnet \

 --network myNet \
 --subnet-range 192.168.1.0/24

Create a router:

openstack router create myRouter

Attach subnet to router:

openstack router add subnet myRouter mySubnet

Set external gateway:

openstack router set myRouter --external-gateway provider_net

List networks:

openstack network list

Security (Security Groups & Rules)

List security groups:

openstack security group list

Create a security group:

openstack security group create mySecGroup

Add SSH access (port 22):

openstack security group rule create \

 --proto tcp \
 --dst-port 22 \
 mySecGroup

Add HTTP access (port 80):

openstack security group rule create \

 --proto tcp \
 --dst-port 80 \
 mySecGroup

Assign security group to instance:

openstack server add security group myVM mySecGroup

Floating IPs (Public Access)

Create a floating IP:

openstack floating ip create provider_net

List floating IPs:

openstack floating ip list

Associate floating IP with instance:

openstack server add floating ip myVM <FLOATING_IP>

Remove floating IP:

openstack server remove floating ip myVM <FLOATING_IP>

Images

List available images:

openstack image list

Show image details:

openstack image show <IMAGE_ID>

Key Pairs (SSH Access)

Create a key pair:

openstack keypair create myKey > myKey.pem
chmod 600 myKey.pem

List key pairs:

openstack keypair list

Delete a key pair:

openstack keypair delete myKey

Automation & Scripting

You can combine commands and variables to automate workflows:

FIP=$(openstack floating ip create provider_net -f value -c floating_ip_address)

openstack server create \
  --image ubuntu-24.04 \
  --flavor m1.small \
  --network myNet \
  --key-name myKey \
  myVM

openstack server add floating ip myVM $FIP