cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
889
Views
0
Helpful
0
Replies

Enum changes in YDK 0.4.0

saalvare
Cisco Employee
Cisco Employee

YDK 0.4.0 introduced a couple of changes to enums that are not backward compatible with YDK 0.3.0.  First, the new enum implementation is based on the enum34 module.  This module backports the enum implementation in Python 3.4 to Python 2.4 and later.  Second, enum class names do not use underscores anymore.  These changes make our enum class easier to use and their names more pythonic.

Let's take a look at the Cisco_IOS_XR_clns_isis_cfg model used to configure the IS-IS protocol.  That model makes frequent use of enums.  As an example, let's compare the enum class used to configure the level associated with an adjacency

YDK 0.3.0

Class name: IsisConfigurableLevels_Enum

YDK 0.4.0

Class name: IsisConfigurableLevelsEnum

More importantly, it's now simpler to access the value and name of an enum.  The isis.instances.instance.is_type attribute/leaf is an object of the IsisConfigurableLevelsEnum class.  You can access its attributes using:

isis.instances.instance.is_type.name

Isis.Instances.Instance.is_type.value

This change also paves the road to support Python 3 in the future.

Happy coding!

0 Replies 0
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: