mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-26 14:40:46 +01:00
cloud-setup: factor out creation of new connection
We're going to create connections on wired devices for OCI VM VNICs, and they're going to also need the same user setting. Factor it out.
This commit is contained in:
parent
9895540a24
commit
93960639e8
1 changed files with 19 additions and 9 deletions
|
|
@ -691,6 +691,24 @@ try_again:
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
_new_connection(void)
|
||||
{
|
||||
NMConnection *connection = NULL;
|
||||
NMSetting *s_user;
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
|
||||
s_user = nm_setting_user_new();
|
||||
nm_connection_add_setting(connection, s_user);
|
||||
nm_setting_user_set_data(NM_SETTING_USER(s_user),
|
||||
"org.freedesktop.NetworkManager.origin",
|
||||
"nm-cloud-setup",
|
||||
NULL);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_config_ethernet(SigTermData *sigterm_data,
|
||||
const NMCSProviderGetConfigIfaceData *config_data,
|
||||
|
|
@ -733,9 +751,8 @@ _oci_new_vlan_dev(SigTermData *sigterm_data,
|
|||
const char *wired_mac_addr = NULL;
|
||||
const NMUtilsNamedValue *map = NULL;
|
||||
const char *ip4_config_method;
|
||||
NMSetting *s_user;
|
||||
|
||||
connection = nm_simple_connection_new();
|
||||
connection = _new_connection();
|
||||
|
||||
macvlan_name = g_strdup_printf("macvlan%ld", config_data->iface_idx);
|
||||
connection_id = g_strdup_printf("%s%ld", connection_type, config_data->iface_idx);
|
||||
|
|
@ -806,13 +823,6 @@ _oci_new_vlan_dev(SigTermData *sigterm_data,
|
|||
hwaddr,
|
||||
NULL));
|
||||
|
||||
s_user = nm_setting_user_new();
|
||||
nm_connection_add_setting(connection, s_user);
|
||||
nm_setting_user_set_data(NM_SETTING_USER(s_user),
|
||||
"org.freedesktop.NetworkManager.origin",
|
||||
"nm-cloud-setup",
|
||||
NULL);
|
||||
|
||||
_nmc_mangle_connection(NULL, connection, result, config_data, NULL, NULL);
|
||||
|
||||
_LOGD("config device %s: creating %s connection for VLAN %d on %s...",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue