Documentation for the Code

ifupdownmain

ifupdownmain is the main ifupdown module.

iface

ifupdown2 network interface object

It is modeled based on the ‘iface’ section in /etc/network/interfaces file. But can be extended to include any other network interface format

class iface.iface(attrsdict={})

ifupdown2 iface object class

Attributes:

name Name of the interface

addr_family Address family eg, inet, inet6. Can be None to
indicate both address families
addr_method Address method eg, static, manual or None for
static address method

config dictionary of config lines for this interface

state Configuration state of an interface as defined by
ifaceState
status Configuration status of an interface as defined by
ifaceStatus

flags Internal flags used by iface processing

priv_flags private flags owned by module using this class

refcnt reference count, indicating number of interfaces
dependent on this iface
lowerifaces list of interface names lower to this interface or
this interface depends on
upperifaces list of interface names upper to this interface or
the interfaces that depend on this interface

auto True if interface belongs to the auto class

classes List of classes the interface belongs to

env shell environment the interface needs during
execution

raw_config raw interface config from file

add_to_upperifaces(upperifacename)

add to the list of upperifaces

get_attr_value(attr_name)

add to the list of upperifaces

get_attr_value_first(attr_name)

get first value of the specified attr name

get_attr_value_n(attr_name, attr_index)

get n’th value of the specified attr name

update_config(attr_name, attr_value)

add attribute name and value to the interface config

update_config_with_status(attr_name, attr_value, attr_status=0)

add attribute name and value to the interface config and also update the config_status dict with status of this attribute config

get_config_attr_status(attr_name, idx=0)

get status of a attribute config on this interface.

Looks at the iface _config_status dict

compare(dstiface)

compares iface object with iface object passed as argument

Returns True if object self is same as dstiface and False otherwise

class iface.ifaceState

Enumerates iface state

class iface.ifaceStatus

Enumerates iface status

class iface.ifaceJsonEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)

scheduler

networkinterfaces

class networkinterfaces.networkInterfaces(interfacesfile='/etc/network/interfaces', interfacesfileiobuf=None, interfacesfileformat='native', template_engine=None, template_lookuppath=None)

debian ifupdown /etc/network/interfaces file parser

load()

This member function loads the networkinterfaces file.

Assumes networkinterfaces parser object is initialized with the parser arguments

subscribe(callback_name, callback_func)

This member function registers callback functions.

Args:

callback_name (str): callback function name (supported names: ‘iface_found’, ‘validateifaceattr’, ‘validateifaceobj’)

callback_func (function pointer): callback function pointer

Warns on error

statemanager

class statemanager.pickling

class with helper methods for pickling/unpickling iface objects

classmethod save(filename, list_of_objects)

pickle a list of iface objects

classmethod save_obj(f, obj)

pickle iface object

classmethod load(filename)

load picked iface object

class statemanager.stateManager

state manager for managing ifupdown iface obj state

ifupdown2 has to maitain old objects for down operation on interfaces. ie to down or delete old configuration.

This class uses pickle to store iface objects.

read_saved_state(filename=None)

This member function reads saved iface objects

Kwargs:
filename (str): name of the state file
save_state()

saves state (ifaceobjects) to persistent state file

graph

class graph.graph

graph functions to sort and print interface graph

classmethod topological_sort_graphs_all(dependency_graphs, indegrees_arg)

runs topological sort on interface list passed as dependency graph

Args:
dependency_graphs (dict): dependency graph with dependency
lists for interfaces

indegrees_arg (dict): indegrees array for all interfaces

classmethod generate_dots(dependency_graph, indegrees)

spits out interface dependency graph in dot format

Args:
dependency_graphs (dict): dependency graph with dependency
lists for interfaces

indegrees_arg (dict): indegrees array for all interfaces

Table Of Contents

This Page