A Beginner’s Guide to OpenStack

Image by Adri V

The Cloud! The Cloud!

Act 1: OpenStack Core Concepts

Act 2: Client Configuration

Pre-requisites

1- Install the OpenStack CLI

pip3 install virtualenv
virtualenv venv
source venv/bin/activate
python -m pip install — upgrade pip
pip install python-openstackclient
openstack --version

2- Connect to OpenStack via openrc.sh

touch .ospwd
printf “export OS_PASSWORD=\”<your_ldap_password>\”” >> .ospwd
openstack user show <your_ldap_username>

3- Rewind. Install the OpenStack SDK and Configure clouds.yaml

pip install openstacksdk
python -m openstack version
mkdir -p ~/.config/openstack
touch ~/.config/openstack/clouds.yaml
export OS_CLOUD=os_tenant1
openstack user show <your_ldap_username>
openstack --os-cloud=os_tenant1 user show <your_ldap_username>

Act 3: Resource Creation

1- Create a security group and rules

export OS_CLOUD=”os_tenant1”openstack security group create “foo”openstack security group rule create --ethertype “IPv4” --ingress --dst-port “22” --protocol “TCP” --remote-ip “<some_value_here>” “foo”
openstack security group show “foo”

2- Create your VM instance

openstack flavor list
openstack image list
openstack --os-cloud=”os_tenant2”
openstack server create --image <image_name_or_id> --flavor <flavor_name_or_id> --security-group <security_group_name> <vm_name>

3- SSH into your machine

VM_IP=$(openstack server show foo1 -f json | jq '.addresses.<project_name>[0]' | tr -d '"')ssh <your_ldap_username>@$VM_IP
brew install jq

Act 4: Misc OpenStack CLI Goodies

1- List all of the servers in your project

openstack server list

2- Delete the specified server from your project

openstack server delete <server_name>

3- List all of the security groups defined in your project

openstack security group list

4- Return the GUID for the image called <image_name>

openstack image list -f json | jq '.[] | select(.Name|test("^<image_name>")) | .ID' | tr -d '"'

Conclusion

Photo by Wolfgang Hasselmann on Unsplash

References

I push the boundaries of software delivery by learning from smart people who challenge the status quo. Former corporate automaton.