Tailf:code-name on enumerations

I have e yang model with conflicting names, the draft for l1topology has two enumerations admin-status and oper-status with a enum “down” which causes a conflict and confdc will not generate them.

I edited the yang model and added tailf:code-name to the enum “down”

      enum "down" {
        description "not available";
        tailf:code-name "down1";
      }

and that worked fine but then I tried to use tailf:annotate to put the change in a annotation file but I could not figure out how to write the xpath…

tailf:annotate “/nd:networks/nd:network/nd:node/l1topo:l1-node-attributes/l1topo:oper-status/XXX/YYY” {
tailf:code-name “down1”;
}

leaf oper-status {
type enumeration {
enum “unknown” {
description “unknown - lost connect with control
plane.”;
}
enum “up” {
description “normal”;
}
enum “down” {
description “not available”;
}
}

    config false;
    description "operational status of a node";
  }
}

Without your full YANG model, it is slightly more difficult to comment on how to do it for your specific case. However, following is a simple example that should illustrate the point of how to do it:

$ ls *.yang
enum-ann.yang       enum.yang
$ cat *.yang
module enum-ann {
  namespace "urn:dummy";
  prefix "dummy";

  import tailf-common {
    prefix tailf;
  }

  tailf:annotate-module "enum" {
    tailf:annotate-statement leaf[name='d'] {
      tailf:code-name "my-d";
    }
  }

}
module enum {
  namespace "urn:enum";
  prefix "e";

  import tailf-common {
    prefix tailf;
  }

  typedef e {
    type enumeration {
      enum a;
      enum b;
    }
  }

  leaf d {
    type enumeration {
      enum c {
        value 3;
      }
      enum d ;
    }
  }
}

My previous example only applied code-name to the leaf element named d. In order to assign a new code-name to the enum named d, the following is a better example:

$ cat *.yang
module enum-ann {
    namespace "urn:dummy";
    prefix "dummy";

  import tailf-common {
    prefix tailf;
  }

  tailf:annotate-module "enum" {
    tailf:annotate-statement leaf[name='d'] {
      tailf:annotate-statement type[name='enumeration'] {
        tailf:annotate-statement enum[name='d'] {
          tailf:code-name "my-d";
        }
      }
    }
  }

}
module enum {
    namespace "urn:enum";
    prefix "e";

  import tailf-common {
    prefix tailf;
  }


  typedef e {
    type enumeration {
      enum a;
      enum b;
    }
  }

  leaf d {
    type enumeration {
      enum c {
        value 3;
      }
      enum d {
        value 4;
      }
    }
  }
}
1 Like

Thanks,
This was exactly what I was looking for.