I have decided to summarize in one page all useful Openstack commands. This post will be useful to anyone interested in learning Openstack cloud commands or use it as a daily reference.
| Openstack commands: | Old equivalents: | 
|---|---|
| General commands: | |
openstack image list | glance image-list | 
| Server commands: | |
openstack server show [SERVER] | nova show [SERVER]  | 
| Server console commands: | |
openstack console log show | nova console-log | 
| SSH Keypairs*: | |
openstack keypair create [KEYPAIR] > key.pemopenstack keypair show[KEYPAIR] --public-key > key.pubopenstack keypair show --public-key [KEYPAIR] | nova keypair-add [KEYPAIR] > key.pemnova keypair-show [KEYPAIR] | grep Public | awk -F': ' '{print $2}' > ./.ssh/key.pubnova keypair-show [KEYPAIR] | 
| Metadata**: | |
Key-value pairs:openstack server create --property [KEY]=[VALUE] Script (any language): openstack server create --user-data [SCRIPT]Cloud-config file (yaml) openstack server create --user-data [FILE]File injection openstack server create --file [DEST_FILE]=[SRC_FILE] | nova boot --meta [KEY]=[VALUE]nova boot --user-data [SCRIPT]nova boot --user-data [FILE]nova boot --file [DEST_FILE]=[SRC_FILE] | 
** There can only be 1 user-data option, but many property and file options .
Metadata is retrieved by process cloud-int in cloud images .
Server requests with curl http://169.254.169.254 –> Metadata service (nova) which replies with
data in JSON format <– (Restful API).
| Openstack network related commands: | 
|---|
| Security group: | 
openstack security group create [SEC_GROUP] | 
| Network: | 
openstack network list | 
| Subnet: | 
openstack subnet list | 
| Port: | 
openstack port list | 
| Floating IP: | 
openstack floating ip list | 
| Router: | 
openstack router create [ROUTER]set [ROUTER] gateway: neutron router-gateway-set [ROUTER] publicclear [ROUTER] gateway: neutron router-gateway-clear [ROUTER]add private subnet to [ROUTER]: openstack router add subnet [ROUTER] private_subnetremove private subnet to [ROUTER]: openstack router remove subnet [ROUTER] private_subnetlist [ROUTER] interfaces: openstack port list --router [ROUTER] | 
** You can associate floating ip with specific port by adding –port PORT
*** You could also add –fixed-ip [subnet=SUBNET|ip-address=IP_ADDRESS]
| Metadata related commands | 
|---|
| Server*: | 
retrieve metadata info:curl http://169.254.169.254/retrieve latest metadata:curl http://169.254.169/254/latestmeta-data/$:curl http://169.254.169/254/latest/meta-dataretrieve floating ip:curl http://169.254.169/254/latest/meta-data/public-ipv4retrieve openstack metadata:curl http://169.254.169.254/openstackretrieve latest metadata:curl http://169.254.169.254/openstack/metadataretrieve meta_data.json:curl http://169.254.169.254/openstack/meta_data.json | 
| Openstack commands: | Old commands: | 
|---|---|
| Server creation*: | |
openstack server create \ | nova boot --image [IMAGE] \ | 
| Few examples: | 
|---|
| Create cirros-image: | 
openstack image create --public --container-format=bare --disk-format=qcow2 --file cirros-0.3.4-x86_64-disk.img cirros-image | 
| Create network: | 
neutron net-create external_network --provider:network_type flat --provider:physical_network extnet --router:external | 
| Create subnet: | 
neutron subnet-create --name public_subnet --enable_dhcp=False --allocation-pool=start=172.30.152.10,end=172.30.152.40 --gateway=172.30.152.1 external_network 172.30.152.0/24 | 
| Create server: | 
openstack server create --image 9d904b2f-8774-4db8-b195-8aa47e3ebe3c --flavor 1 --nic net-id=4d75d36b-cc99-46b3-83aa-6ae5a96ae38e cirros | 
| Cloud config* examples: | 
|---|
| Configure time zone: | 
#cloud-config | 
| Install packages, specific versions** | 
#cloud-config | 
| Upgrade all packages**: | 
#cloud-config | 
| Install NTP if neccessary and configure NTP server map | 
#cloud-config | 
| Configure CentOS users centos and root with password | 
#cloud-config | 
** Works with all package managers if specific distro-package is not specified f.e. 2.7.3-0ubuntu3.1
