Nova - Compute Service
List compute service on a cluster
nova service-list --binary nova-compute
How to suspend all VM on a host
nova list --all-tenants --host <host_name> \
--fields name,status,task_state | \
awk '{ if(NR>3&&$2!=""&&$6=="ACTIVE") print $2; }' | \
xargs -I {} echo nova suspend {}
List VM of all tenants and export to CSV
nova list --all-tenants --fields name,status,tenant_id \
| cut -d "|" -f 2,3,4,5 -s \
| tr "|" ";" \
| sed 's/\s//g' > out.csv
Do a bulk command on a list of vms stored in a file.
If you have a file "list.txt" with a list of vmid you can
do:
for vmid in `cat list.txt`; do nova command $vmid; done
Check console.log file size
find . -name console.log -printf "%k KB\t%p\n" | sort -h
Neutron - Networking Service
If you want to list ext-net (ie. 10.0.0.0/24) IP allocation you can use
neutron port-list | grep -o -e "10.0.0.[0-9]\{1,3\}" | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n
How to dump netns configuration?
On network node you can dump all tenants network configuration simply with
command:
ip netns | xargs -I {} bash -c 'echo ==== {} ====; ip netns exec {} ifconfig'
How to get qrouter IPs ?
ip netns | grep "qrouter" | xargs -I {} ip netns exec {} ip a | grep "inet\s"
Howto attach nic to VM
nova interface-attach [--port-id <port_id>] [--net-id <net_id>]
[--fixed-ip <fixed_ip>]
<server>
Attach a network interface to an instance.
Delete unallocated floating IP
neutron floatingip-list -c "id" -c "port_id" -f csv \
| grep "\"\"" \
| cut -d, -f 1 \
| xargs -I {} neutron floatingip-delete {}
Glance - Image Service
How to load a VHD image ?
glance image-create \
--name "VHD Image" \
--container-format bare \
--disk-format vhd \
--property hypervisor_type=hyperv \
< file.vhd
How to load a vmware VMDK image ?
glance image-create \
--name "VMDK Image" \
--container-format ovf \
--disk-format vmdk \
--property hypervisor_type=vmware \
--property vmware_adaptertype=ide \
--property vmware_disktype=sparse \
< file.vmdk
QEMU
How to extract a VM disk from Ceph?
qemu-img convert -O qcow2 rbd:compute/{image_id}_disk {image_id}.qcow2
Libvirt
How to list all virtual interfaces on a compute node?
for vm in $(virsh list|grep esecuzione|awk '{print $2}'); do virsh domiflist $vm; done
Disable apparmor on Ubuntu
sudo service apparmor stop
sudo service apparmor teardown
sudo update-rc.d -f apparmor remove
General troubleshooting
Filter error and trace messages with openstack services log files
grep -e 'ERROR\|TRACE' file.log | less -S