generated from pavel.muhortov/template-python
added use of entries order
This commit is contained in:
parent
75b65f85c0
commit
f9d50ef65d
|
@ -77,6 +77,9 @@ dev-wg1 = true
|
|||
|
||||
[via-192.168.0.1]
|
||||
# List of CIDR. Only CIDR with the TRUE value will be used.
|
||||
# The order of the entries is important:
|
||||
# - the "add" action applies entries from top to bottom,
|
||||
# - the "del" action applies entries from bottom to top.
|
||||
# If different sources contain the same cidr, use the path part to define your preference.
|
||||
ipv4/via-192.168.0.1.cidr = true
|
||||
ipv4/atlassian.cidr = true
|
||||
|
@ -87,6 +90,9 @@ ipv4/private.cidr
|
|||
|
||||
[dev-wg1]
|
||||
# List of CIDR. Only CIDR with the TRUE value will be used.
|
||||
# The order of the entries is important:
|
||||
# - the "add" action applies entries from top to bottom,
|
||||
# - the "del" action applies entries from bottom to top.
|
||||
# If different sources contain the same cidr, use the path part to define your preference.
|
||||
ipv4/dev-wg1.cidr = true
|
||||
ipv4/public.cidr = true
|
||||
|
|
12
my_route.py
12
my_route.py
|
@ -300,10 +300,10 @@ class Route(Connect):
|
|||
apply_counter = 0
|
||||
gways_counter = 0
|
||||
files_counter = 0
|
||||
commands_list = []
|
||||
for gw, cidr_apply in self._gw.items():
|
||||
gways_counter += 1
|
||||
for cidr in cidr_apply:
|
||||
local_logger = logging.getLogger(cidr)
|
||||
for cidr_file in cidr_current:
|
||||
if cidr in cidr_file:
|
||||
with open(cidr_file, mode='r', encoding='utf-8') as file:
|
||||
|
@ -317,9 +317,15 @@ class Route(Connect):
|
|||
pass
|
||||
else:
|
||||
command = ['ip', 'ro', action, route, gw_type, gw_name]
|
||||
local_logger.info(msg=' '.join(command))
|
||||
commands_list.append({'cidr': cidr, 'command': command})
|
||||
|
||||
if action == 'delete':
|
||||
commands_list = reversed(commands_list)
|
||||
for command in commands_list:
|
||||
local_logger = logging.getLogger(command['cidr'])
|
||||
local_logger.info(msg=' '.join(command['command']))
|
||||
if not imitate:
|
||||
if self.__cmd(command=command) == 0:
|
||||
if self.__cmd(command=command['command']) == 0:
|
||||
apply_counter += 1
|
||||
|
||||
local_logger = logging.getLogger(logger_alias)
|
||||
|
|
Loading…
Reference in New Issue
Block a user