我有一个yang脚本的结构,其中我声明了如下所示的mac-address模式,
type string {
pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'
}
当我尝试使用json转储转储mac-地址时,它不接受并抛出错误,如下所示。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/pyangbind/lib/yangtypes.py", line 760, in add
self.__set(_k=k)
File "/usr/local/lib/python3.5/dist-packages/pyangbind/lib/yangtypes.py", line 679, in __set
raise KeyError("key value must be valid, %s" % m)
KeyError: 'key value must be valid, {\'error-string\': \'mac_address must be of a type compatible with mac-address\', \'defined-type\': \'o_to_w: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="mac-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace=\\\'https://wireless.com/orc_to_wireless\\\', defining_module=\\\'o_to_w\\\', yang_type=\\\'mac-address\\\', is_config=True)\'}'
我用于json的代码如下。
>>> import o_to_w
>>> sw=o_to_w.o_to_w()
>>> obi=sw.handover.client.add("[0-a-F]{2}(:0-a-F){2}){5}")