Developing a custom action adapter using XML
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.
This topic describes the XML template for developing a custom action adapter. See the Device adapter development process for the tasks that you are required to perform for developing an adapter.
XML template for a custom action adapter
Use the following template to create 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>
<deploysFile>true</deploysFile>
<deployedFilePrompt>File to Upload</deployedFilePrompt>
<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. 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:
|
<deploysFile> | Indicates whether the custom action requires a file to be uploaded to device. |
<deployedFilePrompt> | Message to be prompted to the user (executing the custom action job) for attaching the file if <deploysFile> is set to true. |
<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). |