Skip to content

OpenStack CLI Cheat Sheet: A concise and essential collection of commands and troubleshooting tips for efficient management and problem-solving in OpenStack environments.

Notifications You must be signed in to change notification settings

turbra/openstack-cli-cheat-sheat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

OpenStack CLI Cheat Sheet

Table of Contents

  1. Common Commands
  2. Troubleshooting Commands
  3. Formatting Tips

Common Commands

General

  • List Available Commands
    openstack --help

Authentication

  • Set Environment Variables
    source openrc.sh

Identity (Keystone)

  • List All Users
    openstack user list
  • List Identity Service Catalog
    openstack catalog list

Images (Glance)

  • List Images You Can Access
    openstack image list
  • Delete Specified Image
    openstack image delete IMAGE
  • Describe a Specific Image
    openstack image show IMAGE
  • Update Image
    openstack image set IMAGE
  • Upload Kernel, RAM, Three-Part, and Raw Images
    # Various commands for uploading different types of images

Compute (Nova)

  • List Instances, Check Status of Instance
    openstack server list
  • Create a Flavor Named m1.tiny
    openstack flavor create --ram 512 --disk 1 --vcpus 1 m1.tiny
  • List Flavors
    openstack flavor list
  • Boot an Instance Using Flavor and Image Names
    openstack server create --image IMAGE --flavor FLAVOR INSTANCE_NAME
  • Log in to the Instance, Show Details, View Console Log, Set Metadata, Create Snapshot
    # Various commands for managing instances

Networking (Neutron)

  • Create Network, Create a Subnet
    openstack network create NETWORK_NAME
    openstack subnet create --subnet-pool SUBNET --network NETWORK SUBNET_NAME

Block Storage (Cinder)

  • Create a New Volume, Boot Instance and Attach to Volume
    openstack volume create --size SIZE_IN_GB NAME
    openstack server create --image IMAGE --flavor FLAVOR --volume VOLUME_NAME INSTANCE_NAME
  • List Volumes, Attach/Detach a Volume
    openstack volume list
    openstack server add volume INSTANCE_ID VOLUME_ID
  • Additional volumes are attached post-creation
  1. Create the Instance with the Boot Volume:

    • The boot volume contains the operating system and is specified in the server create command.
    openstack server create --image IMAGE --flavor FLAVOR --volume BOOT_VOLUME_NAME INSTANCE_NAME
  2. Attach Additional Volumes After the Instance is Created:

    • Once the instance is up and running, you can attach additional volumes using the openstack server add volume command.
    openstack server add volume INSTANCE_NAME ADDITIONAL_VOLUME_NAME_1
    openstack server add volume INSTANCE_NAME ADDITIONAL_VOLUME_NAME_2
    # Repeat for as many additional volumes as you have
  • Create an instance, specifying the volume as a block device to attach
openstack server create \
    --flavor $FLAVOR \
    --image $IMAGE \
    --port $PORT \
    --block-device uuid=006efd7a-48a8-4c75-bafb-6b483199d284,source_type=volume,destination_type=volume \
    --wait test-server

Object Storage (Swift)

  • Display Information, List Containers
    swift stat
    swift list

Troubleshooting Commands

General Troubleshooting

  • Show OpenStack Client Version, Service List and Status
    openstack --version
    openstack service list

Nova (Compute Service)

  • Show Instance Details for Troubleshooting
    openstack server show <server-name>

Neutron (Networking Service)

  • Network Agent List and Status, Specific Network Details
    openstack network agent list
    openstack network show <network-name>

Cinder (Block Storage Service)

  • Show Volume Details
    openstack volume show <volume-name>

Keystone (Identity Service)

  • Token Validation
    openstack token issue

Glance (Image Service)

  • Image Details
    openstack image show <image-name>

Heat (Orchestration Service)

  • Stack Events and Details
    openstack stack event list/show <stack-name>

Logs

  • View and Tail Logs
    tail -f /var/log/<service-name>/<log-file>

Networking Diagnostics

  • Ping and Traceroute for Connectivity Issues

Resource Clean-Up

  • Force Delete Stuck Resources
    openstack server delete --force <server-name>
    openstack volume delete --force <volume-name>

Additional Tips

  • Structured Output with -f json or -f yaml
  • Help Option for Detailed Command Usage
  • Quota Checks with openstack quota show
  • Regular Service Health Checks

Formatting Tips

General Formatting Options

  • Fit-Width: To ensure output fits the terminal width without wrapping.
    openstack <command> --fit-width
  • Select Columns: Display only specified columns in the output.
    openstack <command> -c COLUMN1 -c COLUMN2
    # or
    openstack <command> --column COLUMN1 --column COLUMN2
  • Output Format: Display output in different formats like JSON, YAML, or table (default).
    openstack <command> -f json
    openstack <command> -f yaml
    openstack <command> -f table
  • No Headers: Hide the table header row in output.
    openstack <command> --no-header

Sorting

  • Sort Output: Sort output by a specific column.
    openstack <command> --sort-column COLUMN_NAME

Filtering

  • Filter Output: Use the grep command to filter output.
    openstack <command> | grep 'filter-term'
  • Combining Commands: Chain commands with Unix pipes for complex filtering.
    openstack <command> | grep 'filter-term' | awk '{print $1}'

Advanced Formatting

  • Custom Scripts: For complex formatting, consider using custom scripts that parse JSON or YAML output.

Tips for Efficiency

  • Aliases: Create shell aliases for commonly used commands with specific formatting.
  • Scripts: Write shell scripts for complex or frequently used command sequences.

About

OpenStack CLI Cheat Sheet: A concise and essential collection of commands and troubleshooting tips for efficient management and problem-solving in OpenStack environments.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published