faucet.stack module

Configuration for a stack.

class faucet.stack.Stack(_id, dp_id, name, canonical_port_order, lacp_down_ports, lacp_ports, conf)[source]

Bases: Conf

Stores state related to DP stack information, this includes the current elected root as that is technically a fixed allocation for this DP Stack instance.

add_port(port)[source]

Add a port to this stack

any_port_up()[source]

Return true if any stack port is UP

canonical_up_ports(ports=None)[source]

Obtains list of UP stack ports in canonical order

clone_dyn_state(prev_stack, dps=None)[source]

Copy dyn state from the old stack instance when warm/cold starting

defaults: dict = {'down_time_multiple': 3, 'min_lacp_health': 1.0, 'min_stack_health': 1.0, 'priority': None, 'route_learning': False}
defaults_types: dict = {'down_time_multiple': <class 'int'>, 'min_lacp_health': <class 'float'>, 'min_stack_health': <class 'float'>, 'priority': <class 'int'>, 'route_learning': <class 'bool'>}
down_ports()[source]

Return tuple of not running stack ports

Return network stacking graph as a node link representation

hash()[source]

Return hash of a topology graph

is_edge()[source]

Return True if this DP is a stack edge.

is_in_path(src_dp, dst_dp)[source]

Return True if the current DP is in the path from src_dp to dst_dp

Parameters:
  • src_dp (str) – DP name

  • dst_dp (str) – DP name

Returns:

True if self is in the path from the src_dp to the dst_dp.

Return type:

bool

is_root()[source]

Return True if this DP is the root of the stack.

is_root_candidate()[source]

Return True if this DP could be a root of the stack.

lacp_port_healthy()[source]

Determines the percentage of UP LACP ports, and whether the current stack node can be considered healthy according to the min_lacp_health configuration option.

Returns:

Whether threshold from DOWN LACP ports is met; considered healthy, float: Percentage of LACP ports UP out of all lacp ports

Return type:

bool

live_timeout_healthy(last_live_time, now, update_time)[source]

Determines the timeout of the current stack node, and whether the current stack node can be considered healthy according to the down_time_multiple number of stack root update time intervals.

Parameters:
  • last_live_time (float) – Last known live time for this current stack node

  • now (float) – Current time

  • update_time (int) – Update time interval

Returns:

If node down time is still in update time interval threshold; considered healthy, float: Time elapsed since timed out

Return type:

bool

longest_path_to_root_len()[source]

Return length of the longest path to root in the stack.

Update the stack topology according to the event

static modify_topology(graph, dp, port, add=True)[source]

Add/remove an edge to the stack graph which originates from this dp and port.

static nominate_stack_root(stacks)[source]

Return stack names in priority order and the chosen root

peer_symmetric_up_ports(peer_dp)[source]

Return list of stack ports that are up towards us from a peer

peer_up_ports(peer_dp)[source]

Return list of stack ports that are up towards a peer.

resolve_topology(dps, meta_dp_state)[source]

Resolve & verify correct inter-DP stacking config

Parameters:
  • dps (list) – List of configured DPs

  • meta_dp_state (MetaDPState) – Provided if reloading when choosing a new root DP

shortest_path(dest_dp, src_dp=None)[source]

Return shortest path to a DP, as a list of DPs.

shortest_path_port(dest_dp)[source]

Return first port on our DP, that is the shortest path towards dest DP.

shortest_path_to_root(src_dp=None)[source]

Return shortest path to root DP, as list of DPs.

shortest_symmetric_path_port(peer_dp)[source]

Return port on our DP that is the first port of the adjacent DP towards us

stack_port_healthy()[source]

Determines the percentage of UP stack ports, and whether the current stack node can be considered healthy according to the min_stack_health configuration option.

Returns:

Whether threshold from DOWN stack ports is met; considered healthy, float: Percentage of stack ports UP out of all stack ports

Return type:

bool

update_health(now, dp_last_live_time, update_time)[source]

Determines whether the current stack node is healthy

Parameters:
  • now (float) – Current time

  • last_live_times (dict) – Last live time value for each DP

  • update_time (int) – Stack root update interval time

Returns:

Current stack node health state, str: Reason for the current state

Return type:

tuple