OpenStack Dev Server Setup Ubuntu

Step-by-step guide to setting up an OpenStack 2024.2 development environment on Ubuntu 22.04 using DevStack for testing and contribution.

OpenStack Dev Server Setup Ubuntu

This guide installs OpenStack 2024.2 on Ubuntu 22.04 using DevStack.

Prerequisites

  • OS: Ubuntu 22.04 LTS
  • RAM: 8 GB minimum
  • Disk: 60 GB free
  • CPU: 4 cores
  • Network: Internet access

Step 1: Update and Install Dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install -y git vim python3-dev python3-pip python3-venv \
  gcc libffi-dev libssl-dev libpq-dev libvirt-daemon-system \
  libvirt-clients bridge-utils iptables iproute2

Step 2: Create the Stack User

sudo useradd -s /bin/bash -d /opt/stack -m stack
sudo chmod +x /opt/stack
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
sudo -u stack -i

Step 3: Clone DevStack

git clone https://opendev.org/openstack/devstack -b stable/2024.2
cd devstack

Step 4: Configure local.conf

Replace 10.0.0.10 with your server's actual IP address.

cat > local.conf <<'EOF'
[[local|localrc]]
ADMIN_PASSWORD=devstack
DATABASE_PASSWORD=devstack
RABBIT_PASSWORD=devstack
SERVICE_PASSWORD=devstack
HOST_IP=10.0.0.10

# Networking with OVN
Q_AGENT=ovn
Q_ML2_PLUGIN_MECHANISM_DRIVERS=ovn
Q_ML2_TENANT_NETWORK_TYPE=geneve
OVN_L3_CREATE_PUBLIC_NETWORK=true

# Cinder with LVM
enable_service c-vol c-api c-sch
CINDER_VOLUME_BACKEND=lvm

# Development tools
enable_service tempest
enable_plugin heat https://opendev.org/openstack/heat stable/2024.2

# Logging
LOGFILE=/opt/stack/logs/stack.sh.log
VERBOSE=True
LOG_COLOR=True

# Avoid recloning on restart
RECLONE=False
OFFLINE=False
EOF

Step 5: Deploy

./stack.sh

Step 6: Verify

source openrc admin admin
openstack service list
openstack endpoint list
openstack network agent list

Access Horizon at http://10.0.0.10/dashboard.

Development Workflow

Install Development Tools

pip3 install tox git-review python-openstackclient

Clone and Set Up a Project

cd /opt/stack
git clone https://opendev.org/openstack/nova
cd nova
git review -s
git checkout -b fix-scheduler-bug stable/2024.2

Run Unit Tests

tox -e py311
tox -e py311 -- nova.tests.unit.scheduler.test_filter_scheduler
tox -e py311 -- nova.tests.unit.scheduler.test_filter_scheduler.FilterSchedulerTestCase.test_schedule_happy_path
tox -e pep8
tox -e docs

Test Changes Live

vim /opt/stack/nova/nova/scheduler/filter_scheduler.py
sudo systemctl restart devstack@n-sch
journalctl -u devstack@n-sch -f

Submit a Patch to Gerrit

cd /opt/stack/nova
git add .
git commit -m "Fix scheduler weight calculation

The RAM weigher was not accounting for reserved memory
when calculating available resources.

Closes-Bug: #12345"
git review

Review and Test Someone Else's Patch

git review -d 123456
tox -e py311
sudo systemctl restart devstack@n-sch

Running Tempest Integration Tests

source openrc admin admin
tempest run --smoke
tempest run --regex tempest.api.compute.servers.test_create_server
tempest run --regex tempest.api.compute

Debugging Services

sudo systemctl stop devstack@n-api
cd /opt/stack/nova
python3 -m pdb -m nova.cmd.api

Or add breakpoints in code:

import pdb; pdb.set_trace()

Managing the Dev Environment

  • Restart all services: sudo systemctl restart devstack@*
  • View service logs: journalctl -u devstack@n-api -f
  • Rebuild from scratch: ./unstack.sh && ./clean.sh && ./stack.sh
  • Update pip packages: pip install -U <package>
  • List running services: systemctl list-units 'devstack@*'

Troubleshooting

  • stack.sh pip failure: pip3 install -U pip setuptools wheel
  • Service won't restart: Check journalctl -u devstack@<svc> for errors
  • Tox environment errors: Delete .tox/ directory and re-run
  • Git review fails: Run git review -s to set up Gerrit
  • Database migration error: sudo systemctl restart devstack@mysql