Translation units for different device versions

In case of needing to implement a new CLI Translation Unit for specific version of device we create a new TranslateUnit (e.g. located in iosxr/mpls).

In this case we use IOSXR4.* implementation as an example.

Device registration

In TranslateUnit we had just created, e.g. MplsUnitXR4.java, we have to register device as a constant located ../iosxr/utils/IosXrDevices.java containing device type and version as described in TranslateUnit documentation.

public void init() {
    reg = registry.registerTranslateUnit(IOS_4, this);
}

This unit can reuse all writers/readers from existing ones, except the writer (or other handler) we want to alter or create (in our example writer for tunnel configuration). We have to create a new writer with desired behaviour and add it into provideWriters method.

private void provideWriters(ModifiableWriterRegistryBuilder wRegistry, Cli cli) {
    wRegistry.add(IIDs.NE_NE_MP_LS_CO_TU_TU_CONFIG, new TunnelConfigWriterXR4(cli));
}

Handlers

In our example, the newly created writer have to implement CliWriter interface as well as all the methods mentioned in Writers. With other handlers we proceed with same logic.

Similar process apply on every new implementation of different device version.