### Examples for Applying Provisioning Filters Using Scripts

- Overview
- Examples for Applying Filters Using Scripts

Overview

This directory includes sample BeanShell scripts that illustrates the implementation of writing Beanshell scripts, for applying provisioning filters. User written BeanShell scripts should also be placed in this directory, in order to execute them. The advantage of using Beanshell scripts is, changes made to the code are interpreted dynamically without restarting the server.

Examples for Applying Filters Using Scripts

Business Rules or provisioning filters written using the BeanShell scripts are much easier, compared to the filters written using user class, since the syntax is much similar to the syntax of Java. The templates for which the Beanshell scripts are applied, can be specified in the file ProvisioningFilters.xml in <Web NMS Home>/conf directory. The script embedded inside the template will have access to the template object being invoked. The user-written script filters have access to the following variables.

During TemplateFiltering - "template"
During PreProvisioning - "template"
During PostProvisioning - "template" and "templateResult"

The scripts can investigate the "template" object and should finally return the "template" object after making changes to it. The PreProvisioning filters can throw "OperationFailedException", if the "template" is not to be provisioned. The PostProvisioning filters can throw "OperationFailedException", if the "templateResult" is not to be sent to the client. The Template filters can throw "InvalidTemplateException" if the "template" is not to be sent to the client.

FormManipulationFilter.bsh

This is an example about using BeanShell script during Template Filtering. This script removes the UserInput tags that are editable, to deny editing certain values of specific hosts. The hosts are specified in an array. Any number of hosts can be added or removed to/from the array.

SchedulingFilter.bsh

This is an example script that can be used for PreProvisioning. This script denies Provisioning, if performed other than the specified time in the script.

MailNotificationFilter.bsh

This is an example script that can be used for PostProvisioning. This example sends a mail to the specified recipients, once the provisioning operation is completed.