05.01 SMF OD V010 Delimited Text Parsing Strategy Final

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Delimited Text Parsing Strategy

Lab 5.1 630m

Lab objectives
In this lab, Cloud Dimensions is requesting that additional attributes be collected for the Apache
Web Server application, that supports the EMEA Dispatch Scanning Service. Part of the Cloud
Dimensions application deployment and release strategy is to deploy a configuration file that
contains valuable information with respect to the application deployment, including location,
country, service supported, app release and version, app install date, and listening port.

A. Review Apache Configuration File


An apache.cfg.txt file was deployed with the Apache installation on the Windows Server. This file
can be used to collect application attributes during discovery. Locate this file on the Windows
Server later in the lab.

1. From your ServiceNow instance, logged in as the System Administrator, navigate to the
EMEA Dispatch Scanning Service map (Service Mapping > Application Services) and
select the Apache icon.

2. From the right Properties pane, under Application, notice there are multiple properties,
App Release Version is not currently one of them.
B. Add New Field Attribute to the Apache Web Server Class
In this section, create a new field on the Apache Web Server table to store values for the App
Release Version.

1. Navigate to Configuration > CI Class Manager.

2. Click Hierarchy.

3. Under CI Classes, search for and select Apache Web Server.

4. Under Class Info, click Attributes.

5. Click the Added tab.

6. At the bottom of the list, double-click Insert a new row and complete the row as shown:
• Column label: App Release Version
• Column name: u_app_release_version
• Type: string
• Max length: 40

7. Click Save.
C. Modify an Existing Discovery Pattern
In this section, add a new identification step that creates a variable and collects information
from the configuration file with a Delimited text Parsing Strategy.

First, create a new variable and populate it using a Delimited text Parsing Strategy, then rerun
discovery and verify the new data is collected.

To populate the new field with data collected from Service Mapping, it is necessary to modify
the appropriate pattern to collect the App Release Version from the configuration file viewed
earlier. Afterwards the value needs to be set into the variable that has the same name as the
field you created.

To modify the discovery logic in an identification section without changing the identification
section itself, an extension section to the pattern can be created to retain the integrity of the
baseline identification section. In this part of the lab, create an extension section with a new
step to collect the Application Release Version from the Apache.cfg.txt file viewed earlier.

1. Navigate to Pattern Designer > Discovery Patterns.

2. From the Discovery Patterns list, search for and open the Apache On Windows pattern.

Note: The Apache On Windows pattern is associated with the CI Type/class,


Apache Web Server, that you just added a new field to.

3. Under the Identification Section, click Identification for HTTP(S) entry point type(s) to open
the Pattern Designer.

Note: This is the Identification Section and the set of steps that were used to identify
the Apache Web Server that is part of the EMEA Dispatch Scanning Service.

4. From the top left of the Pattern Designer, click the arrow next to Apache On Windows
pattern to navigate back to the Apache On Windows pattern.

5. From the Extension Section, click New.

6. In the Name field, enter Apache On Windows Extension and click Done.

7. From the Extension Section, click Apache on Windows Extension to open the Pattern
Designer.

Note: The MID Server runs extension sections after identification sections and only if
at least one identification section completes successfully. If there is more than one
extension section associated with a pattern, an order value can be defined to
determine the order that the MID Server runs the extension sections.
8. From the left pane, double-click Untitled Step and rename the step to Collect App
Release Version.

9. Click OK to the pop-up window.

10. From the top of the Pattern Designer, click the Debug Mode button.

11. Complete the form as shown:


• Select MID Server: Automatic MID Server selection
• Debug Type: Top down
• Select Entry Point Type: HTTP(S) Endpoint
• URL: http://198.51.147.201

Note: The IP address in the screenshot is for the EMEA Dispatch server.

12. Click Connect. When the Debug Progress windows shows Debug has finished
successfully, click Close if the windows remains open.

Note: A green circle should appear on the Debug Mode button to indicate you are
in Debug Mode. Debug Mode is an interactive mode. In Debug Mode, the editor
performs all actions that you perform in the screen. It is recommended that you
work in Debug Mode when creating or editing identification, extension, or
connection sections. Ensure the step you just created is selected before continuing.

13. After Debug Mode appears with a green dot indicating it is turned on, from the
Operation drop-down list, select Parse File.

14. From the Select File field, click Browse.

15. Browse to C:/Apache24/conf/ and double-click apache.cfg.txt.

Note: The file path should populate the Select File field.
16. Click Retrieve File Content.

Note: Service Mapping retrieves the contents of the file and sets the default parsing
to Delimited Text. The file path also can be typed if need be. Use forward slashes in
configuring the path.

17. In the Includes Lines field, enter AppReleaseVersion and hit enter to filter only for the
application release information in the output.

Note: The content retrieved within the text file is now filtered based on your criteria.

18. From the Variables section, click Add Variable.

19. Double-click _Name_ and name the variable u_app_release_version (this matches the
Column Name of the attribute you added earlier to the Apache Web Server CI class).

20. From the Delimiters field, click the pencil icon to configure the delimiter.

21. In the bottom field, enter a space and then click the plus sign to add a space as the
delimiter.
22. Click Done.

23. In the Positions field, enter 2 and then tab out of the field.

Note: 2.0 displays highlighted automatically representing the action of the step.

24. From the top of the form click Test and verify the variable u_app_release_version has a
value of 2.0.

25. Click Close.

Note: It is always best not to hard code file paths into patterns when possible. For
that reason, modify this Step to use a dynamic install directory for future use.

26. Modify the Select File field to now use the string as follows (type, do not copy/paste):
• $install_directory+”/conf/apache.cfg.txt”
27. Click Test to make sure you receive the same results.

Note: Your new step is now configured to search for a file called apache.cfg.txt in
a dynamic directory. If the file is found, it collects the AppReleaseVersion value and
stores it in a variable called u_app_release_version. If the CI Type attribute\field
you created earlier matches the new variable, it will populate the contents of the
variable in the new field after discovery is rerun automatically. It is important that
the variable and the field name match exactly, both from a spelling and case
perspective.

28. From the top of the form, click the Add step comments button to add a comment.

29. In the Step comments field, enter Collect and store App Release for deployed Apache
Server.

Note: It is always good practice to comment any new or modified steps.

30. Click Post to save the comment.

31. From the top of the Pattern Designer form, click Save to save your configurations.

Note: Extension sections only need to be saved to take effect and do not need to
be published.

32. Click the Back to pattern arrow.

33. From the Apache On Windows pattern form, click the Pattern tab and notice how the
original patterns NDL (Neebula Description Language) is not modified as there is no App
Release configured in the Pattern Text.

Note: The extension section is stored in a shared library and does not affect the
baseline pattern text or NDL.
CHALLENGE 1 (Required):
1. Run Discovery on the EMEA Dispatch Scanning Service and after discovery completes,
verify the App Release Version is collected and displays in the Properties pane as shown.

2. View the Discovery Log and verify the new step was executed successfully.

Note: If the App Release Version does not display, verify that the field name you
created in the CI Class Manager matches the variable you created and populated
in the new step. It should be noted that if you deviated from the steps in the lab
and created the field using “Form Layout”, the value may get unexpected results.
D. Navigate Easily to a Discovery Pattern
In this section, use a simple method to navigate to a Discovery Pattern with Debug Mode
configured.

1. From the Discovery Log window, select the Apache on Windows Extension.

2. From the top right of the Discovery Log window, click Debug to automatically navigate
to the Extension Section and have the Debug settings configured.

3. Verify that the Debug Extension Section configuration is automatically configured for you,
then click Connect.

Note: You have easily navigated back to the extension section in debug mode if
further editing is required. This method of accessing the pattern is usually a lot
easier, since you do not need to know the actual pattern or specific parameters
needed for configuring debug mode.
CHALLENGE 2 (Required):
Perform the following new configuration to collect the CityLocation information from the
Apache application apache.cfg.txt file supporting the EMEA Dispatch Scanning Service:
• Create a new Apache Web Server field of type String called City Location.
• Add a new step to the Extension Section you are working with that collects the CityLocation
information defined in the apache.cfg.txt file (again using $install_directory to support a
dynamic file path).
• Run discovery to display the City Location information in the Properties pane as shown.

Hint: Instead of creating a new step from scratch, attempt to copy and paste the
step already created, and modify it accordingly to meet the requirement.

Good Practice: Instead of using the parse file operation for every step to retrieve
the content of the apache.cfg file, one query to the server for content of the file is
all that is needed. The results can then be stored in a variable, and then the
variable can be used in subsequent steps with a parse variable operation to
retrieve the same data required without additional round trips to the server.
Lab Validation (Optional):
ServiceNow offers an Automated Test Framework that is used in this class to check if records
were created correctly, and you met the desired outcome during the lab. Run these tests if you
would like to validate completion of the lab.

1. Navigate to Automated Test Framework > Tests.

2. Execute the test that matches the lab you completed.

Note: If the Run Test windows displays a message of Succeeded 100%, you passed
the test, and your lab work has been validated. Nice work!

There may be situations where you successfully completed the lab, and the test script fails due
to different naming conventions between what you entered and what was written in the book. It
is recommended to complete the labs using the same naming conventions to avoid these
scenarios.

Congratulations! You have completed this lab.

You might also like