Skip to content

Commit

Permalink
Resolved issue #916
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik authored and Abhi Keshav committed May 15, 2019
1 parent d40f811 commit e133c3d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Memory leaks in YDK C++ gNMI Service component ([#902](https://github.com/CiscoDevNet/ydk-gen/issues/902))
* RPC execution stuck when NETCONF server closes session unexpectedly ([#914](https://github.com/CiscoDevNet/ydk-gen/issues/914))
* YDK attempting to send Commit command when 'writable-running' in capabilities ([#915](https://github.com/CiscoDevNet/ydk-gen/issues/915))
* Max value of range is set to None when not specified in the Yang model ([#916](https://github.com/CiscoDevNet/ydk-gen/issues/916))

##### Note
The solution for GitHub issue ([#891](https://github.com/CiscoDevNet/ydk-gen/issues/891)) changed model API. However all model bundles generated with YDK-Gen version 0.7.3 and later are still compatible with core YDK components.
Expand Down
4 changes: 3 additions & 1 deletion sdk/cpp/core/tests/models/ydktest-sanity@2015-11-17.yang
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ module ydktest-sanity {

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

leaf number64 {
Expand Down
1 change: 1 addition & 0 deletions sdk/python/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* YDK-Py docker container does not support Python3 ([#905](https://github.com/CiscoDevNet/ydk-gen/issues/905))
* Installation documentation for YDK-Py needs an update ([#906](https://github.com/CiscoDevNet/ydk-gen/issues/906))
* README file for YDK-Py repo is not rendering correctly ([#907](https://github.com/CiscoDevNet/ydk-gen/issues/907))
* Max value of range is set to None when not specified in the Yang model ([#916](https://github.com/CiscoDevNet/ydk-gen/issues/916))

##### Note
The solution for GitHub issue ([#891](https://github.com/CiscoDevNet/ydk-gen/issues/891)) changed model API. However all model bundles generated with YDK-Gen version 0.7.3 and later are still compatible with core YDK components.
Expand Down
50 changes: 31 additions & 19 deletions ydkgen/printer/meta_data_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,13 @@ def get_meta_info_data(prop, property_type, type_stmt, language, identity_subcla
meta_info_data.doc_link += get_primitive_type_tag('bool', language)
elif isinstance(type_spec, Decimal64TypeSpec):
meta_info_data.ptype = 'Decimal64'
lower = str(type_spec.min.s)
if type_spec.max is not None:
upper = str(type_spec.max.s)
else:
upper = lower
meta_info_data.prange.append(
('%s' % str(type_spec.min.s), '%s' % str(type_spec.max.s)))
('%s' % lower, '%s' % upper))
meta_info_data.doc_link += get_primitive_type_tag('Decimal64', language)
elif isinstance(type_spec, EmptyTypeSpec):
meta_info_data.ptype = 'Empty'
Expand All @@ -347,7 +352,10 @@ def get_meta_info_data(prop, property_type, type_stmt, language, identity_subcla
meta_info_data.ptype = 'int'
meta_info_data.doc_link += meta_info_data.ptype
lower = str(type_spec.min)
upper = str(type_spec.max)
if type_spec.max is not None:
upper = str(type_spec.max)
else:
upper = lower
meta_info_data.prange.append((lower, upper))
elif isinstance(type_spec, LengthTypeSpec):
meta_info_data.ptype = 'str'
Expand Down Expand Up @@ -429,20 +437,22 @@ def _get_identity_docstring(identity_subclasses, property_type, language):


def get_length_limits(length_type):
assert isinstance(length_type, LengthTypeSpec)
prange = []
if isinstance(length_type, LengthTypeSpec):
for m_min, m_max in length_type.lengths:
pmin = None
pmax = None
if m_min == 'min':
pmin = '0'
else:
pmin = m_min
if m_max == 'max':
pmax = '18446744073709551615'
else:
pmax = m_max
prange.append((pmin, pmax))
for m_min, m_max in length_type.lengths:
pmin = None
pmax = None
if m_min == 'min':
pmin = '0'
else:
pmin = m_min
if m_max == 'max':
pmax = '18446744073709551615'
elif m_max is not None:
pmax = m_max
else:
pmax = pmin
prange.append((pmin, pmax))
return prange


Expand All @@ -461,9 +471,10 @@ def get_range_limits(range_type):

if m_max == 'max':
pmax = range_type.base.max
elif m_max is not None:
pmax = m_max
else:
if m_max is not None:
pmax = m_max
pmax = pmin
if types.yang_type_specs['uint64'].max == pmax:
prange.append((str(pmin), str(pmax)))
prange.append((str(pmin), str(pmax)))
Expand All @@ -478,9 +489,10 @@ def get_range_limits(range_type):
pmin = str(m_min)
if m_max == 'max':
pmax = range_type.base.max.s
elif m_max is not None:
pmax = str(m_max)
else:
if m_max is not None:
pmax = str(m_max)
pmax = pmin
prange.append(('%s' % str(pmin), '%s' % str(pmax)))
return prange

Expand Down

0 comments on commit e133c3d

Please sign in to comment.