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

Raise exception if pdns_server and/or auth_token are not provided #755

Merged
merged 2 commits into from
Mar 17, 2021
Merged
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
11 changes: 10 additions & 1 deletion lexicon/providers/powerdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,20 @@ def provider_parser(subparser):
)


class PowerDNSProviderError(Exception):
"""Generic PowerDNS exception"""


class Provider(BaseProvider):
"""Provider class for PowerDNS"""

def __init__(self, config):
super(Provider, self).__init__(config)

self.api_endpoint = self._get_provider_option("pdns_server")
if not self.api_endpoint:
raise PowerDNSProviderError('PowerDNS API endpoint not defined (pdns_server)')

self.disable_slave_notify = self._get_provider_option("pdns-disable-notify")

if self.api_endpoint.endswith("/"):
Expand All @@ -66,7 +73,9 @@ def __init__(self, config):
self.api_endpoint += "/servers/" + self.server_id

self.api_key = self._get_provider_option("auth_token")
assert self.api_key is not None
if not self.api_key:
raise PowerDNSProviderError('PowerDNS API key not defined (auth_token)')

self._zone_data = None

def notify_slaves(self):
Expand Down