6

I am configuring static routes using xml, and I had a question regarding the structure of the xml. Both of these ways work, and I want to know if there is any differences between them, or do they both do the same thing.

Method 1: Using the xml schema

<?xml version="1.0" encoding="UTF-8"?>
<Request MajorVersion="1" MinorVersion="0">
  <Set>
    <Configuration>
      <RouterStatic MajorVersion="3" MinorVersion="2">
    <DefaultVRF>
      <AddressFamily>
        <VRFIPV4>
          <VRFUnicast>
        <VRFPrefixTable>
          <VRFPrefix>
            <Naming>
              <Prefix>
            <IPV4Address>200.0.0.0</IPV4Address>
              </Prefix>
              <PrefixLength>8</PrefixLength>
            </Naming>
            <VRFRoute>
              <VRFNextHopTable>
            <VRFNextHop>
              <Naming>
                <NextHopAddress>
                  <IPV4Address>192.168.1.2</IPV4Address>
                </NextHopAddress>
              </Naming>
            </VRFNextHop>
              </VRFNextHopTable>
            </VRFRoute>
          </VRFPrefix>
        </VRFPrefixTable>
          </VRFUnicast>
        </VRFIPV4>
      </AddressFamily>
    </DefaultVRF>
      </RouterStatic>
    </Configuration>
  </Set>
  <Commit Mode="Atomic" Label="IPV4_Static_Routes" Comment="IPV4 Static routes config updates"/>
</Request>

Method 2: Using the CLI encapsulation tags

<?xml version="1.0" encoding="UTF-8"?>
<Request MajorVersion="1" MinorVersion="0">
    <CLI>
        <Configuration>
                router static
                address-family ipv4 unicast
                200.0.0.0/8 192.168.1.2 
            </Configuration>
    </CLI>  
    <Commit/>
</Request>

On another note, is there a tool out there, that takes CLI commands and translates them into xml schema, like in method 1?

Thanks

1 Answer 1

4
+50

Both of these ways work, and I want to know if there is any differences between them, or do they both do the same thing.

They're both XML documents, and both have schemas. The CLI elements are just treated differently internally to the device in some form or another.

The IOS-XR XML API documentation calls out the important part. The difference between the two is that using method 2 is basically "passing through" commands (except for those not supported via the CLI directives) to the CLI interpreter, and the XML agent on the device will return the response from the CLI which is again wrapped in an XML document. Aside from the downsides noted in the API manual, this would be pretty inefficient if you were doing something that you needed to write a script to do - for this, you'd definitely want method 1. Ultimately though, they both do the same thing. One is more explicit with using elements based on a schema (easier for data serialization/parsing/storage/retrieval etc) and the other is just passing stuff to the CLI that you expect a response from in a non-serialized format (maybe something like a specific show command with some crazy regex because of an odd edge case requirement).

is there a tool out there, that takes CLI commands and translates them into xml schema, like in method 1?

What problem are you trying to solve?

There's this StackOverflow question that features a python library that could be used for this (written by the same guy that wrote exscript - a solid library) but IOS-XR may have the ability to generate output from "show run" to XML (try show run | format), but frankly the API guide linked shows better/more ideal operational examples which would apply more readily to creating automation (if that is the end goal here).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.