pyangbind
pyangbind copied to clipboard
XML serialisation/deserialisation
Hello,
Could you help me please to fix an XML serialisation/deserialisation problem?
- I have a custom yang model, my-topology.yang, which is valid according to pyang.
- I already obtained the pyangbind objects of that model.
- I constructed a python object and serialise it into XML (no problem on this step)
- I want now to deserialise the XML back to a python object, and I get the following exception: 'key value must be valid, {'error-string': 'talker_address must be of a type compatible with yang:mac-address', 'defined-type': 'yang:mac-address', 'generated-type': 'YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={\'pattern\': \'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}\'}), is_leaf=True, yang_name="talker-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace=\'https://domain.com/my-topology\', defining_module=\'my-topology\', yang_type=\'yang:mac-address\', is_config=True)'}' Note: I have also other field of the same type yang:mac-address, and I have no problems serialising/deserialising my_topology when using only that field.
Operating system: Windows 10 Python version: 3.7 pyangbind version: 0.8.1
Validation done under Operating system: CentOS Linux 7 pyang version: 2.1
Thank you in advance Voica
Can you paste a minimal working example that exhibits the problem? (i.e. yang and relevant python code)
The fragment of the yang model is: module CC-topology { yang-version "1";
namespace "https://comcores.com/CC-topology";
prefix "CC-topo";
import ietf-yang-types { prefix yang; }
import ieee802-dot1q-tsn-types { prefix dot1q-tsn-types; }
grouping end-system-grouping { list user-network-configuration-information-list { key "talker-address unique-id"; leaf talker-address { type yang:mac-address; } ... } }
container network { list end-systems { key "host-name"; leaf host-name { type string; } leaf address { type yang:mac-address; } uses end-system-grouping; } ... } }
The problematic XML fragment is:
<CC-topology xmlns="https://comcores.com/CC-topology">
Though the following fragment is decoded just fine:
<CC-topology xmlns="https://comcores.com/CC-topology">
@CC-vga I think you need to make use of Markdown to encapsulate your YANG, and especially your XML, in a pre-formatted code
block so it renders correctly. The XML in particular has lost all its elements.
Hope that now is readable!
The fragment of the yang model is: module CC-topology { yang-version "1";
namespace "https://comcores.com/CC-topology";
prefix "CC-topo";
import ietf-yang-types {
prefix yang;
}
import ieee802-dot1q-tsn-types {
prefix dot1q-tsn-types;
}
grouping end-system-grouping {
list user-network-configuration-information-list {
key "talker-address unique-id";
leaf talker-address {
type yang:mac-address;
}
...
}
}
container network {
list end-systems {
key "host-name";
leaf host-name {
type string;
}
leaf address {
type yang:mac-address;
}
uses end-system-grouping;
}
...
}
}
The problematic XML fragment is:
<CC-topology xmlns="https://comcores.com/CC-topology">
<network>
<end-systems>
<host-name>
ES1</host-name>
<address>
00:95:f8:ce:a0:01</address>
<user-network-configuration-information-list>
<talker-address>
00:95:f8:ce:a0:01</talker-address>
...
</user-network-configuration-information-list>
...
</end-systems>
...
</network>
</CC-topology>
Though the following fragment is decoded just fine:
<CC-topology xmlns="https://comcores.com/CC-topology">
<network>
<end-systems>
<host-name>
ES1</host-name>
<address>
00:95:f8:ce:a0:01</address>
</end-systems>
...
</network>
</CC-topology>
@CC-vga Hi, Any progress with above issue..? Thanks.
Hello, Unfortunately I didn't hear anything new! All best Voica
Hi,
Could you please try again with recent versions of pyangbind?
Thanks.
Closing issue without recent updates.