Невозможно сбросить mac-адрес в скрипте YANG - PullRequest
0 голосов
/ 11 февраля 2019

У меня есть структура для сценария yang, где я объявил шаблон для mac-адреса следующим образом:

type string {
              pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'
          }

Когда я попытался сбросить mac-адрес с помощью дампов json, ошибка не принимается и выдаеткак показано ниже.

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}")
...