# Configuration Trigger

Configuration Trigger is a pre-processor mainly used to grab information (one or a list of items) from devices or to check if specific configuration or information is available on them. Information collected through Trigger will be imported or used in Configuration Templates as Trigger Objects (similar to Device, Job, Profile, and Global objects) for building device commands dynamically according to the device state.

**LIST example:** If the user wants to add a Configuration to all Interfaces on a device without using Trigger, the user has to specify all interface names in the Runtime object (the user must know the name of interfaces, and names might be different for different type of models). In the case of Trigger, Trigger will execute the command, which will list down all interfaces on the device, parse the interface names from the device response, and store it in a LIST output. The same list can be imported into Template using the Trigger object.

**Boolean example:** If the user wants to enable SNMP Service Configuration on 1000 devices without Trigger, the user must know the details of all those not SNMP enabled and create an Upload Job for those devices. With Trigger, Trigger can execute the “SNMP Service Status” command on all devices, parse the SNMP service status, and store the availability in BOOLEAN output (YES/ NO) for each device. The same BOOLEAN output can be imported back into the Template using the Trigger object to execute the SNMP Enabling command for those devices whose trigger BOOLEAN output value is ‘NO.’

{% hint style="info" %}
**Note:** Multiple Triggers can be used within a single Configuration Template.
{% endhint %}

This is a privilege-based feature: The user will be able to access, view, add, edit, delete, execute, and export only if the administrator has given them privileges. This will be defined under roles and privileges.

## **What you see on the screen**

**Configuration trigger Details** | Basic Details

<table data-header-hidden><thead><tr><th width="156"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Label</strong></td><td><strong>Action</strong></td><td><strong>Description/ Example</strong></td></tr><tr><td>Search</td><td>Enter text in the search bar</td><td>Quickly locate specific triggers by name, description, or other attributes</td></tr><tr><td>Filter</td><td>Select criteria from dropdown menus</td><td>Refine the trigger list by Name, Description, Vendor, OS Name, or Trigger Type. Conditions include: in, not in, equal to, not equal to</td></tr><tr><td>Export</td><td>Click the Export button</td><td>Download a CSV file containing all trigger configuration data for offline analysis or backup</td></tr><tr><td>Add</td><td>Click the Add button</td><td>Create a new trigger using either the Manual method or the Import from CSV option</td></tr><tr><td>Trigger Name</td><td>This field is for viewing information only.</td><td>Displays the unique name assigned to each trigger configuration</td></tr><tr><td>Description</td><td>This field is for viewing information only.</td><td>Shows a brief explanation of the trigger's purpose and functionality</td></tr><tr><td>Vendor</td><td>This field is for viewing information only.</td><td>Indicates the network device manufacturer associated with the trigger</td></tr><tr><td>OS Name</td><td>This field is for viewing information only.</td><td>Specifies the operating system for which the trigger is designed</td></tr><tr><td>Trigger Type</td><td>This field is for viewing information only.</td><td>Indicates whether the trigger returns a list of items or a boolean (yes/no) value</td></tr><tr><td>Trigger Parser Type</td><td>This field is for viewing information only.</td><td>Shows the method used to interpret command output (e.g., Python Script, Regex Pattern)</td></tr><tr><td>Creation Time</td><td>This field is for viewing information only.</td><td>Shows the method used to interpret command output (e.g., Python Script, Regex Pattern)</td></tr><tr><td>Created By</td><td>This field is for viewing information only.</td><td>Shows the username of the person who created the trigger</td></tr><tr><td><strong>Action Icons</strong></td><td></td><td></td></tr><tr><td>Edit</td><td>Click to perform the action</td><td>Modify various trigger details, including name, description, visibility settings, trigger type, and other configuration parameters</td></tr><tr><td>Delete</td><td>Click to perform the action</td><td>Remove the trigger from the system. A confirmation prompt will appear to prevent accidental deletions</td></tr></tbody></table>

NCCM supports two types of Triggers

**List Trigger** – to get the List of items as output from the Trigger execution.

1. To get the List of Interfaces
2. To get a List of Gigabit Interfaces
3. To get a List of Connected Ports
4. To get the List of ACL names

{% hint style="info" %}
**Note:** In case of the Device not responding or command Error, an empty list will be returned.
{% endhint %}

**Boolean Trigger** – to get the Boolean value (Yes or No) as the output from the Trigger execution.

1. To check whether BGP Service is enabled.
2. Check whether the SNMP Service is configured.

## **Add Trigger**

* Navigate to the Configuration Trigger page in the NCCM interface.
* Locate and select the "Add” option to initiate the trigger creation process.

To create a new Configuration Trigger, users can employ one of two methods:

1. Manual Creation
2. CSV Import

### **Manual Trigger Creation**

To manually add a new Configuration Trigger, follow these steps:

* Choose the "Manual" option from the available creation methods and follow the below steps to continue:

**Trigger Details** | Basic Details

<table data-header-hidden><thead><tr><th width="172"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Label</strong></td><td><strong>Action</strong></td><td><strong>Description/ Example</strong></td></tr><tr><td>Name</td><td>Enter the Trigger Name</td><td>Must be unique</td></tr><tr><td>Visibility</td><td>Choose between Public and Private</td><td>If Private, select specific User(s) or User Group(s) who can manage or use this Trigger</td></tr><tr><td>Description</td><td>Input a description of the Trigger</td><td>Provide clear, concise information about the Trigger's purpose</td></tr><tr><td>Vendor</td><td>Select from available vendors</td><td>A trigger should be vendor-specific as it executes device commands</td></tr><tr><td>OS Name</td><td>Select OS Type from the available options</td><td><p>The trigger should be vendor OS Type specific since it executes device commands.</p><p>When device commands are different for two different OS Types of the same vendor, two different Triggers must be created.</p></td></tr><tr><td>Trigger Type</td><td>Select LIST or Boolean</td><td><p>Options Include:</p><ul><li>LIST – for list of Items to be returned.</li><li>Boolean value – Yes/No.</li></ul></td></tr><tr><td>Parser Type</td><td>Select from available options</td><td><p>Options include:</p><ul><li>Column Split</li><li>Regex Pattern on all lines</li><li>Python Script</li><li>Regex Pattern on each Line</li><li>Regex Pattern on each Line and Column Split.</li></ul><p>Refer to the Parser Type section for more information</p></td></tr><tr><td>Column Index</td><td>Input the Column index</td><td>Used for Column Split and Regex Pattern on each Line and Column Split</td></tr><tr><td>Trigger Commands</td><td>Input commands to be executed on devices</td><td>These commands will check for specific output</td></tr><tr><td>Parser Text</td><td>Input the Parser Text</td><td>Used for Pattern matching input (Boolean Type) or as input for Python script</td></tr></tbody></table>

**Parser Type** | Drop-down list |&#x20;

**Column Split**

* Will be used for LIST Type only.
* The command output lines will be delimited by white space, and the first column value of all lines will be stored in Trigger Output.

**Regex Pattern on all lines**

* It will be used for Boolean Type only.
* The search Pattern inside “Parser Text” should be matched with any line to get the final output as YES; otherwise, it returns NO.&#x20;

**Python Script**

* It will be used for both Boolean and LIST Type.
* Python script should be written in “Parser Text.”
* Example Python Parser to get Local Ports on HP Device:

```
trigger_result = [] 
found = 0 
columns = ["Interface","Link", "Speed","Duplex", 
"Type", "PVID", "Description"] 
For each_line in trigger_output.split("\n"): 
if each_line.split() == columns: 
  found = 1 
  continue 
if found == 1: 
  local_port = each_line.split()[0].strIP() 
  if local_port.find('/')     !=   -1       and 
(local_port.lower().startswith('fe')                        or 
local_port.lower().startswith('ge')                        or
local_port.lower().startswith('gi')                         or
local_port.lower().startswith('fi')                          or
local_port.lower().startswith('te')                         or
local_port.lower().startswith('eth')): 

trigger_result.append(local_port) 

print "trigger_result",trigger_result 
```

* The command response will be sent to the Python script in variable trigger\_output.
* The parser output from the Python script will be stored in the variable trigger\_result.

**Regex Pattern on each Line**&#x20;

* Will be used for Boolean Type only.
* The search Pattern inside “Parser Text” should be matched with all Lines to get the final output as YES else it returns as NO

**Regex Pattern on each Line and Column Split**&#x20;

* Will be used for LIST Type.
* The search Pattern inside “Parser Text” should be matched with Lines, and matching Lines will be delimited by white space, and the first column value of the lines will be stored in Trigger Output.

Once the details have been added, click on “Next” to continue.

**Test |** Add Trigger |

| **Label**       | **Action**                                            | **Description/ Example**                                                                                               |
| --------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| IP Address      | Add the respective IP address from the drop-down list | Or manually add the IP address of the target device                                                                    |
| Data Collector  | Select from the list of data collectors               | Choose the appropriate data collector for executing the trigger                                                        |
| Username        | Click to add the username                             | Enter the username for device access                                                                                   |
| Password        | Correspondingly add the password for the same         | Enter the password associated with the username                                                                        |
| Enable Password | This is an Optional step                              | In some devices, they'll ask to enable the password once again while executing privileged commands. Enter if required. |

Once you've added the necessary trigger configuration details, click **'Review'** to check your settings or **'Submit'** to immediately add the trigger to the system. Review allows for final adjustments, while Submit finalizes the creation process.

### **CSV Import**

Select the "Import from CSV" option from the list of available creation methods to import configuration triggers using a CSV file. Follow the steps outlined below to complete the import successfully:

* Download the sample CSV template to ensure proper data structure.
* Enter the required information into the CSV file accurately.
* Upload the completed CSV file and click "Next."
* Review the system’s column mapping, adjust if necessary, and click "Import."
* Validate the data, fix any errors, and click "Proceed with the valid records" to finish the steps.

## **How to use Trigger in Configuration Template**

**Step 1:** Create a Trigger within Configuration Trigger.

**Step 2:** Add the created Trigger in the “Configuration Template” through the “Trigger object”.

**Step 3:** Trigger gets executed during

* Review the process of Uploading jobs.
* Just Before the actual execution of Upload commands starts.

{% hint style="info" %}
**Example:** Creating a Trigger to get Checkpoint Log Files
{% endhint %}

Name the Trigger as **checkpoint\_traffic\_list**, choose the LIST Trigger Type, and choose the parser as Column Split.

### **Trigger Commands to get CheckPoint Log files:**

```
<command   timeout="60"          prompt="[Pp]assword">expert</command>           
<command   timeout="60"         
prompt="#">{{Global.checkpoint_expert_password}}</command>    
<command   timeout="60"          prompt="#">cd      /opt/CPsuite-R77/fw1/log</command>          
<command   timeout="60"          prompt="#" action="output-to-store">ls          |         grep  
{{Time.yesterday_YYYYMMDD_formatted}}   </command>        
<command   prompt=""    action="exit">exit</command>
```

### **Add the Trigger into the Configuration Template:**

Trigger will be added In Template as Trigger **.checkpoint\_traffic\_list**

**Template commands:**

```
<command timeout="60" prompt="[Pp]assword">expert</command>
<command timeout="60"
prompt="#">{{Global.checkpoint_expert_password}}</command>
<command timeout="60" prompt="#">cd /opt/CPsuite-R77/fw1/log</command>
<command timeout="60" prompt=":">ftp
{{Global.checkpoint_ftp_backup_IP}}</command>
<command timeout="60"
prompt=":">{{Global.checkpoint_ftp_username_dc}}</command>
<command timeout="60"
prompt=">">{{Global.checkpoint_ftp_password_dc}}</command>
<command timeout="60" prompt=">">bin</command>
<command timeout="60" prompt=">">prompt</command>
{% for item in Trigger.checkpoint_traffic_list %}
<command timeout="1800" prompt=">">mput {{item}}</command>
{% endfor %}
<command prompt="" action="exit">exit</command>
```
