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

The Executor Service fails to return module content back to user #1048

Closed ygorelik closed 2 years ago

ygorelik commented 3 years ago

Current Behavior

The Executor Service fails to return module content to user. The below script succeeds to retrieve the module, but then returns exception:

ydk.errors.YCoreError:  Couldn't fetch child entity 'data' in parent /ietf-netconf-monitoring:get-schema

Your Script

from ydk.providers import NetconfServiceProvider
from ydk.services import ExecutorService
from ydk.models.ietf import ietf_netconf_monitoring as ietf
from test_utils import enable_logging

import logging

if __name__ == '__main__':

    enable_logging(logging.INFO)

    ncc = NetconfServiceProvider(
        address='127.0.0.1',
        username='admin',
        password='admin',
        port=12022)

    es = ExecutorService()

    rpc_entity = ietf.GetSchema()
    rpc_entity.input.identifier = 'ietf-netconf-with-defaults'
    top_entity = ietf.GetSchema.Output()
    output = es.execute_rpc(ncc, rpc_entity, top_entity)
    print(output.data)

Logs

Enable logging and post the logs below

/Users/ygorelik/venv/bin/python /Users/ygorelik/gitlab/ydk-gen/scripts/tests/get_schema.py
2020-12-09 11:09:29,224 - ydk - INFO - ============= Requesting YANG 1.1 capabilities =============
2020-12-09 11:09:29,238 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data>
    <modules-state xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
      <module>
        <name>iana-crypt-hash</name>
        <revision>2014-08-06</revision>
        <namespace>urn:ietf:params:xml:ns:yang:iana-crypt-hash</namespace>
        <feature>crypt-hash-md5</feature>
        <feature>crypt-hash-sha-256</feature>
        <feature>crypt-hash-sha-512</feature>
        <conformance-type>implement</conformance-type>
      </module>
...
    </modules-state>
  </data>
</rpc-reply>

2020-12-09 11:09:29,240 - ydk - INFO - Path where models are to be downloaded: /Users/ygorelik/.ydk/127.0.0.1
2020-12-09 11:09:29,255 - ydk - INFO - Connected to 127.0.0.1 on port 12022 using ssh with timeout of -1
2020-12-09 11:09:29,260 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get-schema xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
  <identifier>ietf-netconf-with-defaults</identifier>
</get-schema>
</rpc>
2020-12-09 11:09:29,266 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <data xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"><![CDATA[module ietf-netconf-with-defaults {

   namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults";

   prefix ncwd;

   import ietf-netconf { prefix nc; }

   organization
    "IETF NETCONF (Network Configuration Protocol) Working Group";

   contact
    "WG Web:   <http://tools.ietf.org/wg/netconf/>

     WG List:  <netconf@ietf.org>

     WG Chair: Bert Wijnen
               <bertietf@bwijnen.net>

     WG Chair: Mehmet Ersue
               <mehmet.ersue@nsn.com>

     Editor: Andy Bierman
             <andy.bierman@brocade.com>

     Editor: Balazs Lengyel
             <balazs.lengyel@ericsson.com>";

   description
    "This module defines an extension to the NETCONF protocol
     that allows the NETCONF client to control how default
     values are handled by the server in particular NETCONF
     operations.

     Copyright (c) 2011 IETF Trust and the persons identified as
     the document authors.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject
     to the license terms contained in, the Simplified BSD License
     set forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC 6243; see
     the RFC itself for full legal notices.";

   revision 2011-06-01 {
     description
       "Initial version.";
     reference
      "RFC 6243: With-defaults Capability for NETCONF";
   }

   typedef with-defaults-mode {
      description
        "Possible modes to report default data.";
      reference
         "RFC 6243; Section 3.";
      type enumeration {
         enum report-all {
             description
               "All default data is reported.";
             reference
               "RFC 6243; Section 3.1";
         }
         enum report-all-tagged {
             description
               "All default data is reported.
                Any nodes considered to be default data
                will contain a 'default' XML attribute,
                set to 'true' or '1'.";
             reference
               "RFC 6243; Section 3.4";
         }
         enum trim {
             description
               "Values are not reported if they contain the default.";
             reference
               "RFC 6243; Section 3.2";
         }
         enum explicit {
             description
               "Report values that contain the definition of
                explicitly set data.";
             reference
               "RFC 6243; Section 3.3";
         }
     }
   }

   grouping with-defaults-parameters {
     description
       "Contains the <with-defaults> parameter for control
        of defaults in NETCONF retrieval operations.";

     leaf with-defaults {
       description
         "The explicit defaults processing mode requested.";
       reference
         "RFC 6243; Section 4.5.1";

       type with-defaults-mode;
     }
   }

   // extending the get-config operation
   augment /nc:get-config/nc:input {
       description
         "Adds the <with-defaults> parameter to the
          input of the NETCONF <get-config> operation.";
       reference
         "RFC 6243; Section 4.5.1";

       uses with-defaults-parameters;
   }

   // extending the get operation
   augment /nc:get/nc:input {
       description
         "Adds the <with-defaults> parameter to
          the input of the NETCONF <get> operation.";
       reference
         "RFC 6243; Section 4.5.1";

       uses with-defaults-parameters;
   }

   // extending the copy-config operation
   augment /nc:copy-config/nc:input {
       description
         "Adds the <with-defaults> parameter to
          the input of the NETCONF <copy-config> operation.";
       reference
         "RFC 6243; Section 4.5.1";

       uses with-defaults-parameters;
   }

}
]]></data>
</rpc-reply>

2020-12-09 11:09:29,267 - ydk - ERROR - Couldn't fetch child entity data in parent /ietf-netconf-monitoring:get-schema!
Traceback (most recent call last):
  File "/Users/ygorelik/gitlab/ydk-gen/scripts/tests/get_schema.py", line 23, in <module>
    output = es.execute_rpc(ncc, rpc_entity, top_entity)
  File "/Users/ygorelik/venv/lib/python3.7/site-packages/ydk/services/executor_service.py", line 32, in execute_rpc
    return self._es.execute_rpc(provider, entity, top_entity)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/ygorelik/venv/lib/python3.7/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
    _raise(_exc)
  File "/Users/ygorelik/venv/lib/python3.7/site-packages/ydk/errors/error_handler.py", line 54, in _raise
    exec("raise exc from None")
  File "<string>", line 1, in <module>
ydk.errors.YCoreError:  Couldn't fetch child entity 'data' in parent /ietf-netconf-monitoring:get-schema
2020-12-09 11:09:29,281 - ydk - INFO - Disconnected from device

Process finished with exit code 1

System Information

YDK-0.8.5

ygorelik commented 2 years ago

Resolved in YDK-0.8.6.