Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Attribute VB_Name = "Act_Custom_Template"
- ' ------------------------------------------------- SCRIPT NOTES -------------------------------------------------
- '
- ' OVERVIEW:
- ' Client scripts are run by the CatTools Client program (CatTools_Client.exe).
- ' A client script is called by an activity's main script.
- ' Client scripts contain a number of common function calls to the device scripts, i.e. the scripts that send
- ' device specific commands in order to get the device to log in, issue the commands required to perform the
- ' activity, then log out of the device again.
- '
- ' FUNCTIONS:
- ' There is only one function within a ClientScript file, which is Function Client().
- ' The Client() function contains all of the necessary program code to call the common device functions and save
- ' the activity results to a file for the main activity script to process.
- '
- ' Below is an example of the device script functions calls required for an activity that needs to login to a
- ' device, then enter the Enable mode in order to run a command:
- '
- ' Login
- ' SendPostLoginCommands
- ' EnterEnableMode
- ' SendPostEnterEnableModeCommands
- ' SendSessionTerminationCommands
- ' * Note: The call to the device script function ExitEnableMode which sends the command to exit enable mode
- ' on the device is not required within the Client script as it is called within SendSessionTerminationCommands
- ' function within the device script file.
- '
- ' There are also a number of calls to the internal CatTools Client functions which are prefixed with "cl."
- ' A full list of cl. functions exposed to the custom client activity template, including a brief description and
- ' example how to use them, can be found within the 'Activities' chapter of our on-line help file at
- ' http://www.kiwisyslog.com/help/cattools/index.html
- '
- ' ACTIVITY OPTIONS:
- ' List each of the activity options you have defined in the .INI file for this custom activity within the
- ' --- ACTIVITY NOTES --- section below.
- ' NOTE: For ease of reference, it is recommended you list ALL the activity options (and in numerical order) whether
- ' they apply to the activity client script or activity main script; however if the option is specific to the main
- ' script (i.e. additional parsing, sorting or filtering of the combined results from the clients), then it isn't
- ' necessary to describe its function within this client script.
- ' Simply add the text (see MAIN script) and add the description to the activity main script file.
- '
- '
- ' TASKS POST INITIAL CLIENT SCRIPT SETUP:
- '
- ' Main script.
- ' If you haven't already created one, a main script file will also need to be created for your new custom
- ' activity/report script.
- ' A main script template file "Main.Custom.Activity.Template.txt" has been created for you and can be found in the
- ' \Templates folder within the main CatTools root directory.
- '
- ' Device scripts.
- ' For each of the device types (custom or predefined) that you want your custom activity to run for, you will need
- ' to create a new custom function within each of the device scripts (.txt files).
- ' Ensure you define your new function using the Custom_ prefix. (i.e. "Function Custom_ " ), to avoid the
- ' possibility of conflict with one of the CatTools predefined activities.
- ' For custom device types, you simply need to modify your custom device script file with your new activity function.
- ' If you are adding a custom activity function to one of the CatTools predefined device types, you will need to
- ' create a new file for your custom activity code, which will then be appended to the CatTools encrypted script code
- ' at run-time. The file must be given the same name as the CatTools device file, but with the addition of a '.custom'
- ' suffix.
- ' For example:
- ' If you are adding a custom activity to the Cisco.Switch.IOS device type (script file Cisco.Switch.IOS.txt),
- ' then you need to create a new file called Cisco.Switch.IOS.txt.custom in the \Scripts folder within the root
- ' CatTools directory.
- ' An example file for the Custom Device (Custom.Device.Template.txt.custom) can be found in the \Templates folder
- ' within the main CatTools root directory.
- '
- ' If you associate a device with your custom activity (within the activity setup screen - Devices tab)
- ' and that device does not have the corresponding activity function within the custom device script
- ' (or .custom extension file for a predefined device), then you will receive the run-time error:
- '
- ' "Client script error: Type Mismatch: [activity name] on line: [line number]"
- '
- ' If you don't want this error to appear, then create the custom activity function within the device script
- ' and simply add the following line within the function:
- '
- ' cl.CatToolsNoSupport
- '
- ' This will then display the following Warning message in the Info Log rather than an error:
- '
- ' "Device type: ___ has not had this functionality added yet. Skipping this device"
- '
- ' ------------------------------------------------ ACTIVITY NOTES ------------------------------------------------
- ' ACTIVITY OPTIONS: (see above)
- ' 1 = Use Alternate command : (checkbox + string) : Overrides the default device script command.
- ' 2 = ... (add as required for your activity)
- '
- ' Add any other activity specific information here...
- '
- ' ------------------------------------------------- END OF NOTES -------------------------------------------------
- Function Client()
- ' Set function return value to tell the CatTools_Client that the script completed normally
- Client = "OK"
- ' Declare variables
- Dim sAltCommand
- Dim sResults
- Dim bResults
- ' Check whether an alternate command has been specified.
- ' This command will then be passed to the device scripts as an overriding command to any default commands
- ' that may have been specified in the device script
- If cl.DBCheckScheduleOption(cl.ScheduleNumber, 1) = 1 Then
- sAltCommand = cl.DBScheduleGetField(cl.ScheduleNumber, "OptionsString1")
- Else
- sAltCommand = ""
- End If
- ' Test current connection status
- If StrComp(cl.TelnetConnectionStatus, "OK", vbTextCompare) <> 0 Then Exit Function
- ' If CatTools receives a request to 'STOP' activity immediately, then exit the function
- If cl.QuitNow = 1 Then Exit Function
- ' Call the device script function Login
- If login = False Then
- ' Exit the activity if the login fails
- Exit Function
- Else ' Login OK, so call device script function SendPostLoginCommands
- 'Note: this is just a call to the function. If it fails, the activity will continue on regardless
- Call SendPostLoginCommands
- End If
- ' Check again whether an immediate STOP activity has been requested.
- If cl.QuitNow = 1 Then Exit Function
- ' Call device script function to EnterEnableMode. If successful, then call device script function
- ' SendPostEnterEnableModeCommands. If EnterEnableMode failed, then continue with activity anyway without
- ' calling SendPostEnterEnableModeCommands
- If EnterEnableMode Then
- ' Call device script function SendPostEnterEnableModeCommands
- Call SendPostEnterEnableModeCommands
- End If
- ' Check for STOP request
- If cl.QuitNow = 1 Then Exit Function
- ' Do the activity.
- ' Call the custom activity function 'Custom_Activity_Template' in the device script file and store any
- ' results in the sResults variable
- cl.Log 3, "Test"
- '
- Activity_UpdatePassword
- sResults = Custom_Activity_Template(sAltCommand)
- 'If EnterConfigMode = False Then
- ' Exit Function
- 'Else setInterface
- 'End If
- 'If cl.QuitNow = 1 Then Exit Function
- 'cl.Log 3, "Test2"
- ' Save the results to a temporary file within the \ClientTemp folder
- Call cl.SaveResults(sResults, 0)
- ' Check for STOP request
- If cl.QuitNow = 1 Then Exit Function
- ' Call device script function SendSessionTerminationCommands to exit or logout the session on the device
- Call SendSessionTerminationCommands
- ' Disconnect from client
- cl.DisconnectHost
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement