Archive for: ‘May 2017’

Openstack Command CheatSheet

May 18, 2017 Posted by admin

Monitor OpenStack Service Logs Here is a quick and dirty way to watch the necessary logs on the controller or compute nodes.

Ubuntu

Controller logs:

tail -f /var/log/{ceilometer,cinder,glance,keystone,mysql,neutron,nova,openvswitch,rabbitmq}/*.log /var/log/syslog

Compute logs:

tail -f /var/log/{ceilometer,neutron,nova,openvswitch}/*.log /var/log/syslog
CentOS/RHEL

Controller logs:

tail -f /var/log/{ceilometer,cinder,glance,keystone,mysql,neutron,nova,openvswitch,rabbitmq}/*.log /var/log/messages
Compute logs:

tail -f /var/log/{ceilometer,neutron,nova,openvswitch}/*.log /var/log/messages
Keystone See Status of Keystone Services

keystone service-list
List All Keystone Endpoints

keystone endpoint-list
Glance List Current Glance Images

glance image-list
Upload Images to Glance

glance image-create –name –is-public –container-format –disk-format –copy-from
Example 1, upload the cirros-0.3.2-x86_64 cloud image:

glance image-create –name cirros-0.3.2-x86_64 –is-public true –container-format bare –disk-format qcow2 –copy-from http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img
Example 2, upload the ubuntu-server-12.04 cloud image:

glance image-create –name ubuntu-server-12.04 –is-public true –container-format bare –disk-format qcow2 –copy-from http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
Example 3, upload the centos-6.5 cloud image:

glance image-create –name centos-6.5-x86_64 –is-public true –container-format bare –disk-format qcow2 –copy-from http://public.thornelabs.net/centos-6.5-20140117.0.x86_64.qcow2
Nova See Status of Nova Services

nova service-list
List Current Nova Instances

nova list
Boot an Instance

Boot an instance assigned to a particular Neutron Network:

nova boot –image –flavor –security-groups –key-name –nic net-id= –availability-zone
Boot an instance assigned to a particular Neutron Port:

nova boot –image –flavor –security-groups –key-name –nic port-id= –availability-zone
Create a Flavor

nova flavor-create
For example, create a new flavor called m1.custom with an ID of 6, 512 MB of RAM, 5 GB of root disk space, and 1 vCPU:

nova flavor-create m1.custom 6 512 5 1
Create Nova Security Group

This command is only used if you are using nova-network.

nova secgroup-create
Add Rules to Nova Security Group

These command is only used if you are using nova-network.

nova secgroup-add-rule
Example 1, add a rule to the default Nova Security Group to allow SSH access to instances:

nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
Example 2, to add a rule to the default Nova Security Group Rule to allow ICMP communication to instances:

nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
Apply Nova Security Group to Instance

This command is only used if you are using nova-network.

nova add-secgroup
Create Nova Key SSH Pair

nova keypair-add –pub_key
Create Nova Floating IP Pool

nova-manage floating create
Create Host Aggregate With Availability Zone

nova aggregate-create
Add Compute Host to Host Aggregate

nova aggregate-add-host
Live Migrate an Instance

If your compute hosts use shared storage:

nova live-migration
If your compute hosts do not use shared storage:

nova live-migration –block-migrate
Attach Cinder Volume to Instance

Before running this command, you will need to have already created a Cinder Volume.

nova volume-attach
Create and Boot an Instance from a Cinder Volume

Before running this command, you will need to have already created a Cinder Volume from a Glance Image.

nova boot –flavor –block_device_mapping vda=:::0
Create and Boot an Instance from a Cinder Volume Snapshot

Before running this command, you will have to have already created a Cinder Volume Snapshot:

nova boot –flavor –block_device_mapping vda=:snap::0
Reset the State of an Instance

If an instance gets stuck in a delete state, the instance state can be reset then deleted:

nova reset-state

nova delete
You can also use the active command line switch to force an instance back into an active state:

nova reset-state –active
Get Direct URL to Instance Console Using novnc

nova get-vnc-console novnc
Get Direct URL to Instance Console Using xvpvnc

nova get-vnc-console xvpvnc
Cinder See Status of Cinder Services

cinder service-list
List Current Cinder Volumes

cinder list
Create Cinder Volume

cinder create –display-name
Create Cinder Volume from Glance Image

cinder create –image-id –display-name
Create Snapshot of Cinder Volume

cinder snapshot-create –display-name
If the Cinder Volume is not available, i.e. it is currently attached to an instance, you must pass the force flag:

cinder snapshot-create –display-name –force True
Neutron See Status of Neutron Services

neutron agent-list
List Current Neutron Networks

neutron net-list
List Current Neutron Subnets

neutron subnet-list
Rename Neutron Network

neutron net-update –name
Rename Neutron Subnet

neutron subnet-update –name
Create Neutron Security Group

neutron security-group-create
Add Rules to Neutron Security Group

neutron security-group-rule-create –direction –ethertype –protocol –port-range-min –port-range-max
Example 1, add a rule to the default Neutron Security Group to allow SSH access to instances:

neutron security-group-rule-create –direction ingress –ethertype IPv4 –protocol tcp –port-range-min 22 –port-range-max 22 default
Example 2, add a rule to the default Neutron Security Group to allow ICMP communication to instances:

neutron security-group-rule-create –direction ingress –ethertype IPv4 –protocol icmp default
Create a Neutron Tenant Network

neutron net-create

neutron subnet-create –name
Create a Neutron Provider Network

neutron net-create –provider:physical_network=

neutron subnet-create –name –gateway –allocation-pool start=,end= –dns-nameservers list=true
Create a Neutron Router

neutron router-create
Set Default Gateway on a Neutron Router

neutron router-gateway-set
Attach a Tenant Network to a Neutron Router

neutron router-interface-add
Create a Neutron Floating IP Pool

If you need N number of floating IP addresses, run this command N number of times:

neutron floatingip-create
Assign a Neutron Floating IP Address to an Instances

neutron floatingip-associate
Create a Neutron Port with a Fixed IP Address

neutron port-create –fixed-ip ip_address=