Giter Site home page Giter Site logo

Comments (4)

lae avatar lae commented on June 12, 2024

Seems like this was introduced in 3.1.0? (netbox-community/netbox#7619) So from my perspective this is one of those features that should be configurable by this role in order to get 3.1.0 support through the door in the first place.

If I understand correctly this would fundamentally be the same as netbox_scripts/netbox_reports (with the slight difference of those validators being referenced in the custom validators config)?

from ansible-role-netbox.

tyler-8 avatar tyler-8 commented on June 12, 2024

They were part of the 3.0 release. They are slightly different from reports and scripts because there is no "root" folder that NetBox automatically looks for them in.

That means the user has to have a package/folder in the path so NetBox can followed the dotted path configured (I use local_validators in the same directory as manage.py).

Other than that, I am using similar logic to reports/scripts for copying & linking files.

from ansible-role-netbox.

lae avatar lae commented on June 12, 2024

Oh I thought the custom validator support in 3.0 was just a specific DSL in configuration.py, not external files.

I just thought of something I've done before that might be useful. You can add directories to the PYTHONPATH at runtime:

import os
import sys
sys.path.insert(0, os.path.join(os.getcwd(), "{{ shared_directory }}/validators"))

That could go at the top of the configuration.py template. This way they don't necessarily have to be in the netbox folder itself, and might possibly be simpler to reason about (e.g. what if someone wanted to use a different package name than local_validators in their config?). Food for thought.

from ansible-role-netbox.

tyler-8 avatar tyler-8 commented on June 12, 2024

specific DSL in configuration.py, not external files.

It's both :)

The external files part is where you want to write a CustomValidator class that overrides the validate() method to do more complex validation than what the DSL provides. The dynamic configuration is "best" IMO and so there's no need to put anything in configuration.py (except perhaps your sys.path trick to get the path set up correctly) - and if users of this role want/need to define their validators in configuration.py, they still can using the role as it exists today, rather than adding new role-specific variables to handle it.

from ansible-role-netbox.

Related Issues (20)

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.