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

Max value of range is set to None when not specified in the Yang model #916

Closed
ygorelik opened this issue Apr 25, 2019 · 1 comment
Closed
Assignees

Comments

@ygorelik
Copy link
Collaborator

ygorelik commented Apr 25, 2019

Reported by Leon Xu leoxu@cisco.com

Expected Behavior

When leaf node defines int type and range contains single value it should appear in the YDK generated metadata as a range with the same value for min and max.

Current Behavior

When leaf node defines int type and range contains single value the max value in metadata appears as None. Example:

_Cisco_IOS_XR_sysadmin_sm.py:                [('0', 'None')], [], 

This creates error conditions in Python runtime:

## From Yang file ##
container label {
description "Label properties";
container range {
description "Label range";
list table {
key "table-index";
description "Specify label table";
leaf table-index {
type uint32 {
range "0" {
description "Label table index";
}
}
description "Label table index";
}
 
## From YDK py file ##
class Table(object):
"""
Specify label table

.. attribute:: table_index <key>

Label table index
**type**\: int

**range:** 0..None
 
 
## Template file ##
  - iosxr:
      ydk_service_operators:
      - create
      - delete
      modes:
      - positive
      - positive
      num_operations: 1
      triggers: []
      enable_triggers: false
      sleep: 10
      failed_reason: []
      verify_cli_cmds: []
      config_paths:
      - feature: mpls_lsd
        parent: table_cfg
        path: $table_cfg
        ydk_internal_operator: ''
        leaf_dict:
          table_index:
            type: int
            ytype: uint32
            range:
            - 0
            - None
            values:
            - 0
          maximum_label:
            type: int
            ytype: uint32
            range:
            - 16000
            - 1048575
            values:
            - 959517
          minimum_label:
            type: int
            ytype: uint32
            range:
            - 16000
            - 1048575
            values:
            - 900583
 
2975: ##
2976: [host 64.104.148.26 session-id 3367002746] Received:
2977: <?xml version="1.0"?>
2978: <rpc-reply message-id="urn:uuid:4c2aeada-47e4-4d3c-9acb-4488ccb416ff" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
2979: <ok/>
2980: </rpc-reply>
2981: 
2982: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4c2aeada-47e4-4d3c-9acb-4488ccb416ff">
2983: <ok/>
2984: </rpc-reply>
2985: Executor operation completed
2986: CREATE operation initiated
2987: CREATE operation completed
2988: Failed reason: Mpls.Label.Range.Table_test: Mpls.Label.Range.Table_test: create:crud failed due to invalid literal for int() with base 10: 'None'
2989: The result of section test is => FAILED

System Information

YDK-0.5.5 and 0.8.2

ygorelik pushed a commit that referenced this issue Apr 26, 2019
ygorelik pushed a commit that referenced this issue Apr 26, 2019
@ygorelik ygorelik self-assigned this Apr 26, 2019
@ygorelik
Copy link
Collaborator Author

Resolved to YDK-0.5.5 and 0.8.2.

Here is an example of how the bug was resolved.

Yang model

        leaf number32 {
          description "integer value type";
          type int32 {
            range "min..0 | 19 | 1000..max";
          }
        }

Metadata before

            _MetaInfoClassMember('number32', ATTRIBUTE, 'int', 'int32', None, None, 
                [('-2147483648', '0'), ('19', 'None'), ('1000', '2147483647')], [], 
                '''                integer value type
                ''',
                'number32',
                'ydktest-sanity', False),

Metadata after the fix is applied

            _MetaInfoClassMember('number32', ATTRIBUTE, 'int', 'int32', None, None, 
                [('-2147483648', '0'), ('19', '19'), ('1000', '2147483647')], [], 
                '''                integer value type
                ''',
                'number32',
                'ydktest-sanity', False),

Note the change for range upper value '19' versus 'None'.

ygorelik pushed a commit that referenced this issue Apr 26, 2019
ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue May 2, 2019
ghost pushed a commit that referenced this issue May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant