Compare commits
5 commits
9f6dcbe8a7
...
adeca856be
Author | SHA1 | Date | |
---|---|---|---|
adeca856be | |||
c1b21bf093 | |||
ba2a3f6edf | |||
60b3226361 | |||
|
0051c30b8d |
7 changed files with 89 additions and 43 deletions
|
@ -1,2 +1 @@
|
||||||
just 1.25.2
|
just 1.25.2
|
||||||
lefthook 1.4.6
|
|
||||||
|
|
|
@ -3,4 +3,4 @@ FROM lscr.io/linuxserver/netbox:3.7.6
|
||||||
RUN pip install -U \
|
RUN pip install -U \
|
||||||
wheel \
|
wheel \
|
||||||
setuptools \
|
setuptools \
|
||||||
netbox-plugin-dns
|
netbox-plugin-dns==0.22.8
|
||||||
|
|
43
dev/sync2.yml
Normal file
43
dev/sync2.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
manager:
|
||||||
|
max_workers: 1
|
||||||
|
plan_outputs:
|
||||||
|
html:
|
||||||
|
class: octodns.provider.plan.PlanMarkdown
|
||||||
|
processors:
|
||||||
|
spf:
|
||||||
|
class: octodns_spf.SpfDnsLookupProcessor
|
||||||
|
no-root-ns:
|
||||||
|
class: octodns.processor.filter.IgnoreRootNsFilter
|
||||||
|
min-max-ttl:
|
||||||
|
class: octodns.processor.restrict.TtlRestrictionFilter
|
||||||
|
allowed_ttls:
|
||||||
|
- 60
|
||||||
|
- 300
|
||||||
|
- 600
|
||||||
|
- 900
|
||||||
|
- 1800
|
||||||
|
- 3600
|
||||||
|
- 7200
|
||||||
|
- 10800
|
||||||
|
providers:
|
||||||
|
config:
|
||||||
|
class: octodns.provider.yaml.YamlProvider
|
||||||
|
directory: ./zones
|
||||||
|
default_ttl: 3600
|
||||||
|
enforce_order: true
|
||||||
|
populate_should_replace: false
|
||||||
|
netbox:
|
||||||
|
class: octodns_netbox_dns.NetBoxDNSProvider
|
||||||
|
url: http://localhost:8000
|
||||||
|
token: 1ca8f8de1d651b0859052dc5e6a0858fd1e43e3d # change token for netbox
|
||||||
|
view: false
|
||||||
|
replace_duplicates: false
|
||||||
|
make_absolute: true
|
||||||
|
zones:
|
||||||
|
"*":
|
||||||
|
sources:
|
||||||
|
- config
|
||||||
|
processors:
|
||||||
|
- spf
|
||||||
|
targets:
|
||||||
|
- netbox
|
3
justfile
3
justfile
|
@ -77,5 +77,8 @@ sync *args:
|
||||||
dump *args:
|
dump *args:
|
||||||
hatch -v run default:dump {{ args }}
|
hatch -v run default:dump {{ args }}
|
||||||
|
|
||||||
|
dump2 *args:
|
||||||
|
hatch -v run default:dump2 {{ args }}
|
||||||
|
|
||||||
validate *args:
|
validate *args:
|
||||||
hatch -v run default:validate {{ args }}
|
hatch -v run default:validate {{ args }}
|
||||||
|
|
14
lefthook.yml
14
lefthook.yml
|
@ -1,14 +0,0 @@
|
||||||
colors: true
|
|
||||||
no_tty: false
|
|
||||||
|
|
||||||
pre-commit:
|
|
||||||
commands:
|
|
||||||
01_ruff_check:
|
|
||||||
stage_fixed: true
|
|
||||||
glob: "*.py"
|
|
||||||
run: ruff check --fix-only --exit-zero --silent {all_files}
|
|
||||||
|
|
||||||
02_ruff_format:
|
|
||||||
stage_fixed: true
|
|
||||||
glob: "*.py"
|
|
||||||
run: ruff format {all_files}
|
|
|
@ -1,5 +1,5 @@
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling>=1.18", "hatch-regex-commit>=0.0.3"]
|
requires = ["hatchling>=1.24", "hatch-regex-commit>=0.0.3"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
|
@ -11,7 +11,7 @@ requires-python = ">=3.11"
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Jeffrey C. Ollie", email = "" },
|
{ name = "Jeffrey C. Ollie", email = "" },
|
||||||
{ name = "Ivan Schaller", email = "ivan@schaller.sh" }
|
{ name = "Ivan Schaller", email = "ivan@schaller.sh" },
|
||||||
]
|
]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: MIT License",
|
||||||
|
@ -19,10 +19,7 @@ classifiers = [
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = ["pynetbox>=7.2.0", "dnspython>=2.4.2"]
|
||||||
"pynetbox>=7.2.0",
|
|
||||||
"dnspython>=2.4.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = "https://github.com/olofvndrhr/octodns-netbox-dns"
|
Homepage = "https://github.com/olofvndrhr/octodns-netbox-dns"
|
||||||
|
@ -48,9 +45,9 @@ packages = ["src/octodns_netbox_dns"]
|
||||||
[tool.hatch.envs.default]
|
[tool.hatch.envs.default]
|
||||||
python = "3.11"
|
python = "3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pytest==7.4.4",
|
"pytest==8.2.2",
|
||||||
"coverage==7.4.2",
|
"coverage==7.5.3",
|
||||||
"octodns==1.7.0",
|
"octodns==1.9.1",
|
||||||
"octodns-spf==0.0.2",
|
"octodns-spf==0.0.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -61,28 +58,23 @@ cov-report = ["- coverage combine", "coverage report", "coverage xml"]
|
||||||
cov = ["test-cov", "cov-report"]
|
cov = ["test-cov", "cov-report"]
|
||||||
|
|
||||||
sync = ["cd dev && octodns-sync --debug --config-file sync.yml --force {args}"]
|
sync = ["cd dev && octodns-sync --debug --config-file sync.yml --force {args}"]
|
||||||
dump = ["cd dev && octodns-dump --debug --config-file sync.yml --output-dir output {args} '*' netbox"]
|
dump = [
|
||||||
|
"cd dev && octodns-dump --debug --config-file sync.yml --output-dir output {args} '*' netbox",
|
||||||
|
]
|
||||||
|
dump2 = [
|
||||||
|
"cd dev && octodns-dump --debug --config-file sync2.yml --output-dir output {args} '*' netbox",
|
||||||
|
]
|
||||||
validate = ["cd dev && octodns-validate --debug --config-file sync.yml {args}"]
|
validate = ["cd dev && octodns-validate --debug --config-file sync.yml {args}"]
|
||||||
|
|
||||||
[tool.hatch.envs.lint]
|
[tool.hatch.envs.lint]
|
||||||
python = "3.11"
|
python = "3.11"
|
||||||
detached = true
|
detached = true
|
||||||
dependencies = [
|
dependencies = ["mypy==1.10.0", "ruff==0.4.8"]
|
||||||
"mypy==1.8.0",
|
|
||||||
"ruff==0.2.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.hatch.envs.lint.scripts]
|
[tool.hatch.envs.lint.scripts]
|
||||||
typing = "mypy --non-interactive --install-types {args:src/octodns_netbox_dns}"
|
typing = "mypy --non-interactive --install-types {args:src/octodns_netbox_dns}"
|
||||||
style = [
|
style = ["ruff check --diff {args:.}", "ruff format --check --diff {args:.}"]
|
||||||
"ruff check --diff {args:.}",
|
fmt = ["ruff check --fix {args:.}", "ruff format {args:.}", "style"]
|
||||||
"ruff format --check --diff {args:.}"
|
|
||||||
]
|
|
||||||
fmt = [
|
|
||||||
"ruff check --fix {args:.}",
|
|
||||||
"ruff format {args:.}",
|
|
||||||
"style"
|
|
||||||
]
|
|
||||||
all = ["style", "typing"]
|
all = ["style", "typing"]
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -112,7 +104,7 @@ exclude = [
|
||||||
"dist",
|
"dist",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"venv",
|
"venv",
|
||||||
"dev"
|
"dev",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
|
@ -143,8 +135,18 @@ select = [
|
||||||
"W",
|
"W",
|
||||||
"YTT",
|
"YTT",
|
||||||
]
|
]
|
||||||
ignore-init-module-imports = true
|
ignore = [
|
||||||
ignore = ["E501", "D103", "D100", "D102", "PLR2004", "D403", "ISC001", "FBT001", "FBT002", "FBT003"]
|
"E501",
|
||||||
|
"D103",
|
||||||
|
"D100",
|
||||||
|
"D102",
|
||||||
|
"PLR2004",
|
||||||
|
"D403",
|
||||||
|
"ISC001",
|
||||||
|
"FBT001",
|
||||||
|
"FBT002",
|
||||||
|
"FBT003",
|
||||||
|
]
|
||||||
unfixable = ["F401"]
|
unfixable = ["F401"]
|
||||||
|
|
||||||
[tool.ruff.format]
|
[tool.ruff.format]
|
||||||
|
@ -231,7 +233,10 @@ parallel = true
|
||||||
omit = ["src/octodns_netbox_dns/__about__.py"]
|
omit = ["src/octodns_netbox_dns/__about__.py"]
|
||||||
|
|
||||||
[tool.coverage.paths]
|
[tool.coverage.paths]
|
||||||
octodns_netbox_dns = ["src/octodns_netbox_dns", "*/octodns-netbox-dns/src/octodns_netbox_dns"]
|
octodns_netbox_dns = [
|
||||||
|
"src/octodns_netbox_dns",
|
||||||
|
"*/octodns-netbox-dns/src/octodns_netbox_dns",
|
||||||
|
]
|
||||||
tests = ["tests", "*/octodns-netbox-dns/tests"]
|
tests = ["tests", "*/octodns-netbox-dns/tests"]
|
||||||
|
|
||||||
[tool.coverage.report]
|
[tool.coverage.report]
|
||||||
|
|
|
@ -430,3 +430,13 @@ class NetBoxDNSProvider(octodns.provider.base.BaseProvider):
|
||||||
value=record,
|
value=record,
|
||||||
disable_ptr=self.disable_ptr,
|
disable_ptr=self.disable_ptr,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def list_zones(self) -> list[str]:
|
||||||
|
"""get all zones from netbox
|
||||||
|
|
||||||
|
@return: a list with all active zones
|
||||||
|
"""
|
||||||
|
query_params = {"status": "active", **self.nb_view}
|
||||||
|
zones = self.api.plugins.netbox_dns.zones.filter(**query_params)
|
||||||
|
|
||||||
|
return sorted([self._make_absolute(z.name) for z in zones])
|
||||||
|
|
Loading…
Reference in a new issue