12-20-2020 05:41 AM
Hi, I am new in NSO and I want to develop my own services using python.
I want to ask what is the proplist argument in the cb_create(self, tctx, root, service, proplist) function ?
Solved! Go to Solution.
12-20-2020 09:57 PM
12-20-2020 01:42 PM
12-20-2020 01:49 PM
Thank you vleijon for your reply. Could you please explain to me more with some easy words ?
12-20-2020 09:57 PM
01-26-2021 05:21 PM
So there were a few things that weren't immediately obvious to about proplists that I figured I'd share.
- proplists do get persisted across commits. If you restart NSO, upgrade your code, etc, you'll still get that proplist back when you make a change or do a re-deploy of your service. No other service will have access to these.
- Like you'd expect, a modified proplist doesn't get stored if the commit isn't successful (or if it's a dry-run)
- Probably not like you'd expect, proplists don't seem to show up in the config tree
- Each tuple in the list must have exactly 2 items and they must be strings. No integers, no objects, no complex types. So more like: `[ (str, str), ... ]`
- proplists can be converted to/from dictionaries pretty easily in Python.
props = dict(proplist)
... do stuff ...
proplist = [ (str(k), str(v)) for k, v in props.items() ] return proplist
You accept a few limitations while doing it this way. Namely that a proplist can have multiple entries for the same "key". IE: `[ ("message", "hello"), ("message", "goodbye"), ("other_attribute", "something_else), ... ]`.
You also give up the notion of ordering to the proplist, which isn't likely a big deal. If worse comes to worse, you can always "json.dumps()" and "json.loads()" to stash data.
- These values cannot be read/modified by other services and cannot be read/modified by the CLI user that I know of.
If there is a way to view `proplist` data for debugging purposes, I'm interested.
01-26-2021 05:41 PM
01-28-2021 06:13 AM
That's helpful. Thanks!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide