#!/usr/bin/env bash
# tenancy-audit.sh -- read-only snapshot of your Omega Cloud tenancy.
#
# Changes NOTHING. Lists every resource class you own plus your quota
# envelope. Run it as your automation credential (export OS_CLOUD=<name>,
# per the CI/Automation Integration Guide) any time you want a picture of
# current state -- and always before making changes. This is also the
# recommended first test of a new tool or AI-assistant setup: it proves
# authentication, the CA bundle, and endpoint discovery in one pass.
#
# Usage: bash tenancy-audit.sh
# Exit: 0 every listing answered | 1 one or more listings failed.
set -uo pipefail
fail=0
list() {
  echo "== openstack $*"
  if ! openstack "$@"; then
    echo "   FAILED -- triage order: token, quota, boundary (see the skill's troubleshooting reference)"
    fail=1
  fi
  echo
}
list network list
list subnet list
list router list
list security group list
list server list
list volume list
list floating ip list
list loadbalancer list
list coe cluster list
echo "== quota envelope and current consumption"
if ! openstack limits show --absolute; then
  echo "   FAILED to read limits"; fail=1
fi
echo
if [ "$fail" -eq 0 ]; then echo "AUDIT: PASS (read-only; nothing was changed)"; else echo "AUDIT: FAIL"; fi
exit "$fail"
