DRAFT PR - Use sentinel value to allow for distinguishing between implicit and null values#1520
DRAFT PR - Use sentinel value to allow for distinguishing between implicit and null values#1520robduffy2010 wants to merge 5 commits intonetbox-community:develfrom
Conversation
… and explicit null values. this allows use to set a field to null in netbox using this module
|
Using the |
|
I am going to re-run the jobs. It might have been impacted by the GH outage yesterday. Can you make a simple changelog fragment so that this can get through that test, so that it does a full CI run? Content doesn't matter, just enough to make the job happy. |
|
Sure, I'll do that shortly. I'm thinking now that the OMITTED object should be instantiated in one file and then imported into others from there, so I'll make that change. |
…ect is always referenced
|
OK. I like where this is going, but I have some thoughts: Because you define So it got me thinking. What if we instead did something like: class OmittedArgument():
def __str__(self):
return "Omitted Argument"First off, that makes it much better for debugging purposes since it's not just printing object and an address in memory. Secondly, it allows us to check based on it being an instance of the class, rather than relying on it having the same memory location. I just get concerned that it could somehow bite us. Which means some of your logic would change to: elif v not isinstance(OmmittedArgument):
...Thoughts? |
|
I really much prefer your suggestion actually. I went ahead and updated the PR. If you're happy with it, I can make the changes for the rest of the modules. |
|
Let's keep iterating on it here. I like the idea so far, I think the next thing is maybe build a test case for creating a device in a rack, then un-racking it via the I'm okay with hacking it to make it work since we're still at the "would this work like we think phase" so feel free to focus on expediency rather than correctness. I also have a TODO for myself to figure out why the sanity checks are failing, sometimes that's an upstream change that bites us but it's sometimes hard to determine. Great work so far, thank you for contributing. |
|
Ok looks like there might be another property or method that we need to define for |
|
I think it might be |
|
The sanity checking is quite problematic. Ansible also doesn't allow setting the type to custom class. I've done some testing and it seems we're left with the following options, none of which are ideal, unless you have any other ideas.
Thoughts? |
This allows use to set a field to null in Netbox using this module
Related Issue
#330
New Behavior
Setting a field to null in the Ansible Netbox module will set a null value for the same field in Netbox.
Contrast to Current Behavior
Right now, setting a field to null does nothing.
Discussion: Benefits and Drawbacks
Right now, there is no way to set a field to null using the Ansible Netbox module. This can be important for different reasons, like when a VLAN should be removed from an interface or when an asset tag needs to be removed when recycling a device.
Changes to the Documentation
Unclear. Perhaps it can be documented that it is now possible to set fields to null although it's intuitive behaviour.
Proposed Release Note Entry
Added ability to set fields to null when supported by Netbox.
Double Check
develbranch.