OpenStack Dev Server Setup Ubuntu
Ubuntu 22.04 is the most common platform for OpenStack development. This guide sets up a complete development environment using DevStack on Ubuntu, configured for contributing to OpenStack 2024.2 Dalmatian, running tests, and debugging services.
Prerequisites
| Requirement | Minimum |
|---|---|
| OS | Ubuntu 22.04 LTS (fresh install or VM) |
| RAM | 8 GB (16 GB recommended) |
| 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
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
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
Expect 20–45 minutes. All services start as systemd units named devstack@<service>.
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
# Set up Gerrit remote for code review
git review -s
# Create a feature branch
git checkout -b fix-scheduler-bug stable/2024.2
Run Unit Tests
# All tests
tox -e py311
# Specific test module
tox -e py311 -- nova.tests.unit.scheduler.test_filter_scheduler
# Specific test method
tox -e py311 -- nova.tests.unit.scheduler.test_filter_scheduler.FilterSchedulerTestCase.test_schedule_happy_path
# Code style
tox -e pep8
# Generate docs
tox -e docs
Test Changes Live
After modifying code, restart the affected service:
# Edit Nova code
vim /opt/stack/nova/nova/scheduler/filter_scheduler.py
# Restart just the scheduler
sudo systemctl restart devstack@n-sch
# Watch logs
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"
# Submit for review
git review
Review and Test Someone Else's Patch
# Download a patch by Gerrit change number
git review -d 123456
# Run tests on it
tox -e py311
# Test it live
sudo systemctl restart devstack@n-sch
Running Tempest Integration Tests
source openrc admin admin
# Smoke tests (quick)
tempest run --smoke
# Specific API tests
tempest run --regex tempest.api.compute.servers.test_create_server
# Full compute test suite
tempest run --regex tempest.api.compute
IDE Setup
VS Code Remote Development
- Install VS Code with Remote-SSH extension
- Connect to your dev server
- Open
/opt/stack/novaas workspace - Install Python extension for IntelliSense
PyCharm Remote Interpreter
- Configure SSH interpreter pointing to
/opt/stack - Set project root to the OpenStack project directory
- Configure test runner as
pytestorstestr
Debugging Services
# Stop the service
sudo systemctl stop devstack@n-api
# Run manually with debugger
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
| Task | Command |
|---|---|
| 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
| Issue | Fix |
|---|---|
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 |
Summary
Ubuntu 22.04 with DevStack provides the standard OpenStack development environment. The workflow is: edit code, run unit tests with tox, test live by restarting services, and submit patches via git-review to Gerrit.