-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add a custom script variable for IP addresses #3509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Considering this further, |
if |
I can imagine instances where you want to prompt the user for specifically either an IP address (e.g. defining an NTP server) or a prefix (e.g. a site aggregate). It should be minimal effort to introduce an |
@hSaria I started commenting on #3924 but wanted to share some more thoughts here. IMO we should accept a mask value for IP addresses. I think the ideal behavior for the two fields would be:
I think it would make sense to allow the user to require or disable the innclusion of a mask on |
I'm not quite following. Wouldn't an >>> netaddr.IPNetwork('1.1.1.1/24')
IPNetwork('1.1.1.1/24') So wouldn't that be used in case a subnet mask is needed for an address? I figured that, from your NTP example, you'd want the user to indicate that this is an IP with no relation to the L3 domain it lives in, like – as you mentioned – a source/destination address. I'm probably misunderstanding, but I'm not sure how |
There are three use cases for an IP-like value that I can think of:
A prefix must include a mask and must not be a host address. For example, Where we run into an issue is the way syslog_server = IPAddressVar(include_mask=False) would return an interface_ip = IPAddressVar(include_mask=True) would return an Granted it may not be the most intuitive approach, but I do think we need to support all three discrete use cases above. |
Ah, now I see. That would introduce a change to the Edit: another option would be to add an optional argument to
This would be backwards compatible with existing scripts. |
We should maintain the current validation behavior when creating a prefix normally in NetBox, which is to raise a ValidationError. For example, if I try to create the prefix
(Again, this is primarily a sanity check against the input data.) We should use |
I fully agree.
That's the thing. The current behavior for Final thing: do you want |
Yeah, I think we've tolerated
I think that's really the only option. Should be fine so long as the script author knows to expect either type (which should be indicated in the documentation for the field). |
Alright, I've adjusted the PR.
Best way to answer an |
…vars Closes #3509: Add IP address vars for custom scripts
Environment
Proposed Functionality
Add a variable type for representing IP addresses in custom scripts. This would be similar to the existing
IPNetworkVar
, but for individual IPs rather than prefixes.Use Case
Adding this variable type will allow for validation of IP addresses.
Database Changes
None
External Dependencies
None
The text was updated successfully, but these errors were encountered: