CLI Init Translation Unit

Init translation unit does not contain readers and writers but it only contains implementation of TranslateUnit. There should be only one init translation unit per device type. Purpose of the init TU is to setup CLI prompt and define rollback strategy.

The implementation of TranslateUnit needs to override methods:

SessionInitializationStrategy getInitializer(@Nonnull final RemoteDeviceId id, @Nonnull final CliNode cliNodeConfiguration)

  • Implement and return device specific SessionInitializationStrategy where:
    • Setup device CLI terminal with attributes like width and length allowing to display infinite output.
    • Enter desired CLI mode which will be used as default - every reader and writer gets CLI prompt in this state (e.g. EXEC mode for IOS, config mode for IOS-XR, cli mode for Junos)

String toString()

  • Return unique string among all translation units which will be used as ID for the registration of the translation unit (e.g. “Junos cli init (FRINX) translate unit”).

These methods may be overridden if necessary:

getPreCommitHook() - method that is invoked before actual commit is written into device. For example this method can enter configuration mode.

getCommitHook() - method that invokes actual commit and should catch any error on commit. Also it should handle any post-commit actions when the commit was successful.

getPostFailedHook() - method that is invoked when commit fails. Should implement aborts or revert strategies.

Methods like getYangSchemas, getRpcs should return empty sets and method provideHandlers should return nothing, just use the read registry and write registry to register handlers..