Guide: OpenStack CLI – Basic Usage

From bwCloud-OS
Revision as of 22:10, 24 April 2026 by Sia (talk | contribs)
Jump to navigation Jump to search

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


Compute (Instances, Images)

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

List available images:

openstack image list

Show image details:

openstack image show <IMAGE_ID>


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

List networks:

openstack network list

Create a network:

openstack network create myNet

Subnets, Routers

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


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>


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


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