You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
* 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
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:
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:
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:
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.
The text was updated successfully, but these errors were encountered: