ConfD User Community

Usage of unique statement


#1

Hello,

I would like to have an array of IS-IS protocols under control-plane-protocols:
For example:
ISIS
ISIS-1
ISIS-2

ISIS-5

and use the current definition of ietf-isis.yang for each one of the instances.

My idea was to call isis several times from control-plane-protocols and keep a counting attribute to distinguish between the instances.

I tried to do the following and got pyang failure.

augment "/rt:routing/rt:control-plane-protocols/"
  +"rt:control-plane-protocol/isis:isis" { 
   leaf isis-protocol-instance {
	  type uint16 {
			range "0..5" ;
		} 
	}
}

deviation "/rt:routing/rt:control-plane-protocols/"
  +"rt:control-plane-protocol" { 
   deviate add {
		unique "name isis-protocol-instance";
	}
		
}

pyange error: “the identifier “isis-protocol-instance” in the unique argument does not reference an existing container”

I tried to use the following syntax and also failed but when using MGSOFT Explorer I don’t get errors
deviation “/rt:routing/rt:control-plane-protocols/”
+“rt:control-plane-protocol” {
deviate add {
unique “isis/isis-protocol-instance”;
}

}

If there is another way to provide a solution please let me know.

Regards
Orly


#2

That’s a really weird error message:-) - it should presumably say “leaf”, not “container”. This is probably not the best place to look for pyang support (out of curiosity, why are you using it?), but using confdc, you should (unless you’re using an ancient version) instead get an error like the node 'isis-protocol-instance' from module 'ietf-routing' (in node 'control-plane-protocol' from 'ietf-routing') is not found. Maybe not a whole lot better, but at least it avoids claiming that isis-protocol-instance should be a container:-) - and gives an important hint: 'isis-protocol-instance' from module 'ietf-routing'.

I.e. your unique statement is interpreted in the context of the deviated module - just as if it had actually been defined in ietf-routing. And in that context, isis-protocol-instance must be prefixed with the prefix of the module where it is defined, i.e. the module you are quoting the augment statement from. And there is an additional problem, that you’re already on to: isis-protocol-instance is not a child of the control-plane-protocol list, but of the ‘isis’ container augmented from ietf-isis, which thus needs to be included in the unique argument - i.e. it should be

unique "name isis:isis/<your-module-prefix>:isis-protocol-instance";`

Then confdc gives you a brand new error: deviation causes circular dependency between ietf-isis.yang and ./ietf-routing.yang - and it’s true: ietf-isis depends on ietf-routing since it augments ietf-routing, and your unique statement makes ietf-routing depend on ietf-isis, since it references a node from ietf-isis - and such circular dependencies are forbidden by the YANG spec. (There is actually also a circular dependency between your module and ietf-routing, since your module effectively augments ietf-routing, and the unique statement also references the isis-protocol-instance node from your module.)

Unfortunately I can’t see a way to achieve what you want using YANG alone - perhaps you could instead of deviate-adding the unique annotate a tailf:validate statement, and check the uniqueness in the validation callback. Or perhaps you can come up with a different modeling, that avoids the circular dependency.


#3

Hello Peter,

Thanks for your response.

To avoid circular dependency I placed augmentation and deviation at the same level (i.e. control-plan-protocol) and added when statement to restrict the use only for isis protocol.

augment “/rt:routing/rt:control-plane-protocols/”
+“rt:control-plane-protocol” {
leaf isis-protocol-instance {
when “derived-from-or-self (current()/…/rt:type,‘isis:isis’)”;
type uint16 {
range “0…5” ;
}
}
}

deviation "/rt:routing/rt:control-plane-protocols/"
  +"rt:control-plane-protocol" { 
   deviate add {
		unique "isis-protocol-instance";
	}
}

Now MGSOFT explorer and Designer don’t raise any warnings.
Still have a problem with pyang. If we face issues in confd I will remove the “unique” statement and the validation will be as part of confd callbacks.

thanks
Orly