Skip to content

Instantly share code, notes, and snippets.

@se7enack
Created June 5, 2025 19:32
Show Gist options
  • Save se7enack/94af433ed565950d2ce884a86f3d1723 to your computer and use it in GitHub Desktop.
Save se7enack/94af433ed565950d2ce884a86f3d1723 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
def domaininput():
try:
subdomain = input("Enter a valid subdomain (Example: sub1.domain.com): ").lower().split(".")
sub = subdomain[0]
domain = f"{subdomain[1]}.{subdomain[2]}"
return sub, domain
except IndexError:
print("A valid subdomain was not entered (Example format: sub1.domain.com)")
return domaininput()
def coloquestion():
try:
colo = input("Which CoLo? (Example: \"bos\"): ").lower()
return colo
except:
return coloquestion()
def lbquestion(domain, colo):
loadbal = input("Type? (\"internal\" or \"prod\" load balancer): ").lower()
if loadbal not in ["internal", "prod"]:
print("Only accepts \"internal\" or \"prod\"")
return lbquestion(domain, colo)
if loadbal == "prod":
path = f"zones/{domain}"
else:
path = f"internal/{colo}/zones/{colo}.domain.com"
return loadbal, path
def main():
sub, domain = domaininput()
colo = coloquestion()
loadbal, path = lbquestion(domain, colo)
print(f"curl -H \"Authorization: bearer $token\" -H \"Content-Type: application/json\" "
f"-d '{{\"record_type\": \"CNAME\", \"record_value\": \"{loadbal}.lb.{colo}.domain.com\"}}' "
f"-X POST https://daas.domain.com/{path}/records/{sub}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment