Created
June 5, 2025 19:32
-
-
Save se7enack/94af433ed565950d2ce884a86f3d1723 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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