Comments (7)
I would see that _presence
would work like _mchanged
where hierarchically it would be True
if any descendent was set. I'll look into implementing this over the coming few days.
from pyangbind.
Hi,
This was currently a design choice. Pyangbind would generate something that looks like the following if requested to create this object (I made some minor modifications to think about this):
class new_net(object):
_pyangbind_elements = {}
This class seems relatively useless - since I'm not sure what one would do to manipulate it. Currently, there is no support for the presence
keyword. Could you explain to me how you would expect to use this such that we can design how this would work?
Thanks,
r.
from pyangbind.
In the IETF network model they use presence to indicate the network types.
In section 3.4.8. it says:
A network's network types are represented using a container which
contains a data node for each of its network types. A network can
encompass several types of network simultaneously, hence a container
is used instead of a case construct, with each network type in turn
represented by a dedicated presence container itself. The reason for
not simply using an empty leaf, or even simpler, do away even with
the network container and just use a leaf-list of network-type
instead, is to be able to represent "class hierarchies" of network
types, with one network type refining the other. Network-type
specific containers are to be defined in the network-specific
modules, augmenting the network-types container.
In the model it has the following:
container network-types {
description
"Serves as an augmentation target.
The network type is indicated through corresponding
presence containers augmented into this container.";
}
I couldn't load JSON data which has a network type specified with an empty container.
from pyangbind.
Right - but how would you want to interact with this in Python?
One option would be to have something in the meta-class that lets one set the presence, for example:
model.container._presence = True
This would then set _changed
to True
as well, which would mean that it would be serialised when creating JSON instances.
When de-serialising we would need to understand that "model": { "container": {} }
meant that _presence
for container
needed to be set, but that is something that we could do relatively easily in the lib.serialise
modules.
Would this make sense for you?
r.
from pyangbind.
Yes, that makes sense to me.
One question: if there is a hierarchy of presence containers, how can it be handled?
container network-types {
container type-a {
presence "type-a";
container type-a-1 {
presence "type-a-1";
}
}
}
When serializing should _presence
for both type-a
and type-a-1
be set True
to include type-a-1
container?
from pyangbind.
Hi @sangwookha-vz,
If you pull the presence
branch - the functionality that we discussed above is implemented therein.
You can see some examples of how to use it in https://github.com/robshakir/pyangbind/blob/presence/tests/presence/run.py
Any comments very welcome.
Cheers,
r.
from pyangbind.
I merged this branch and released it to PyPI. If there are issues, please do let me know.
Cheers,
r.
from pyangbind.
Related Issues (20)
- Help with pyangbind error: Loading json instance errors out HOT 1
- Unable to build module from Cisco-IOS-XE-native HOT 1
- ModuleNotFoundError: No module named 'bitarray' - Python 3.9 on MacOS HOT 1
- XML Deserialisation HOT 2
- pybindIETEXMLEncode serialize class unable to maintain xml hierarchy as input value when I was use python 2.7 HOT 1
- How to get a empty list objects use for query all sub-resources. HOT 2
- Empty RPC XML Serialisation will not work HOT 3
- Nested lists
- bindings generation for "ietf-netconf.yang" with --build-rpcs option causes an exeption HOT 3
- Add async as a reserved Python name. HOT 1
- Pyangbind PYPI release does not have pybindIETFXMLEncoder class HOT 1
- How to inspect yang model HOT 2
- pyangbind is not taking care of "when" statement in yang definitions. HOT 2
- Problem with list's key made of multiple leaf identifiers HOT 3
- Is pyangbind still maintained? HOT 3
- RuntimeError when importing an older revision of a YANG file HOT 1
- Failure on OpenConfig BFD Model HOT 3
- Fix binary type representation HOT 2
- Integration and Sample UnitTests using BGP are broken
- __add_metadata is not adding the @metadata object to JSON or XML HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyangbind.