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

Support azure-mgmt-dns 8.0.0 #5

Merged
merged 2 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions certbot_dns_azure/_internal/dns_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import zope.interface
from azure.mgmt.dns import DnsManagementClient
from azure.mgmt.dns.models import RecordSet, TxtRecord
from azure.common.exceptions import CloudError
from azure.common.credentials import ServicePrincipalCredentials
from azure.core.exceptions import HttpResponseError
from azure.identity import ClientSecretCredential
from msrestazure.azure_active_directory import MSIAuthentication

from certbot import errors
Expand Down Expand Up @@ -97,13 +97,13 @@ def _setup_credentials(self):
)

@staticmethod
def _get_azure_credentials(client_id=None, client_secret=None, tenant=None, msi_client_id=None):
has_sp = all((client_id, client_secret, tenant))
def _get_azure_credentials(client_id=None, client_secret=None, tenant_id=None, msi_client_id=None):
has_sp = all((client_id, client_secret, tenant_id))
if has_sp:
return ServicePrincipalCredentials(
return ClientSecretCredential(
client_id=client_id,
secret=client_secret,
tenant=tenant
client_secret=client_secret,
tenant_id=tenant_id
)
elif msi_client_id:
return MSIAuthentication(client_id=msi_client_id)
Expand Down Expand Up @@ -146,7 +146,7 @@ def _perform(self, domain, validation_name, validation):
for record in existing_rr.txt_records:
for value in record.value:
txt_value.add(value)
except CloudError as err:
except HttpResponseError as err:
if err.status_code != 404: # Ignore RR not found
raise errors.PluginError('Failed to check TXT record for domain '
'{}, error: {}'.format(domain, err))
Expand All @@ -159,7 +159,7 @@ def _perform(self, domain, validation_name, validation):
record_type='TXT',
parameters=RecordSet(ttl=self.ttl, txt_records=[TxtRecord(value=list(txt_value))])
)
except CloudError as err:
except HttpResponseError as err:
raise errors.PluginError('Failed to add TXT record to domain '
'{}, error: {}'.format(domain, err))

Expand All @@ -180,7 +180,7 @@ def _cleanup(self, domain, validation_name, validation):
for record in existing_rr.txt_records:
for value in record.value:
txt_value.add(value)
except CloudError as err:
except HttpResponseError as err:
if err.status_code != 404: # Ignore RR not found
raise errors.PluginError('Failed to check TXT record for domain '
'{}, error: {}'.format(domain, err))
Expand All @@ -204,7 +204,7 @@ def _cleanup(self, domain, validation_name, validation):
relative_record_set_name=relative_validation_name,
record_type='TXT'
)
except CloudError as err:
except HttpResponseError as err:
if err.status_code != 404: # Ignore RR not found
raise errors.PluginError('Failed to remove TXT record for domain '
'{}, error: {}'.format(domain, err))
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# azure-mgmt-dns is still the old style SDK, so will change dramatically
# when they refactor, most notably the credential parts
install_requires = [
'azure-mgmt-dns>=3.0.0',
'azure-identity>=1.5.0',
'azure-mgmt-dns>=8.0.0',
'msrestazure>=0.6.4',
'setuptools>=39.0.1',
'zope.interface',
]
Expand Down