Cleanup / delete OpenStack objects

PROJECT_ID=f0f745a9c79c47fdbbdd187d728f9e41
 
# Delete VMs
openstack server list --project ${PROJECT_ID}
openstack server delete ${SERVER_ID}
 
openstack volume list --project ${PROJECT_ID}
openstack volume delete ${VOLUME_ID}
 
openstack image list --private --long | grep ${PROJECT_ID}
openstack image delete ${IMAGE_ID}
 
# Delete loadbalancer
openstack loadbalancer list --project ${PROJECT_ID}
openstack loadbalancer delete --cascade ${LOADBALANCER_ID}
 
# Delete secrets
openstack secret list
openstack secret delete ${SECRET_URL}
 
# Delete VPNs
openstack vpn ipsec site connection list --long | grep ${PROJECT_ID}
openstack vpn ipsec site connection delete ${IPSEC_SITE_CONNECTION_ID}
openstack vpn endpoint group list --long | grep ${PROJECT_ID}
openstack vpn endpoint group delete ${VPN_LOCAL_ENDPOINT_GROUP_ID} ${VPN_PEER_ENDPOINT_GROUP_ID}
openstack vpn service list --long | grep ${PROJECT_ID}
openstack vpn service delete ${VPN_SERVICE_ID}
openstack vpn ipsec policy list --long | grep ${PROJECT_ID}
openstack vpn ipsec policy delete ${VPN_IPSEC_POLICY_ID}
openstack vpn ike policy list --long | grep ${PROJECT_ID}
openstack vpn ike policy delete ${VPN_IKE_POLICY_ID}
 
# Delete k8s
openstack coe cluster list 
 
# Delete floating ip
openstack floating ip list --project ${PROJECT_ID}
openstack floating ip delete ${FLOATING_IP}
 
# Delete router
openstack router list --project ${PROJECT_ID}
openstack subnet list --project ${PROJECT_ID}
openstack router remove subnet ${ROUTER_ID} ${SUBNET_ID}
openstack router delete ${ROUTER_ID}
 
# Delete subnet
openstack subnet list --project ${PROJECT_ID}
openstack subnet delete ${SUBNET_ID}
 
# Delete network
openstack network list --project ${PROJECT_ID}
openstack network delete ${NETWORK_ID}
 
# Delete ports
openstack port list --project ${PROJECT_ID}
openstack port list --network ${NETWORK_ID}
openstack port delete ${PORT_ID}
# Disable DHCP ports
# openstack subnet set --no-dhcp ${SUBNET_ID}
 
# Delete security group
openstack security group list --project ${PROJECT_ID}
openstack security group delete ${SECURITY_GROUP_ID}
 
# Delete security group rule
openstack security group rule list ${SECURITY_GROUP_ID}
openstack security group rule delete ${SECURITY_GROUP_RULE_ID}
 
# Delete keypair
openstack keypair list
openstack keypair delete ${KEYPAIR_ID}
 
# Delete user
openstack user list --long --project ${PROJECT_ID}
openstack user delete ${USER_ID}
 
# Delete project
openstack project list --domain foo
openstack project delete ${PROJECT_ID}
 
# Delete Domain
openstack domain list
openstack domain set --disable ${DOMAIN_ID}
openstack project delete ${DOMAIN_ID}

Links
https://docs.openstack.org/python-openstackclient/latest/cli/command-list.html