Lab 08 Discovering apps¶
Lab Overview¶
In this lab we will explore the Nautobot app eco system, were to find documentation and the features of the Data Validation Engine app.
Table of Contents¶
Task 1 - Review installed apps¶
Nautobot apps provide a way to extend the features and capabilities of Nautobot. There are apps maintained by NTC, apps built by the community and, you can build your own apps as well.
Step 1-1 - Login via the web browser to Nautobot¶
If you have not already, use a web browser to navigate to your instance of Nautobot at https://{{ your pod }}. We will be using the Nautobot GUI for the remainder of this lab so there won't be a need for a terminal. Log into Nautobot by using the login option in the upper right of the Nautobot homepage. You can log in as the superuser you created in a previous lab or the superuser account included with your lab environment, the credentials for this account will be provided by the instructor.
Step 1-2 - Review app details¶
From the Nautobot homepage, click on the Plugins drop down menu. Two of the sections on this menu, Data Validation Engine and Nautobot Welcome Wizard are being provide by apps. Apps may inject links into this menu or even create new top level menus.

Looking across the top of the menu bar, Device Life Cycle and Golden Config are menus being generated by those apps.

Return to the Plugins drop down menu and click on Installed Plugins. There are a number of plugins installed, some by us in a previous lab, and some were pre-installed for this course.

If you click on the name of an installed app, you will be redirected to a detail page with more information about that app. Click on Nautobot Device Life Cycle Management.
On the left side of the page is some high level information including the Package Name, Description, Version, Author, and Nautobot version compatability.

The right side of the page provides more in-depth information such as Data Models, Jobs, API Endpoints, and Views/URLs are being provided by the app.

Step 1-3 - Browse to the NTC app ecosystem page¶
Access the Nautobot apps page here https://networktocode.com/nautobot/nautobot-apps/
Information about all the apps NTC maintains can be found on this page, along with screenshots and links straight to the code.

Click on the Data Validation app and look for the GitHub URL: https://github.com/nautobot/nautobot-plugin-data-validation-engine. Scroll down the documentation section to find the following:
- User Guide
- Administrator Guide
- Developer Guide
- Release Notes/Changelog
- Frequently Asked Questions
If you plan on installing the application, the best place to start is the Administrator Guide. Click on that link.

The Administrator Guide provides information about prerequisites, app configuration and more. The Data Validation Engine does not require much configuration, so the Administrator Guide is brief. The Golden Config app has quite a bit more configuration as seen here: https://docs.nautobot.com/projects/golden-config/en/latest/admin/admin_install/

This page contains links directly to some of the more popular apps. If you don't see what you need here, there are links on the GitHub pages as shown previously.
https://docs.nautobot.com/projects/core/en/stable/apps/

Task 2 - Try out the Data Validation app¶
High quality, reliable data is extremely important, especially when that data is to be used for automation. One of the best ways to maintain data quality is by preventing "bad" data from entering the system via user inputs. For example, which of these values is correct (shrug emoji)? Using spreadsheets and text files to store data, easily leads to issues like this.
- N/A
- Not Applicable
- notapplicable
- NotApplicable
- None
- null
- NULL
- does not apply
- unknown
- leave blank
The data validation engine app offers a set of user definable rules which are used to enforce business constraints on the data in Nautobot. These rules are tied to particular models and each rule is meant to enforce one aspect of a business use case.
Supported rule types include: - Regular expression - Min/max value - Required fields - Unique values
Step 2-1 - Review and edit a Min/Max Validation Rule¶
Click on the Plugins drop down menu and look for the Data Validation Engine section of the menu. There are two options, Min/Max Rules and Regex Rules. We are going to start with Min/Max rules so click that option to bring up the list of Min/Max rules that have already been created.
There is already a rule in the list, this is not a built-in rule however, it was added for use in this lab. If this was a fresh installation of the Data Validation Engin app, there would be no rules listed here.
The rule limits the maximum VLAN ID (VLANs are found in the IPAM menu) to 3999.

Click on the name of the rule Max VLAN ID to go to the detail page, and then click on the Edit button in the upper right. The required fields are Name, Slug, Content Type, and Field. We've seen fields like this in other forms except Field. In this case, Field is referring to the database row name as specified by a Django model field. This may sound complicated, but it is simply referring to the name of that field in the model code.
You don't have to go looking up source code to get these field names, just look at the bulk import tables, which use the same field names. In this example, to see the proper field name, go to the bulk import form under IPAM --> VLANs.
Change the Max to 15 and click the blue Update button.

Click on the IPAM drop down menu from the top of the page and select VLANs to open the VLAN list. Right away you can see thee are VLANs with IDs much higher than 15. What happened? Validation rules are enforced when an object is created or saved and are NOT retroactive.

Step 2-2 - Edit an object restricted by a Validation Rule¶
Click on the ID of the VLAN at the top of the VLAN list we opened in the previous step. From the detail page of that VLAN, in my case ams01-101-mgmt, click on the Edit button to edit the VLAN's attributes.
Change the VLAN ID to 16 and click Update at the bottom of the form.
The VLAN fails to update and an error is generated explaining why. This same restriction would apply to newly created VLANs until the validation rule was either disabled or deleted.

Step 2-3 - Review Regex Rule Details¶
Throughout the previous labs, we have been following a regular expression validation rule for Device names. To see this rule click on the Plugins drop down menu and select Regex Rules. There is only one rule on the list, and it is for Device names. As with the Min/Max rule, this is not a default rule, it is something that was added for this lab.
Click on the name of the rule to open the detail page.

If you are unfamiliar with regex, it can look confusing, but it's fairly simple when broken down. Here is the rule for Device names:
^[a-z]{3}[0-9]{0,2}\-[a-z0-9]*\-[0-9]{2}(\.[^.]+)*$
And here is breakdown of what each piece means:
- ^ - Matches the beginning of the string
- [a-z] - Match any letter in the a-z range
- {3} - Match exactly three instances of the previous token
- [0-9] - Match any number in the 0-9 range
- {0,2} - Match exactly 0 or exactly 2 instances of the previous token
- \- - Escape the - character, and a - here is required
- $ - Matches the end of the string
(\.[^.]+)* This section of the pattern is a bit more complicated. It is in parentheses which means it is matched as a group. The * means 0 or more instances, making the entire pattern in the parentheses optional. The + means 1 or more instances. [^.] is a negated . and \. simply means a . When put together this section allows for a . followed by any number of non . characters.
Do you have all that memorized?! There is no need to memorize any of this, just use http://regexr.com. In the example below, I've input the Device name regex and a sample Device name. On the right there is a confirmation that one of the entered strings matches. At the bottom of the page is an explanation of each part of the pattern.

Step 2-4 - Create a Regex Validation Rule¶
Click on the Plugins menu drop down and select the green button next to Regex Rules to open the Add a new regular expression validation rule form. For this example we will be creating a rule restrict Site names to a preferred format. Create a new rule with the following attributes:
- Name: Site name
- Slug: site-name
- Enabled: True
- Content type: dcim|site
- Regular expression:
^[A-Z]{3}[0-9]{3,4}$ - Error Message: Site names must be in the format AAA000 or AAA0000. The name must begin with exactly 3 upper case letters followed by 3 or 4 numbers between 0 and 9.
This pattern provides some flexibility by allowing a Site name to end with 3 or 4 digits. When creating regex rules, be careful to include a detailed error message and do not expect users to parse the regex pattern.

Step 2-5 - Test the new Regex Validation Rule¶
Click on the Organization drop down menu and select the green button next to Sites to open the Add a new site form. Enter and invalid name and attempt to save the form. The values I used are below. Don't forget to include a Slug and Status.
- Name: aaa54321
- slug: aaa54321
- Status: Active
An invalid value in the Name field will tigger an error:
