Developing a custom action adapter
A custom action device adapter adds a new function to what the system can do to or on a device. A custom action wraps a unit of work done on a device during a login session. You can run any command or request that the device allows, or any combination of multiple commands or requests. You can then run a job that runs the custom action on the devices where the custom action has been implemented. This topic describes the basics of a custom action adapter and XML template for a custom action adapter. It provides a reference to all available XML elements relevant to custom actions. Examples-of-custom-action-adapters provides examples and more detailed explanations of various parts of a custom action adapter.
Custom action adapter basics
Create a new custom action if you need to gather the settings or change the behavior of a device in a new way that is not already present in the system. You need to be able to express the work that you want to do within the confines of the device adapter XML syntax supported by the <deviceCommand> or <httpDeviceCommand> elements that send commands to a device and process the responses, with simple conditional and looping constructs.
A custom action is made up of the declaration, followed by the per-device-type implementation. A custom action might examine features or components or statistics in a device (that is, inspect a device without making changes), or it can make changes (for example, you can wrap commonly performed update commands in a custom action to relieve your users from knowing obscure command syntax, especially across different device types).
When you first import a new custom action, the system ensures that you are able to run that action, to perform debugging of your XML code. If you already have full network rights, you can access all actions by default. But if you do not have full network rights, the system creates a new role that grants the right to run the new custom action and adds you as a user to that new role. Once you finish debugging and want to publish the custom action to other users, you can use the role the system created or you can include the custom action right into other roles.
Template for a custom action adapter
Use the following template for the XML for a custom action adapter:
<deviceTypeMap>
<customDeviceCommandDeclaration>
<name>display name</name>
<guid>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</guid>
<groupName></groupName>
<description></description>
<generalInfo></generalInfo>
<browserExecutable>true</browserExecutable>
<approvable>true</approvable>
<inspectionOnly>true</inspectionOnly>
<hideMakeTrustedOption>false</hideMakeTrustedOption>
<classification>3</classification>
<dynamicField>
<name></name>
<sourceResult></sourceResult>
<rejectUnknownMenuOption>false</rejectUnknownMenuOption>
<onBadValue>failActionMajor</onBadValue>
</dynamicField>
<importedHardware>
<sourceResult></sourceResult>
</importedHardware>
<runtimeParameters>
<runtimeParameter>
<name></name>
<prompt></prompt>
<type>text</type>
<required>true</required>
<sortOrder>1</sortOrder>
<defaultValue></defaultValue>
<maxSize>40</maxSize>
<mask></mask>
<errorMessage></errorMessage>
</runtimeParameter>
</runtimeParameters>
</customDeviceCommandDeclaration>
<deviceType>
<guid>yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyy</guid>
<extension>true</extension>
<deviceCommand>
<guid>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</guid>
</deviceCommand>
</deviceType>
</deviceTypeMap>
The legal XML elements in a custom action adapter are:
Tag | Description |
---|---|
<name> | (Required) Name of the custom action, up to 255 characters in length This name appears in the GUI and must be unique across all custom actions. |
<guid> | (Required) A globally unique ID (GUID) Run the create_guid.sh or create_guid.bat script in the BCAN_HOME\tools directory to generate a new GUID for use here. |
<groupName> | String that defines the group or category of custom action for organizing actions into submenus in the GUI (for example, VLAN Management and Interface Monitoring) You can invent your own groups or you can use groups shared with the out-of-the-box content (such as Diagnostics, Hardware, or Topology). Default value is null, so the custom action appears in the first level of the cascaded menu. |
<description> | String that contains a message to display to users when they are creating or editing this action, to provide instructions or more detailed information about what the action does Default value is null. |
<generalInfo> | String containing general notes, warnings, quirks, or anything else special about this custom action that might affect how users use it Use a CDATA tag to enclose HTML elements that format this information for display in the Device Adapter Capabilities report. Refer to Common concepts and XML elements for more information about CDATA. Default value is null. |
<browserExecutable> | Indicates if this custom action can be executed from the GUI. Otherwise, it is available only through web services. Valid values are true and false (default). |
<approvable> | Indicates if the custom action is available in the list of actions for the Enable Job Approval For Action system parameter on the Admin > System Parameters page The administrator can control whether the action requires job approval and which users can perform the approval. Valid values are true and false (default). |
<inspectionOnly> | Indicates if the custom action makes no changes to the device Valid values are true and false (default). If it is flagged as false (meaning changes are made), the system automatically takes a snapshot to keep track of the changes. If it is flagged as true, no snapshot is taken. This setting also affects when the discover-core device command is run, which is usually used to discover the model and operating system version. When true, discover-core is not executed at all. When false, it is executed after the custom action logic and before the automatic snapshot. In either case, your custom action logic cannot depend on properties being present that are normally populated by discover-core. |
<hideMakeTrustedOption> | Indicates if the GUI presents the Mark As Trusted option for this custom action (which controls what happens to the configurations taken during the snapshot). Ignored if <inspectionOnly> is true. Valid values are true and false (default). |
<classification> | Number that specifies the category or type of the action. The classification is based on how the action manipulates the device. BMC Decision Support – Network Automation uses this information when it generates various reports based on the types of jobs and actions that were performed. Otherwise, this value does not affect any processing Valid numeric values are:
|
<dynamicField> <name> <sourceResult> <rejectUnknownMenuOptions> <onBadValue> | Indicates that custom action results are to be populated into a device dynamic field The <dynamicField> element contains the following sub-elements:
|
<importedHardware> <sourceResult> | Indicates that custom action results are to be populated into the device's imported hardware inventory, which is displayed when you view the device or the Device Inventory report. You can specify multiple <importedHardware> elements, in which case the property values are concatenated together. This element contains the following child element:
|
<runtimeParameters> <runtimeParameter> <name> <prompt> <type> <required> <sortOrder> <defaultValue> <maxSize> <mask> <minValue> <maxValue> <errorMessage> <menuValues> <file> <fileName> <inline> <menuValue> <jdbc> <dbUrl> <dbQuery> | Specifies a value that is passed from the user into the custom action XML logic, for use in running the command or the request on the device. Each value is populated into a property named runtime followed by a dot followed by the specified name. The XML code refers to the value through a keyword, such as %runtime.parameter1%. The <runtimeParameter> element contains the following child elements:
|
<deviceType> <guid> <extension> <deviceCommand> <guid> | Implementation of the custom action for a particular device type. The first <guid> identifies the device type. The second <guid> identifies which custom action you are implementing, using the GUID you created in the declaration. Follow this second GUID with interactions and other elements that perform the logic of interacting with the device and parsing its output to gather results. The elements allowed here are <deviceCommand> and <httpDeviceCOmmand> and their child elements. See Device-type-CLI-interaction-XML-element-reference for a CLI based device type, and Device-type-HTTP-interaction-XML-element-reference for an HTTP or HTTPS based device type. You can implement your custom action in as many device types as you like. Simply include a <deviceType> section for each one. <extension>: true or false to indicate if this extends an existing device type. Set this to true for all custom actions (else, errors will ensue). |