Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cloudinit/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ def apply_network_config(self, netconfig, bring_up=False) -> bool:
# Now try to bring them up
if bring_up:
LOG.debug('Bringing up newly configured network interfaces')
network_activator = activators.select_activator()
try:
network_activator = activators.select_activator()
except activators.NoActivatorException:
LOG.warning("No network activator found, not bringing up "
"network interfaces")
return True
network_activator.bring_up_all_interfaces(network_state)
else:
LOG.debug("Not bringing up newly configured network interfaces")
Expand Down
6 changes: 5 additions & 1 deletion cloudinit/net/activators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
LOG = logging.getLogger(__name__)


class NoActivatorException(Exception):
pass


def _alter_interface(cmd, device_name) -> bool:
LOG.debug("Attempting command %s for device %s", cmd, device_name)
try:
Expand Down Expand Up @@ -271,7 +275,7 @@ def select_activator(priority=None, target=None) -> Type[NetworkActivator]:
tmsg = ""
if target and target != "/":
tmsg = " in target=%s" % target
raise RuntimeError(
raise NoActivatorException(
"No available network activators found%s. Searched "
"through list: %s" % (tmsg, priority))
selected = found[0]
Expand Down
5 changes: 3 additions & 2 deletions tests/unittests/test_net_activators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
IfUpDownActivator,
NetplanActivator,
NetworkManagerActivator,
NetworkdActivator
NetworkdActivator,
NoActivatorException,
)
from cloudinit.net.network_state import parse_net_config_data
from cloudinit.safeyaml import load
Expand Down Expand Up @@ -99,7 +100,7 @@ def test_none_available(self, unavailable_mocks):
resp = search_activator()
assert resp == []

with pytest.raises(RuntimeError):
with pytest.raises(NoActivatorException):
select_activator()


Expand Down