libyang
libyang copied to clipboard
Wrong target namespace for deviations
Hi,
please consider the following two YANG schema modules:
module test-deviation {
namespace "urn:test:deviation";
prefix test-dev;
identity base-identity-delete;
identity derived-identity1-delete {
base base-identity-delete;
}
identity derived-identity2-delete {
base base-identity-delete;
}
identity derived-identity3-delete {
base base-identity-delete;
}
container deviation-container {
container delete-container {
leaf delete-leaf {
type identityref {
base base-identity-delete;
}
must ". = 'derived-identity1-delete' or "
+ ". = 'derived-identity2-delete'";
}
}
}
}
module test-deviation-dv {
namespace "urn:test:deviation:dv";
prefix test-dev-dv;
import test-deviation {
prefix test-dev;
}
deviation "/test-dev:deviation-container"
+ "/test-dev:delete-container"
+ "/test-dev:delete-leaf" {
deviate delete {
must ". = 'derived-identity1-delete' or "
+ ". = 'derived-identity2-delete'";
}
deviate add {
must ". = 'derived-identity2-delete'";
}
}
}
When these modules are installed and the following edit-config snippet is issued via netopeer-cli:
<deviation-container xmlns="urn:test:deviation">
<delete-container>
<delete-leaf xmlns:test-dev="urn:test:deviation">test-dev:derived-identity2-delete</delete-leaf>
</delete-container>
</deviation-container>
the RPC is rejected because the following libyang error occurs:
Must condition ". = 'derived-identity2-delete'" not satisfied.
It seems that the identityref derived-identity2-delete is evaluated in the namespace of the deviating (source) module instead of the deviated (target) module. When I use the prefix of the deviated module:
deviate add {
must ". = 'test-dev:derived-identity2-delete'";
}
the edit-config is accepted.
Could you please have a look at this?
BR, Peter
It seems that the identityref derived-identity2-delete is evaluated in the namespace of the deviating (source) module instead of the deviated (target) module.
What makes you think it should work the other way around? The specs mention current node which is ambiguous in this case. However, you should always include the prefix in these cases, anyway. Lastly, in the past years these resolutions were changed several times back-and-forth until it got fully cleared up on the mailing list so I am quite sure how it works right now is correct and I will not be changing it again.
OK.