-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AV-174376 Adding support for Infoblox Dns #279
base: master
Are you sure you want to change the base?
Conversation
except Exception as e: | ||
raise Exception("exception req[%s] rsp[%s]", logout_url, str(e)) | ||
|
||
def add_dns_text_record(key_digest_64, txt_record_name, kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
txt_record_name contains a trailing .
which is not supported by infoblox.
except Exception as e: | ||
raise Exception("Error adding dns txt record to vs {}", e) | ||
|
||
def remove_dns_text_record(key_digest_64, txt_record_name, kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
txt_record_name contains a trailing .
which is not supported by infoblox.
# Check if we need to overwrite the VS UUID if it was specified | ||
# We request the info here once, instead in the loop for each SAN entry below. | ||
if overwrite_vs != None: | ||
if debug: | ||
print ("DEBUG: overwrite_vs is set to '{}'".format(overwrite_vs)) | ||
if overwrite_vs.lower().startswith('virtualservice-'): | ||
search_term = "uuid={}".format(overwrite_vs.lower()) | ||
else: | ||
search_term = "name={}".format(urllib.parse.quote(overwrite_vs, safe='')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS is not needed for DNS validation
vhMode = False | ||
|
||
# Check if we need to overwrite VirtualService UUID to something specific | ||
if overwrite_vs == None: | ||
|
||
# Get VSVIPs/VSs, based on FQDN | ||
rsp = _do_request_avi("vsvip/?search=(fqdn,{})".format(domain), "GET").json() | ||
if debug: | ||
print ("DEBUG: Found {} matching VSVIP FQDNs".format(rsp["count"])) | ||
if rsp["count"] == 0: | ||
print ("Warning: Could not find a VSVIP with fqdn = {}".format(domain)) | ||
# As a fallback we search for VirtualHosting entries with that domain | ||
vhMode = True | ||
search_term = "vh_domain_name.contains={}".format(domain) | ||
else: | ||
vsvip_uuid = rsp["results"][0]["uuid"] | ||
search_term = "vsvip_ref={}".format(vsvip_uuid) | ||
|
||
rsp = _do_request_avi("virtualservice/?{}".format(search_term), "GET").json() | ||
if debug: | ||
print ("DEBUG: Found {} matching VSs".format(rsp["count"])) | ||
if rsp['count'] == 0: | ||
raise Exception("Could not find a VS with fqdn = {}".format(domain)) | ||
|
||
vs_uuid = rsp["results"][0]["uuid"] | ||
|
||
else: | ||
# Overwriting VS UUID to what user specified. | ||
# ALL SANs of the CSR must be reachable on the specified VS to succeed. | ||
rsp = overwrite_vs | ||
vs_uuid = rsp["results"][0]["uuid"] | ||
print ("Note: Overwriting VS UUID to {}".format(vs_uuid)) | ||
|
||
print ("Found VS {} with fqdn {}".format(vs_uuid, domain)) | ||
|
||
# Let's check if VS is enabled, otherwise challenge can never successfully complete. | ||
if not rsp["results"][0]["enabled"]: | ||
raise Exception("VS with fqdn {} is not enabled.".format(domain)) | ||
|
||
# Special handling for virtualHosting: if child, get services from parent. | ||
if vhMode and rsp["results"][0]["type"] == "VS_TYPE_VH_CHILD": | ||
# vh_parent_vs_ref is schema of https://avi.domain.tld/api/virtualservice/virtualservice-UUID, hence picking the last part | ||
vs_uuid_parent = rsp["results"][0]["vh_parent_vs_ref"].split("/")[-1] | ||
vhRsp = _do_request_avi("virtualservice/?uuid={}".format(vs_uuid_parent), "GET").json() | ||
if debug: | ||
print ("DEBUG: Parent VS of Child-VS is {} and found {} matches".format(vs_uuid_parent, vhRsp['count'])) | ||
if vhRsp['count'] == 0: | ||
raise Exception("Could not find parent VS {} of child VS UUID = {}".format(vs_uuid_parent, vs_uuid)) | ||
|
||
# we just copy it over. more transparent for further logic. | ||
rsp["results"][0]["services"] = vhRsp["results"][0]["services"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS is not needed for DNS validation
print("Install DNS TXT resource for domain: %s", domain) | ||
add_dns_text_record(keydigest64, txt_record_name, kwargs) | ||
|
||
print ("Challenge completed, notifying LetsEncrypt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a delay from creating the record and it being publicly accessible. Need at test or sleep before continuing.
AV-174376 Adding support for Infoblox Dns