Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ietf-netconf-monitoring:get-schema' returns schema with escape sequences #614

Closed
111pontes opened this issue Nov 1, 2017 · 4 comments
Closed
Assignees
Labels
Projects

Comments

@111pontes
Copy link
Collaborator

'ietf-netconf-monitoring:get-schema' returns schema data with "predefined entities" representing special characters: < (<), & (&), > (>), " ("), and ' ('). The actual characters should be used in the schema Instead of the "predefined entities".

For instance, instead of returning:

module openconfig-bgp {

  yang-version &quot;1&quot;;

  // namespace
  namespace &quot;http://openconfig.net/yang/bgp&quot;;

  prefix &quot;oc-bgp&quot;;
....

The following data should be returned:

module openconfig-bgp {

  yang-version "1";

  // namespace
  namespace "http://openconfig.net/yang/bgp";

  prefix "oc-bgp";
....
@ghost
Copy link

ghost commented Feb 22, 2018

To reproduce:

from ydk.path import NetconfSession
from ydk.path import Codec
from ydk.types import EncodingFormat

# Create a NetconfSession instance to connect to the device
netconf_session = NetconfSession(address='10.0.0.1' , username='admin', password='admin')

c = Codec()

# Get the root schema node
root = netconf_session.get_root_schema()

# Create the 'ietf-netconf-monitoring:get-schema' RPC object
get_schema = root.create_rpc('ietf-netconf-monitoring:get-schema')

# Set the 'identifier' to 'Cisco-IOS-XR-aaa-lib-cfg'
get_schema.get_input_node().create_datanode('identifier','openconfig-bgp')

# Invoke the RPC
output_data = get_schema(netconf_session)

# Encode the RPC reply to XML
output_xml =  c.encode(output_data, EncodingFormat.XML, True)

# Print the XML
print(output_xml)

@ygorelik
Copy link
Collaborator

Added code to convert XML special character sequences to regular ones and encapsulate the data to CDATA tag. Added C++ test case.
See test case and log file for details.
test_614.zip

@ghost
Copy link

ghost commented Mar 9, 2018

Seeing the same escape characters when using a different client like ncclient. Not sure if YDK should be 'unescaping' the data returned by the device.

@ghost ghost reopened this Mar 9, 2018
@ghost ghost added this to To do in YDK May 1, 2018
@ygorelik ygorelik added C++ and removed bug labels Sep 10, 2019
@ygorelik ygorelik changed the title 'ietf-netconf-monitoring:get-schema' returns schema with escape strings 'ietf-netconf-monitoring:get-schema' returns schema with escape sequences Sep 11, 2019
@ygorelik
Copy link
Collaborator

Added replacement of "&quot;" and "&#13;" sequences in Codec.encode operation. The rest of escape sequences left untouched to keep XML string valid.

Above test would produce the following:

<get-schema xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
  <data>module Cisco-IOS-XR-aaa-lib-cfg {

  /*** NAMESPACE / PREFIX DEFINITION ***/

  namespace "http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-lib-cfg";


  prefix "aaa-lib-cfg";

  /*** LINKAGE (IMPORTS / INCLUDES) ***/

  import Cisco-IOS-XR-types { prefix "xr"; }

  import cisco-semver { prefix "semver"; }

  import Cisco-IOS-XR-aaa-lib-datatypes { prefix "dt1"; }

  /*** META INFORMATION ***/

  organization "Cisco Systems, Inc.";

  contact
    "Cisco Systems, Inc.
     Customer Service

     Postal: 170 West Tasman Drive
     San Jose, CA 95134

     Tel: +1 800 553-NETS

     E-mail: cs-yang@cisco.com";

  description 
    "This module contains a collection of YANG definitions
     for Cisco IOS-XR aaa-lib package configuration.

     This module contains definitions
     for the following management objects:
       aaa: Authentication, Authorization and Accounting

     Copyright (c) 2013-2019 by Cisco Systems, Inc.
     All rights reserved.";

  revision "2019-04-05" {
    description
      "Establish semantic version baseline.";
    semver:module-version "1.0.0";
  }

  revision "2017-11-14" {
    description
      "Modified Accounting method to support local accounting as syslog";
  }

  revision "2017-05-01" {
    description
      "Fixing backward compatibility error in module.";
  }

  revision "2015-11-09" {
    description
      "IOS XR 6.0 revision.";
  }


  container aaa {
    description "Authentication, Authorization and Accounting";

    container accountings {
      description "AAA accounting";

      list accounting {
        key "type listname";
        description "Configurations related to accounting";
        leaf type {
          type xr:Cisco-ios-xr-string;
          description
            "exec:Account exec sessions, commands: Account
            CLI commands";
        }
        leaf listname {
          type xr:Cisco-ios-xr-string;
          description "Named accounting list";
        }
        leaf rp-failover {
          type dt1:Aaa-accounting-rp-failover;
          description "rpfailover";
        }
        leaf broadcast {
          type dt1:Aaa-accounting-broadcast;
          description "Broadcast";
        }
        leaf type-xr {
          type dt1:Aaa-accounting;
          description "Stop only/Start Stop";
        }
        leaf method1 {
          type dt1:Aaa-method-accounting;
          description "Method Type";
        }
        leaf method2 {
          type dt1:Aaa-method-accounting;
          description "Method Type";
        }
        leaf method3 {
          type dt1:Aaa-method-accounting;
          description "Method Type";
        }
        leaf method4 {
          type dt1:Aaa-method-accounting;
          description "Method Type";
        }
        leaf server-group-name1 {
          type string;
          description "Server group name";
        }
        leaf server-group-name2 {
          type string;
          description "Server group name";
        }
        leaf server-group-name3 {
          type string;
          description "Server group name";
        }
        leaf server-group-name4 {
          type string;
          description "Server group name";
        }
      }
    }

    container authorizations {
      description "AAA authorization";

      list authorization {
        key "type listname";
        description "Configurations related to authorization";
        leaf type {
          type xr:Cisco-ios-xr-string;
          description
            "network: Authorize IKE requests, commands:
            Authorize CLI commands";
        }
        leaf listname {
          type xr:Cisco-ios-xr-string;
          description "List name for AAA authorization";
        }
        leaf method1 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf method2 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf method3 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf method4 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf server-group-name1 {
          type string;
          description "Server group name";
        }
        leaf server-group-name2 {
          type string;
          description "Server group name";
        }
        leaf server-group-name3 {
          type string;
          description "Server group name";
        }
        leaf server-group-name4 {
          type string;
          description "Server group name";
        }
      }
    }

    container accounting-update {
      presence "Indicates a accounting-update node is configured.";
      description "Configuration related to 'update' accounting";
      leaf type {
        type dt1:Aaa-accounting-update;
        mandatory true;
        description "newinfo/periodic";
      }
      leaf periodic-interval {
        type uint32 {
          range "0..35791394";
        }
        units "minute";
        description "Periodic update interval in minutes";
      }
    }

    container banner {
      description "AAA banner";
      leaf login {
        type string;
        description "AAA login banner";
      }
    }

    container authentications {
      description "AAA authentication";

      list authentication {
        key "type listname";
        description "Configurations related to authentication";
        leaf type {
          type xr:Cisco-ios-xr-string;
          description
            "login: Authenticate login sessions, ppp:
            Authenticate ppp sessions";
        }
        leaf listname {
          type xr:Cisco-ios-xr-string;
          description "List name for AAA authentication";
        }
        leaf method1 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf method2 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf method3 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf method4 {
          type dt1:Aaa-method;
          description "Method Type";
        }
        leaf server-group-name1 {
          type string;
          description "Server group name";
        }
        leaf server-group-name2 {
          type string;
          description "Server group name";
        }
        leaf server-group-name3 {
          type string;
          description "Server group name";
        }
        leaf server-group-name4 {
          type string;
          description "Server group name";
        }
      }
    }
  }
}
</data>
</get-schema>

YDK automation moved this from To do to Done Sep 11, 2019
ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
YDK
  
Done
Development

No branches or pull requests

2 participants