Skip to content

Commit b26c330

Browse files
authored
Merge pull request #16 from wwt/timothyhull/august-2021-updates-5
August 2021 updates 5
2 parents 52744eb + ae59c7b commit b26c330

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+513
-98
lines changed

Diff for: docs/images/pf_lab/10_jupyter_nav_2.png

22.4 KB
Loading

Diff for: docs/images/pf_lab/11_jupyter_nav_3.png

289 KB
Loading

Diff for: docs/images/pf_lab/12_jupyter_nav_4.png

-633 KB
Binary file not shown.

Diff for: docs/images/pf_lab/12_lab_restart.png

694 KB
Loading

Diff for: docs/images/pf_lab/13_lab_restart.png

-585 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.

Diff for: docs/images/pf_lab/7_paste_ps_commands.png

31.3 KB
Loading

Diff for: docs/images/pf_lab/8_jupyter_setup.png

327 KB
Loading

Diff for: docs/images/pf_lab/9_jupyter_nav_1.png

23.9 KB
Loading

Diff for: docs/index.md

+91-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,94 @@
11
# DEVASC Associate NETCONF Intro Hands-On Lab Guide
22

3-
## :fontawesome-solid-laptop-code: Notice
3+
## :fontawesome-solid-laptop-code: Overview
44

5-
This documentation will publish on or before 8/4/2021
5+
What's the big fuss over IT automation? Well, more than anything, the excitement is about the sorts of things that you _don't_ have to do when automation is on your side. Things like _not_ having to either copy and paste configuration changes to dozens (maybe hundreds) of different systems or repeat the same click, click, click, click, click-through-the-UI marathon over, and over, and over..._every single time_ there's a need to make a bulk change :rage:.
6+
7+
To automate configuration and management workflows for network devices, we need to learn to write some form of automation-specific code, and the **NETCONF** protocol makes that possible. **NETCONF** provides a programmatic way to automate the network device workflows based on the predictable data structures found in YANG models.
8+
9+
This guide will walk you through some hands-on exercises that help teach and give you a place to practice using Python to automate workflows with **NETCONF**. You'll get the most from these exercises if you have some familiarity with:
10+
11+
- :fontawesome-brands-python: Python fundamentals.
12+
- :fontawesome-solid-code: Managing and transposing structured data between XML and Python objects.
13+
- :material-code-json: Interpreting YANG models.
14+
15+
---
16+
17+
### :fontawesome-solid-file-code: Unstructured vs Structured Data
18+
19+
#### Data Meant for Humans to Read
20+
21+
When we interact with the CLI of a network device, we typically send text commands and receive text responses. Usually, the responses to our commands are in plain text, in an **unstructured** format. We often see the raw text responses formatted with various spaces, tabs, numbering, tables, or even text-based graphics, to make the text easier for humans to read.
22+
23+
---
24+
25+
#### Data Meant for Computers to Read
26+
27+
When a computer, such as an automation system, tries to read that same, **unstructured** data, we usually have to tell the computer precisely how it needs to find the information we need. That is, we have to write some form of a search pattern, or **parser**, to sift through all of the spaces, special characters, and text graphics, etc., to find the specific, raw data we want. Parsing through unstructured data is often difficult to configure, temperamental to test successfully, and a headache to maintain. Plus, anytime an IT system undergoes a software or hardware change, the unstructured command response a parser expects can change, even if by a single character, and cause the parser to fail or work improperly.
28+
29+
---
30+
31+
#### The NETCONF Protocol
32+
33+
So, how do we automate configuration and management workflows for network devices and avoid having our lives consumed by the "joy" of writing and maintaining text parsers? Fortunately, the NETCONF protocol, defined in [IETF RFC 6241](https://datatracker.ietf.org/doc/html/rfc6241 "IETF RFC 6241"){target=_blank}, allows us to use code to automate how we configure and manage network devices using open-source or OEM-proprietary **structured** YANG data models.
34+
35+
Using [openly available YANG models](https://github.com/YangModels/yang "YANG Model Git Repository"){target=_blank}, our automation code can programmatically interact with network devices at scale because NETCONF uses XML to structure the data it sends between NETCONF clients[^1] and NETCONF servers[^2].
36+
37+
---
38+
39+
## :fontawesome-solid-code: A Practical Example
40+
41+
Here is an example of data returned by a network device in response to a CLI command compared with the same data returned by a network device in response to a NETCONF RPC. Now, unless you happen to be a computer, you will probably find the CLI example (**unstructured data**) a bit easier to read than the NETCONF example (**structured data**).
42+
43+
---
44+
45+
### :fontawesome-regular-file-code: A Side-by-Side Comparision
46+
47+
???+ abstract "Example Network Device CLI and NETCONF Response Data"
48+
49+
Even though the CLI and NETCONF data formats look drastically different, they both provide the _exact_ same data.
50+
51+
=== "CLI Response Output - Unstructured Data"
52+
```text
53+
--8<-- "includes/data_cli.txt"
54+
```
55+
56+
=== "NETCONF Response Output - Structured Data"
57+
58+
```xml
59+
--8<-- "includes/data_xml.xml"
60+
```
61+
62+
---
63+
64+
### :fontawesome-brands-python: Comparing the Code
65+
66+
If you're thinking, _"Why would I ever want to deal with the **structured data** in a NETCONF RPC reply? It looks like a mess!"_ Well, to put it simply, **structured data** in NETCONF RPCs is _way_ easier to work with **programmatically**. Take a look at how we might parse both the CLI and NETCONF responses with some Python code:
67+
68+
???+ note "Example Code Exercise"
69+
70+
This exercise aims to parse the interface ID from each of the CLI and NETCONF response data sets. For reference, the correct result of a search for the interface ID is the text **1/10**. These examples assume the CLI and NETCONF data sets are already available to the Python interpreter in the variable with the name **`data`**.
71+
72+
- Even though the CLI response data is only a few lines long, the Python code to parse the interface ID from that data, with a regular expression, is lengthy and somewhat complex to read.
73+
- By contrast, even though the NETCONF response data is lengthy, the Python code to parse the interface ID is short and far less complex to read.
74+
75+
??? example "Click to view the code examples"
76+
77+
=== "Parse the Unstructured (CLI) Response"
78+
```python linenums="1" hl_lines="5-17 19 21-25"
79+
--8<-- "includes/parse_unstructured.py"
80+
```
81+
82+
=== "Parsing the Structured (NETCONF) Response"
83+
```python linenums="1" hl_lines="5-9"
84+
--8<-- "includes/parse_structured.py"
85+
```
86+
87+
---
88+
89+
All right, that's enough reading for now. It's time to get into the lab exercises and get some real practice. If everything to this point makes perfect sense to you, great! If not, don't worry because you're about to get plenty of hands-on repetitions with functional code. [Click here to continue to the next section](sections/section_1.md "Hands-On Lab Setup").
90+
91+
[^1]: NETCONF documentation often uses the terms **managers** and **clients** interchangeably to describe management workstations or servers.
92+
[^2]: NETCONF documentation uses the terms **agents**, **devices**, and **servers** interchangeably to describe network devices.
93+
94+
--8<-- "includes/glossary.txt"

0 commit comments

Comments
 (0)