mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Merge remote-tracking branch 'cumulus/dev'
This commit is contained in:
78
docs/README.rst
Normal file
78
docs/README.rst
Normal file
@@ -0,0 +1,78 @@
|
||||
python-ifupdown2
|
||||
================
|
||||
|
||||
This package is a replacement for the debian ifupdown package.
|
||||
It is ifupdown re-written in python. It maintains the original ifupdown
|
||||
pluggable architecture and extends it further.
|
||||
|
||||
The python-ifupdown2 package provides the infrastructure for
|
||||
parsing /etc/network/interfaces file, loading, scheduling and state
|
||||
management of interfaces.
|
||||
|
||||
It dynamically loads python modules from /usr/share/ifupdownmodules (provided
|
||||
by the python-ifupdown2-addons package). 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/.
|
||||
|
||||
It publishes an interface object which is passed to all loadble python
|
||||
modules. For more details on adding a addon module, see the section on
|
||||
adding python modules.
|
||||
|
||||
|
||||
pluggable python modules:
|
||||
=========================
|
||||
Unlike original ifupdown, all interface configuration is moved to external
|
||||
python modules. That includes inet, inet6 and dhcp configurations.
|
||||
|
||||
A set of default modules are provided by the python-ifupdown2-addons deb.
|
||||
|
||||
python-ifupdown2 expects a few things from the pluggable modules:
|
||||
- the module should implement a class by the same name
|
||||
- the interface object (class iface) and the operation to be performed is
|
||||
passed to the modules
|
||||
- the python addon class should 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
|
||||
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).
|
||||
|
||||
Example: Address handling module /usr/share/ifupdownaddons/address.py
|
||||
|
||||
|
||||
build
|
||||
=====
|
||||
- get source
|
||||
|
||||
- install build dependencies:
|
||||
apt-get install python-stdeb
|
||||
apt-get install python-docutils
|
||||
|
||||
- cd <python-ifupdown2 sourcedir> && ./build.sh
|
||||
|
||||
(generates python-ifupdown2-<ver>.deb)
|
||||
|
||||
install
|
||||
=======
|
||||
|
||||
- remove existing ifupdown package
|
||||
dpkg -r ifupdown
|
||||
|
||||
- install python-ifupdown2 using `dpkg -i`
|
||||
|
||||
- or install from deb
|
||||
dpkg -i python-ifupdown2-<ver>.deb
|
||||
|
||||
- note that python-ifupdown2 requires python-ifupdown2-addons package to
|
||||
function. And python-ifupdown2-addons deb has an install dependency on
|
||||
python-ifupdown2
|
@@ -3,6 +3,10 @@
|
||||
import argparse
|
||||
import sys
|
||||
import subprocess
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import os
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
""" This script prints to stdout /etc/network/interfaces entries for
|
||||
requested interfaces.
|
||||
@@ -30,6 +34,7 @@ import subprocess
|
||||
|
||||
"""
|
||||
|
||||
<<<<<<< HEAD
|
||||
def get_swp_interfaces():
|
||||
porttab_path = '/var/lib/cumulus/porttab'
|
||||
ports = []
|
||||
@@ -43,6 +48,49 @@ def get_swp_interfaces():
|
||||
ports.append(line.split()[0])
|
||||
except ValueError:
|
||||
continue
|
||||
=======
|
||||
def get_pci_interfaces():
|
||||
ports = []
|
||||
FNULL = open(os.devnull, 'w')
|
||||
try:
|
||||
cmd = '(ip -o link show | grep -v "@" | cut -d" " -f2 | sed \'s/:$//\')'
|
||||
output = subprocess.check_output(cmd, shell=True).split()
|
||||
for interface in output:
|
||||
cmd = 'udevadm info -a -p /sys/class/net/%s | grep \'SUBSYSTEMS=="pci"\'' % interface
|
||||
try:
|
||||
subprocess.check_call(cmd, shell=True, stdout=FNULL)
|
||||
ports.append(interface)
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
FNULL.close()
|
||||
return ports
|
||||
|
||||
def get_swp_interfaces():
|
||||
porttab_path = '/var/lib/cumulus/porttab'
|
||||
ports = []
|
||||
try:
|
||||
with open(porttab_path, 'r') as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if '#' in line:
|
||||
continue
|
||||
try:
|
||||
ports.append(line.split()[0])
|
||||
except ValueError:
|
||||
continue
|
||||
except:
|
||||
try:
|
||||
ports = get_pci_interfaces()
|
||||
except Exception as e:
|
||||
print 'Error: Unsupported script: %s' % str(e)
|
||||
exit(1)
|
||||
if not ports:
|
||||
print 'Error: No ports found in %s' % porttab_path
|
||||
exit(1)
|
||||
>>>>>>> cumulus/dev
|
||||
return ports
|
||||
|
||||
def print_swp_defaults_header():
|
||||
@@ -138,9 +186,12 @@ if args.bridgedefault and args.mergefile:
|
||||
exit(1)
|
||||
|
||||
swp_intfs = get_swp_interfaces()
|
||||
<<<<<<< HEAD
|
||||
if not swp_intfs:
|
||||
print 'error: no ports found'
|
||||
exit(1)
|
||||
=======
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
if args.swpdefaults:
|
||||
interfaces_print_swp_defaults(swp_intfs)
|
||||
|
@@ -21,16 +21,27 @@ iface swp30
|
||||
alias "test network"
|
||||
link-duplex full
|
||||
link-speed 1000
|
||||
<<<<<<< HEAD
|
||||
link-autoneg off
|
||||
=======
|
||||
link-autoneg no
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
# bond interface
|
||||
auto bond3
|
||||
iface bond3 inet static
|
||||
<<<<<<< HEAD
|
||||
address 100.0.0.4/16
|
||||
bond-slaves swp1 swp2
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-slaves swp1 swp2
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit_hash_policy layer3+4
|
||||
@@ -38,16 +49,27 @@ iface bond3 inet static
|
||||
# bond interface
|
||||
auto bond4
|
||||
iface bond4 inet static
|
||||
<<<<<<< HEAD
|
||||
address 100.0.0.6/16
|
||||
bond-slaves swp3 swp4
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-slaves swp3 swp4
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit_hash_policy layer3+4
|
||||
|
||||
<<<<<<< HEAD
|
||||
# bond interface
|
||||
=======
|
||||
# bridge interface
|
||||
>>>>>>> cumulus/dev
|
||||
auto br0
|
||||
iface br0
|
||||
address 12.0.0.4/24
|
||||
@@ -59,11 +81,17 @@ iface br0
|
||||
# vlan interface on bond
|
||||
auto bond3.2000
|
||||
iface bond3.2000 inet static
|
||||
<<<<<<< HEAD
|
||||
address 100.1.0.4/16
|
||||
|
||||
auto bond4.2000
|
||||
iface bond4.2000 inet static
|
||||
address 100.1.0.6/16
|
||||
=======
|
||||
|
||||
auto bond4.2000
|
||||
iface bond4.2000 inet static
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
auto br2000
|
||||
iface br2000 inet6 static
|
||||
|
@@ -31,11 +31,19 @@ iface br-300 inet static
|
||||
mstpctl-hello 2
|
||||
mstpctl-portnetwork swp13.300=no
|
||||
bridge-mclmc 3
|
||||
<<<<<<< HEAD
|
||||
bridge-mcrouter 0
|
||||
bridge-mcsnoop 1
|
||||
bridge-mcsqc 3
|
||||
bridge-mcqifaddr 1
|
||||
bridge-mcquerier 1
|
||||
=======
|
||||
bridge-mcrouter no
|
||||
bridge-mcsnoop yes
|
||||
bridge-mcsqc 3
|
||||
bridge-mcqifaddr yes
|
||||
bridge-mcquerier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bridge-hashel 3
|
||||
bridge-hashmax 4
|
||||
bridge-mclmi 3
|
||||
|
16
docs/examples/mgmt-vrf
Normal file
16
docs/examples/mgmt-vrf
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
# Example config for management VRF
|
||||
# - 'vrf-default-route no' tells ifupdown2 not to install
|
||||
# the default unreachable route (dhclient will add the
|
||||
# default route)
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
vrf mgmt
|
||||
|
||||
auto mgmt
|
||||
iface mgmt
|
||||
address 127.0.0.1/8
|
||||
vrf-table auto
|
||||
vrf-default-route no
|
||||
|
@@ -23,7 +23,11 @@ iface uplink1
|
||||
bond-slaves swp32
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer2
|
||||
@@ -35,7 +39,11 @@ iface peerlink
|
||||
bond-slaves swp30 swp31
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -47,7 +55,11 @@ iface downlink
|
||||
bond-slaves swp1
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
|
@@ -25,7 +25,11 @@ iface spine-bond
|
||||
bond-slaves glob swp19-22
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -38,7 +42,11 @@ iface peer-bond
|
||||
bond-slaves glob swp23-24
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -61,7 +69,11 @@ iface host-bond-01
|
||||
bond-slaves swp1
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -72,7 +84,11 @@ iface host-bond-02
|
||||
bond-slaves swp2
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
|
@@ -32,12 +32,21 @@ ethtool
|
||||
|
||||
.. autoclass:: ethtool
|
||||
|
||||
<<<<<<< HEAD
|
||||
ifenslave
|
||||
=========
|
||||
|
||||
.. automodule:: ifenslave
|
||||
|
||||
.. autoclass:: ifenslave
|
||||
=======
|
||||
bond
|
||||
====
|
||||
|
||||
.. automodule:: bond
|
||||
|
||||
.. autoclass:: bond
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
mstpctl
|
||||
=======
|
||||
|
@@ -15,15 +15,26 @@ Helper module to work with bridgeutil commands
|
||||
|
||||
.. autoclass:: brctl
|
||||
|
||||
<<<<<<< HEAD
|
||||
ifenslaveutil
|
||||
=============
|
||||
=======
|
||||
bondutil
|
||||
========
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
Helper module to interact with linux api to create bonds.
|
||||
Currently this is via sysfs.
|
||||
|
||||
<<<<<<< HEAD
|
||||
.. automodule:: ifenslaveutil
|
||||
|
||||
.. autoclass:: ifenslaveutil
|
||||
=======
|
||||
.. automodule:: bondutil
|
||||
|
||||
.. autoclass:: bondutil
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
dhclient
|
||||
========
|
||||
|
@@ -66,7 +66,11 @@ Man Pages
|
||||
Configuration Files
|
||||
===================
|
||||
|
||||
<<<<<<< HEAD
|
||||
* /etc/network/interfaces
|
||||
=======
|
||||
* config file defined in ifupdown2.conf (default /etc/network/interfaces)
|
||||
>>>>>>> cumulus/dev
|
||||
|
||||
|
||||
ifupdown Built-in Interfaces
|
||||
@@ -109,7 +113,11 @@ following example configuration::
|
||||
bond-slaves swp29 swp30
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -120,7 +128,11 @@ following example configuration::
|
||||
bond-slaves swp31 swp32
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -298,7 +310,11 @@ The contents of the sourced file used above are::
|
||||
bond-slaves swp25 swp26
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -317,6 +333,13 @@ bridge ports and bond slaves::
|
||||
iface br1
|
||||
bridge-ports glob swp7-9.100 swp11.100 glob swp15-18.100
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
auto br2
|
||||
iface br2
|
||||
bridge-ports glob swp[1-6]s[0-3].100
|
||||
|
||||
>>>>>>> cumulus/dev
|
||||
Using Templates
|
||||
===============
|
||||
|
||||
@@ -359,7 +382,11 @@ file, run::
|
||||
bond-slaves swp25 swp26
|
||||
bond-mode 802.3ad
|
||||
bond-miimon 100
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1
|
||||
=======
|
||||
bond-use-carrier yes
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1
|
||||
bond-min-links 1
|
||||
bond-xmit-hash-policy layer3+4
|
||||
@@ -375,7 +402,11 @@ does not match::
|
||||
iface bond0
|
||||
bond-mode 802.3ad (✓)
|
||||
bond-miimon 100 (✓)
|
||||
<<<<<<< HEAD
|
||||
bond-use-carrier 1 (✓)
|
||||
=======
|
||||
bond-use-carrier yes (✓)
|
||||
>>>>>>> cumulus/dev
|
||||
bond-lacp-rate 1 (✓)
|
||||
bond-min-links 1 (✓)
|
||||
bond-xmit-hash-policy layer3+4 (✓)
|
||||
@@ -413,10 +444,17 @@ the ``interfaces`` file. For complete syntax on the ``interfaces`` file, see
|
||||
{
|
||||
"auto": true,
|
||||
"config": {
|
||||
<<<<<<< HEAD
|
||||
"bond-use-carrier": "1",
|
||||
"bond-xmit-hash-policy": "layer3+4",
|
||||
"bond-miimon": "100",
|
||||
"bond-lacp-rate": "1",
|
||||
=======
|
||||
"bond-use-carrier": "yes",
|
||||
"bond-xmit-hash-policy": "layer3+4",
|
||||
"bond-miimon": "100",
|
||||
"bond-lacp-rate": "1",
|
||||
>>>>>>> cumulus/dev
|
||||
"bond-min-links": "1",
|
||||
"bond-slaves": "swp25 swp26",
|
||||
"bond-mode": "802.3ad",
|
||||
|
Reference in New Issue
Block a user