container: Don't fail if there's no fbx network

Display debugging info if the reason for failure is different.

Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
[sunil: Indentation, fix pylint message]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Fioddor Superconcentrado 2021-08-21 20:08:16 +02:00 committed by Sunil Mohan Adapa
parent 4b51396860
commit 0a2091a366
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -812,8 +812,16 @@ def _destroy(distribution):
connection_name = f'fbx-{distribution}-shared'
logger.info('Removing Network Manager connection %s', connection_name)
subprocess.run(['sudo', 'nmcli', 'connection', 'delete', connection_name],
stdout=subprocess.DEVNULL)
result = subprocess.run(
['sudo', 'nmcli', 'connection', 'delete', connection_name],
capture_output=True)
if result.returncode not in (0, 10):
# nmcli failed and not due to 'Connection, device, or access point does
# not exist.' See
# https://developer-old.gnome.org/NetworkManager/stable/nmcli.html
logger.error('nmcli returned code %d', result.returncode)
logger.error('Error message:\n%s', result.stderr.decode())
logger.error('Output:\n%s', result.stdout.decode())
logger.info('Keeping downloaded image: %s',
_get_compressed_image_path(distribution))