Automation Of CLI Generation

 

Overview of the case
  • The intention of the project was to develop a framework such that the CLI syntax files can be auto-generated and provided to the CLI frameworks like klish.
  • The auto-generation was based in Python and used to generate the XML files required by the klish framework.
  • This was achieved by querying the various classes (metadata) supported by the system using the REST APIs and then get the various attributes associated with the class.
  • Now based on the various type of attributes, the CLI syntax files were generated, which were XML based
  • The XML files were then fed to the CLI framework tool, like klish.
  • The command handlers of the various CLIs were also quite generic and were implemented using the REST APIs.
Challenges
  • The challenge was to generate a CLI solution which is a CISCO like CLI, but CLI grammar and the handler shouldn’t be changed manually based on the changes in the various classes supported. Everything had to be automated and CLI automation framework was written.
  • Complete technology was quite new to Benison.
  • Benison’s exposure to Python, Web technologies was quite limited and the model to generate CLI was quite new.

 

Requirements

Most of the CLI frameworks works in the following manner:-
  • They need the CLI definition related files, which are manually written.
  • The CLI framework reads those files and generates the CLI tree using those files.
  • The developer needs to provide a callback handler with each of the command, which is then used to do the processing related to the command.
  • However, there is an advantage in the above approach, because anytime a new feature gets added/modified the CLI needs to be changed, right from the CLI definition files to the command handlers. Hence, the requirement was to generate the CLI definition in the automated fashion such that any addition/deletion/modification in the parameters are automatically taken care of and the command handlers are generic enough such that they are able to take care of various attributes with any specific code addition.

Look and feel of the CLI should be similar to Cisco.

Solution
  • Klish was used as an open source framework, which provides Cisco like CLI framework
  • Klish uses various XML files, for the CLI definition.
  • Framework was written in Python to generate the XML files which can be fed to the klish for generating the CLI framework.
  • The basis of the solution was the usage of REST APIs.
  • The REST APIs were provided which used to provide the various classes in the system and the attributes associated with the each classes.
  • Rest APIs were used to add/delete/modify/show the various attributes of the various classes.
  • The automation framework, used to query the various classes in the system and their attributes and accordingly used to prepare the CLI syntax files.
  • These CLI syntax files were fed to the klish.

LET’S GET IN TOUCH

Please fill out the form below and we’ll contact you to schedule a live demonstration with one of our platform experts.

[recaptcha]