fix 'Abstract base class, log property missing'
This commit is contained in:
parent
cab1692ea5
commit
f8251ad8ff
2 changed files with 13 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
|
.env
|
|
@ -48,14 +48,14 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
}
|
}
|
||||||
|
|
||||||
_api: pynetbox.core.api.Api
|
_api: pynetbox.core.api.Api
|
||||||
_log: logging.Logger
|
# log: logging.Logger
|
||||||
_nb_view: pynetbox.core.response.Record | None
|
_nb_view: pynetbox.core.response.Record | None
|
||||||
_ttl: int
|
_ttl: int
|
||||||
|
|
||||||
def __init__(self, id: int, url: str, token: str, view: str | None, ttl=3600):
|
def __init__(self, id: int, url: str, token: str, view: str | None, ttl=3600):
|
||||||
"""Initialize the NetboxDNSSource."""
|
"""Initialize the NetboxDNSSource."""
|
||||||
self._log = logging.getLogger(f"NetboxDNSSource[{id}]")
|
self.log = logging.getLogger(f"NetboxDNSSource[{id}]")
|
||||||
self._log.debug(f"__init__: id={id}, url={url}, view={view}")
|
self.log.debug(f"__init__: id={id}, url={url}, view={view}")
|
||||||
super(NetBoxDNSSource, self).__init__(id)
|
super(NetBoxDNSSource, self).__init__(id)
|
||||||
self._api = pynetbox.core.api.Api(url, token)
|
self._api = pynetbox.core.api.Api(url, token)
|
||||||
self._nb_view = None
|
self._nb_view = None
|
||||||
|
@ -63,7 +63,7 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
self._nb_view = self._api.plugins.netbox_dns.views.get(name=view)
|
self._nb_view = self._api.plugins.netbox_dns.views.get(name=view)
|
||||||
if self._nb_view is None:
|
if self._nb_view is None:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
self._log.debug(f"found {self._nb_view.name} {self._nb_view.id}")
|
self.log.debug(f"found {self._nb_view.name} {self._nb_view.id}")
|
||||||
self._ttl = ttl
|
self._ttl = ttl
|
||||||
|
|
||||||
def _get_nb_zone(self, name: str) -> pynetbox.core.response.Record:
|
def _get_nb_zone(self, name: str) -> pynetbox.core.response.Record:
|
||||||
|
@ -80,7 +80,7 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
view_id=self._nb_view.id, name=name[:-1]
|
view_id=self._nb_view.id, name=name[:-1]
|
||||||
)
|
)
|
||||||
for nb_zone in nb_zones:
|
for nb_zone in nb_zones:
|
||||||
self._log.debug(f"{nb_zone.name} {nb_zone.view.id}")
|
self.log.debug(f"{nb_zone.name} {nb_zone.view.id}")
|
||||||
if nb_zone.name == name[:-1] and nb_zone.view.id == self._nb_view.id:
|
if nb_zone.name == name[:-1] and nb_zone.view.id == self._nb_view.id:
|
||||||
return nb_zone
|
return nb_zone
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
self, zone: octodns.zone.Zone, target: bool = False, lenient: bool = False
|
self, zone: octodns.zone.Zone, target: bool = False, lenient: bool = False
|
||||||
):
|
):
|
||||||
"""Get all of the records of a zone from NetBox and add them to the OctoDNS zone."""
|
"""Get all of the records of a zone from NetBox and add them to the OctoDNS zone."""
|
||||||
self._log.debug(
|
self.log.debug(
|
||||||
f"populate: name={zone.name}, target={target}, lenient={lenient}"
|
f"populate: name={zone.name}, target={target}, lenient={lenient}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
|
|
||||||
nb_records = self._api.plugins.netbox_dns.records.filter(zone_id=nb_zone.id)
|
nb_records = self._api.plugins.netbox_dns.records.filter(zone_id=nb_zone.id)
|
||||||
for nb_record in nb_records:
|
for nb_record in nb_records:
|
||||||
self._log.debug(
|
self.log.debug(
|
||||||
f"{nb_record.name!r} {nb_record.type!r} {nb_record.value!r}"
|
f"{nb_record.name!r} {nb_record.type!r} {nb_record.value!r}"
|
||||||
)
|
)
|
||||||
name = nb_record.name
|
name = nb_record.name
|
||||||
|
@ -167,7 +167,7 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
}
|
}
|
||||||
|
|
||||||
case "SOA":
|
case "SOA":
|
||||||
self._log.debug("SOA")
|
self.log.debug("SOA")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
case "SPF" | "TXT":
|
case "SPF" | "TXT":
|
||||||
|
@ -203,7 +203,7 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
|
|
||||||
def _apply(self, plan: octodns.provider.plan.Plan):
|
def _apply(self, plan: octodns.provider.plan.Plan):
|
||||||
"""Apply the changes to the NetBox DNS zone."""
|
"""Apply the changes to the NetBox DNS zone."""
|
||||||
self._log.debug(
|
self.log.debug(
|
||||||
f"_apply: zone={plan.desired.name}, len(changes)={len(plan.changes)}"
|
f"_apply: zone={plan.desired.name}, len(changes)={len(plan.changes)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
value=value,
|
value=value,
|
||||||
disable_ptr=True,
|
disable_ptr=True,
|
||||||
)
|
)
|
||||||
self._log.debug(f"{nb_record!r}")
|
self.log.debug(f"{nb_record!r}")
|
||||||
|
|
||||||
case octodns.record.Delete():
|
case octodns.record.Delete():
|
||||||
name = change.existing.name
|
name = change.existing.name
|
||||||
|
@ -260,10 +260,10 @@ class NetBoxDNSSource(octodns.provider.base.BaseProvider):
|
||||||
for nb_record in nb_records:
|
for nb_record in nb_records:
|
||||||
for value in existing:
|
for value in existing:
|
||||||
if nb_record.value == value:
|
if nb_record.value == value:
|
||||||
self._log.debug(
|
self.log.debug(
|
||||||
f"{nb_record.id} {nb_record.name} {nb_record.type} {nb_record.value} {value}"
|
f"{nb_record.id} {nb_record.name} {nb_record.type} {nb_record.value} {value}"
|
||||||
)
|
)
|
||||||
self._log.debug(
|
self.log.debug(
|
||||||
f"{nb_record.url} {nb_record.endpoint.url}"
|
f"{nb_record.url} {nb_record.endpoint.url}"
|
||||||
)
|
)
|
||||||
nb_record.delete()
|
nb_record.delete()
|
||||||
|
|
Loading…
Reference in a new issue