mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Ticket: CM-7361 Reviewed By: CCR- Testing Done: Tested with clag Certain loggers, most notably the syslog, don't allow non-printable characters in their output, and so they convert them to a string of printable characters. For example, the newline character is converted to #012. This results in output that looks like this: 2016-08-29T18:50:46.263178+00:00 act-5712-08 clagd[21539]: RXed RTM_NEWNEIGH, length 68, seq 0, pid 0, flags 0x0#012#012 #033[91mNetlink Header#033[0m#012 1: #033[91m0x44000000#033[0m D... Length 0x00000044 (68)#012 2: #033[91m0x1c000000#033[0m .... Type 0x001c (28 - RTM_NEWNEIGH), Flags 0x0000 ()#012 3: #033[91m0x00000000#033[0m .... Sequence Number 0x00000000 (0)#012 4: #033[91m0x00000000#033[0m .... Process ID 0x00000000 (0)#012 #033[93mService Header#033[0m#012 5: #033[93m0x07000000#033[0m .... Family 0x07 (7)#012 6: #033[93m0x29010000#033[0m )... Interface Index 0x00000129 (297)#012 7: #033[93m0x02000000#033[0m .... State 0x0002 (2), Flags 0x00, Type 0x0000 (0)#012 Attributes#012 8: #033[92m0x0a000200#033[0m .... Length 0x000a (10) padded to 12, Type 0x0002 (2) NDA_LLADDR#012 9: #033[92m0x00020000#033[0m .... 00:02:00:00:00:09#012 10: #033[92m0x00090000#033[0m .... #012 11: #033[94m0x08000900#033[0m .... Length 0x0008 (8), Type 0x0009 (9) NDA_MASTER#012 12: #033[94m0x2b010000#033[0m +... 299#012 13: #033[92m0x14000300#033[0m .... Length 0x0014 (20), Type 0x0003 (3) NDA_CACHEINFO#012 14: #033[92m0x00000000#033[0m .... 0#012 15: #033[92m0x00000000#033[0m .... 0#012 16: #033[92m0x00000000#033[0m .... 0#012 17: #033[92m0x00000000#033[0m .... 0#012#012Attributes Summary#012{'( 2) NDA_LLADDR': '00:02:00:00:00:09',#012 '( 3) NDA_CACHEINFO': (0, 0, 0, 0),#012 '( 9) NDA_MASTER': 299} which is rather hard to interpret. So this patch modifes the nlpacket debug output so that the user can specify whether or not color output should be used by including an extra, optional parameter when instantiating a NetlinkPacket object. The default is for color output, just like before this patch. But if color output is not desired, then no VT100 control sequences will be output. Nor will there be any newline characters embedded in the output. The NetlinkManagerWithListener and NetlinkManager classes were also modified to add the same optional use_color attribute, which defaults to True. Thus when class members which instantiate NetlinkPacket objects are created the appropriate value for the use_color attribute will be applied. I also noticed that the default pid_offset of the NetlinkListener class was 2, when it should have been 1. So I fixed that too.
…
…
…
…
…
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
Description
Languages
Python
99.2%
Shell
0.6%
Makefile
0.2%