General utilities
From __init__.py
:
Exception |
|
Undocumented |
Function | check |
Check if the given password matches the given shadow password hash. |
Function | generic |
Generate a generic error for the APIs. |
Function | get |
Return all sections with the given option value |
Function | get |
Return all sections of the given utype from the given config |
Function | get |
Retrieve all device IPs |
Function | get |
Retrieve all devices associated to the given zone |
Function | get |
Retrieve all devices associated to the lan zone, except for VPN ones |
Function | get |
Retrieve all devices associated to the wan zone |
Function | get |
List all WAN interfaces with their IP addresses Exclude bond management IPs. |
Function | get |
Retrieve the physical device name given the MAC address |
Function | get |
Return a valid UCI id based on the given string. All auto-generated NethSecurity ids: |
Function | get |
Retrieve the logical UCI interface name given the device name |
Function | get |
Retrieve the logical UCI interface name given the MAC address |
Function | get |
Return the public addresses associated to a private IP address. |
Function | get |
Return a random valid UCI id. |
Function | get |
Retrieve all unused/unassigned devices. |
Function | get |
Retrieve the user object id (UCI section) given the username |
Function | sanitize |
Replace illegal chars with _ char. UCI identifiers and config file names may contain only the characters a-z, 0-9 and _ |
Function | shadow |
Generates a shadow password hash using SHA-512 algorithm. |
Function | validation |
Generate a validation error for the APIs. |
Function | validation |
Generate a validation error for the APIs from an array. |
Check if the given password matches the given shadow password hash.
- Arguments:
- password (str) - the password to be checked.
- shadow (str) - the shadow password hash to be checked.
- Returns:
- True if the password matches the hash, False otherwise
Generate a generic error for the APIs.
- Arguments:
- message -- An error message
- Returns:
- A validation error object
Return all sections with the given option value
- Arguments:
- uci -- EUci pointer
- config -- Configuration database name
- option -- Option name
- value -- Option value
- deep - If true, return a dict of all matched keys, otherwise return a list of section names
- Returns:
- A dictionary or a list of all matched sections
Return all sections of the given utype from the given config
- Arguments:
- uci -- EUci pointer
- config -- Configuration database name
- utype -- Section type
- Returns:
- A dictionary of all matched sections, None in case of error
Retrieve all devices associated to the given zone
- Arguments:
- uci -- EUci pointer
- zone -- Firewall zone name
- Returns:
- A list of device names
Retrieve all devices associated to the lan zone, except for VPN ones
- Arguments:
- uci -- EUci pointer
- Returns:
- A list of device names
Retrieve all devices associated to the wan zone
- Arguments:
- uci -- EUci pointer
- exclude_aliases -- If true, exclude devices starting with @
- Returns:
- A list of device names
List all WAN interfaces with their IP addresses Exclude bond management IPs.
- Arguments:
- uci -- EUci pointer
- Returns:
- A list of dictionaries with device and IP address
Retrieve the physical device name given the MAC address
- Aarguments:
- hwaddr -- MAC address string
- Returns:
- The device name as a string if the network interface has been found, None otherwise.
Return a valid UCI id based on the given string. All auto-generated NethSecurity ids:
- have a maximum length of 100 characters
- start with ns_ prefix
- are sanitized accordingly to UCI conventions
- Arguments:
- name -- the name of the section
- length -- maximum id length, default is 100. Maximum length for firewall zones is 15.
- Returns:
- a valid UCI identifier as string
Retrieve the logical UCI interface name given the device name
- Arguments:
- uci -- EUci pointer
- device -- Device name
- Returns:
- The device name as a string if the interface has been found, None otherwise
Retrieve the logical UCI interface name given the MAC address
- Arguments:
- uci -- EUci pointer
- hwaddr -- MAC address string
- Returns:
- The device name as a string if the interface has been found, None otherwise
Return the public addresses associated to a private IP address.
- Arguments:
- ip_address -- the private IP address of a network interface. If not specified, the default network interface is used.
- Returns:
- a list of public addresses. Usually, the list contains only one element.
Return a random valid UCI id.
- Random ids:
- have a length of 11 characters
- are sanitized accordingly to UCI conventions (see 'sanitize' function)
- start with ns_ prefix
- Arguments:
- name -- the name of the section
- Returns:
- a valid UCI identifier as string
Retrieve the user object id (UCI section) given the username
- Arguments:
- uci -- EUci pointer
- username -- Username
- Returns:
- The user object id (UCI section) if the user has been found, None otherwise
Replace illegal chars with _ char. UCI identifiers and config file names may contain only the characters a-z, 0-9 and _
- Arguments:
- name -- the name of the section
- Returns:
- a string with valid chachars for UCI
Generates a shadow password hash using SHA-512 algorithm.
- Arguments:
- password (str) - the password to be hashed.
- Returns:
- the shadow password hash as strin
Generate a validation error for the APIs.
- Arguments:
- parameter -- The name of the parameter
- message -- The validation error reason, default is empty
- value -- The parmeter original value that caused the error
- Returns:
- A validation error object