mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
container: unstable: Handle interface naming for systemd < 245
systemd-nspawn versions < 245 seem to truncate the interface name from 've-fbx-unstable' to 've-fbx-unstabl'. See: - https://github.com/systemd/systemd/pull/12865 - https://salsa.debian.org/freedombox-team/freedombox/-/merge_requests/1856 Tests: - On Debian Buster with systemd version 241, start testing and unstable containers. For testing the interface name is ve-fbx-testing and for unstable it is ve-fbx-unstabl. The containers are brought up and provisioned successfully. Running 'nmcli c show fbx-${distribution}-shared' shows the correct interface name assigned. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
2773c4737e
commit
866fa6cde3
16
container
16
container
@ -451,6 +451,18 @@ def _runc(image_file, command, **kwargs):
|
||||
**kwargs)
|
||||
|
||||
|
||||
def _get_interface_name(distribution):
|
||||
"""Return the name of the interface."""
|
||||
interface = f've-fbx-{distribution}'
|
||||
process = subprocess.run(['systemd-nspawn', '--version'],
|
||||
stdout=subprocess.PIPE, check=True)
|
||||
version = process.stdout.decode().splitlines()[0].split()[1]
|
||||
if int(float(version)) < 245:
|
||||
return interface[:14]
|
||||
|
||||
return interface
|
||||
|
||||
|
||||
def _setup_nm_connection(distribution):
|
||||
"""Create a network manager conn. on host for DHCP/DNS with container."""
|
||||
connection_name = f'fbx-{distribution}-shared'
|
||||
@ -465,7 +477,7 @@ def _setup_nm_connection(distribution):
|
||||
properties = {
|
||||
'connection.id': connection_name,
|
||||
'connection.type': '802-3-ethernet',
|
||||
'connection.interface-name': f've-fbx-{distribution}',
|
||||
'connection.interface-name': _get_interface_name(distribution),
|
||||
'connection.autoconnect': 'yes',
|
||||
'ipv4.method': 'shared',
|
||||
}
|
||||
@ -757,7 +769,7 @@ def _get_ssh_command(ip_address, distribution):
|
||||
"""Exec an SSH command."""
|
||||
public_key = work_directory / 'ssh' / 'id_ed25519'
|
||||
if ipaddress.ip_address(ip_address).is_link_local:
|
||||
ip_address = f'{ip_address}%ve-fbx-{distribution}'
|
||||
ip_address = f'{ip_address}%' + _get_interface_name(distribution)
|
||||
|
||||
return [
|
||||
'ssh', '-i',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user