-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
T7147: Simple op command for nat & policy, not for firewall and connt…
…ract
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<interfaceDefinition> | ||
<node name="update"> | ||
<children> | ||
<leafNode name="firewall-groups"> | ||
<properties> | ||
<help>Update firewall sets</help> | ||
</properties> | ||
<command>sudo ${vyos_libexec_dir}/firewall-group-update.py</command> | ||
</leafNode> | ||
</children> | ||
</node> | ||
</interfaceDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright (C) 2021 VyOS maintainers and contributors | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 or later as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import sys | ||
|
||
from vyos.configquery import ConfigTreeQuery | ||
from vyos.firewall import firewall_group_update | ||
|
||
def get_config(config=None): | ||
if config: | ||
conf = config | ||
else: | ||
conf = ConfigTreeQuery() | ||
|
||
config = conf.get_config_dict([], key_mangling=('-', '_'), get_first_key=True, | ||
no_tag_node_value_mangle=True) | ||
|
||
firewall_group = conf.get_config_dict(['firewall', 'group'], key_mangling=('-', '_'), | ||
get_first_key=True, | ||
no_tag_node_value_mangle=True) | ||
if 'nat' in config: | ||
config['nat']['firewall_group'] = firewall_group | ||
|
||
if 'policy' in config: | ||
config['policy']['firewall_group'] = firewall_group | ||
|
||
return config | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
config = get_config() | ||
|
||
if not firewall_group_update(config): | ||
sys.exit(1) |