Skip to content

Commit

Permalink
[airos][doc] changed to comply to pull request review
Browse files Browse the repository at this point in the history
  • Loading branch information
edoput committed Jul 17, 2017
1 parent f82a34f commit c7a7069
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion docs/source/backends/airos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ And another that set the authentication protocol to WPA2 enterprise, but this is
]
}
Leaving the `NetJSON Encryption object <http://netjson.org/rfc.html#rfc.section.5.4.2.1>` empty defaults to no encryption at all
Leaving the `NetJSON Encryption object <http://netjson.org/rfc.html#rfc.section.5.4.2.1>` empty defaults to no encryption at all.
106 changes: 53 additions & 53 deletions docs/source/backends/intermediate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Intermediate representation

The intermediate representation is the output of the a :ref:`converter`,
it is backend specific and is built as a tree structure made from python
builtins values
builtins values.

A tree is a *acyclic, directional graph* with an element called *root*.

The root of our tree is stored in the first element of a tuple, along with
the root's direct sons as a list
the root's direct sons as a list:

.. code-block:: python
Expand All @@ -30,9 +30,9 @@ As an example here we present the tree `('spam', ['eggs', 'snakes'])`
}

As a son may be a carrier of a value so we store it in a dictionary instead of adding a *leaf*
with another level of recursion
with another level of recursion.

As an example here we present the tree `('spam', [ { 'eggs': 2 }, { 'snakes' : { 'loved' : 'python' }}])`
As an example here we present the tree `('spam', [ { 'eggs': 2 }, { 'snakes' : { 'loved' : 'python' }}])`:

.. graphviz::

Expand All @@ -46,7 +46,7 @@ As an example here we present the tree `('spam', [ { 'eggs': 2 }, { 'snakes' : {

}

This tree could be tranlated to a configuration file for AirOS that looks like this
This tree could be tranlated to a configuration file for AirOS that looks like this:

.. code-block:: ini
Expand All @@ -55,7 +55,7 @@ This tree could be tranlated to a configuration file for AirOS that looks like t
So our tree representation is based on the simple assumption that a *leaf* is a dictionary
without nested values and nested values in a dictionary creates a father-son relationship
without nested values and nested values in a dictionary creates a father-son relationship.

Instead when the configuration requires that the son values must be prefixed from a number,
e.g. `vlan.1.devname=eth0` we store a list of dictionaries.
Expand All @@ -65,27 +65,27 @@ e.g. `vlan.1.devname=eth0` we store a list of dictionaries.
(
'spam',
[
{
'eggs' : 2,
{
'eggs' : 2,
},
{
'snakes' : {
'loved' : [
{
'python2' : True,
},
{
'python3' : True,
},
{
'ipython' : True,
}
],
},
{
'snakes' : {
'loved' : [
{
'python2' : True,
},
{
'python3' : True,
},
{
'ipython' : True,
}
],
},
}
]
}
])
And the resulting tree is this
And the resulting tree is:

.. graphviz::

Expand All @@ -109,7 +109,7 @@ And the resulting tree is this

}

And the configuration is
And the configuration is:

.. code-block:: ini
Expand All @@ -119,32 +119,32 @@ And the configuration is
spam.snakes.loved.2.ipython=true
The process by which we can go from the intermediate representation from
the output configuration is called flattening
the output configuration is called flattening, you can find more in the next section.

Flattening
----------

To avoid at all cost a recursive logic in the template we flatten the intermediate
representation to something that has a *namespace* a *key* and a *value*
representation to something that has a *namespace* a *key* and a *value*.

This input NetJSON will be converted to a python :ref:`configuration_dictionary`
This input NetJSON will be converted to a python :ref:`configuration_dictionary`:

.. code-block:: json
//netjson
{
"type" : "DeviceConfiguration",
"interfaces" : [
{
"name" : "eth0.1",
"type" : "ethernet",
"comment" : "management vlan"
},
{
"name" : "eth0.2",
"type" : "ethernet",
"comment" : "traffic vlan"
}
{
"name" : "eth0.1",
"type" : "ethernet",
"comment" : "management vlan"
},
{
"name" : "eth0.2",
"type" : "ethernet",
"comment" : "traffic vlan"
}
]
}
Expand All @@ -153,21 +153,21 @@ This input NetJSON will be converted to a python :ref:`configuration_dictionary`
#python
{
'interfaces' : [
{
'name' : 'eth0.1',
'type' : 'ethernet',
'comment' : 'management'
},
{
'name' : 'eth0.2',
'type' : 'ethernet',
'comment' : 'traffic'
}
{
'name' : 'eth0.1',
'type' : 'ethernet',
'comment' : 'management vlan'
},
{
'name' : 'eth0.2',
'type' : 'ethernet',
'comment' : 'traffic vlan'
}
]
}
And this must be converted to an appropiate AirOS configuration which looks like this
And this must be converted to an appropiate AirOS configuration which looks like this:

.. code-block:: ini
Expand All @@ -182,7 +182,7 @@ And this must be converted to an appropiate AirOS configuration which looks like
vlan.status=enabled
To do this we must convert the :ref:`configuration_dictionary` into something that
resemble the target text, the output configuration
resembles the target text, the output configuration.

.. code-block:: python
Expand All @@ -208,9 +208,9 @@ resemble the target text, the output configuration
)
And to do that we get rid of the multiple indentation levels by flattening the tree structure
And to do that we get rid of the multiple indentation levels by flattening the tree structure.

The tree associated with the previous NetJSON example is this
The tree associated with the previous NetJSON example is this:

.. graphviz::

Expand Down

0 comments on commit c7a7069

Please sign in to comment.