Skip to content

Commit

Permalink
Merge pull request vyos#4232 from nvollmar/T6927
Browse files Browse the repository at this point in the history
T6927: adds option to set container name server
  • Loading branch information
c-po authored Dec 12, 2024
2 parents 678c6cd + 2de9fc6 commit 4221687
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion smoketest/scripts/cli/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,21 @@ def test_basic(self):

def test_name_server(self):
cont_name = 'dns-test'
net_name = 'net-test'
name_server = '192.168.0.1'
self.cli_set(base_path + ['name', cont_name, 'allow-host-networks'])
prefix = '192.0.2.0/24'

self.cli_set(base_path + ['network', net_name, 'prefix', prefix])

self.cli_set(base_path + ['name', cont_name, 'image', cont_image])
self.cli_set(base_path + ['name', cont_name, 'name-server', name_server])
self.cli_set(base_path + ['name', cont_name, 'network', net_name, 'address', str(ip_interface(prefix).ip + 2)])

# verify() - name server has no effect when container network has dns enabled
with self.assertRaises(ConfigSessionError):
self.cli_commit()

self.cli_set(base_path + ['network', net_name, 'no-name-server'])
self.cli_commit()

n = cmd_to_json(f'sudo podman inspect {cont_name}')
Expand Down
3 changes: 3 additions & 0 deletions src/conf_mode/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def verify(container):
if network_name not in container.get('network', {}):
raise ConfigError(f'Container network "{network_name}" does not exist!')

if 'name_server' in container_config and 'no_name_server' not in container['network'][network_name]:
raise ConfigError(f'Setting name server has no effect when attached container network has DNS enabled!')

if 'address' in container_config['network'][network_name]:
cnt_ipv4 = 0
cnt_ipv6 = 0
Expand Down

0 comments on commit 4221687

Please sign in to comment.