Giter Club home page Giter Club logo

netbox-kea-dhcp's Issues

Stuck running script

Netbox 3.7.3
Python: 3.10.2
Kea: 2.2.1

I'm manually running the script and feeding it a basic config. I can see connections being made to both kea and netbox, however it pukes on the first prefix it receives back from netbox. This particular subnet (10.10.0.0/16) is actually empty. I don't have "status" set as dhcp in the config.

2024-02-29 11:32:01,451 [INFO] Start full sync
2024-02-29 11:32:01,451 [INFO] pull running config from DHCP server
2024-02-29 11:32:01,459 [DEBUG] command "config-get" OK (text: None)
2024-02-29 11:32:01,459 [INFO] delete all current subnets
2024-02-29 11:32:01,459 [DEBUG] check configuration
2024-02-29 11:32:01,465 [DEBUG] command "config-test" OK (text: Configuration seems sane. Control-socket, hook-libraries, and D2 configuration were sanity checked, but not applied.)
2024-02-29 11:32:01,465 [DEBUG] commit configuration
2024-02-29 11:32:01,997 [DEBUG] prefix 10.10.0.0/16: generate DHCP config
2024-02-29 11:32:01,997 [INFO] subnets: add 10.10.0.0/16, ID 33997
Traceback (most recent call last):
  File "/usr/local/bin/netbox-kea-dhcp", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.10/dist-packages/netboxkea/entry_point.py", line 32, in run
    conn.sync_all()
  File "/usr/local/lib/python3.10/dist-packages/netboxkea/connector.py", line 96, in sync_all
    self._prefix_to_subnet(p, fullsync=True)
  File "/usr/local/lib/python3.10/dist-packages/netboxkea/connector.py", line 179, in _prefix_to_subnet
    for r in self.nb.ip_ranges(parent=pref.prefix):
  File "/usr/local/lib/python3.10/dist-packages/netboxkea/netbox.py", line 31, in ip_ranges
    for r in self.nb.ipam.ip_ranges.filter(
  File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/response.py", line 127, in __next__
    next(self.response), self.endpoint.api, self.endpoint
  File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/query.py", line 280, in get
    req = self._make_call(add_params=add_params)
  File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/query.py", line 247, in _make_call
    raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'status': ['Select a valid choice. dhcp is not one of the available choices.']}

Feature-Request: Get Information from Parent-Prefix

Hello,

would it be possible to read various DHCP options such as the domain name or the NTP server from the parent prefix? In most cases, the options are the same for all subnets, so that they do not have to be configured individually for each subnet as a Custom_Field in Netbox.

Thanks and Regards,
Daniel

Program crashes when dhcp4 service is offline

During a server reboot, netbox-kea-dhcp crashes with the following trace:

août 22 09:32:08 charade netbox-kea-dhcp[846]: netbox: https://netbox-srv, kea: http://127.0.0.1:8000/
août 22 09:32:08 charade netbox-kea-dhcp[846]: Start full sync
août 22 09:32:08 charade netbox-kea-dhcp[846]: pull running config from DHCP server
août 22 09:32:08 charade netbox-kea-dhcp[846]: Traceback (most recent call last):
août 22 09:32:08 charade netbox-kea-dhcp[846]:   File "/usr/local/bin/netbox-kea-dhcp", line 8, in <module>
août 22 09:32:08 charade netbox-kea-dhcp[846]:     sys.exit(run())
août 22 09:32:08 charade netbox-kea-dhcp[846]:   File "/usr/local/lib/netbox-kea-dhcp/lib/python3.10/site-packages/netboxkea/entry_point.py", line 32, in run
août 22 09:32:08 charade netbox-kea-dhcp[846]:     conn.sync_all()
août 22 09:32:08 charade netbox-kea-dhcp[846]:   File "/usr/local/lib/netbox-kea-dhcp/lib/python3.10/site-packages/netboxkea/connector.py", line 83, in sync_all
août 22 09:32:08 charade netbox-kea-dhcp[846]:     self.kea.pull()
août 22 09:32:08 charade netbox-kea-dhcp[846]:   File "/usr/local/lib/netbox-kea-dhcp/lib/python3.10/site-packages/netboxkea/kea/app.py", line 64, in pull
août 22 09:32:08 charade netbox-kea-dhcp[846]:     self.conf = self.api.get_conf()
août 22 09:32:08 charade netbox-kea-dhcp[846]:   File "/usr/local/lib/netbox-kea-dhcp/lib/python3.10/site-packages/netboxkea/kea/api.py", line 68, in get_conf
août 22 09:32:08 charade netbox-kea-dhcp[846]:     return self._request_kea('config-get')['Dhcp4']
août 22 09:32:08 charade netbox-kea-dhcp[846]:   File "/usr/local/lib/netbox-kea-dhcp/lib/python3.10/site-packages/netboxkea/kea/api.py", line 60, in _request_kea
août 22 09:32:08 charade netbox-kea-dhcp[846]:     raise KeaCmdError(f'command "{command}" returns "{text}"')
août 22 09:32:08 charade netbox-kea-dhcp[846]: netboxkea.kea.exceptions.KeaCmdError: command "config-get" returns "unable to forward command to the dhcp4 service: No such file or directory. The server is likely to be offline"

Expected result: handle errors trowned by Kea API, retry later when dhcp4 service is alive

/health/ route doesn't exist in current pypi release

Symptoms
/health/ route returns 404 error when listener is running

Reproduction Steps

  1. Install netbox-kea-dhcp from PyPI
  2. Run netbox-kea-dhcp with --listen flag
  3. Attempt an HTTP GET request to /health/
  4. Recieve a 404 from server

Potential solutions
Re-release pypi package to be in sync with repo

ip-ranges dhcp status is not one of the valid choices

current location of issue: ipaddress_filter={'status': 'dhcp'}
netbox docs explicitly state:

Statuses are hard-coded in NetBox and can be one of the following:

  • Container - A summary of child prefixes
  • Active - Provisioned and in use
  • Reserved - Designated for future use
  • Deprecated - No longer in use

I'd suggest to change this to roles or, is there a plugin that creates extra status fields?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.