#!/usr/bin/env bash
# fake openstack: emulates 'network show <name> -f json' and 'subnet show <name> -f json'.
# Emits the env-pointed fixture (exit 0) when set+present, else a not-found error (exit 1),
# so the verify's "network not created yet" branch can be exercised.
cmd="${1:-}"; sub="${2:-}"; name="${3:-}"
if [ "$cmd" = "network" ] && [ "$sub" = "show" ]; then
  if [ -n "${FIX_NET:-}" ] && [ -f "${FIX_NET}" ]; then cat "$FIX_NET"; exit 0; fi
  echo "No Network found for $name" >&2; exit 1
elif [ "$cmd" = "subnet" ] && [ "$sub" = "show" ]; then
  if [ -n "${FIX_SUBNET:-}" ] && [ -f "${FIX_SUBNET}" ]; then cat "$FIX_SUBNET"; exit 0; fi
  echo "No Subnet found for $name" >&2; exit 1
fi
exit 0
