Compare commits
14 commits
73e36d49db
...
0d79d882e2
Author | SHA1 | Date | |
---|---|---|---|
0d79d882e2 | |||
09898b7a22 | |||
ba9d301dac | |||
c5f3fa9e00 | |||
3728594b4e | |||
880a210b9b | |||
c81f3241d9 | |||
daef5bf30a | |||
a97428e81c | |||
e0e769409d | |||
e047aa3d30 | |||
74c447b282 | |||
86789a1c4b | |||
6aeda2c48b |
24 changed files with 855 additions and 73 deletions
|
@ -1,16 +0,0 @@
|
|||
name: build and publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
|
||||
jobs:
|
||||
build-pypackage:
|
||||
uses: actions/workflows/.gitea/workflows/build_pypackage.yml@master
|
||||
secrets:
|
||||
username: __token__
|
||||
token: ${{ secrets.PACKAGE_TOKEN }}
|
26
.gitea/workflows/build_release.yml
Normal file
26
.gitea/workflows/build_release.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
name: build and publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
|
||||
jobs:
|
||||
build-pypackage:
|
||||
uses: actions/workflows/.gitea/workflows/release_pypackage_github.yml@master
|
||||
with:
|
||||
repository: main
|
||||
gh-owner: olofvndrhr
|
||||
gh-repo: octodns-netbox-dns
|
||||
secrets:
|
||||
username: __token__
|
||||
token: ${{ secrets.PACKAGE_TOKEN }}
|
||||
gh-token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
update-changelog:
|
||||
uses: actions/workflows/.gitea/workflows/update_changelog.yml@master
|
||||
with:
|
||||
branch: main
|
|
@ -1,10 +0,0 @@
|
|||
name: update changelog
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
update-changelog:
|
||||
uses: actions/workflows/.gitea/workflows/update_changelog.yml@master
|
|
@ -11,4 +11,4 @@ jobs:
|
|||
check-code:
|
||||
uses: actions/workflows/.gitea/workflows/check_python_hatch.yml@master
|
||||
with:
|
||||
run-tests: false
|
||||
run-tests: true
|
||||
|
|
35
.github/issue_template/bug_report.md
vendored
Normal file
35
.github/issue_template/bug_report.md
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help improve the tool
|
||||
title: "[BUG] <short summary>"
|
||||
labels: bug
|
||||
assignees: olofvndrhr
|
||||
|
||||
---
|
||||
|
||||
**System info (please complete the following information):**
|
||||
|
||||
- Host: [e.g. Linux/Debian or Docker]
|
||||
- `octodns-netbox-dns` version [e.g. v2.1.5]
|
||||
- `netbox-dns` version [e.g. v2.1.5]
|
||||
- Netbox version [e.g. v2.1.5]
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
20
.github/issue_template/feature_request.md
vendored
Normal file
20
.github/issue_template/feature_request.md
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[FEATURE] <short summary>"
|
||||
labels: feature-request
|
||||
assignees: olofvndrhr
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
31
.github/workflows/check_code.yml
vendored
Normal file
31
.github/workflows/check_code.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
name: check code
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
|
||||
jobs:
|
||||
check-code:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- name: install hatch
|
||||
run: pip install -U hatch
|
||||
|
||||
- name: test codestyle
|
||||
run: hatch run lint:style
|
||||
|
||||
- name: test typing
|
||||
run: hatch run lint:typing
|
||||
|
||||
- name: run tests
|
||||
run: hatch run default:test
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -9,7 +9,12 @@ venv
|
|||
.ruff_cache/
|
||||
__pycache__/
|
||||
.pytest_cache/
|
||||
.pytest_cache&
|
||||
|
||||
# dev
|
||||
dev/db-data
|
||||
dev/redis-data
|
||||
dev/netbox-data
|
||||
dev/output
|
||||
|
||||
### Python template
|
||||
# Byte-compiled / optimized / DLL files
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
just format
|
79
CHANGELOG.md
79
CHANGELOG.md
|
@ -0,0 +1,79 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
## [v0.3.3](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/compare/v0.3.2...v0.3.3) - 2024-02-20
|
||||
|
||||
### Commits
|
||||
|
||||
- fix changelog generation [`e0e7694`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/e0e769409d7c5c369e7f0c0c1cbd74da1f2ddcde)
|
||||
|
||||
## [v0.3.2](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/compare/v0.3.1...v0.3.2) - 2024-02-20
|
||||
|
||||
### Commits
|
||||
|
||||
- add issue templates, ci linting and update pre-commit [`6aeda2c`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/6aeda2c48bf50c5081a2f5cf8dfed096440a6e5f)
|
||||
- update ci files for future releases [`86789a1`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/86789a1c4bc3ab45d34e1dfcdcc765d7890138d5)
|
||||
- add CONTRIBUTING.md [`74c447b`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/74c447b282949184be41f05bd975f442ac6f7b92)
|
||||
- add changelog [`35c069e`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/35c069efe94442c6307e3ac87185a84ad49a1282)
|
||||
|
||||
## [v0.3.1](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/compare/v0.3.0...v0.3.1) - 2024-01-25
|
||||
|
||||
### Commits
|
||||
|
||||
- fix for single value rcd [`256d1a8`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/256d1a8f0ecc5de6a8d8d3e3ff10752785b3d2d2)
|
||||
- fix type errors [`f20e190`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/f20e190ef6d4bf130550616fac7d83af721b4ff2)
|
||||
- fix type hint for rdata [`95c6815`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/95c6815dad6ea0b2c2eca42e83f79da08487e409)
|
||||
|
||||
## [v0.3.0](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/compare/v0.2.1...v0.3.0) - 2024-01-25
|
||||
|
||||
### Commits
|
||||
|
||||
- make populate function smaller [`c95f95f`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/c95f95fb8b8a2ae79b8f4db05675e98386a723b6)
|
||||
- add docstrings and refactor make absolute function [`f7f54f8`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/f7f54f8eb71fef26c6759509a589d9afc7a91bdc)
|
||||
- add new workflows [`ff3dd03`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/ff3dd03ce53002e457e172b8718af1e65ac7f78d)
|
||||
- fix mypy issues [`988502a`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/988502a499d86339fc7f2f4c623c442590b1f59d)
|
||||
- fix deps [`de1e67c`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/de1e67c6be5063c6dbed6483f232baf9420dcfa7)
|
||||
|
||||
## v0.2.1 - 2024-01-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- remove wayward debug pprint [`#10`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/issues/10)
|
||||
- Record type as parameter value passed to get_nb_zone [`#7`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/issues/7)
|
||||
|
||||
### Commits
|
||||
|
||||
- first commit [`cab1692`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/cab1692ea57fedc54a2633330c442d2acebba1e8)
|
||||
- update query for views and use hatch as a build tool [`cdd0b00`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/cdd0b00cd155ac5af9d6a457fa1ecfb71081b3a9)
|
||||
- update to python template for future pypi releases [`4a2ba28`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/4a2ba28aaa3c05fdc163a3b703c7226a74e349e6)
|
||||
- use fork of pynetbox until pkg_resources runtime dependency is removed [`daa03aa`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/daa03aae2df979c2469696011ce42c694192a02c)
|
||||
- move from provider base class to source [`5714ce5`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/5714ce5af9d738999ddb68e7b92eb60c5776cd02)
|
||||
- update readme and make absolute optional [`61b1b47`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/61b1b47a96bb81ab6eb216a4a0988f7682a7fa9f)
|
||||
- update dependencies [`4cf1c62`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/4cf1c627742593a8590f26d49bd375e3b51b31bc)
|
||||
- _get_nb_zone() is now aware of same zones declared under different view [`c2f27f7`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/c2f27f7c43f78040d79d6fdc2c84d250f6f64403)
|
||||
- add @ support and make cname records absolute [`9d79906`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/9d79906f960bb61aacfb464979899805bce34dbf)
|
||||
- implement replace duplicate option [`790a2de`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/790a2de3458e3fd9cefd0fdf35b82dfa156820bf)
|
||||
- fix 'Abstract base class, log property missing' [`f8251ad`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/f8251ad8ffcf6f92dfcf1dfdcffe954ac55eee4c)
|
||||
- update view query [`3cb883a`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/3cb883abd67a275e4e64a79c6a28f46d706b9679)
|
||||
- zone can also be configured without assigned view [`4828bbf`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/4828bbf00bb8f4946f07134a39cddc04a2ed306b)
|
||||
- make some records absolute [`c77cef6`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/c77cef64ee5d0470ab8fa1f5fc2781e1f24a75a2)
|
||||
- update requirements [`66d9551`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/66d95519b1070489859d665671d50e50f94f5a8e)
|
||||
- Fix issue where octodns was failing on missing TTL value for NS records in PTR zones [`d3c1d0f`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/d3c1d0f65390dd595441ac3dca1cf52db790ddad)
|
||||
- fix parameter call to better reflect function type hint. [`e4db78a`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/e4db78a281a27765271f1afda07dee08602ed2d0)
|
||||
- Use upstream pynetbox library as their pull req #426 is merged. [`423207e`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/423207e5dd1673f306fb392cc5d37f63a4545fe5)
|
||||
- fix attribute error in case view is null [`693ea86`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/693ea866296132b1cd94e2dda61ae94e94a77557)
|
||||
- fix log merge [`f0b502a`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/f0b502a74f3ea72cfd78d9837bbbcc0934e0b826)
|
||||
- fix literal type [`bec8384`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/bec83845577417d0ede5bd57a7772946bd997142)
|
||||
- update debug log [`3537917`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/353791797ded363c9610b5f40e4bd857b93fd328)
|
||||
- escape ; character in txt records [`ac395e8`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/ac395e84e24b1b271ff76721137e2d82f548553c)
|
||||
- fix request parameter [`d4c0955`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/d4c095540f0b925dcca249d2896ca890731af256)
|
||||
- add log message for total records found [`14a98fe`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/14a98fe132b3e6789ca3ad410bc101bac00b4f78)
|
||||
- view argument type hints must also accept None value [`c5ae5bf`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/c5ae5bf4057756030f0447681e9e6c2dccb59ec1)
|
||||
- update lock [`d4a4032`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/d4a403261fb2e80a4335071cc17dbff00fa9366c)
|
||||
- Fix invalid query to Netbox, search only with zone ID. [`e752d3d`](https://git.44net.ch/olofvndrhr/octodns-netbox-dns/commit/e752d3db221f9b79e3df5dc30ca40f597a655873)
|
42
CONTRIBUTING.md
Normal file
42
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
# getting started
|
||||
|
||||
## with asdf
|
||||
|
||||
### tools needed
|
||||
|
||||
- python 3.11
|
||||
- [hatch](https://hatch.pypa.io/)
|
||||
- [asdf](https://asdf-vm.com/guide/getting-started.html)
|
||||
|
||||
### setup
|
||||
|
||||
1. install [asdf](https://asdf-vm.com/guide/getting-started.html)
|
||||
2. run `asdf install` in this directory to install all needed tools
|
||||
3. run `just setup` to install the pre-commit hooks etc.
|
||||
|
||||
### pre-commit
|
||||
|
||||
1. run `just check` to lint the files and auto-format them.
|
||||
you can optionally run `just format` and `just lint` as a single action.
|
||||
2. fix the issues which ruff reports
|
||||
3. run `just build` to check if it builds correctly
|
||||
4. commit changes
|
||||
|
||||
## manual
|
||||
|
||||
### tools needed
|
||||
|
||||
- python 3.11
|
||||
- [hatch](https://hatch.pypa.io/)
|
||||
|
||||
### setup
|
||||
|
||||
1. install [just](https://github.com/casey/just)
|
||||
2. run `just setup` to install the pre-commit hooks etc.
|
||||
|
||||
### pre-commit
|
||||
|
||||
1. run `hatch run lint:fmt` to lint the files and auto-format them.
|
||||
2. fix the issues which ruff reports
|
||||
3. run `hatch build --clean` to check if it builds correctly
|
||||
4. commit changes
|
6
dev/Dockerfile
Normal file
6
dev/Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
|||
FROM lscr.io/linuxserver/netbox:3.7.2
|
||||
|
||||
RUN pip install -U \
|
||||
wheel \
|
||||
setuptools \
|
||||
netbox-plugin-dns
|
66
dev/compose.yml
Normal file
66
dev/compose.yml
Normal file
|
@ -0,0 +1,66 @@
|
|||
services:
|
||||
app:
|
||||
image: netbox-dev:build
|
||||
container_name: netbox-dev-app
|
||||
restart: unless-stopped
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
networks:
|
||||
- appnet
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./netbox-data/:/config/:rw
|
||||
- ./configuration.py:/config/configuration.py:ro
|
||||
environment:
|
||||
- TZ=Europe/Zurich
|
||||
- PUID=${UID}
|
||||
- PGID=${GID}
|
||||
- DB_HOST=netbox-dev-db
|
||||
- DB_NAME=netbox
|
||||
- DB_USER=netbox
|
||||
- DB_PASSWORD=netbox-dev
|
||||
- REDIS_HOST=netbox-dev-redis
|
||||
- SUPERUSER_EMAIL=admin@example.com
|
||||
- SUPERUSER_PASSWORD=netbox-dev
|
||||
|
||||
db:
|
||||
image: bitnami/postgresql:14.9.0
|
||||
container_name: netbox-dev-db
|
||||
restart: unless-stopped
|
||||
user: ${UID}
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks:
|
||||
- appnet
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ./db-data/:/bitnami/postgresql/:rw
|
||||
environment:
|
||||
- TZ=Europe/Zurich
|
||||
- POSTGRESQL_POSTGRES_PASSWORD=netbox-dev
|
||||
- POSTGRES_DB=netbox
|
||||
- POSTGRES_USER=netbox
|
||||
- POSTGRES_PASSWORD=netbox-dev
|
||||
|
||||
redis:
|
||||
image: bitnami/redis:7.2
|
||||
container_name: netbox-dev-redis
|
||||
restart: unless-stopped
|
||||
user: ${UID}
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
networks:
|
||||
- appnet
|
||||
volumes:
|
||||
- ./redis-data/:/bitnami/redis/data/:rw
|
||||
environment:
|
||||
- TZ=Europe/Zurich
|
||||
- ALLOW_EMPTY_PASSWORD=yes
|
||||
|
||||
networks:
|
||||
appnet:
|
||||
name: netbox-dev
|
||||
driver: bridge
|
304
dev/configuration.py
Normal file
304
dev/configuration.py
Normal file
|
@ -0,0 +1,304 @@
|
|||
#########################
|
||||
# #
|
||||
# Required settings #
|
||||
# #
|
||||
#########################
|
||||
|
||||
PLUGINS = ["netbox_dns"]
|
||||
|
||||
PLUGINS_CONFIG = {
|
||||
"netbox_dns": {
|
||||
"zone_default_ttl": 3600,
|
||||
"zone_soa_serial_auto": True,
|
||||
"zone_soa_minimum": 3600,
|
||||
"zone_nameservers": ["ns1.example.com", "ns2.example.com"],
|
||||
"zone_soa_mname": "ns1.example.com",
|
||||
"zone_soa_rname": "admin.example.com",
|
||||
"tolerate_underscores_in_hostnames": False,
|
||||
"tolerate_leading_underscore_types": [
|
||||
"TXT",
|
||||
"SRV",
|
||||
],
|
||||
"enable_root_zones": False,
|
||||
"enforce_unique_records": False,
|
||||
"feature_ipam_coupling": False,
|
||||
"feature_ipam_dns_info": True,
|
||||
},
|
||||
}
|
||||
|
||||
# This is a list of valid fully-qualified domain names (FQDNs) for the NetBox server. NetBox will not permit write
|
||||
# access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name.
|
||||
#
|
||||
# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
|
||||
ALLOWED_HOSTS = ["localhost"]
|
||||
|
||||
# PostgreSQL database configuration. See the Django documentation for a complete list of available parameters:
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#databases
|
||||
DATABASE = {
|
||||
"NAME": "netbox", # Database name
|
||||
"USER": "netbox", # PostgreSQL username
|
||||
"PASSWORD": "netbox-dev", # PostgreSQL password
|
||||
"HOST": "netbox-dev-db", # Database server
|
||||
"PORT": "", # Database port (leave blank for default)
|
||||
"CONN_MAX_AGE": 300, # Max database connection age
|
||||
}
|
||||
|
||||
# Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate
|
||||
# configuration exists for each. Full connection details are required in both sections, and it is strongly recommended
|
||||
# to use two separate database IDs.
|
||||
REDIS = {
|
||||
"tasks": {
|
||||
"HOST": "netbox-dev-redis",
|
||||
"PORT": 6379,
|
||||
# Comment out `HOST` and `PORT` lines and uncomment the following if using Redis Sentinel
|
||||
# 'SENTINELS': [('mysentinel.redis.example.com', 6379)],
|
||||
# 'SENTINEL_SERVICE': 'netbox',
|
||||
"PASSWORD": "",
|
||||
"DATABASE": 0,
|
||||
"SSL": False,
|
||||
# Set this to True to skip TLS certificate verification
|
||||
# This can expose the connection to attacks, be careful
|
||||
# 'INSECURE_SKIP_TLS_VERIFY': False,
|
||||
},
|
||||
"caching": {
|
||||
"HOST": "netbox-dev-redis",
|
||||
"PORT": 6379,
|
||||
# Comment out `HOST` and `PORT` lines and uncomment the following if using Redis Sentinel
|
||||
# 'SENTINELS': [('mysentinel.redis.example.com', 6379)],
|
||||
# 'SENTINEL_SERVICE': 'netbox',
|
||||
"PASSWORD": "",
|
||||
"DATABASE": 1,
|
||||
"SSL": False,
|
||||
# Set this to True to skip TLS certificate verification
|
||||
# This can expose the connection to attacks, be careful
|
||||
# 'INSECURE_SKIP_TLS_VERIFY': False,
|
||||
},
|
||||
}
|
||||
|
||||
# This key is used for secure generation of random numbers and strings. It must never be exposed outside of this file.
|
||||
# For optimal security, SECRET_KEY should be at least 50 characters in length and contain a mix of letters, numbers, and
|
||||
# symbols. NetBox will not run without this defined. For more information, see
|
||||
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-SECRET_KEY
|
||||
SECRET_KEY = "ZFK2dO-pD@Vnjxf7gM@gh#jHwXm_wih%V6v@Byld7yX6c^Vsb!"
|
||||
|
||||
#########################
|
||||
# #
|
||||
# Optional settings #
|
||||
# #
|
||||
#########################
|
||||
|
||||
# Specify one or more name and email address tuples representing NetBox administrators. These people will be notified of
|
||||
# application errors (assuming correct email settings are provided).
|
||||
ADMINS = [
|
||||
# ('John Doe', 'jdoe@example.com'),
|
||||
]
|
||||
|
||||
# URL schemes that are allowed within links in NetBox
|
||||
ALLOWED_URL_SCHEMES = (
|
||||
"file",
|
||||
"ftp",
|
||||
"ftps",
|
||||
"http",
|
||||
"https",
|
||||
"irc",
|
||||
"mailto",
|
||||
"sftp",
|
||||
"ssh",
|
||||
"tel",
|
||||
"telnet",
|
||||
"tftp",
|
||||
"vnc",
|
||||
"xmpp",
|
||||
)
|
||||
|
||||
# Optionally display a persistent banner at the top and/or bottom of every page. HTML is allowed. To display the same
|
||||
# content in both banners, define BANNER_TOP and set BANNER_BOTTOM = BANNER_TOP.
|
||||
BANNER_TOP = ""
|
||||
BANNER_BOTTOM = ""
|
||||
|
||||
# Text to include on the login page above the login form. HTML is allowed.
|
||||
BANNER_LOGIN = ""
|
||||
|
||||
# Base URL path if accessing NetBox within a directory. For example, if installed at https://example.com/netbox/, set:
|
||||
# BASE_PATH = 'netbox/'
|
||||
BASE_PATH = ""
|
||||
|
||||
# Maximum number of days to retain logged changes. Set to 0 to retain changes indefinitely. (Default: 90)
|
||||
CHANGELOG_RETENTION = 90
|
||||
|
||||
# API Cross-Origin Resource Sharing (CORS) settings. If CORS_ORIGIN_ALLOW_ALL is set to True, all origins will be
|
||||
# allowed. Otherwise, define a list of allowed origins using either CORS_ORIGIN_WHITELIST or
|
||||
# CORS_ORIGIN_REGEX_WHITELIST. For more information, see https://github.com/ottoyiu/django-cors-headers
|
||||
CORS_ORIGIN_ALLOW_ALL = False
|
||||
CORS_ORIGIN_WHITELIST = [
|
||||
# 'https://hostname.example.com',
|
||||
]
|
||||
CORS_ORIGIN_REGEX_WHITELIST = [
|
||||
# r'^(https?://)?(\w+\.)?example\.com$',
|
||||
]
|
||||
|
||||
# Specify any custom validators here, as a mapping of model to a list of validators classes. Validators should be
|
||||
# instances of or inherit from CustomValidator.
|
||||
# from extras.validators import CustomValidator
|
||||
CUSTOM_VALIDATORS = {
|
||||
# 'dcim.site': [
|
||||
# CustomValidator({
|
||||
# 'name': {
|
||||
# 'min_length': 10,
|
||||
# 'regex': r'\d{3}$',
|
||||
# }
|
||||
# })
|
||||
# ],
|
||||
}
|
||||
|
||||
# Set to True to enable server debugging. WARNING: Debugging introduces a substantial performance penalty and may reveal
|
||||
# sensitive information about your installation. Only enable debugging while performing testing. Never enable debugging
|
||||
# on a production system.
|
||||
DEBUG = False
|
||||
|
||||
# Email settings
|
||||
EMAIL = {
|
||||
"SERVER": "localhost",
|
||||
"PORT": 25,
|
||||
"USERNAME": "",
|
||||
"PASSWORD": "",
|
||||
"USE_SSL": False,
|
||||
"USE_TLS": False,
|
||||
"TIMEOUT": 10, # seconds
|
||||
"FROM_EMAIL": "",
|
||||
}
|
||||
|
||||
# Enforcement of unique IP space can be toggled on a per-VRF basis. To enforce unique IP space within the global table
|
||||
# (all prefixes and IP addresses not assigned to a VRF), set ENFORCE_GLOBAL_UNIQUE to True.
|
||||
ENFORCE_GLOBAL_UNIQUE = False
|
||||
|
||||
# Exempt certain models from the enforcement of view permissions. Models listed here will be viewable by all users and
|
||||
# by anonymous users. List models in the form `<app>.<model>`. Add '*' to this list to exempt all models.
|
||||
EXEMPT_VIEW_PERMISSIONS = [
|
||||
# 'dcim.site',
|
||||
# 'dcim.region',
|
||||
# 'ipam.prefix',
|
||||
]
|
||||
|
||||
# Enable the GraphQL API
|
||||
GRAPHQL_ENABLED = True
|
||||
|
||||
# HTTP proxies NetBox should use when sending outbound HTTP requests (e.g. for webhooks).
|
||||
# HTTP_PROXIES = {
|
||||
# 'http': 'http://10.10.1.10:3128',
|
||||
# 'https': 'http://10.10.1.10:1080',
|
||||
# }
|
||||
|
||||
# IP addresses recognized as internal to the system. The debugging toolbar will be available only to clients accessing
|
||||
# NetBox from an internal IP.
|
||||
INTERNAL_IPS = ("127.0.0.1", "::1")
|
||||
|
||||
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
|
||||
# https://docs.djangoproject.com/en/stable/topics/logging/
|
||||
LOGGING = {}
|
||||
|
||||
# Automatically reset the lifetime of a valid session upon each authenticated request. Enables users to remain
|
||||
# authenticated to NetBox indefinitely.
|
||||
LOGIN_PERSISTENCE = False
|
||||
|
||||
# Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
|
||||
# are permitted to access most data in NetBox but not make any changes.
|
||||
LOGIN_REQUIRED = False
|
||||
|
||||
# The length of time (in seconds) for which a user will remain logged into the web UI before being prompted to
|
||||
# re-authenticate. (Default: 1209600 [14 days])
|
||||
LOGIN_TIMEOUT = None
|
||||
|
||||
# Setting this to True will display a "maintenance mode" banner at the top of every page.
|
||||
MAINTENANCE_MODE = False
|
||||
|
||||
# The URL to use when mapping physical addresses or GPS coordinates
|
||||
MAPS_URL = "https://maps.google.com/?q="
|
||||
|
||||
# An API consumer can request an arbitrary number of objects =by appending the "limit" parameter to the URL (e.g.
|
||||
# "?limit=1000"). This setting defines the maximum limit. Setting it to 0 or None will allow an API consumer to request
|
||||
# all objects by specifying "?limit=0".
|
||||
MAX_PAGE_SIZE = 1000
|
||||
|
||||
# The file path where uploaded media such as image attachments are stored. A trailing slash is not needed. Note that
|
||||
# the default value of this setting is derived from the installed location.
|
||||
# MEDIA_ROOT = '/opt/netbox/netbox/media'
|
||||
|
||||
# By default uploaded media is stored on the local filesystem. Using Django-storages is also supported. Provide the
|
||||
# class path of the storage driver in STORAGE_BACKEND and any configuration options in STORAGE_CONFIG. For example:
|
||||
# STORAGE_BACKEND = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||
# STORAGE_CONFIG = {
|
||||
# 'AWS_ACCESS_KEY_ID': 'Key ID',
|
||||
# 'AWS_SECRET_ACCESS_KEY': 'Secret',
|
||||
# 'AWS_STORAGE_BUCKET_NAME': 'netbox',
|
||||
# 'AWS_S3_REGION_NAME': 'eu-west-1',
|
||||
# }
|
||||
|
||||
# Expose Prometheus monitoring metrics at the HTTP endpoint '/metrics'
|
||||
METRICS_ENABLED = False
|
||||
|
||||
# Credentials that NetBox will uses to authenticate to devices when connecting via NAPALM.
|
||||
NAPALM_USERNAME = ""
|
||||
NAPALM_PASSWORD = ""
|
||||
|
||||
# NAPALM timeout (in seconds). (Default: 30)
|
||||
NAPALM_TIMEOUT = 30
|
||||
|
||||
# NAPALM optional arguments (see https://napalm.readthedocs.io/en/latest/support/#optional-arguments). Arguments must
|
||||
# be provided as a dictionary.
|
||||
NAPALM_ARGS = {}
|
||||
|
||||
# Determine how many objects to display per page within a list. (Default: 50)
|
||||
PAGINATE_COUNT = 50
|
||||
|
||||
# When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to
|
||||
# prefer IPv4 instead.
|
||||
PREFER_IPV4 = False
|
||||
|
||||
# Rack elevation size defaults, in pixels. For best results, the ratio of width to height should be roughly 10:1.
|
||||
RACK_ELEVATION_DEFAULT_UNIT_HEIGHT = 22
|
||||
RACK_ELEVATION_DEFAULT_UNIT_WIDTH = 220
|
||||
|
||||
# Remote authentication support
|
||||
REMOTE_AUTH_ENABLED = False
|
||||
REMOTE_AUTH_BACKEND = "netbox.authentication.RemoteUserBackend"
|
||||
REMOTE_AUTH_HEADER = "HTTP_REMOTE_USER"
|
||||
REMOTE_AUTH_AUTO_CREATE_USER = False
|
||||
REMOTE_AUTH_DEFAULT_GROUPS = []
|
||||
REMOTE_AUTH_DEFAULT_PERMISSIONS = {}
|
||||
|
||||
# This repository is used to check whether there is a new release of NetBox available. Set to None to disable the
|
||||
# version check or use the URL below to check for release in the official NetBox repository.
|
||||
RELEASE_CHECK_URL = None
|
||||
# RELEASE_CHECK_URL = 'https://api.github.com/repos/netbox-community/netbox/releases'
|
||||
|
||||
# The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of
|
||||
# this setting is derived from the installed location.
|
||||
# REPORTS_ROOT = '/opt/netbox/netbox/reports'
|
||||
|
||||
# Maximum execution time for background tasks, in seconds.
|
||||
RQ_DEFAULT_TIMEOUT = 300
|
||||
|
||||
# The file path where custom scripts will be stored. A trailing slash is not needed. Note that the default value of
|
||||
# this setting is derived from the installed location.
|
||||
SCRIPTS_ROOT = "/config/scripts"
|
||||
|
||||
# The name to use for the session cookie.
|
||||
SESSION_COOKIE_NAME = "sessionid"
|
||||
|
||||
# By default, NetBox will store session data in the database. Alternatively, a file path can be specified here to use
|
||||
# local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only
|
||||
# database access.) Note that the user as which NetBox runs must have read and write permissions to this path.
|
||||
SESSION_FILE_PATH = None
|
||||
|
||||
# Time zone (default: UTC)
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
# Date/time formatting. See the following link for supported formats:
|
||||
# https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
|
||||
DATE_FORMAT = "N j, Y"
|
||||
SHORT_DATE_FORMAT = "Y-m-d"
|
||||
TIME_FORMAT = "g:i a"
|
||||
SHORT_TIME_FORMAT = "H:i:s"
|
||||
DATETIME_FORMAT = "N j, Y g:i a"
|
||||
SHORT_DATETIME_FORMAT = "Y-m-d H:i"
|
57
dev/sync.yml
Normal file
57
dev/sync.yml
Normal file
|
@ -0,0 +1,57 @@
|
|||
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.NetBoxDNSSource
|
||||
url: http://localhost:8000
|
||||
token: 1ca8f8de1d651b0859052dc5e6a0858fd1e43e3d # change token for netbox
|
||||
view: false
|
||||
replace_duplicates: false
|
||||
make_absolute: true
|
||||
zones:
|
||||
example.com.:
|
||||
sources:
|
||||
- config
|
||||
processors:
|
||||
- spf
|
||||
targets:
|
||||
- netbox
|
||||
test.example.com.:
|
||||
sources:
|
||||
- config
|
||||
processors:
|
||||
- spf
|
||||
targets:
|
||||
- netbox
|
||||
view.example.com.:
|
||||
sources:
|
||||
- config
|
||||
processors:
|
||||
- spf
|
||||
targets:
|
||||
- netbox
|
23
dev/zones/example.com.yaml
Normal file
23
dev/zones/example.com.yaml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
? ''
|
||||
:
|
||||
ttl: 172800
|
||||
type: NS
|
||||
values:
|
||||
- ns1.example.com.
|
||||
- ns2.example.com.
|
||||
ns1:
|
||||
type: A
|
||||
value: 192.168.1.1
|
||||
ns2:
|
||||
type: A
|
||||
value: 192.168.1.2
|
||||
record1:
|
||||
type: CNAME
|
||||
value: record11.example.com.
|
||||
record11:
|
||||
type: A
|
||||
value: 192.168.1.11
|
||||
record12:
|
||||
type: A
|
||||
value: 192.168.1.12
|
17
dev/zones/test.example.com.yaml
Normal file
17
dev/zones/test.example.com.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
? ''
|
||||
:
|
||||
ttl: 172800
|
||||
type: NS
|
||||
values:
|
||||
- ns1.example.com.
|
||||
- ns2.example.com.
|
||||
record1:
|
||||
type: CNAME
|
||||
value: record11.test.example.com.
|
||||
record11:
|
||||
type: A
|
||||
value: 192.168.1.11
|
||||
record12:
|
||||
type: A
|
||||
value: 192.168.1.12
|
17
dev/zones/view.example.com.yaml
Normal file
17
dev/zones/view.example.com.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
? ''
|
||||
:
|
||||
ttl: 172800
|
||||
type: NS
|
||||
values:
|
||||
- ns1.example.com.
|
||||
- ns2.example.com.
|
||||
record1:
|
||||
type: CNAME
|
||||
value: record11.view.example.com.
|
||||
record11:
|
||||
type: A
|
||||
value: 192.168.1.11
|
||||
record12:
|
||||
type: A
|
||||
value: 192.168.1.12
|
60
justfile
60
justfile
|
@ -6,7 +6,7 @@ set shell := ["bash", "-uc"]
|
|||
set dotenv-load
|
||||
|
||||
show_receipts:
|
||||
@just --list
|
||||
just --list
|
||||
|
||||
show_system_info:
|
||||
@echo "=================================="
|
||||
|
@ -18,34 +18,64 @@ show_system_info:
|
|||
@echo "=================================="
|
||||
|
||||
setup:
|
||||
@asdf install
|
||||
@lefthook install
|
||||
asdf install
|
||||
lefthook install
|
||||
|
||||
create_venv:
|
||||
@echo "creating venv"
|
||||
@python3 -m pip install --upgrade pip setuptools wheel
|
||||
@python3 -m venv venv
|
||||
python3 -m pip install --upgrade pip setuptools wheel
|
||||
python3 -m venv venv
|
||||
|
||||
install_deps:
|
||||
@echo "installing dependencies"
|
||||
@python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt
|
||||
@pip3 install -r /tmp/requirements.txt
|
||||
python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt
|
||||
pip3 install -r /tmp/requirements.txt
|
||||
|
||||
install_deps_dev:
|
||||
@echo "installing dev dependencies"
|
||||
@python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt
|
||||
@python3 -m hatch dep show requirements --env-only >> /tmp/requirements.txt
|
||||
@pip3 install -r /tmp/requirements.txt
|
||||
python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt
|
||||
python3 -m hatch dep show requirements --env-only >> /tmp/requirements.txt
|
||||
pip3 install -r /tmp/requirements.txt
|
||||
|
||||
create_reqs:
|
||||
@echo "creating requirements"
|
||||
@pipreqs --force --savepath requirements.txt src/octodns_netbox_dns
|
||||
pipreqs --force --savepath requirements.txt src/octodns_netbox_dns
|
||||
|
||||
lint:
|
||||
just show_system_info
|
||||
@hatch run lint:style
|
||||
@hatch run lint:typing
|
||||
hatch run lint:style
|
||||
hatch run lint:typing
|
||||
|
||||
format:
|
||||
format *args:
|
||||
just show_system_info
|
||||
@hatch run lint:fmt
|
||||
hatch run lint:fmt {{ args }}
|
||||
|
||||
check:
|
||||
just lint
|
||||
just format
|
||||
|
||||
build:
|
||||
hatch build --clean
|
||||
|
||||
test:
|
||||
hatch run default:test
|
||||
|
||||
up:
|
||||
docker compose -f dev/compose.yml up
|
||||
|
||||
down:
|
||||
docker compose -f dev/compose.yml down
|
||||
|
||||
clean:
|
||||
rm -rf dev/db-data/*
|
||||
rm -rf dev/redis-data/*
|
||||
rm -rf dev/netbox-data/*
|
||||
|
||||
sync *args:
|
||||
hatch -v run default:sync {{ args }}
|
||||
|
||||
dump *args:
|
||||
hatch -v run default:dump {{ args }}
|
||||
|
||||
validate *args:
|
||||
hatch -v run default:validate {{ args }}
|
||||
|
|
12
lefthook.yml
12
lefthook.yml
|
@ -2,7 +2,13 @@ colors: true
|
|||
no_tty: false
|
||||
|
||||
pre-commit:
|
||||
scripts:
|
||||
"format.sh":
|
||||
commands:
|
||||
01_ruff_check:
|
||||
stage_fixed: true
|
||||
runner: bash
|
||||
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}
|
||||
|
|
|
@ -35,22 +35,23 @@ source = "regex_commit"
|
|||
path = "src/octodns_netbox_dns/__about__.py"
|
||||
tag_sign = false
|
||||
|
||||
[tool.hatch.build]
|
||||
ignore-vcs = true
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
packages = ["src/octodns_netbox_dns"]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/octodns_netbox_dns"]
|
||||
|
||||
###
|
||||
### envs
|
||||
###
|
||||
|
||||
[tool.hatch.envs.default]
|
||||
python = "3.11"
|
||||
dependencies = [
|
||||
"pytest==8.0.1",
|
||||
"coverage==7.3.2",
|
||||
"coverage==7.4.2",
|
||||
"octodns==1.4.0",
|
||||
"octodns-spf==0.0.2",
|
||||
]
|
||||
|
||||
[tool.hatch.envs.default.scripts]
|
||||
|
@ -59,21 +60,34 @@ test-cov = ["coverage erase", "coverage run -m pytest {args:tests}"]
|
|||
cov-report = ["- coverage combine", "coverage report", "coverage xml"]
|
||||
cov = ["test-cov", "cov-report"]
|
||||
|
||||
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"]
|
||||
validate = ["cd dev && octodns-validate --debug --config-file sync.yml {args}"]
|
||||
|
||||
[tool.hatch.envs.lint]
|
||||
python = "3.11"
|
||||
detached = true
|
||||
dependencies = [
|
||||
"mypy==1.7.1",
|
||||
"ruff==0.1.7",
|
||||
"mypy==1.8.0",
|
||||
"ruff==0.2.2",
|
||||
]
|
||||
|
||||
[tool.hatch.envs.lint.scripts]
|
||||
typing = "mypy --non-interactive --install-types {args:src/octodns_netbox_dns}"
|
||||
style = ["ruff check --diff {args:.}", "ruff format --check --diff {args:.}"]
|
||||
fmt = ["ruff format {args:.}", "ruff check --fix {args:.}", "style"]
|
||||
style = [
|
||||
"ruff check --diff {args:.}",
|
||||
"ruff format --check --diff {args:.}"
|
||||
]
|
||||
fmt = [
|
||||
"ruff check --fix {args:.}",
|
||||
"ruff format {args:.}",
|
||||
"style"
|
||||
]
|
||||
all = ["style", "typing"]
|
||||
|
||||
###
|
||||
### ruff
|
||||
###
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py311"
|
||||
|
@ -81,7 +95,6 @@ line-length = 100
|
|||
indent-width = 4
|
||||
fix = true
|
||||
show-fixes = true
|
||||
ignore-init-module-imports = true
|
||||
respect-gitignore = true
|
||||
src = ["src", "tests"]
|
||||
exclude = [
|
||||
|
@ -99,6 +112,7 @@ exclude = [
|
|||
"dist",
|
||||
"node_modules",
|
||||
"venv",
|
||||
"dev"
|
||||
]
|
||||
|
||||
[tool.ruff.lint]
|
||||
|
@ -129,6 +143,7 @@ select = [
|
|||
"W",
|
||||
"YTT",
|
||||
]
|
||||
ignore-init-module-imports = true
|
||||
ignore = ["E501", "D103", "D100", "D102", "PLR2004", "D403", "ISC001", "FBT001", "FBT002", "FBT003"]
|
||||
unfixable = ["F401"]
|
||||
|
||||
|
@ -137,39 +152,42 @@ quote-style = "double"
|
|||
indent-style = "space"
|
||||
skip-magic-trailing-comma = false
|
||||
line-ending = "lf"
|
||||
docstring-code-format = true
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"__init__.py" = ["D104"]
|
||||
"__about__.py" = ["D104", "F841"]
|
||||
"tests/**/*" = ["PLR2004", "S101", "TID252"]
|
||||
|
||||
[tool.ruff.pyupgrade]
|
||||
[tool.ruff.lint.pyupgrade]
|
||||
keep-runtime-typing = true
|
||||
|
||||
[tool.ruff.isort]
|
||||
[tool.ruff.lint.isort]
|
||||
lines-after-imports = 2
|
||||
known-first-party = ["octodns_netbox_dns"]
|
||||
|
||||
[tool.ruff.flake8-tidy-imports]
|
||||
[tool.ruff.lint.flake8-tidy-imports]
|
||||
ban-relative-imports = "all"
|
||||
|
||||
[tool.ruff.pylint]
|
||||
[tool.ruff.lint.pylint]
|
||||
max-branches = 24
|
||||
max-returns = 12
|
||||
max-statements = 100
|
||||
max-args = 15
|
||||
allow-magic-value-types = ["str", "bytes", "complex", "float", "int"]
|
||||
|
||||
[tool.ruff.mccabe]
|
||||
[tool.ruff.lint.mccabe]
|
||||
max-complexity = 15
|
||||
|
||||
[tool.ruff.pydocstyle]
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
convention = "google"
|
||||
|
||||
[tool.ruff.pycodestyle]
|
||||
[tool.ruff.lint.pycodestyle]
|
||||
max-doc-length = 100
|
||||
|
||||
###
|
||||
### mypy
|
||||
###
|
||||
|
||||
[tool.mypy]
|
||||
#plugins = ["pydantic.mypy"]
|
||||
|
@ -191,16 +209,20 @@ show_error_context = true
|
|||
#init_typed = true
|
||||
#warn_required_dynamic_aliases = true
|
||||
|
||||
###
|
||||
### pytest
|
||||
###
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
pythonpath = ["src"]
|
||||
addopts = "--color=yes --exitfirst --verbose -ra"
|
||||
#addopts = "--color=yes --exitfirst --verbose -ra --capture=tee-sys"
|
||||
filterwarnings = [
|
||||
'ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning',
|
||||
]
|
||||
|
||||
###
|
||||
### coverage
|
||||
###
|
||||
|
||||
[tool.coverage.run]
|
||||
source_pkgs = ["octodns_netbox_dns", "tests"]
|
||||
|
@ -209,8 +231,8 @@ parallel = true
|
|||
omit = ["src/octodns_netbox_dns/__about__.py"]
|
||||
|
||||
[tool.coverage.paths]
|
||||
testproj = ["src/octodns_netbox_dns", "*/octodns_netbox_dns/src/octodns_netbox_dns"]
|
||||
tests = ["tests", "*/octodns_netbox_dns/tests"]
|
||||
octodns_netbox_dns = ["src/octodns_netbox_dns", "*/octodns-netbox-dns/src/octodns_netbox_dns"]
|
||||
tests = ["tests", "*/octodns-netbox-dns/tests"]
|
||||
|
||||
[tool.coverage.report]
|
||||
# Regexes for lines to exclude from consideration
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = "0.3.1"
|
||||
__version__ = "0.3.3"
|
||||
|
|
|
@ -231,7 +231,7 @@ class NetBoxDNSSource(octodns.source.base.BaseSource):
|
|||
raise LookupError
|
||||
|
||||
nb_records: pynetbox.core.response.RecordSet = self.api.plugins.netbox_dns.records.filter(
|
||||
zone_id=nb_zone.id
|
||||
zone_id=nb_zone.id, status="active"
|
||||
)
|
||||
for nb_record in nb_records:
|
||||
rcd_name: str = nb_record.name if nb_record.name != "@" else ""
|
||||
|
|
27
tests/test_source.py
Normal file
27
tests/test_source.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from octodns_netbox_dns import NetBoxDNSSource
|
||||
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
"id": 1,
|
||||
"url": "https://localhost:8000",
|
||||
"token": "",
|
||||
"view": False,
|
||||
"replace_duplicates": False,
|
||||
"make_absolute": True,
|
||||
}
|
||||
|
||||
|
||||
def test_absolute1():
|
||||
nbdns = NetBoxDNSSource(**DEFAULT_CONFIG)
|
||||
rcd = "example.com"
|
||||
absolute = nbdns._make_absolute(rcd)
|
||||
|
||||
assert absolute == "example.com."
|
||||
|
||||
|
||||
def test_absolute2():
|
||||
nbdns = NetBoxDNSSource(**DEFAULT_CONFIG)
|
||||
rcd = "example.com."
|
||||
absolute = nbdns._make_absolute(rcd)
|
||||
|
||||
assert absolute == "example.com."
|
Loading…
Reference in a new issue