OpenStack:CLI Cheet Sheet
Jump to navigation
Jump to search
CLI Commands
From: https://docs.openstack.org/nova/latest/admin/services.html
# list hypervisor details
openstack hypervisor list --long
# list VMs with availability zone
openstack server list --long -c ID -c Name -c Status -c Networks -c "Image Name" -c "Flavor Name" -c "Availability Zone"
# list VMs on all hypervisor
openstack server list --all --long -c ID -c Name -c Host
# list VMs on specific hypervisor
openstack server list --all-projects --host ${COMPUTE_NODE}
# get VM count by hypervisor
openstack server list --all --long -c Host -f value | sort | uniq -c
# list compute nodes
openstack compute service list --service nova-compute
# list compute service
openstack compute service list --host ${OS_NODE}
# add / enable compute service
openstack compute service set --enable com1-dev nova-compute
# disable compute service
for OS_SERVICE in $(openstack compute service list --host ${OS_NODE} -c Binary -f value); do
openstack compute service set --disable --disable-reason "Maintenance" ${OS_NODE} ${OS_SERVICE}
done
# Search for server witch status error
openstack server list --all --status ERROR
# Search for server with status resizing
openstack server list --all --status=VERIFY_RESIZE
# List instances / VMs
openstack server list
openstack server list -c ID -c Name -c Status -c Networks -c Host --long
# Show VM diagnostics / statistics
nova diagnostics ${SERVER_ID}
openstack server show --diagnostics ${SERVER_ID}
# show hypervisor usage
openstack usage list
Disable Compute Node
openstack compute service set --disable os-com2-dev nova-compute openstack hypervisor list openstack compute service list --service nova-compute openstack aggregate show <NAME>
Debug
Debug
# Search for server processes on wrong compute node
for COMPUTE_NODE in $(openstack compute service list --service nova-compute -c Host -f value); do
for UUID in $(ssh ${COMPUTE_NODE} pgrep qemu -a | grep -o -P '(?<=-uuid ).*(?= -smbios)'); do
VM_HOST=$(openstack server show -c "OS-EXT-SRV-ATTR:host" -f value ${UUID})
if [ -z "${VM_HOST}" ]; then
echo "Server process ${UUID} on ${COMPUTE_NODE} not available in OpenStack"
else
if [ "${VM_HOST}" != "${COMPUTE_NODE}" ]; then
echo "VM ${UUID} on wrong compute node ${COMPUTE_NODE}"
fi
fi
done
done
Remove compute service / server
openstack server list --all-projects --host ${NODE_ID}
openstack compute service list --host ${NODE_ID}
openstack compute service delete ${NODE_ID}