Skip to content

Command builder

Jonathan Stout edited this page Sep 21, 2018 · 5 revisions

Command Template

Define a command template. These are commands that may be run by the user. Commands of type interface will be placed on the interfaces tab. Commands of type vlan will be place on the vlan tab. Commands of type switch will be placed on the switch tab.

Special variables

Each tab on the commands page have special variables available to your command template.

The interfaces tab may use:

  • port: show interface [% port %] >> show interface et-2/0/0

The vlans tab may use:

  • vlan_id: show vlan [% vlan_id %] >> show vlan 300

Custom variables

If a command requires an additional argument. A parameter may be defined. A parameter may be one of two types, input or option. To define a parameter you must provide.

- name: This is the variable to use in a command string
  description: Text describing its purpose
  regex: A regex to validate user input
  type: The input's type, input or option

input

An input parameter will take text from the user and be inserted into the command.

Command parameters of type input should use a regex similar to the example below:

- command: `conf t; interface [% port %]; tagged [% vlan_id %]`
  parameters:
  - name: vlan_id
    description: A number between 1-4095
    regex: ^(40[0-9][0-5]|[1-3][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[1-9])$
    type: input

option

An option parameter will present the user with a drop down of selectable options (again at run time) and insert the selection into the command.

Command parameters of type option should use a regex similar to the example below:

- command: `conf t; interface [% port %]; [% toggle %]`
  parameters:
  - name: port
    description: A port string
    regex: (.*)
    type: input
  - name: toggle
    description: Desired state of selected interface
    regex: (enabled|disabled)
    type: option

Clone this wiki locally