cloud-setup: split up _nmc_skip_connection_by_type()

Split _nmc_skip_connection_by_type() so that we can get a little
more finely grained error reporting.
This commit is contained in:
Lubomir Rintel
2025-04-10 10:35:21 +02:00
parent 95b9b4b678
commit 961be7d971
2 changed files with 15 additions and 20 deletions

View File

@@ -387,17 +387,6 @@ _nmc_skip_connection_by_user_data(NMConnection *connection)
return FALSE; return FALSE;
} }
static gboolean
_nmc_skip_connection_by_type(NMConnection *connection, const char *connection_type)
{
if (!nm_streq0(nm_connection_get_connection_type(connection), connection_type))
return TRUE;
if (!nm_connection_get_setting_ip4_config(connection))
return TRUE;
return FALSE;
}
static void static void
_nmc_mangle_connection(NMDevice *device, _nmc_mangle_connection(NMDevice *device,
NMConnection *connection, NMConnection *connection,
@@ -618,8 +607,14 @@ try_again:
return any_changes; return any_changes;
} }
if (_nmc_skip_connection_by_type(applied_connection, connection_type)) { if (!nm_streq0(nm_connection_get_connection_type(applied_connection), connection_type)) {
_LOGD("config device %s: device has no suitable applied connection. Skip", hwaddr); _LOGD("config device %s: skip applied connection due to type mismatch", hwaddr);
return any_changes;
}
if (!nm_connection_get_setting_ip4_config(applied_connection)) {
_LOGD("config device %s: skip applied connection due to missing IPv4 configuration",
hwaddr);
return any_changes; return any_changes;
} }

View File

@@ -2532,7 +2532,7 @@ class TestNmCloudSetup(unittest.TestCase):
pexp.expect("get-config: success") pexp.expect("get-config: success")
pexp.expect("meta data received") pexp.expect("meta data received")
# One of the devices has no IPv4 configuration to be modified # One of the devices has no IPv4 configuration to be modified
pexp.expect("device has no suitable applied connection. Skip") pexp.expect("skip applied connection due to missing IPv4 configuration")
# The other one was lacking an address set it up. # The other one was lacking an address set it up.
pexp.expect("some changes were applied for provider aliyun") pexp.expect("some changes were applied for provider aliyun")
(exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp) (exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp)
@@ -2628,7 +2628,7 @@ class TestNmCloudSetup(unittest.TestCase):
pexp.expect("get-config: success") pexp.expect("get-config: success")
pexp.expect("meta data received") pexp.expect("meta data received")
# One of the devices has no IPv4 configuration to be modified # One of the devices has no IPv4 configuration to be modified
pexp.expect("device has no suitable applied connection. Skip") pexp.expect("skip applied connection due to missing IPv4 configuration")
# The other one was lacking an address set it up. # The other one was lacking an address set it up.
pexp.expect("some changes were applied for provider azure") pexp.expect("some changes were applied for provider azure")
(exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp) (exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp)
@@ -2707,7 +2707,7 @@ class TestNmCloudSetup(unittest.TestCase):
pexp.expect("get-config: success") pexp.expect("get-config: success")
pexp.expect("meta data received") pexp.expect("meta data received")
# One of the devices has no IPv4 configuration to be modified # One of the devices has no IPv4 configuration to be modified
pexp.expect("device has no suitable applied connection. Skip") pexp.expect("skip applied connection due to missing IPv4 configuration")
# The other one was lacking an address set it up. # The other one was lacking an address set it up.
pexp.expect("some changes were applied for provider ec2") pexp.expect("some changes were applied for provider ec2")
(exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp) (exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp)
@@ -2778,7 +2778,7 @@ class TestNmCloudSetup(unittest.TestCase):
pexp.expect("get-config: success") pexp.expect("get-config: success")
pexp.expect("meta data received") pexp.expect("meta data received")
# One of the devices has no IPv4 configuration to be modified # One of the devices has no IPv4 configuration to be modified
pexp.expect("device has no suitable applied connection. Skip") pexp.expect("skip applied connection due to missing IPv4 configuration")
# The other one was lacking an address set it up. # The other one was lacking an address set it up.
pexp.expect("some changes were applied for provider GCP") pexp.expect("some changes were applied for provider GCP")
(exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp) (exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp)
@@ -2869,7 +2869,7 @@ class TestNmCloudSetup(unittest.TestCase):
pexp.expect("get-config: success") pexp.expect("get-config: success")
pexp.expect("meta data received") pexp.expect("meta data received")
# One of the devices has no IPv4 configuration to be modified # One of the devices has no IPv4 configuration to be modified
pexp.expect("device has no suitable applied connection. Skip") pexp.expect("skip applied connection due to missing IPv4 configuration")
# The other one was lacking an address set it up. # The other one was lacking an address set it up.
pexp.expect("some changes were applied for provider oci") pexp.expect("some changes were applied for provider oci")
(exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp) (exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp)
@@ -2973,7 +2973,7 @@ class TestNmCloudSetup(unittest.TestCase):
# No configuration for the ethernets # No configuration for the ethernets
pexp.expect('configuring "eth0"') pexp.expect('configuring "eth0"')
pexp.expect("device has no suitable applied connection. Skip") pexp.expect("skip applied connection due to missing IPv4 configuration")
# Setting up the VLAN # Setting up the VLAN
pexp.expect("creating macvlan2 connection for VLAN 700 on CC:00:00:00:00:01...") pexp.expect("creating macvlan2 connection for VLAN 700 on CC:00:00:00:00:01...")
@@ -3013,7 +3013,7 @@ class TestNmCloudSetup(unittest.TestCase):
pexp.expect("get-config: success") pexp.expect("get-config: success")
pexp.expect("meta data received") pexp.expect("meta data received")
pexp.expect('configuring "eth0"') pexp.expect('configuring "eth0"')
pexp.expect("device has no suitable applied connection. Skip") pexp.expect("skip applied connection due to missing IPv4 configuration")
pexp.expect("no changes were applied for provider oci") pexp.expect("no changes were applied for provider oci")
(exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp) (exitstatus, signalstatus, valgrind_log) = self.ctx.cmd_close_pexpect(pexp)