Open phil-dileo opened 8 years ago
This is not currently possible. Attribute values are currently limited to only strings, or a list of strings if multi=True
. You could store the value of an attribute as a JSON-encoded string, but that's about it for now.
Is it of interest? I could help contribute some code to do this if the framework of nsot can fit something like this in.
Well, what are your thoughts on how you might use nested attribute data like this? Would you want to be able to search for nested values?
I'd like to keep all data models in nsot and then pull it into Ansible which implements the configuration template via Jinja.
If you're just using it for data storage, it seems having it designated as a JSON "type" could be a relatively quick win.
Perhaps a first step could be if that pattern works for you on the client side? And if it does we can talk about how it might work on the server side?
Currently, however, the value is limited to 255 bytes in length (it's a varchar(255)
). That will also need to be taken into consideration.
Having this flexibility could be nice I think. It could help people who don't want to use attribute name prefixing to do similar grouping.
As far as querying, attr.key
but that would need to restrict .
from attribute names or at least dict
type attribute names. A json
type like you say could be easy too - let the user handle parsing/querying the return with jq
and such.
[get value of vlans attribute] | jq '[].name'
I would also like to put in my support for arbitrary model storage. I am looking to use NSOT as a one stop shop for device inventory and openconfig storage.
It would also be nice to leverage the interface and network objects from NSOT in the models too. This would probably call for some kind of openconfig generation built in though.
Hi - I've just started playing with nsot and I'm curious how you would do something like this:
Create attribute called 'vlans' where each item is a dict.