If you’re a beginning OpenStack developer, contributor Nisha Yadav helps you get set up.

image

Although there are developer and wiki guides on how to get started with OpenStack, I have found them bit overwhelming as a beginner. After reading various docs and asking for help from my mentor, who is a core contributor in OpenStack, I came up with the following easy-to-follow guide.  If you still face any problems while setting up your environment, feel free to reach out by commenting below.

1. Install Ubuntu in an Oracle Virtual Box

A virtual machine (VM) is recommended because usually we don’t want a ton of dependencies installed on our everyday environment. Also, if at any point we mess up things, it’s easier to start over from scratch using a VM.

  1. Download a suitable Oracle Virtual Box for your operating system.
  2. Download the desired Ubuntu iso file.
  3. Install and start Oracle Virtual Box.
  4. Click on the “New” button in the wizard, give the new virtual machine a name, check “Linux” in the “Type” area and check “Ubuntu” in the “Version” area (32 or 64-bit, depending on downloaded iso file).
  5. Set the amount of RAM (ideally not more than 50% of your total RAM). Something to keep in mind: DevStack will perform best with 4GB or more of RAM.
  6. Select “Create a Virtual Hard Disk Now,” check “VDI (VirtualBox Disk Image),” then select “Dynamically Allocated” and finally set the hard disk size (60- 100 GB ideally)
  7. Double-click your new machine in the left menu and select the downloaded iso file.
  8. Next, click “Install Ubuntu”. Click “Continue” and then select “Erase Disk and Install Ubuntu”. (Note: this will not erase files on your local machine). Complete the rest of the wizard and, finally, you’ll have Ubuntu installed inside your VM.
  9. Before restarting the VM:
    • Select your machine and click on “Settings”.
    • Under the “Storage” tab, check if the installation iso file is still present; if it is, select and remove it.
  10. To work in full screen, install guest additions. To do so, restart your VM, click on “Devices” from menu, select “Insert Guest Additions CD image” and press “Run”. After completion, press “Enter” and restart your VM.

NOTE: Press Ctrl+Alt+t to open the Terminal application. To distinguish commands from normal sentences, $ sign has been added at their beginning.  So, you have to write the words after ‘$’ on the terminal and then press “enter” to run the command. To use copy/paste option for commands, you should open this web page inside any web browser of your created VM. After selecting the command text press Ctrl+C to copy and then inside the terminal press Ctrl+Shft+V to paste. Also, the words which have to be replaced by specific information pertaining to you have been indicated by capitals words, like YOUR_FIRST_NAME.

2. Set up a Stack user with superuser permissions

Devstack should be run as a non-root user with sudo enabled (standard logins to cloud images such as “ubuntu” or “cloud-user” are usually fine). Since this user will be making many changes to your system, it will need to have sudo privileges.

a) Create the group stack and add the user stack in it:

$sudo groupadd stack

$sudo useradd -g stack -s /bin/bash -d /opt/stack -m stack

b) Grant superuser permissions to the stack user:

$sudo su

$echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

c) Logout as your default user:
Ctrl+d

d) Create a password for the stack user:

$sudo passwd stack

e) Now to login as the stack user:

$su stack

f) Go to the home directory of the stack user:

$cd ~

3. Set up SSH Keys : Source

a) Check the present working directory; it should output “/opt/stack”:

$pwd

If it doesn’t output that, redo steps 2.e) and 2.f) before moving on.

b) Create a new SSH key, using your provided email as a label:
$ssh-keygen -t rsa -C "YOUR_EMAIL@EMAIL_ADDRESS.com"

c) Press the “Enter” key to accept the default file location in which to save the key.

d) At the prompt, type a secure passphrase. You may keep it empty by directly pressing the “Enter” key for no passphrase.

e) Start the ssh-agent in the background
$eval "$(ssh-agent -s)"

f) Add your SSH key to ssh-agent.
$ssh-add ~/.ssh/id_rsa

g) Download and install xclip.
$sudo apt-get install xclip

h) Copy the SSH key (i.e. contents of the id_rsa.pub file) to your clipboard.

$sudo xclip -sel clip < ~/.ssh/id_rsa.pub

i) If you don’t have a github account, first create one. Then, login into your github account, go to “Settings”, click “SSH and GPG keys” then select “new SSH key”. Write a description in “Title” and paste your key into the “Key” field (for pasting, press Ctrl+V). Finally press “Add SSH Key”.

j) Test your connection using ssh:

$ssh -T [email protected]

Now if the fingerprint matches, type “yes.” If you now see you username in the message, you have successfully set up your SSH key!

4. Set up Git : Source

a) Check the present working directory, it should output “/opt/stack”:

$pwd

If it doesn’t output that, redo steps 2.e) and 2.f) before moving on.

b) Install git from terminal:

$sudo apt-get install git

c) Use config and write in your full name:

$git config --global user.name "YOUR_FIRSTNAME YOUR_LASTNAME"

d) Use config and write in your email address:

$git config --global user.email YOUR_EMAIL@EMAIL_ADDRESS.com

e) Check your git configuration

$git config --list   

5. Set up DevStack

a) Check the present working directory, it should output “/opt/stack”:

$pwd

If it doesn’t output that, redo steps 2.e) and 2.f) before moving on.

b) Download DevStack

$git clone https://git.openstack.org/openstack-dev/devstack

c) Go to the devstack directory

$cd devstack

d) Copy the sample configurations into this current directory

$cp samples/local.conf .

e) Notice that the main projects (Keystone, Nova, etc.) are already downloaded, but the clients (like python-keystoneclient or python-novaclient) services are not.

The following commands will download the source code from python-keystoneclient and will let you modify it for your development. Then, you can test it against the DevStack’s OpenStack cloud:

$sudo apt-get install vim
$vim local.conf
To get into INSERT MODE Press i
At the bottom, add LIBS_FROM_GIT=python-keystoneclient
To get back into COMMAND MODE Press Esc
To save and quit, write:wq

f) Run the stack script:

$./stack.sh

You will get the following output after successful completion of the command.

The default users are: admin and demo
The password: nomoresecret

g) In any web browser open:

http://localhost:5000/

If you are able to establish a connection, then you have successfully setup your DevStack!

6. Set up Gerrit : Source

Gerrit is the code review system used in OpenStack development. Git-review tool is a git subcommand that handles all the details of working with Gerrit.

a) Join the OpenStack Foundation

b) Create a LaunchPad account

c) Open a terminal window and check the present working directory, it should output “/opt/stack”.

$pwd

If it doesn’t output that, redo steps 2.e) and 2.f) before moving on.

d) Copy your SSH key:

$ sudo xclip -sel clip < ~/.ssh/id_rsa.pub

e) Open https://review.openstack.org/, click “Sign In” (top-right corner) and log in with your Launchpad ID.

f) Now click on “Settings,” then select “SSH Public Keys” and press “Add Key”. Press Ctrl+V to paste the key and then click “Add.”

g) Install git review

$sudo apt-get install git-review

h) Check if git review works inside the Keystone (or any other project for that matter) directory of OpenStack:

$cd keystone

$git review -s

7. Install dependencies : Source

a) Check the present working directory, it should output “/opt/stack”:

$pwd

If it doesn’t output that, redo steps 2.e) and 2.f) before moving on.

b) Install the dependencies:

$sudo apt-get install python-dev python3-dev libxml2-dev libsqlite3-dev libssl-dev libldap2-dev libffi-dev

8. Run the tox command

Each project like Keystone, Nova, Cinder etc. has a tox.ini file defined in it. It defines the tox environment and the commands to run for each environment. Please note that the  subsequent runs of tox will be faster because everything fetched will be in .tox already.

a) Check the present working directory, it should output “/opt/stack”:

$pwd

If it doesn’t output that, redo steps 2.e) and 2.f) before moving on.

b) Install tox and pbr:

$sudo apt-get install python-tox

$sudo pip install pbr

c) Update and upgrade:

$sudo apt-get update

$sudo apt-get upgrade

d) Go inside any project directory like Keystone, Cinder or Nova:

$cd keystone

e) Run tox

$tox

f) If you get the following output on the terminal after entering the command, the tox has installed successfully.

____________________________summary ______________________________
py27: commands succeeded
pep8: commands succeeded
api-ref: commands succeeded
docs: commands succeeded
genconfig: commands succeeded
releasenotes: commands succeeded

Now that you have set up your work environment, you can start contributing as a developer. For more tips on that, stay tuned! smiley 2

Nisha Yadav is a former OpenStack Outreachy intern and current OpenStack contributor. This post first appeared on her blog. Superuser is always interested in community content, email: [email protected].