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

YDK api generation failed when list key is enum #475

Closed
traveldan88 opened this issue Jun 12, 2017 · 1 comment
Closed

YDK api generation failed when list key is enum #475

traveldan88 opened this issue Jun 12, 2017 · 1 comment

Comments

@traveldan88
Copy link

traveldan88 commented Jun 12, 2017

I tried to use YDK to generate python API from latest opencfg isis yang model. When I try to generate the yang model api, ydk hit an error on the isis openconfig yang model:

  ./generate.py -p --bundle profiles/bundles/ocni_0_1_2.json
 
    ocni_0_1_2.json is the file I created locally which tries to compile openconfig network instance model which includes isis, bgp, mpls, etc. This is the model google required us to implemented.
 
Error(s) occurred in YdkGenerator()!
Cross resolution of enum failed for openconfig_network_instance.NetworkInstances.NetworkInstance.Protocols.Protocol.Isis.Levels.Level.LinkStateDatabase.Lsp.Tlvs.Tlv.RouterCapabilities.RouterCapability.Subtlvs.Subtlv.SegmentRoutingAlgorithms.SegmentRoutingAlgorithm.algorithm

ISIS lspdb segment routing algorithm is defined as ENUM and it’s used as key for a list, it appears YDK could not allow this to happen, if I change the opencfg isis yang model and change for segment routing algorthm from enum to uint8, then ydk generation is ok.

In this case, opencfg isis yang model defintion seems to be valid, I think this is probably a YDK bug which can’t handle a list key if it’s of enum type.

Here is the relevant defintion for segment algorithm which generates this error, which is defined in openconfig-isis-lsp.yang:

    container segment-routing-algorithms {
                  when "../state/type = " +
                       "'oc-isis-lsdb-types:ROUTER_CAPABILITY_SR_ALGORITHM'" {
                    description
                      "Only include segment routing algorithm when the
                      sub-TLV is type 19.";
                  }
                  description
                    "This container defines SR algorithm sub-TLV 19.";
 
                  reference
                    "draft-ietf-isis-segment-routing-extensions.
                     TLV 242, sub-TLV 19";
 
                  list segment-routing-algorithm {
                    key "algorithm";
 
                    description
                      "List of the segment routing algorithsm advertised within the TLV.";
 
                    leaf algorithm {
                      type leafref {
                        path "../state/algorithm";
                      }
                      description
                        "Reference to the SR algorithm that the subTLV
                        describes.";
                    }
 
                    container state {
                      description
                        "State parameters of sub-TLV 19 - Segment
                        Routing Algorithm.";
 
                      leaf algorithm {
type enumeration {
                          enum SPF {
                            value 0;
                            description
                              "Shortest Path First (SPF) algorithm based
                              on link metric.  This is the well-known
                              shortest path algorithm as computed by
                              the IS-IS Decision process.  Consistent
                              with the deployed practice for link-
                              state protocols, algorithm 0 permits any
                              node to overwrite the SPF
                              path with a different path based on local
                              policy.";
                          }
                          enum STRICT_SPF {
                            value 1;
                            description
                              "Strict Shortest Path First (SPF)
                              algorithm based on link metric. The
                              algorithm is identical to algorithm 0 but
                              algorithm 1 requires that all nodes
                              along the path will honor the SPF routing
                              decision. Local policy MUST NOT alter the
                              forwarding decision computed by algorithm
                              1 at the node claiming to support
                              algorithm 1.";
                          }
                        }
                        description
                          "The Segment Routing algorithm that is described
                          by the TLV.";
                      }
                    }
                  }
                }

If I changed the algorithm from enum to uint8, then everything worked, this looks like an error on the ydk side. Could you please look into this issue and fixed the problem?

There’s another issue in the ydk generate.py, if I use –v option, when it hits this error, it doesn't print out the detailed error message. The code in ydk generate.py is as follows:

        except YdkGenException as e:
                print('Error(s) occurred in YdkGenerator()!')
                if not options.verbose:
                     print(e.msg)
        sys.exit(1)

So if –v is used, the script will not print detailed error messge, which is very counter-intuitive. I think in this case, the if statement shall be removed and we shall always report the YDK excpetion errors. It tooke me a while to figure out what is wrong and remove the if check when ydk hits this enum error.

@ghost ghost added bug bundle labels Jun 12, 2017
@ghost
Copy link

ghost commented Aug 7, 2017

Same issue occurs with openconfig-network-instance.yang

@ghost ghost closed this as completed in #517 Aug 10, 2017
ghost pushed a commit that referenced this issue Aug 10, 2017
* Fix more documentation and fix cpp bundle compile issues

 * Fix all dependency models not being copied to bundle repository

* Codacy

* Fix api generation for leafref pointing to embedded enum

 * Fixes #475
This issue was closed.
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