Though, there are developer and wiki guides on how to get started, I found them bit overwhelming as a beginner. After reading various docs and taking 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 lots of dependencies installed in our everyday environment. Also, if at any point, we mess up things, it’s easier to start over from scratch.

  1. Download suitable oracle virtual box version for your current Operating System.
  2. Download the desired Ubuntu iso file.
  3. Install and start the oracle virtual box program.
  4. Click on “New” button in the wizard. Then, give the new virtual machine a name and choose Type: “Linux” and Version: “Ubuntu” (32 or 64-bit, depending on downloaded iso file).
  5. Next set the amount of RAM, ideally not more than 50% of your total RAM. Note: DevStack will perform best with 4GB or more of RAM.
  6. Then select, “Create a Virtual hard disk now”, next select “VDI(VirtualBox Disk Image)”, then “Dynamically Allocated” and finally set the hard disk size (60- 100 GB ideally)
  7. Double-click your new machine in the left menu and then, select the downloaded iso file.
  8. Next, select “Install Ubuntu”. Click “continue” and then, select “Erase disk and Install Ubuntu”. (Note: this will not erase files on your original host OS). Complete the rest of the wizard and then, you’ll have Ubuntu installed inside your VM.
  9. Before restarting the VM: – Select your machine, then click on “settings”. Under “storage” tab, if the installation iso file is still present then, select and remove it.
  10. To work on full screen, install guest additions. To do so, after restarting your VM click on “Devices” from menu and then 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 webpage 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 a group stack and add 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) Now logout as your default user
Ctrl+d

d) Create a password for the stack user

$sudo passwd stack

e) Now to login as stack user

$su stack

f) Go to the home directory of stack user

$cd ~

3. Set up SSH Keys : Source

a) Check the present working directory, it should output /opt/stack.

$pwd

If not, do steps 2.e) and 2.f) before going to next step.

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

c) Now press enter 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 enter key for no passphrase.

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

f) Add your SSH key to the 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, then create one.Then, login into your github account, go to “Settings”, then click “SSH and GPG keys” and and 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 git@github.com

Now if the fingerprint matches type yes, if you now see you username in the message then, 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 not, do steps 2.e) and 2.f) before going to next step.

b) Install git from terminal

$sudo apt-get install git

c) Configure by writing your full name

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

d) Configure by writing 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 not, do steps 2.e) and 2.f) before going to next step.

b) Download devstack

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

c) Enter devstack directory

$cd devstack

d) Copy sample config into current directory

$cp samples/local.conf .

e) Note generally the main projects (keystone, nova, …) are already downloaded but the clients aren’t- like python-keystoneclient or python-novaclient etc.

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 not, do steps 2.e) and 2.f) before going to next step.

d) Now copy your SSH key

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

e) Open https://review.openstack.org/ and click the Sign In (top-right corner). Now, 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 keystone, nova, cinder or any other project directory of openstack

$cd keystone

$git review -s

 NOTE: Gerrit has SSH running on the non-standard port 29418. So, if you get an error connecting to gerrit, then make sure the port is not being blocked by a firewall or proxy or something else. If the problem persists, considering switching to your personal internet connection instead of your company's/university's LAN or WiFi.

7. Install dependencies : Source

a) Check the present working directory, it should output /opt/stack.

$pwd

If not, do steps 2.e) and 2.f) before going to next step.

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 not, do steps 2.e) and 2.f) before going to next step.

b) Install tox, pip and pbr

$sudo apt-get install python-tox

$sudo apt-get install python-pip

$sudo pip install pbr

c) Update and Upgrade

$sudo apt-get update

$sudo apt-get upgrade

d) Go inside any project directory like keystone, nova, cinder etc.

$cd keystone

e) Run tox

$tox

f) If you get the following output on the terminal after the completion of the command, then the tox command ran 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 tips on that, stay tuned! smiley 2

Advertisements