Mwan utilities
From __init__.py
:
Function | clear |
Clears mwan3 configuration. |
Function | delete |
Deletes a mwan3 policy. |
Function | delete |
Deletes a mwan3 rule. |
Function | edit |
Edits a mwan3 policy. |
Function | edit |
Edits a mwan3 rule. |
Function | get |
Returns default configuration for mwan3. |
Function | index |
Returns a list of policies with their members, interfaces and metrics/weights. |
Function | index |
Returns a list of rules with their policies. |
Function | order |
Orders mwan3 rules, moves everything else but rules to the end of the list. |
Function | set |
Sets default configuration for mwan3. |
Function | store |
Stores a policy for mwan3, takes care of creating interfaces and members. |
Function | store |
Stores a rule for mwan3 |
Function | update |
Updates mwan3 rules with objects addresses |
Function | __add |
Add interfaces to policy, takes care of creating interfaces and members. |
Function | __fetch |
Undocumented |
Function | __generate |
Generates a metric for an interface. |
Function | __parse |
Parses a member configuration and returns formatted data. |
Function | __set |
Undocumented |
Function | __store |
Stores interface configuration for mwan3 and network, not suited to be used outside store_policy. |
Function | __store |
Stores member configuration for mwan3, not suited to be used outside store_policy. |
Function | _is |
Validate the given object for destination. Destination objects can be only: - dhcp reservation - dns domain - vpn user - a singleton host set |
Function | _is |
Validate the given object for source. Source objects can be only: - dhcp reservation - dns domain - vpn user - a singleton host set |
Deletes a mwan3 policy.
- Args:
- e_uci: euci instance name: name of policy to delete
- Returns:
- list of deleted mwan3 entries
Deletes a mwan3 rule.
- Args:
- e_uci: euci instance name: rule name to delete
- Returns:
- name of rule deleted
EUci
, name: str
, label: str
, interfaces: list[ dict]
) -> list[ str]
:
(source)
¶
Edits a mwan3 policy.
- Args:
- e_uci: euci instance name: name of policy to edit label: policy label interfaces: dict of interfaces to add to policy
- Returns:
- list of changed mwan3 entries
- Raises:
- ValidationError: if name is not valid
EUci
, name: str
, policy: str
, label: str
, protocol: str
= None, source_address: str
= None, source_port: str
= None, destination_address: str
= None, destination_port: str
= None, sticky: bool
= False, ns_src: str
= None, ns_dst: str
= None):
(source)
¶
Edits a mwan3 rule.
- Args:
- e_uci: EUci instance name: rule name policy: policy to use for the rule label: rule label protocol: protocol in which the rule applies source_address: CIDR notation of source address source_port: port or port range destination_address: CIDR notation of destination address destination_port: port or port range sticky: whether to use sticky connections ns_src: source object, it overrides source_address ns_dst: destination object, it overrides destination_address
- Raises:
- ValidationError: if name is not valid or policy is not valid
Returns default configuration for mwan3.
- Args:
- e_uci: euci instance
- Returns:
- dict with default configuration
Returns a list of policies with their members, interfaces and metrics/weights.
- Args:
- e_uci: EUci instance
- Returns:
- list of dicts with policy data
Returns a list of rules with their policies.
- Args:
- e_uci: euci instance
- Returns:
- parsed list of rules with assigned policy
Orders mwan3 rules, moves everything else but rules to the end of the list.
- Args:
- e_uci: euci instance rules: which order to put rules
- Returns:
- list of ordered mwan3 entries
- Raises:
- ValidationError: if a rule is not present in /etc/config/mwan3
EUci
, track_ip: list[ str]
, ping_timeout: int
, ping_interval: int
, ping_failure_interval: int
, interface_down_threshold: int
, interface_up_threshold: int
):
(source)
¶
Sets default configuration for mwan3.
- Args:
- e_uci: euci instance track_ip: list of IPs to track ping_timeout: timeout for ping ping_interval: interval between pings ping_failure_interval: interval between failed pings interface_down_threshold: threshold for interface down interface_up_threshold: threshold for interface up
Stores a policy for mwan3, takes care of creating interfaces and members.
- Args:
- e_uci: EUci instance name: name of policy interfaces: list of interfaces to add to policy, must have name, metric and weight fields
- Returns:
- list of changed configuration
- Raises:
- ValidationError: if name is not unique or length or get_id > 15
EUci
, name: str
, policy: str
, protocol: str
= None, source_address: str
= None, source_port: str
= None, destination_address: str
= None, destination_port: str
= None, sticky: bool
= False, ns_src: str
= None, ns_dst: str
= None) -> str
:
(source)
¶
Stores a rule for mwan3
- Args:
- e_uci: EUci instance name: name of the rule, must be unique policy: policy to use for the rule, must be already set protocol: must be one of tcp, udp, icmp or all, defaults to 'all' source_address: source addresses to match source_port: source ports to match or range destination_address: destination addresses to match destination_port: destination ports to match or range sticky: whether to use sticky connections ns_src: source object, it overrides source_address ns_dst: destination object, it overrides destination_address
- Returns:
- name of the rule created
- Raises:
- ValidationError if name is not unique, policy is not valid or length get_id > 15
EUci
, interfaces: list[ dict]
, changed_config: list[ str]
= None) -> list[ str]
:
(source)
¶
Add interfaces to policy, takes care of creating interfaces and members.
- Args:
- e_uci: euci instance interfaces: list of interfaces to add changed_config: array of changed configuration
- Returns:
- list of member names added to policy
- Raises:
- ValidationError: if interface name is not defined in /etc/config/network
Generates a metric for an interface.
- Args:
- e_uci: EUci instance
- Returns:
- first metric that is not present in interface_metrics
Parses a member configuration and returns formatted data.
- Args:
- e_uci: EUci instance member_name: member name
- Returns:
- dict with member data
Stores interface configuration for mwan3 and network, not suited to be used outside store_policy.
- Args:
- e_uci: EUci instance name: name of interface
- Returns:
- tuple of booleans, first one indicates if mwan interface was created, second one indicates if metric was added to network interface
- Raises:
- ValidationError: if interface name is not defined in /etc/config/network
EUci
, interface_name: str
, metric: int
, weight: int
) -> tuple[ str, bool]
:
(source)
¶
Stores member configuration for mwan3, not suited to be used outside store_policy.
- Args:
- e_uci: EUci instance interface_name: name of interface to link the member to metric: metric of the member weight: weight of the member
- Returns:
- tuple of string and boolean, first one is the generated name of the member, second one indicates if the member was created