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
Class name: IsisConfigurableLevels_Enum
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:
This change also paves the road to support Python 3 in the future.