1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

move ifupdown2/* .

ifupdown2 code was one level deeper because ifupdown2 initially
had ifupdown2 and ifupdown2-addons as two separate packages.
Since they were combined into one package, it makes sense to
move all combined code under the top level directory

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
Roopa Prabhu
2015-08-02 05:05:52 -07:00
parent 6b14b64e62
commit ff50f301d5
89 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
Documentation for the ifupdownaddons default addons modules
***********************************************************
address
=======
.. automodule:: address
.. autoclass:: address
:members: run, get_ops
bridge
======
.. automodule:: bridge
.. autoclass:: bridge
:members: run, get_ops
dhcp
====
.. automodule:: dhcp
.. autoclass:: dhcp
ethtool
=======
.. automodule:: ethtool
.. autoclass:: ethtool
ifenslave
=========
.. automodule:: ifenslave
.. autoclass:: ifenslave
mstpctl
=======
.. automodule:: mstpctl
.. autoclass:: mstpctl
usercmds
========
.. automodule:: usercmds
.. autoclass:: usercmds
vlan
====
.. automodule:: vlan
.. autoclass:: vlan

View File

@@ -0,0 +1,44 @@
Documentation for the ifupdownaddons package helper modules
***********************************************************
This package contains modules that provide helper methods
for ifupdown2 addon modules to interact directly with tools
like iproute2, brctl etc.
bridgeutils
===========
Helper module to work with bridgeutil commands
.. automodule:: bridgeutils
.. autoclass:: brctl
ifenslaveutil
=============
Helper module to interact with linux api to create bonds.
Currently this is via sysfs.
.. automodule:: ifenslaveutil
.. autoclass:: ifenslaveutil
dhclient
========
Helper module to interact with dhclient tools.
.. automodule:: dhclient
.. autoclass:: dhclient
iproute2
========
Helper module to interact with iproute2 tools.
.. automodule:: iproute2
.. autoclass:: iproute2

65
docs/source/apiref.rst Normal file
View File

@@ -0,0 +1,65 @@
Documentation for the Code
**************************
ifupdownmain
============
ifupdownmain is the main ifupdown module.
.. automodule:: ifupdownmain
.. autoclass:: ifupdownMain
:members: up, down, reload, query
iface
=====
.. automodule:: iface
.. autoclass:: iface
:members: state, status, flags, priv_flags, refcnt, lowerifaces, upperifaces, add_to_upperifaces, get_attr_value, get_attr_value_first, get_attr_value_n, update_config, update_config_with_status, get_config_attr_status, compare, dump_raw, dump, dump_pretty
.. autoclass:: ifaceState
.. autoclass:: ifaceStatus
.. autoclass:: ifaceJsonEncoder
scheduler
=========
.. automodule:: scheduler
.. autoclass:: ifaceScheduler
:members: sched_ifaces
.. autoclass:: ifaceSchedulerFlags
networkinterfaces
=================
.. automodule:: networkinterfaces
.. autoclass:: networkInterfaces
:members: load, subscribe
statemanager
============
.. automodule:: statemanager
.. autoclass:: pickling
:members: save, save_obj, load
.. autoclass:: stateManager
:members: read_saved_state, save_state
graph
=====
.. automodule:: graph
.. autoclass:: graph
:members: topological_sort_graphs_all, generate_dots

250
docs/source/conf.py Normal file
View File

@@ -0,0 +1,250 @@
# -*- coding: utf-8 -*-
#
# ifupdown2 documentation build configuration file, created by
# sphinx-quickstart on Sun Jul 6 23:49:20 2014.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../../ifupdown'))
sys.path.append(os.path.abspath('../../addons'))
sys.path.append(os.path.abspath('../../'))
sys.path.append(os.path.abspath('../../ifupdownaddons'))
sys.path.append(os.path.abspath('../../../ifupdown2'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'ifupdown2'
copyright = u'2014, Roopa Prabhu'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'ifupdown2doc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'ifupdown2.tex', u'ifupdown2 Documentation',
u'Roopa Prabhu', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'ifupdown2', u'ifupdown2 Documentation',
[u'Roopa Prabhu'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'ifupdown2', u'ifupdown2 Documentation',
u'Roopa Prabhu', 'ifupdown2', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}

View File

@@ -0,0 +1,72 @@
Development Corner
==================
Getting started
---------------
Unlike original ifupdown, all interface configuration is moved to external
python modules. That includes inet, inet6 and dhcp configurations.
* if you are looking at fixing bugs or adding new features to the ifupdown2
infrastructure package, pls look at the apiref, documentation and code
for python-ifupdown2
Writing a ifupdown2 addon module
--------------------------------
Addon modules are a nice way to add additional functionality to ifupdown2.
Typically a new addon module will include support for a new network interface
configuration which is not already supported by existing ifupdown2 addon
modules.
ifupdown2 addon modules are written in python. python-ifupdown2 package
comes with default addon modules. All addon modules are installed under
/usr/share/ifupdownaddons directory.
The center of the universe for an addon module is the 'class iface' object
exported by the python-ifupdown2 package.
The iface object is modeled after an iface entry in the user provided network
configuration file (eg. /etc/network/interfaces). For more details see
the api reference for the iface class.
ifupdown2 dynamically loads a python addon module. It expects the addon module
to implement a few methods.
* all addon modules must inherit from moduleBase class
* the module must implement a class by the same name
* the network interface object (class iface) and the operation to be performed
is passed to the modules. Operation can be any of 'pre-up', 'up', 'post-up',
'pre-down', 'down', 'post-down', 'query-check', 'query-running'.
The module can choose to support a subset or all operations.
In cases when the operation is query-check, the module must compare between
the given and running state and return the checked state of the object in
queryobjcur passed as argument to the run menthod.
* the python addon class must provide a few methods:
* run() : method to configure the interface.
* get_ops() : must return a list of operations it supports.
eg: 'pre-up', 'post-down'
* get_dependent_ifacenames() : must return a list of interfaces the
supported interface is dependent on. This is used to build the
dependency list for sorting and executing interfaces in dependency order.
* if the module supports -r option to ifquery, ie ability to construct the
ifaceobj from running state, it can optionally implement the
get_dependent_ifacenames_running() method, to return the list of
dependent interfaces derived from running state of the interface.
This is different from get_dependent_ifacenames() where the dependent
interfaces are derived from the interfaces config file (provided by the
user).
* provide a dictionary of all supported attributes in the _modinfo
attribute. This is useful for syntax help and man page generation.
python-ifupdown2 package also installs ifupdownaddons python package
that contains helper modules for all addon modules.
see example address handling module /usr/share/ifupdownaddons/address.py
API reference
-------------
.. toctree::
:maxdepth: 2
addonsapiref.rst
addonshelperapiref.rst

View File

@@ -0,0 +1,27 @@
Getting Started
===============
Prerequisites
-------------
* python-ifupdown2 is currently only tested on debian wheezy
* python-ifupdown2 needs python version 2.6 or greater
* Depends on: python-stdeb (for deb builds), python-docutils
(for rst2man), python-argcomplete, 'python-ipaddr'
* Depends on python-gvgen package for printing interface graphs (this will be made optional in the future)
* Optional dependency for template engine: python-mako
Building
--------
$git clone <ifupdown2 git url> ifupdown2
$cd ifupdown2/ifupdown2
$./build.sh
Installing
----------
install generated python-ifupdown2-<ver>.deb
$dpkg -i <python-ifupdown2-<ver>.deb

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

25
docs/source/index.rst Normal file
View File

@@ -0,0 +1,25 @@
.. ifupdown2 documentation master file, created by
sphinx-quickstart on Sun Jul 6 23:49:20 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to ifupdown2's documentation!
=====================================
Contents:
.. toctree::
:maxdepth: 2
intro.rst
gettingstarted.rst
userguide.rst
developmentcorner.rst
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

31
docs/source/intro.rst Normal file
View File

@@ -0,0 +1,31 @@
python-ifupdown2
----------------
The python-ifupdown2 package provides the infrastructure for
parsing /etc/network/interfaces file, loading, scheduling, template parsing,
state management and interface dependency generation of interfaces.
It dynamically loads python addon modules from /usr/share/ifupdownmodules.
To remain compatible with other packages that depend on ifupdown, it also
executes scripts under /etc/network/. To make the transition smoother, a
python module under /usr/share/ifupdownmodules will override a script by
the same name under /etc/network/. ifupdown2 publishes an interface object which
is passed to all loadble python addon modules. All lodable modules are
called for every interface declared in the /etc/network/interfaces file.
Addon modules are responsible for applying interface configuration.
python-ifupdown2 ships with a set of default addon modules. Each module can
declare its own set of supported attributes. Each module is passed the iface
object (which is a representation of /etc/network/interfaces
iface entry). Each module is also passed the operation to be performed.
Example modules are /usr/share/ifupdownmodules/address.py,
/usr/share/ifupdownmodules/bridge.py etc
The order in which these modules are invoked is listed in
/var/lib/ifupdownaddons/addons.conf. There is an ifaddon utility in the works
to better manage the module ordering.
For more details on adding an addon module, see the section on adding python
modules. For details on how to write a module, see the api reference and
development documentation.

447
docs/source/userguide.rst Normal file
View File

@@ -0,0 +1,447 @@
.. index:: ifupdown
.. _ifupdown:
**********
User Guide
**********
Keep the following points in mind before you start configuring interfaces using
``ifupdown2``:
* IPv4 and IPv6 addresses for an interface can be listed in the same ``iface``
section. For examples, see ``/usr/share/doc/python-ifupdown2/examples/``.
* Do not use a legacy interface alias. They are only supported for backward
compatibility with ``ifupdown``. They do get configured, but ``ifquery`` has
problems recognizing them.
* ``ifupdown`` only understands interfaces that were configured using
``ifupdown``. Any interfaces created with a command other than ``ifupdown``
(like ``brctl``) must be de-configured in the same manner.
* Use globs for port lists wherever applicable. Regular expressions work as well,
however regular expressions require all matching interfaces to be present in
the ``interfaces`` file. And declaring all interfaces in the ``interfaces``
file leads to losing all the advantages that built-in interfaces provide.
* Extensions to ``ifquery`` help with validation and debugging.
* By default, ``ifupdown`` is quiet; use the verbose option ``-v`` when you want
to know what is going on when bringing an interface down or up.
Contents
========
* `Commands`_
* `Man Pages`_
* `Configuration Files`_
* `ifupdown Built-in Interfaces`_
* `ifupdown Interface Dependencies`_
* `Configuring IP Addresses`_
* `Specifying User Commands`_
* `Sourcing Interface File Snippets`_
* `Using Globs for Port Lists`_
* `Using Templates`_
* `Using ifquery to Validate and Debug Interface Configurations`_
* `Useful Links`_
Commands
========
* ifdown
* ifquery
* ifreload
* ifup
Man Pages
=========
* man ifdown(8)
* man ifquery(8)
* man ifreload
* man ifup(8)
* man ifupdown-addons-interfaces(5)
* man interfaces(5)
Configuration Files
===================
* /etc/network/interfaces
ifupdown Built-in Interfaces
============================
``ifupdown`` understands VLAN interfaces and physical interfaces that may appear
as dependents. There is no need to list them unless they need the specific
configuration or they need to match a regular expression used in the
``interfaces`` file. Use globs to avoid limitations with regular expressions.
For example, swp1.100 and swp2.100 below do not need an entry in the
``interfaces`` file::
auto br-100
iface br-100
address 10.0.12.2/24
address 2001:dad:beef::3/64
bridge-ports swp1.100 swp2.100
bridge-stp on
ifupdown Interface Dependencies
===============================
``ifupdown`` understands interface dependency relationships. When ``ifup`` and
``ifdown`` are run with all interfaces, they always run with all interfaces
in dependency order. When run with the interface list on the command line, the
default behavior is to not run with dependents. But if there are any built-in
dependents, they will be brought up or down.
To run with dependents when you specify the interface list, use the
``--with-depends`` option. ``--with-depends`` walks through all dependents
in the dependency tree rooted at the interface you specify. Consider the
following example configuration::
auto bond1
iface bond1
address 100.0.0.2/16
bond-slaves swp29 swp30
bond-mode 802.3ad
bond-miimon 100
bond-use-carrier 1
bond-lacp-rate 1
bond-min-links 1
bond-xmit-hash-policy layer3+4
auto bond2
iface bond2
address 100.0.0.5/16
bond-slaves swp31 swp32
bond-mode 802.3ad
bond-miimon 100
bond-use-carrier 1
bond-lacp-rate 1
bond-min-links 1
bond-xmit-hash-policy layer3+4
auto br2001
iface br2001
address 12.0.1.3/24
bridge-ports bond1.2001 bond2.2001
bridge-stp on
Specifying ``ifup --with-depends br2001`` brings up all dependents: bond1.2001,
bond2.2001, bond1, bond2, bond1.2001, bond2.2001, swp29, swp30, swp31, swp32.
Similarly, specifying ``ifdown --with-depends br2001`` brings down all
dependents: bond1.2001, bond2.2001, bond1, bond2, bond1.2001, bond2.2001, swp29,
swp30, swp31, swp32.
.. warning:: ``ifdown`` always deletes logical interfaces after bringing them
down. Use the ``--admin-state`` option if you only want to administratively
bring the interface up or down. In terms of the above example,
``ifdown br2001`` deletes ``br2001``.
To guide you through which interfaces will be brought down and up, use the
``--print-dependency`` option to get the list of dependents.
Use ``ifup --print-dependency=list -a`` to get the dependency list of all
interfaces::
cumulus@switch:~$ sudo ifup --print-dependency=list -a
lo : None
eth0 : None
bond0 : ['swp25', 'swp26']
bond1 : ['swp29', 'swp30']
bond2 : ['swp31', 'swp32']
br0 : ['bond1', 'bond2']
bond1.2000 : ['bond1']
bond2.2000 : ['bond2']
br2000 : ['bond1.2000', 'bond2.2000']
bond1.2001 : ['bond1']
bond2.2001 : ['bond2']
br2001 : ['bond1.2001', 'bond2.2001']
swp40 : None
swp25 : None
swp26 : None
swp29 : None
swp30 : None
swp31 : None
swp32 : None
To print the dependency list of a single interface, use::
cumulus@switch:~$ sudo ifup --print-dependency=list br2001
br2001 : ['bond1.2001', 'bond2.2001']
bond1.2001 : ['bond1']
bond2.2001 : ['bond2']
bond1 : ['swp29', 'swp30']
bond2 : ['swp31', 'swp32']
swp29 : None
swp30 : None
swp31 : None
swp32 : None
To print the dependency information of an interface in ``dot`` format::
cumulus@switch:~$ sudo ifup --print-dependency=dot br2001
/* Generated by GvGen v.0.9 (http://software.inl.fr/trac/wiki/GvGen) */
digraph G {
compound=true;
node1 [label="br2001"];
node2 [label="bond1.2001"];
node3 [label="bond2.2001"];
node4 [label="bond1"];
node5 [label="bond2"];
node6 [label="swp29"];
node7 [label="swp30"];
node8 [label="swp31"];
node9 [label="swp32"];
node1->node2;
node1->node3;
node2->node4;
node3->node5;
node4->node6;
node4->node7;
node5->node8;
node5->node9;
}
You can use ``dot`` to render the graph on an external system where ``dot`` is
installed.
.. image:: images/interfaces.png
To print the dependency information of the entire ``interfaces`` file::
cumulus@switch:~$ sudo ifup --print-dependency=dot -a >interfaces_all.dot
.. image:: images/interfaces_all.png
:width: 800px
.. note: The '--print-dependency' option is available with the ``ifup``,
``ifdown`` and ``ifquery`` commands.
Configuring IP Addresses
========================
In ``/etc/network/interfaces``, list all IP addresses as shown below under the
``iface`` section (see ``man interfaces`` for more information)::
auto swp1
iface swp1
address 12.0.0.1/30
address 12.0.0.2/30
The address method and address family are not mandatory. They default to
``inet``/``inet6`` and ``static`` by default, but ``inet``/``inet6`` **must** be
specified if you need to specify ``dhcp`` or ``loopback``.
You can specify both IPv4 and IPv6 addresses under the same ``iface`` section::
auto swp1
iface swp1
address 12.0.0.1/30
address 12.0.0.2/30
address 2001:dee:eeef:2::1/64
Specifying User Commands
========================
You can specify additional user commands in the ``interfaces`` file. As shown in
the example below, the interface stanzas in ``/etc/network/interfaces`` can have
a command that runs at pre-up, up, post-up, pre-down, down, and post-down::
auto swp1
iface swp1
address 12.0.0.1/30
up /sbin/foo bar
Any valid command can be hooked in the sequencing of bringing an interface up or
down, although commands should be limited in scope to network-related commands
associated with the particular interface.
For example, it wouldn't make sense to install some Debian package on ``ifup``
of swp1, even though that is technically possible. See ``man interfaces`` for
more details.
Sourcing Interface File Snippets
================================
Sourcing interface files helps organize and manage the ``interfaces(5)`` file.
For example::
cumulus@switch:~$ cat /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
source /etc/network/interfaces.d/bond0
The contents of the sourced file used above are::
cumulus@switch:~$ cat /etc/network/interfaces.d/bond0
auto bond0
iface bond0
address 14.0.0.9/30
address 2001:ded:beef:2::1/64
bond-slaves swp25 swp26
bond-mode 802.3ad
bond-miimon 100
bond-use-carrier 1
bond-lacp-rate 1
bond-min-links 1
bond-xmit-hash-policy layer3+4
Using Globs for Port Lists
==========================
Some modules support globs to describe port lists. You can use globs to specify
bridge ports and bond slaves::
auto br0
iface br0
bridge-ports glob swp1-6.100
auto br1
iface br1
bridge-ports glob swp7-9.100 swp11.100 glob swp15-18.100
Using Templates
===============
``ifupdown2`` supports Mako-style templates. For more information see
`www.makotemplates.org <http://www.makotemplates.org/>`_. The Mako template
engine is run over the ``interfaces`` file before parsing.
Use the template to declare cookie-cutter bridges in the ``interfaces`` file::
%for v in [11,12]:
auto vlan${v}
iface vlan${v}
address 10.20.${v}.3/24
bridge-ports glob swp19-20.${v}
bridge-stp on
%endfor
And use it to declare addresses in the ``interfaces`` file::
%for i in [1,12]:
auto swp${i}
iface swp${i}
address 10.20.${i}.3/24
Using ifquery to Validate and Debug Interface Configurations
============================================================
You use ``ifquery`` to print parsed ``interfaces`` file entries.
To use ``ifquery`` to pretty print ``iface`` entries from the ``interfaces``
file, run::
cumulus@switch:~$ sudo ifquery bond0
auto bond0
iface bond0
address 14.0.0.9/30
address 2001:ded:beef:2::1/64
bond-slaves swp25 swp26
bond-mode 802.3ad
bond-miimon 100
bond-use-carrier 1
bond-lacp-rate 1
bond-min-links 1
bond-xmit-hash-policy layer3+4
.. Use ``ifquery -a`` to pretty print all ``iface`` entries from the
``interfaces`` file.
Use ``ifquery --check`` to check the current running state of an interface within
the ``interfaces`` file. It returns exit code ``0`` or ``1`` if the configuration
does not match::
cumulus@switch:~$ sudo ifquery --check bond0
iface bond0
bond-mode 802.3ad (✓)
bond-miimon 100 (✓)
bond-use-carrier 1 (✓)
bond-lacp-rate 1 (✓)
bond-min-links 1 (✓)
bond-xmit-hash-policy layer3+4 (✓)
bond-slaves swp25 swp26 (✓)
address 14.0.0.9/30 (✓)
address 2001:ded:beef:2::1/64 (✓)
.. note:: ``ifquery --check`` is an experimental feature.
.. Use ``ifquery --check -a`` to check all interfaces.
Use ``ifquery --running`` to print the running state of interfaces in the
``interfaces`` file format::
cumulus@switch:~$ sudo ifquery --running bond0
auto bond0
iface bond0
bond-xmit-hash-policy layer3+4
bond-miimon 100
bond-lacp-rate 1
bond-min-links 1
bond-slaves swp25 swp26
bond-mode 802.3ad
address 14.0.0.9/30
address 2001:ded:beef:2::1/64
``ifquery --syntax-help`` provides help on all possible attributes supported in
the ``interfaces`` file. For complete syntax on the ``interfaces`` file, see
``man interfaces`` and ``man ifupdown-addons-interfaces``.
``ifquery`` can dump information in JSON format::
cumulus@switch:~$ sudo ifquery --format=json bond0
{
"auto": true,
"config": {
"bond-use-carrier": "1",
"bond-xmit-hash-policy": "layer3+4",
"bond-miimon": "100",
"bond-lacp-rate": "1",
"bond-min-links": "1",
"bond-slaves": "swp25 swp26",
"bond-mode": "802.3ad",
"address": [
"14.0.0.9/30",
"2001:ded:beef:2::1/64"
]
},
"addr_method": null,
"name": "bond0",
"addr_family": null
}
.. By default ``ifquery`` outputs information in the ``interfaces`` format. Some
options do take the ``--format`` option and can output in JSON format.
Useful Links
============
* `<http://wiki.debian.org/NetworkConfiguration>`_
* `<http://www.linuxfoundation.org/collaborate/workgroups/networking/bonding>`_
* `<http://www.linuxfoundation.org/collaborate/workgroups/networking/bridge>`_
* `<http://www.linuxfoundation.org/collaborate/workgroups/networking/vlan>`_
.. Caveats and Errata
.. ==================