mirror of
https://github.com/linux-system-roles/network.git
synced 2026-07-21 02:11:23 +00:00
Add firewalld "zone" variable for connections
This commit is contained in:
parent
5e29382bc9
commit
1df778917e
3 changed files with 29 additions and 0 deletions
|
|
@ -159,6 +159,12 @@ interface. In case of a missing `interface_name`, the profile name `name` is use
|
|||
Note the destinction between the profile name `name` and the device
|
||||
name `interface_name`, which may or may not be the same.
|
||||
|
||||
### `zone`
|
||||
|
||||
Sets the firewalld zone for the interface.
|
||||
|
||||
Slaves to bridge/bond/team devices cannot specify a zone.
|
||||
|
||||
### `state: up`
|
||||
|
||||
#### Example
|
||||
|
|
|
|||
|
|
@ -802,6 +802,7 @@ class ArgValidator_DictConnection(ArgValidatorDict):
|
|||
ArgValidatorStr ('interface_name'),
|
||||
ArgValidatorMac ('mac'),
|
||||
ArgValidatorNum ('mtu', val_min = 0, val_max = 0xFFFFFFFF, default_value = None),
|
||||
ArgValidatorStr ('zone'),
|
||||
ArgValidatorBool('check_iface_exists', default_value = True),
|
||||
ArgValidatorStr ('parent'),
|
||||
ArgValidatorNum ('vlan_id', val_min = 0, val_max = 4094, default_value = None),
|
||||
|
|
@ -1192,6 +1193,9 @@ class IfcfgUtil:
|
|||
route4_file = content_current['route']
|
||||
route6_file = content_current['route6']
|
||||
else:
|
||||
if connection['zone']:
|
||||
ifcfg['ZONE'] = connection['zone']
|
||||
|
||||
addrs4 = list([a for a in ip['address'] if a['family'] == socket.AF_INET])
|
||||
addrs6 = list([a for a in ip['address'] if a['family'] == socket.AF_INET6])
|
||||
|
||||
|
|
@ -1555,6 +1559,9 @@ class NMUtil:
|
|||
s_con.set_property(NM.SETTING_CONNECTION_SLAVE_TYPE, connection['slave_type'])
|
||||
s_con.set_property(NM.SETTING_CONNECTION_MASTER, ArgUtil.connection_find_master_uuid(connection['master'], connections, idx))
|
||||
else:
|
||||
if connection['zone']:
|
||||
s_con.set_property(NM.SETTING_CONNECTION_ZONE, connection['zone'])
|
||||
|
||||
ip = connection['ip']
|
||||
|
||||
s_ip4 = self.connection_ensure_setting(con, NM.SettingIP4Config)
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -300,6 +301,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -370,6 +372,7 @@ class TestValidator(unittest.TestCase):
|
|||
'check_iface_exists': True,
|
||||
'force_state_change': None,
|
||||
'mac': '52:54:00:44:9f:ba',
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -433,6 +436,7 @@ class TestValidator(unittest.TestCase):
|
|||
'check_iface_exists': True,
|
||||
'force_state_change': None,
|
||||
'mac': '52:54:00:44:9f:ba',
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -483,6 +487,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'check_iface_exists': True,
|
||||
'force_state_change': None,
|
||||
'state': 'up',
|
||||
|
|
@ -558,6 +563,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'check_iface_exists': True,
|
||||
'force_state_change': None,
|
||||
'state': 'up',
|
||||
|
|
@ -592,6 +598,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'check_iface_exists': True,
|
||||
'force_state_change': None,
|
||||
'state': 'up',
|
||||
|
|
@ -650,6 +657,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'check_iface_exists': True,
|
||||
'force_state_change': None,
|
||||
'state': 'up',
|
||||
|
|
@ -700,6 +708,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'check_iface_exists': True,
|
||||
'force_state_change': None,
|
||||
'state': 'up',
|
||||
|
|
@ -755,6 +764,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': 'aa:bb:cc:dd:ee:ff',
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'check_iface_exists': True,
|
||||
'name': '5',
|
||||
|
|
@ -802,6 +812,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -847,6 +858,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -909,6 +921,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': None,
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -1007,6 +1020,7 @@ class TestValidator(unittest.TestCase):
|
|||
},
|
||||
'mac': None,
|
||||
'mtu': None,
|
||||
'zone': 'external',
|
||||
'master': None,
|
||||
'vlan_id': None,
|
||||
'ignore_errors': None,
|
||||
|
|
@ -1023,6 +1037,7 @@ class TestValidator(unittest.TestCase):
|
|||
{ 'name': 'e556',
|
||||
'state': 'up',
|
||||
'type': 'ethernet',
|
||||
'zone': 'external',
|
||||
'ip': {
|
||||
'dns_search': [ 'aa', 'bb' ],
|
||||
'route_append_only': True,
|
||||
|
|
@ -1103,6 +1118,7 @@ class TestValidator(unittest.TestCase):
|
|||
'NM_CONTROLLED': 'no',
|
||||
'ONBOOT': 'yes',
|
||||
'TYPE': 'Ethernet',
|
||||
'ZONE': 'external',
|
||||
},
|
||||
'keys': None,
|
||||
'route': '192.168.40.0/24 metric 545\n192.168.46.0/30\n192.168.45.0/24 metric 545\n',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue