ConfD User Community

Key reference of leaf inside container


#1

i have below list for interfaces; if i use key as description; it works fine. But I want that as soon new list is open; it should ask for the interface-choice…yang model is given below;
is this possible?

list interfaces {
        key "description";
  leaf description
        {
        type string {
        length "0..240";
      }
     }
container Choice{
choice interface-choice {
case GigabitEthernet {
  leaf GigabitEthernet {
        type string {
          pattern '[0-9]+.*';
         }
  }
    leaf GigabitEthernet-Description {
      type string {
        length "0..240";
			}
		}    
	}
case TenGigabitEthernet {
        leaf TenGigabitEthernet {
        type string {
        pattern '[0-9]+.*';
         }
        }
    leaf TenGigabitEthernet-Description {
      type string {
        length "0..240";
  }	} } } } }

#2

You may try to play with CLI annotations (tailf:cli-prefix-key) and data model structure. I do not think you can achieve desired behavior if you keep container Choice. Perhaps something like this is similar to what you need:

list interfaces {
    key "description";
    leaf description
    {
      type string {
        length "0..240";
      }
    }
    choice interface-choice {
      case GigabitEthernet {
        leaf GigabitEthernet {
          tailf:cli-prefix-key;
          mandatory true;
          type string {
            pattern '[0-9]+.*';
          }
        }
      }
      case TenGigabitEthernet {
        leaf TenGigabitEthernet {
          tailf:cli-prefix-key;
          mandatory true;
          type string {
            pattern '[0-9]+.*';
          }
        }
      }
    }
  }

This is relatively complicated CLI related question (put of ConfD Basic scope), it may be good idea to contact Tail-f directly.