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.
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.