0

''' i want to change a yang model into xml, but there is a union type in yang model, and the odl check there is a error in the xml, i don`t known how to solve it '''

''' the part of yang model

 leaf prefix {
       type leafref {
          path "../config/prefix";
       }
       description
       "Reference to the configured prefix for this aggregate";
  }

  typedef ip-prefix {
    type union {
      type ipv4-prefix;
      type ipv6-prefix;
    }
    description
      "An IPv4 or IPv6 prefix.";
  }

''' ''' the part of xml

<prefix>10.0.0.0/24</prefix>

''' ''' the error msg

<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
    <error>
        <error-type>protocol</error-type>
        <error-tag>malformed-message</error-tag>
        <error-message>Error parsing input: Invalid value ""10.0.0.0/24"" for union type.</error-message>
        <error-info>Invalid value ""10.0.0.0/24"" for union type.</error-info>
    </error>
</errors>

'''

1 Answers1

0

This seems unrelated with the fact that this is a union. The prefix parameter has several rules in this case:

  • It is a leafref, meaning the value you provide (10.0.0.0/24) must exist as an existing config/prefix.
  • The value also needs to match either the ipv4-prefix or the ipv6-prefix. Each of these are strings with specific regex. For this particular case, the value you've provided looks like a valid ipv4-prefix.

In short, most likely the error is related with the fact that the leafref constraint is not being followed. I'd need to see the actual XML being sent in order to know the error root-cause.

Paulo Gomes
  • 156
  • 3