Skip to content

Commit

Permalink
Revert "cli:apply: improve networkd restart logic for non-existent ne…
Browse files Browse the repository at this point in the history
…tworkd config"

This reverts commit a527c51.
  • Loading branch information
daniloegea committed Sep 23, 2024
1 parent e0e8711 commit cac4b12
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions netplan_cli/cli/commands/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,8 @@ def command_apply(self, run_generate=True, sync=False, exit_on_error=True, state
restart_networkd = False
with tempfile.TemporaryDirectory() as tmp_dir:
# needs to be a subfolder as copytree wants to create it
run_systemd_network = '/run/systemd/network'
old_files_dir = os.path.join(tmp_dir, 'cfg')
has_old_networkd_config = os.path.isdir(run_systemd_network)
if has_old_networkd_config:
shutil.copytree(run_systemd_network, old_files_dir)
shutil.copytree('/run/systemd/network', old_files_dir)

generator_call = []
generate_out = None
Expand All @@ -142,13 +139,9 @@ def command_apply(self, run_generate=True, sync=False, exit_on_error=True, state
raise ConfigurationError("the configuration could not be generated")

# Restart networkd if something in the configuration changed
has_new_networkd_config = os.path.isdir(run_systemd_network)
if has_old_networkd_config != has_new_networkd_config:
comp = filecmp.dircmp('/run/systemd/network', old_files_dir)
if comp.left_only or comp.right_only or comp.diff_files:
restart_networkd = True
elif has_old_networkd_config and has_new_networkd_config:
comp = filecmp.dircmp(run_systemd_network, old_files_dir)
if comp.left_only or comp.right_only or comp.diff_files:
restart_networkd = True

devices = utils.get_interfaces()

Expand Down

0 comments on commit cac4b12

Please sign in to comment.