Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pkoshtavmware
Copy link
Contributor

AV-174376 Adding support for Infoblox Dns

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):
Copy link

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):
Copy link

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.

Comment on lines +272 to +280
# 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=''))
Copy link

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

Comment on lines +356 to +406
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"]
Copy link

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")
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants