How to Manage Interface (Cisco ISR / CLI)

Overview

In this tutorial you will learn how to create an object for managing a Cisco ISR router interfaces.

The example is based on Cisco ISR CLI but can be adapted to other type of devices with CLI based management.

Configuration sample

Here is an example of the configuration that we want to import in our object.

MSA358#sho ip interface
GigabitEthernet1 is administratively down, line protocol is down
  Internet protocol processing disabled
GigabitEthernet2 is up, line protocol is up
  Internet address is 10.30.19.12/23
  Broadcast address is 255.255.255.255
  Address determined by setup command
  MTU is 1500 bytes
  Helper address is not set
  Directed broadcast forwarding is disabled
  Outgoing Common access list is not set
  Outgoing access list is not set
  Inbound Common access list is not set		    				
		    				

IMPORT method

Configuration parser Import to use

InterfaceImport_CiscoISR.png

details of the parser

  • Object indentifier Extractor
@(?<object_id>\S+) is administratively \S+, line protocol is (?<status>\S+)@
@(?<object_id>\S+) is \S+, line protocol is (?<status>\S+)@
  • Objects variable extractor
@\s+Internet address is (?<address>\S+)/(?<_cidr>\S+)@

it is also possible to extract additional parameters such as MTU, byte in/out, packets in/out

@\s+(?<packets_in>\S+) packets input, (?<bytes_in>\S+) bytes@
@\s+(?<packets_out>\S+) packets output, (?<bytes_out>\S+) bytes@
@\s+MTU (?<MTU>\S+) bytes, BW (?<BW>\S+) Kbit/sec@
  • Ignore line parsers
@^\s@

Post import

with this parser we extract the CIDR number of the subnet but in the case where we want to display the mask in the form 255.X.X.X then we need to use a post-import operation to create a new variable 'mask':

{if !empty($params._cidr)}
{get_mask_from_len len=$params._cidr var="_mask"}
 {assign_object_variable var="mask" value=$_mask}
{/if}

VARIABLES

Interface_variables_CiscoISR.png

UPDATE method

a simple implementation can be used here:

interface {$params.object_id}
{if empty($params.address)}
 no ip address
 shut
{else}
 ip address {$params.address} {$params.mask}
 no shut
{/if}

Result in the object console

InterfaceImport_CiscoISR_result.png

display the interface status with colors

Useful to enhance the visual aspect of your Microservices and ease the monitoring of your interface.

Colourization is done with a POST-IMPORT that assigns the special variable _color:

{if  $params.status == down }
      {assign_object_variable var="_color" value=red}
{/if}
{if  $params.status == up }
      {assign_object_variable var="_color" value=green}
{/if}

InterfaceImport_CiscoISR_resultWithColor.png