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

Issue with encoding protocol enum #566

Closed
ghost opened this issue Sep 21, 2017 · 1 comment
Closed

Issue with encoding protocol enum #566

ghost opened this issue Sep 21, 2017 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Sep 21, 2017

      from ydk.models.cisco_ios_xr import Cisco_IOS_XR_telemetry_model_driven_cfg as teleconfig

       encode_enum = teleconfig.EncodeType()
       protocol_enum = teleconfig.ProtoType()
       telemetry = teleconfig.TelemetryModelDriven()
       dstgrps = telemetry.DestinationGroups()
#DestinationGroup  
       dstgrp = dstgrps.DestinationGroup()
       ip4dstns = dstgrp.Ipv4Destinations()
       ip6dstns = dstgrp.Ipv6Destinations()

       ip4dstn = ip4dstns.Ipv4Destination()
       ip6dstn = ip6dstns.Ipv6Destination()

       proto4 = ip4dstn.Protocol()
       proto6 = ip6dstn.Protocol()

       proto4.no_tls = 1
       proto4.packetsize = 1500
       proto4.protocol = protocol_enum.tcp
       proto4.tls_hostname = "nexus_router"

       proto6.no_tls = 2
       proto6.packetsize = 2000
       proto6.protocol = protocol_enum.tcp
       proto6.tls_hostname = "nexus_router"

       ip4dstn.ipv4_address = "10.10.10.10"
       ip4dstn.destination_port = 4000
       ip4dstn.encoding = encode_enum.gpb
       ip4dstn.protocol = proto4

       ip6dstn.ipv6_address = "10::10"
       ip6dstn.destination_port = 4000
       ip6dstn.encoding = encode_enum.gpb
       ip6dstn.protocol = proto6

       ip4dstns.ipv4_destination.append(ip4dstn)
       ip6dstns.ipv6_destination.append(ip6dstn)
       dstgrp.destination_id = "groupvlan"
       dstgrp.ipv4_destinations = ip4dstns
       dstgrp.ipv6_destinations = ip6dstns
       dstgrp.vrf = "test_config"
       dstgrps.destination_group.append(dstgrp)

#SensorGroups
       sensorgrps = telemetry.SensorGroups()

       sensorgrp = sensorgrps.SensorGroup()
       sensorpaths = sensorgrp.SensorPaths()
       sensorpath = sensorpaths.SensorPath()

       sensorpath.telemetry_sensor_path = "/asa/bin"

       sensorpaths.sensor_path.append(sensorpath)
       sensorgrp.sensor_group_identifier = "nexus_router"
       sensorgrp.sensor_paths = sensorpaths
       sensorgrps.sensor_group.append(sensorgrp)
#Subscriptions
       subscrips = telemetry.Subscriptions()
       subscrip = subscrips.Subscription()

       dstprofiles = subscrip.DestinationProfiles()
       dstprofile = dstprofiles.DestinationProfile()

       dstprofile.destination_id = "groupvlan"
       dstprofiles.destination_profile.append(dstprofile)

       sensorprofiles = subscrip.SensorProfiles()
       sensorprofile = sensorprofiles.SensorProfile()

       sensorprofile.sensorgroupid = "nexus_group"
       sensorprofile.sample_interval = 1000
       sensorprofiles.sensor_profile.append(sensorprofile)
       subscrip.subscription_identifier = "nexus_router"
       subscrip.destination_profiles = dstprofiles
       subscrip.sensor_profiles = sensorprofiles
       subscrip.source_interface = "GigabitEthernet0/0/0/0"

       telemetry.destination_groups = dstgrps
       telemetry.sensor_groups = sensorgrps
       telemetry.subscriptions = subscrips

      crud_service.create(provider,telemetry)

Ydk is missing addition of a field:

          <protocol>
            <no-tls>1</no-tls>
            <packetsize>1500</packetsize>
            <tls-hostname>nexus_router</tls-hostname>
          </protocol>

It should be :

          <protocol>
            <protocol>tcp</protocol>
            <no-tls>1</no-tls>
            <packetsize>1500</packetsize>
            <tls-hostname>nexus_router</tls-hostname>
          </protocol>
====================================================================================
|   RPC request and Reply (Complete XML)                                           |
====================================================================================

  <destination-groups>
    <destination-group>
      <destination-id>groupvlan</destination-id>
      <vrf>test_config</vrf>
      <ipv4-destinations>
        <ipv4-destination>
          <ipv4-address>10.10.10.10</ipv4-address>
          <destination-port>4000</destination-port>
          <encoding>gpb</encoding>
          <protocol>
            <no-tls>1</no-tls>
            <packetsize>1500</packetsize>
            <tls-hostname>nexus_router</tls-hostname>
          </protocol>
        </ipv4-destination>
      </ipv4-destinations>
      <ipv6-destinations>
        <ipv6-destination>
          <ipv6-address>10::10</ipv6-address>
          <destination-port>4000</destination-port>
          <encoding>gpb</encoding>
          <protocol>
            <no-tls>2</no-tls>
            <packetsize>2000</packetsize>
            <tls-hostname>nexus_router</tls-hostname>
          </protocol>
        </ipv6-destination>
      </ipv6-destinations>
    </destination-group>
  </destination-groups>
  <sensor-groups>
    <sensor-group>
      <sensor-group-identifier>nexus_router</sensor-group-identifier>
      <sensor-paths>
        <sensor-path>
          <telemetry-sensor-path>/asa/bin</telemetry-sensor-path>
        </sensor-path>
      </sensor-paths>
    </sensor-group>
  </sensor-groups>
</telemetry-model-driven>
' in 'edit-config'
DEBUG:ydk:Performing encode operation on XML
INFO:ydk:=============Generating payload to send to device=============
INFO:ydk:<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <target>
    <candidate/>
  </target>
  <error-option>rollback-on-error</error-option>
  <config><telemetry-model-driven xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-telemetry-model-driven-cfg" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
  <destination-groups>
    <destination-group>
      <destination-id>groupvlan</destination-id>
      <vrf>test_config</vrf>
      <ipv4-destinations>
        <ipv4-destination>
          <ipv4-address>10.10.10.10</ipv4-address>
          <destination-port>4000</destination-port>
          <encoding>gpb</encoding>
          <protocol>
            <no-tls>1</no-tls>
            <packetsize>1500</packetsize>
            <tls-hostname>nexus_router</tls-hostname>
          </protocol>
        </ipv4-destination>
      </ipv4-destinations>
      <ipv6-destinations>
        <ipv6-destination>
          <ipv6-address>10::10</ipv6-address>
          <destination-port>4000</destination-port>
          <encoding>gpb</encoding>
          <protocol>
            <no-tls>2</no-tls>
            <packetsize>2000</packetsize>
            <tls-hostname>nexus_router</tls-hostname>
          </protocol>
        </ipv6-destination>
      </ipv6-destinations>
    </destination-group>
  </destination-groups>
  <sensor-groups>
    <sensor-group>
      <sensor-group-identifier>nexus_router</sensor-group-identifier>
      <sensor-paths>
        <sensor-path>
          <telemetry-sensor-path>/asa/bin</telemetry-sensor-path>
        </sensor-path>
      </sensor-paths>
    </sensor-group>
  </sensor-groups>
</telemetry-model-driven>
</config>
</edit-config>
</rpc>
INFO:ydk:

DEBUG:ydk:libnetconf TRACE: Missing message-id in rpc.
DEBUG:ydk:libnetconf TRACE: Writing message (session 4055394660): <?xml version="1.0"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <edit-config>
    <target>
      <candidate/>
    </target>
    <error-option>rollback-on-error</error-option>
    <config>
      <telemetry-model-driven xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-telemetry-model-driven-cfg" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
        <destination-groups>
          <destination-group>
            <destination-id>groupvlan</destination-id>
            <vrf>test_config</vrf>
            <ipv4-destinations>
              <ipv4-destination>
                <ipv4-address>10.10.10.10</ipv4-address>
                <destination-port>4000</destination-port>
                <encoding>gpb</encoding>
                <protocol>
                  <no-tls>1</no-tls>
                  <packetsize>1500</packetsize>
                  <tls-hostname>nexus_router</tls-hostname>
                </protocol>
              </ipv4-destination>
            </ipv4-destinations>
            <ipv6-destinations>
              <ipv6-destination>
                <ipv6-address>10::10</ipv6-address>
                <destination-port>4000</destination-port>
                <encoding>gpb</encoding>
                <protocol>
                  <no-tls>2</no-tls>
                  <packetsize>2000</packetsize>
                  <tls-hostname>nexus_router</tls-hostname>
                </protocol>
              </ipv6-destination>
            </ipv6-destinations>
          </destination-group>
        </destination-groups>
        <sensor-groups>
          <sensor-group>
            <sensor-group-identifier>nexus_router</sensor-group-identifier>
            <sensor-paths>
              <sensor-path>
                <telemetry-sensor-path>/asa/bin</telemetry-sensor-path>
              </sensor-path>
            </sensor-paths>
          </sensor-group>
        </sensor-groups>
      </telemetry-model-driven>
    </config>
  </edit-config>
</rpc>

DEBUG:ydk:libnetconf TRACE: Received message (session 4055394660): <?xml version="1.0"?>
<rpc-reply message-id="2" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
 <rpc-error>
  <error-type>protocol</error-type>
  <error-tag>missing-element</error-tag>
  <error-severity>error</error-severity>
  <error-path xmlns:ns1="http://cisco.com/ns/yang/Cisco-IOS-XR-telemetry-model-driven-cfg">ns1:telemetry-model-driven/ns1:destination-groups/ns1:destination-group[destination-id = 'groupvlan']/ns1:ipv6-destinations/ns1:ipv6-destination[ipv6-address = '10::10' and destination-port = '4000']/ns1:protocol/ns1:protocol</error-path>
  <error-info>
   <bad-element>protocol</bad-element>
   <error-message>mandatory leaf missing from request, please add it and try again.</error-message>
  </error-info>
 </rpc-error>
 <rpc-error>
  <error-type>protocol</error-type>
  <error-tag>missing-element</error-tag>
  <error-severity>error</error-severity>
  <error-path xmlns:ns1="http://cisco.com/ns/yang/Cisco-IOS-XR-telemetry-model-driven-cfg">ns1:telemetry-model-driven/ns1:destination-groups/ns1:destination-group[destination-id = 'groupvlan']/ns1:ipv4-destinations/ns1:ipv4-destination[ipv4-address = '10.10.10.10' and destination-port = '4000']/ns1:protocol/ns1:protocol</error-path>
  <error-info>
   <bad-element>protocol</bad-element>
   <error-message>mandatory leaf missing from request, please add it and try again.</error-message>
  </error-info>
 </rpc-error>
</rpc-reply>
@ghost ghost added the bug label Sep 21, 2017
@ghost
Copy link
Author

ghost commented Oct 12, 2017

<?xml version="1.0"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="6">
  <edit-config>
    <target>
      <candidate/>
    </target>
    <error-option>rollback-on-error</error-option>
    <config>
      <telemetry-model-driven xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-telemetry-model-driven-cfg" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
        <destination-groups>
          <destination-group>
            <destination-id>groupvlan</destination-id>
            <vrf>test_config</vrf>
            <ipv4-destinations>
              <ipv4-destination>
                <ipv4-address>10.10.10.10</ipv4-address>
                <destination-port>4000</destination-port>
                <encoding>gpb</encoding>
                <protocol>
                  <packetsize>1500</packetsize>
                  <tls-hostname>nexus_router</tls-hostname>
                  <protocol>tcp</protocol>
                  <no-tls>1</no-tls>
                </protocol>
              </ipv4-destination>
            </ipv4-destinations>
            <ipv6-destinations>
              <ipv6-destination>
                <ipv6-address>10::10</ipv6-address>
                <destination-port>4000</destination-port>
                <encoding>gpb</encoding>
                <protocol>
                  <packetsize>2000</packetsize>
                  <tls-hostname>nexus_router</tls-hostname>
                  <protocol>tcp</protocol>
                  <no-tls>2</no-tls>
                </protocol>
              </ipv6-destination>
            </ipv6-destinations>
          </destination-group>
        </destination-groups>
        <sensor-groups>
          <sensor-group>
            <sensor-group-identifier>nexus_router</sensor-group-identifier>
            <sensor-paths>
              <sensor-path>
                <telemetry-sensor-path>/asa/bin</telemetry-sensor-path>
              </sensor-path>
            </sensor-paths>
          </sensor-group>
        </sensor-groups>
      </telemetry-model-driven>
    </config>
  </edit-config>
</rpc>

This has been fixed in the latest ydk-gen master branch. Now, the correct payload is produced.

In the next release of YDK, they will be packaged into libydk and ydk-py.
In the meanwhile, you can always use the steps in the ydk-gen README to generate/install libydk, python core and bundles containing these fixes:
https://github.com/CiscoDevNet/ydk-gen#installation
https://github.com/CiscoDevNet/ydk-gen#second-step-generate--install-the-core

@ghost ghost closed this as completed Oct 12, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants