This tutorial will guide you through installing and using the OpenStack command-line interface (CLI) tools to manage your RamNode Cloud VPS instances programmatically.
Prerequisites
Before getting started, ensure you have:
- A RamNode Cloud account with at least one project
- Python 3.6 or higher installed on your local machine
- Basic command-line familiarity
Install the OpenStack CLI Tools
The easiest way to install the OpenStack CLI is using pip, Python's package manager.
Linux (Ubuntu/Debian)
# Update package lists
sudo apt update
# Install Python pip
sudo apt install python3-pip -y
# Install OpenStack CLI
sudo pip3 install python-openstackclientLinux (CentOS/Rocky/AlmaLinux)
# Install EPEL repository (if not already installed)
sudo yum install epel-release -y
# Install Python and pip
sudo yum install python3 python3-pip -y
# Install OpenStack CLI
sudo pip3 install python-openstackclientmacOS
# Install using pip (requires Python 3)
pip3 install python-openstackclient
# Or using Homebrew
brew install openstackclientWindows
# Install using pip (requires Python 3)
pip install python-openstackclientDownload Your OpenStack RC File
The RC file contains your authentication credentials and API endpoints.
- Log into the Cloud Control Panel
- Click on your username in the top right corner
- Select OpenStack RC File from the dropdown menu
- Choose OpenStack RC File (Identity API v3) - this is the recommended version
- Save the file to your local machine (typically named
openrc.sh)
Load Your Credentials
Source the RC file to load your credentials into your environment:
Linux/macOS
# Navigate to where you saved the RC file
cd ~/Downloads
# Source the file
source openrc.sh
# You'll be prompted to enter your Cloud Control Panel password
# Type your password (it won't be visible as you type)Windows (PowerShell)
# Set environment variables manually
$env:OS_AUTH_URL="https://cloud.ramnode.com:5000/v3"
$env:OS_PROJECT_NAME="your-project-name"
$env:OS_USERNAME="your-email"
$env:OS_PASSWORD="your-password"
$env:OS_USER_DOMAIN_NAME="Default"
$env:OS_PROJECT_DOMAIN_NAME="Default"
$env:OS_IDENTITY_API_VERSION="3"Verify the Connection
Test that your CLI is properly configured:
# List your current projects
openstack project list
# List available server flavors (plans)
openstack flavor list
# List available images
openstack image list
# List your existing instances
openstack server listInstance Management
Manage your cloud instances with these common commands:
# Create a new instance
openstack server create \
--flavor c1.small \
--image "Ubuntu 22.04 LTS" \
--key-name my-ssh-key \
--network public \
my-server-name
# List all instances
openstack server list
# Show instance details
openstack server show my-server-name
# Stop an instance
openstack server stop my-server-name
# Start an instance
openstack server start my-server-name
# Reboot an instance
openstack server reboot my-server-name
# Delete an instance
openstack server delete my-server-nameSSH Key Management
Manage SSH keys for secure server access:
# List SSH keys
openstack keypair list
# Upload a new SSH key
openstack keypair create --public-key ~/.ssh/id_rsa.pub my-key-name
# Delete an SSH key
openstack keypair delete my-key-nameNetwork Management
Manage floating IPs and network resources:
# List networks
openstack network list
# Create a floating IP
openstack floating ip create public
# List floating IPs
openstack floating ip list
# Attach floating IP to instance
openstack server add floating ip my-server-name 198.51.100.10
# Remove floating IP from instance
openstack server remove floating ip my-server-name 198.51.100.10Snapshot Management
Create and manage instance snapshots:
# Create a snapshot of an instance
openstack server image create --name my-snapshot my-server-name
# List all snapshots/images
openstack image list
# Delete a snapshot
openstack image delete my-snapshotSecurity Group Management
Configure firewall rules with security groups:
# List security groups
openstack security group list
# Create a security group
openstack security group create --description "Web Server" web-sg
# Add a rule to allow HTTP
openstack security group rule create \
--protocol tcp \
--dst-port 80 \
web-sg
# Add a rule to allow SSH
openstack security group rule create \
--protocol tcp \
--dst-port 22 \
web-sgVolume (Block Storage) Management
Manage block storage volumes:
# List volumes
openstack volume list
# Create a volume
openstack volume create --size 100 my-volume
# Attach volume to instance
openstack server add volume my-server-name my-volume
# Detach volume from instance
openstack server remove volume my-server-name my-volume
# Delete a volume
openstack volume delete my-volumeAdvanced Usage
Output Formatting
You can format CLI output in different ways:
# JSON output
openstack server list -f json
# YAML output
openstack server list -f yaml
# CSV output
openstack server list -f csv
# Table (default)
openstack server list -f tableFiltering and Querying
# Show only specific columns
openstack server list -c Name -c Status
# Filter by status
openstack server list --status ACTIVETroubleshooting
Authentication Issues
If you encounter authentication errors:
- Verify your password is correct
- Check that you've sourced the RC file in your current terminal session
- Ensure your project name is correct
- Try downloading a fresh RC file from the control panel
Connection Timeouts
If commands are timing out:
- Check your internet connection
- Verify that your firewall isn't blocking the API endpoints
- Try increasing the timeout:
export OS_TIMEOUT=300
Command Not Found
If the openstack command isn't found:
- Ensure you've installed the client correctly
- Check that Python's bin directory is in your PATH
- Try running:
python3 -m pip install --upgrade python-openstackclient
Using with Scripts
You can use the OpenStack CLI in shell scripts for automation:
#!/bin/bash
# Source credentials
source ~/openrc.sh
# Get list of instances
INSTANCES=$(openstack server list -f value -c Name)
# Loop through and reboot each instance
for instance in $INSTANCES; do
echo "Rebooting $instance..."
openstack server reboot "$instance"
done
echo "All instances rebooted!"Python SDK Alternative
For more complex automation, you can use the OpenStack Python SDK:
# Install the SDK
pip install openstacksdk
# Example Python script
import openstack
# Create connection
conn = openstack.connect(cloud='openstack')
# List instances
for server in conn.compute.servers():
print(server.name, server.status)
# Create an instance
server = conn.compute.create_server(
name='my-server',
image='Ubuntu 22.04',
flavor='c1.small',
network='public'
)
print(f"Created server: {server.name}")Pro Tip: For managing multiple clouds or projects, you can create a clouds.yaml file in ~/.config/openstack/ to store multiple sets of credentials. See the OpenStack CLI documentation for details.
