CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
135 stars 74 forks source link

Commit error needs to be reported correctly #190

Closed ghost closed 8 years ago

ghost commented 8 years ago

For example, for the below commit error:

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>in-use</error-tag>
    <error-severity>error</error-severity>
    <error-message xml:lang="en">'YANG framework' detected the 'fatal' condition 'Datastore locked'</error-message>
  </rpc-error>
</rpc-reply>

The error is reported as:

  File "ydk/tests/parser/Cisco_IOS_XR_parser_cfgTest.py", line 394, in test_parser_submodeexit
    self.crud.create(self.ncc, parser_submodeexit)
  File "/Users///002/ydk-gen/gen-api/python/ydk/services/crud_service.py", line 61, in create
    self._execute_crud_operation_on_provider(provider, entity, 'CREATE', False)
  File "/Users///002/ydk-gen/gen-api/python/ydk/services/crud_service.py", line 166, in _execute_crud_operation_on_provider
    operation
  File "/Users//002/ydk-gen/gen-api/python/ydk/services/service.py", line 37, in execute_payload
    reply = provider.execute(payload, operation)
  File "/Users//002/ydk-gen/gen-api/python/ydk/providers/native_netconf_provider.py", line 90, in execute
    return self.sp_instance.execute_operation(payload, operation)
  File "/Users//002/ydk-gen/gen-api/python/ydk/providers/_provider_plugin.py", line 217, in execute_operation
    return self._handle_rpc_reply(operation, payload, reply_str)
  File "/Users//002/ydk-gen/gen-api/python/ydk/providers/_provider_plugin.py", line 241, in _handle_rpc_reply
    self._handle_rpc_ok(optype, payload, reply_str)
  File "/Users//002/ydk-gen/gen-api/python/ydk/providers/_provider_plugin.py", line 255, in _handle_rpc_ok
    self._handle_commit(payload, reply_str)
  File "/Users//002/ydk-gen/gen-api/python/ydk/providers/_provider_plugin.py", line 276, in _handle_commit
    raise YPYServiceProviderError(error_code=YPYErrorCode.SERVER_COMMIT_ERR, error_msg=reply_str)
YPYServiceProviderError: Server reported an error while committing change.

The below info needs to be added to the above error message:

    error-type: application
    error-tag: in-use
    error-severity: error
    error-message: 'YANG framework' detected the 'fatal' condition 'Datastore locked'
ghost commented 8 years ago

To reproduce, run the sanity test and at the same time, try to do CRUD create operation:

To run sanity test: python test/test_sanity_types.py

To run CRUD create operation, run this in a python terminal:

from ydk.providers import NetconfServiceProvider
from ydk.services import CRUDService
from ydk.models.ydktest.ydktest_sanity import Runner

crud = CRUDService()
ncc = NetconfServiceProvider(address='127.0.0.1' , username='admin', password='admin', port=12022)
crud.create(ncc,Runner())