Skip to content

Commit

Permalink
CP-50546: systemctl -> networkctl to apply network configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Liu <[email protected]>
  • Loading branch information
liulinC committed Dec 12, 2024
1 parent 10efffe commit ef09fa8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def configureNetworking(ui, device, config):
netutil.writeNetInterfaceFiles(netcfg)
netutil.writeResolverFile(netcfg, '/etc/resolv.conf')

# Restart systemd-networkd serivce to apply the configuration
netutil.reloadSystemdNetworkdService()
# Reload network to apply the configuration
netutil.reloadNetwork()

iface_to_start = []
if device == 'all':
Expand Down
8 changes: 4 additions & 4 deletions netutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ def writeResolverFile(configuration, filename):

interface_up = {}

def reloadSystemdNetworkdService(timeout=20):
""" Reload systemd-networkd service """
util.runCmd2(["systemctl", "restart", "systemd-networkd"])
# systemd return immediately, wait until network is up
def reloadNetwork(timeout=20):
""" Use networkctl to reload the configuration """
util.runCmd2(["networkctl", "reload"])
# Command return immediately, wait until network is up
ret = util.runCmd2(["/usr/lib/systemd/systemd-networkd-wait-online", f"--timeout={timeout}"])
if ret:
LOG.error(f"Timeout {timeout} waiting for network online")
Expand Down
4 changes: 2 additions & 2 deletions tui/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ def specify_configuration(answers, txt, defaults):
ifaceName = conf_dict['config'].getInterfaceName(conf_dict['interface'])
netutil.ifdown(ifaceName)

# Restart systemd-networkd serivce to apply the configuration
netutil.reloadSystemdNetworkdService()
# Reload network to apply the configuration
netutil.reloadNetwork()

# check that we have *some* network:
if netutil.ifup(ifaceName) != 0 or not netutil.interfaceUp(ifaceName):
Expand Down

0 comments on commit ef09fa8

Please sign in to comment.