- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Printer Friendly Page
Single API call to see if server/host/dns name is in use !?
07-29-2021 06:32 AM
Is there a single API call to see if a server/host/dns name is in use?
Essentially, when needing to provision a new server, I want to do a DNS check (of sorts) to see if a host with that name already exists, but I noticed that host-record, host-alias, cname (and possibly others) etc. are all seperate calls and objects.
For instance, I could have a host-alias called "myserver.mydomain.org", but if I were to do a host check against this server, it would return nothing. Similarly I could have a cname called "myserver.mydomain.org" and do a host and/or alias check, and still get nothing back because cnames are yet again different.
I'm hoping there is a single API call I can make that would return a match irregardless of the type, but so far I haven't been able to find it or overlooked it.
Re: Single API call to see if server/host/dns name is in use !?[ Edited ]
07-29-2021 11:37 AM - edited 07-30-2021 07:18 AM
I think you're looking for something similar to a global search. Here's a sample call for the use-case :
# Find matching patterns from the Grid import requests import urllib3 import json from os import system, name def clear(): if name == 'nt': _ = system('cls') else: _ = system('clear') urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) gm_ip = input("\n\nEnter Grid Mater's IP :") type(gm_ip) gm_user = input("\nEnter user name :") type(gm_user) gm_password = input("\nEnter password :") type(gm_password) clear() fqdn_to_be_searched = input("\nEnter the FQDN to be searched :") urL = 'https://' + gm_ip + '/wapi/v2.9/search?search_string=' + fqdn_to_be_searched response = requests.get(urL, auth=(gm_user, gm_password), verify=False) mid_value = response.content response_native = json.loads(mid_value) format_output_data = json.dumps(response_native, indent=1) if format_output_data == "": print("No matching patterns found in search") else: print("Found at least one matching entry..\n\n") print(format_output_data)
Hope this is helpful!
Re: Single API call to see if server/host/dns name is in use !?
07-30-2021 06:27 AM
Thanks Mohammed. I also found the "allrecords" object which I think can help. This is quite a vast API .. it's like a treasure hunt
Anyway, thanks again for all your help. Much appreciated!