You can modify parsing strategies that come as part of the base system or add new ones. Parsing strategies are part of discovery patterns, which Service Mapping and Discovery use to discover and map configuration items (CIs).

Before you begin

Practical knowledge of Java scripting is required.

Role required: pd_admin

About this task

Parsing serves to analyze syntax of the source file. You extract values from parsed files, which allows you to convert these values into variables. There are standard parsing strategies, which are part of the base system. If you cannot extract data using the standard parsing strategies, you can create your own parsing strategy. Custom parsing strategies are JavaScript files.

The JavaScript for parsing strategy must comply to the following guidelines:
  • You may use the content variable to refer to the raw data resulting from executing the operation.
  • Use rtrn to indicate the string, which is the result of your custom parsing.
  • The script output must be in well-formed XML syntax.

    For example, the output must contain correct tags and markup:

    <root>
    <OS>Windows</OS>
    <version>10</version>
    </root> 
  • If necessary, you may use third-party JavaScripts to convert the content into XML.

    For example, to convert the content from JSON into XML, use the X2JS JavaScript provided by open-source software.

    var xtojs = new X2JS();
    var result = xtojs.js2xml(jsonObj);
    var finalResult = "<root>" + result + "</root>";

Procedure

  1. Navigate to All > Pattern Designer > Custom Parsing Strategies.
  2. To modify the JSON custom parsing strategy, select JSON file.
    Alternatively, click New to create a new JSON file.
  3. For the new custom parsing strategy, enter a name describing the new strategy in the Name field.
    For example, if the purpose of this strategy is to extract information using a certain protocol, use this protocol as the name.
  4. Enter or modify the parsing strategy purpose in the Description field.
  5. Write the JavaScript in the Script pane to define the business logic of parsing.
  6. Click Update or Submit.

What to do next

Use this custom parsing strategy for defining operations inside pattern steps.