diff options
| author | Michael Biebl <biebl@debian.org> | 2017-11-10 19:02:08 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-11-10 19:02:08 +0100 |
| commit | 417f6015c3dc8c47cf27daa59f64e0e36c521b9c (patch) | |
| tree | 1bec2cd2b25a902a4e2e1ff8cfe39e66a5a97704 /src/settings | |
| parent | 90e8691111889a7b5f3c812f5a41f15a8a058913 (diff) | |
New upstream version 1.10.0 upstream/1.10.0
Diffstat (limited to 'src/settings')
4 files changed, 77 insertions, 3 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 4754bea5..66add713 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -5261,8 +5261,12 @@ connection_from_file_full (const char *filename, else if (!strcasecmp (devtype, TYPE_TEAM_PORT)) { gs_free char *device = NULL; + type = svGetValueStr_cp (parsed, "TYPE"); device = svGetValueStr_cp (parsed, "DEVICE"); - if (device && is_vlan_device (device, parsed)) + + if (type) { + /* nothing to do */ + } else if (device && is_vlan_device (device, parsed)) type = g_strdup (TYPE_VLAN); else type = g_strdup (TYPE_ETHERNET); @@ -5273,7 +5277,7 @@ connection_from_file_full (const char *filename, gs_free char *t = NULL; /* Team and TeamPort types are also accepted by the mere - * presense of TEAM_CONFIG/TEAM_MASTER. They don't require + * presence of TEAM_CONFIG/TEAM_MASTER. They don't require * DEVICETYPE. */ t = svGetValueStr_cp (parsed, "TEAM_CONFIG"); if (t) diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index d16f46be..5c8de7d1 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -1821,7 +1821,10 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) { svSetValueStr (ifcfg, "TEAM_MASTER_UUID", master); svSetValueStr (ifcfg, "TEAM_MASTER", master_iface); - svUnsetValue (ifcfg, "TYPE"); + if (NM_IN_STRSET (type, + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_VLAN_SETTING_NAME)) + svUnsetValue (ifcfg, "TYPE"); } } diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected new file mode 100644 index 00000000..460278e1 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected @@ -0,0 +1,9 @@ +CONNECTED_MODE=no +TYPE=InfiniBand +TEAM_PORT_CONFIG="{ \"inf1\": { \"prio\": -10, \"sticky\": true } }" +NAME="Test Write Team Infiniband Port" +UUID=${UUID} +DEVICE=inf1 +ONBOOT=yes +TEAM_MASTER=team0 +DEVICETYPE=TeamPort diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 52dbd932..5044a2d7 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -8863,6 +8863,63 @@ test_write_team_port (void) } static void +test_write_team_infiniband_port (void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingConnection *s_con; + NMSettingTeamPort *s_team_port; + NMSettingInfiniband *s_inf; + const char *expected_config = "{ \"inf1\": { \"prio\": -10, \"sticky\": true } }"; + shvarFile *f; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Write Team Infiniband Port", + NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (), + NM_SETTING_CONNECTION_TYPE, NM_SETTING_INFINIBAND_SETTING_NAME, + NM_SETTING_CONNECTION_MASTER, "team0", + NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, + NM_SETTING_CONNECTION_INTERFACE_NAME, "inf1", + NULL); + + /* Team setting */ + s_team_port = (NMSettingTeamPort *) nm_setting_team_port_new (); + nm_connection_add_setting (connection, NM_SETTING (s_team_port)); + g_object_set (s_team_port, NM_SETTING_TEAM_PORT_CONFIG, expected_config, NULL); + + /* Infiniband setting */ + s_inf = (NMSettingInfiniband *) nm_setting_infiniband_new (); + nm_connection_add_setting (connection, NM_SETTING (s_inf)); + g_object_set (s_inf, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); + + nmtst_assert_connection_verifies (connection); + + _writer_new_connec_exp (connection, + TEST_SCRATCH_DIR "/network-scripts/", + TEST_IFCFG_DIR "/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected", + &testfile); + + f = _svOpenFile (testfile); + _svGetValue_check (f, "TYPE", "InfiniBand"); + _svGetValue_check (f, "DEVICETYPE", "TeamPort"); + _svGetValue_check (f, "TEAM_PORT_CONFIG", expected_config); + _svGetValue_check (f, "TEAM_MASTER", "team0"); + svCloseFile (f); + + reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, + NULL); + + nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); +} + +static void test_read_team_port_empty_config (void) { NMConnection *connection; @@ -9821,6 +9878,7 @@ int main (int argc, char **argv) g_test_add_data_func (TPATH "team/read-port-1", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-1", test_read_team_port); g_test_add_data_func (TPATH "team/read-port-2", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-2", test_read_team_port); g_test_add_func (TPATH "team/write-port", test_write_team_port); + g_test_add_func (TPATH "team/write-infiniband-port", test_write_team_infiniband_port); g_test_add_func (TPATH "team/read-port-empty-config", test_read_team_port_empty_config); g_test_add_func (TPATH "team/reread-slave", test_team_reread_slave); |