0

I would like to assign different default value to a leaf according to type of key the list entries take. as an example, although not correct:

typedef type-id {
    type enumeration {
      enum a{
        value 1;
      }
      enum b{
        value 2;
      }
      enum c{
        value 3;
      }
    }
}
list domain {
    key id;
    leaf id {
      type type-id;
    }
leaf my-leaf {
      when "../id = 'a'"{
        default 10;
      }
      when "../id = 'b'"{
        default 20;
      }
      when "../id = 'c'"{
        default 20;
      }
    }
}

So let say there are two entries for the list and the corresponding keys are 'a' and 'c' When I walk through the model I would like to have values as

domain   id   my-leaf

         'a'    10
         'c'    30

Which expression is the best solution for this purpose? How can I model such a structure?

yogi
  • 107
  • 1
  • 9
  • Possible duplicate of [Conditional assignment of default values in yang](https://stackoverflow.com/questions/35907872/conditional-assignment-of-default-values-in-yang) – predi Jun 27 '18 at 12:38
  • the solution provided not directly covering the question I think because I would like to make comparison with respect to the key value – yogi Jun 27 '18 at 12:58
  • 1
    It does not matter what the condition is (in your example a key comparison) - you are still trying to conditionally assign a default value, which cannot be done. – predi Jun 27 '18 at 13:11

0 Answers0