Wednesday, 1 September 2021

DevNet - data formats [XML, JSON, YAML]

-> XML - Extensible Markup Language - platform neutral and data format. It has a tree like structure starting with a root element at the top and a parent/child relationship between elements. In below example device is the root element. First line in XML file is called prologue and it includes version and encoding information. Tags are used defined and usually documented by API provider. 

XML can be problematic to parse in Python due to the fact that the order of data is important Python module: xmltodict converts XML into ordered dictionary.

Example:

<?xml version="1.0" encoding=“UTF-8"?>
<!— example of comment in XML —>
<device>
<hostname>Edge1<hostname/>
<interface>
<name>Ethernet0</name>
<description>L2 Uplink</description>
<enabled>true</enabled>
</interface>
</device>


Keep in mind: in XML whitespace is insignificant

-> JSON - JavaScript Object Notation - data structure that comes from Java programming language but it is not limited to it and can be used independently. Data objects in JSON are comma separated key/value pairs which can be nested to create hierarchy/structure of data model. following are examples of supported data types: Strings, numbers, booleans or nulls.


Example:


{ "node":

  { "hostname": "Edge1", "details": { "interface":

   { "name": "Ethernet0", "description": "L2 Uplink", "enabled": "true"

   }

                                    }

  }

  }


Keep in mind: JSON does not support comments unlike XML or YAML, whitespace is insignificant and used to help with human readability.


-> YAML - YAML Ain’t Markup Language - human friendly data format that can be used with all programming language. Syntax is very minimal, YAML file opens with three dashes (“—-”) and close with three dots (“…”), hash and a space (“# ”) indicates comment. 


Example:


---

device:

    hostname: Edge1

    interface:

        name:Ethernet0

        description:Uplink

        enabled:true

...


To work with YAML 



Keep in mind: YAML parsers can parse JSON as well. White space is significant, indentation with a use of space (not Tab) indicates hierarchy and it should be consistent.


Plumbing... QoS

Rule no 1. QoS does not help in situations where there is no enough bandwidth but helps optimize performance by prioritization of the traffi...