Skip to content

Instantly share code, notes, and snippets.

@tjdett
Last active August 29, 2015 14:16
Show Gist options
  • Save tjdett/0ac871775e042a55001c to your computer and use it in GitHub Desktop.
Save tjdett/0ac871775e042a55001c to your computer and use it in GitHub Desktop.
List records for a Designate domain on NeCTAR
#!/bin/bash
# In addition to `curl`, `jq` is needed for JSON querying
# Change these for your domain
OS_DESIGNATE_DOMAIN=cloud.edu.au.
OS_DESIGNATE_RECORD=resbaz.$OS_DESIGNATE_DOMAIN
OS_TOKEN=$(curl -s \
-H "Content-Type: application/json" \
-d "
{
\"auth\": {
\"tenantName\": \"$OS_TENANT_NAME\",
\"passwordCredentials\": {
\"username\": \"$OS_USERNAME\",
\"password\": \"$OS_PASSWORD\"
}
}
}" \
https://keystone.rc.nectar.org.au:5000/v2.0/tokens | jq -r .access.token.id)
OS_DESIGNATE_DOMAIN_ID=$(curl -s -H "X-Auth-Token: $OS_TOKEN" \
https://designate.rc.nectar.org.au:9001/v1/domains | \
jq -r ".domains | map(select(.name == \"$OS_DESIGNATE_DOMAIN\")) | .[0].id")
curl -s -H "X-Auth-Token: $OS_TOKEN" \
https://designate.rc.nectar.org.au:9001/v1/domains/$OS_DESIGNATE_DOMAIN_ID/records | \
jq -r ".records | map(select(.name == \"$OS_DESIGNATE_RECORD\"))"
#!/bin/bash
# In addition to `curl`, `jq` is needed for JSON querying
# Change these for your domain
OS_DESIGNATE_DOMAIN=cloud.edu.au.
OS_DESIGNATE_RECORD=resbaz.$OS_DESIGNATE_DOMAIN
OS_TOKEN=$(
curl -i -s \
-H "Content-Type: application/json" \
-d "
{
\"auth\": {
\"identity\": {
\"methods\": [
\"password\"
],
\"password\": {
\"user\": {
\"domain\": {
\"name\": \"default\"
},
\"name\": \"$OS_USERNAME\",
\"password\": \"$OS_PASSWORD\"
}
}
},
\"scope\": {
\"project\": {
\"domain\": {
\"name\": \"default\"
},
\"name\": \"$OS_TENANT_NAME\"
}
}
}
}" \
https://keystone.rc.nectar.org.au:5000/v3/auth/tokens?nocatalog | grep -Po '^X-Subject-Token: .*$' | cut -d " " -f2
)
OS_DESIGNATE_DOMAIN_ID=$(curl -s -H "X-Auth-Token: $OS_TOKEN" \
https://designate.rc.nectar.org.au:9001/v1/domains | \
jq -r ".domains | map(select(.name == \"$OS_DESIGNATE_DOMAIN\")) | .[0].id")
curl -s -H "X-Auth-Token: $OS_TOKEN" \
https://designate.rc.nectar.org.au:9001/v1/domains/$OS_DESIGNATE_DOMAIN_ID/records | \
jq -r ".records | map(select(.name == \"$OS_DESIGNATE_RECORD\"))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment