On Fri, 2012-02-24 at 15:31 +0100, Thomas Graf wrote:
> For bonding-master:
> TYPE=bond
> BONDING_MASTER=yes
> DEVICE=
> BONDING_OPTS="..."
>
> For bonding-slaves:
> MASTER=
>
> v2: Resolved test failures after feedback from Jirka.
Pushed, thanks.
Dan
> Signed-off-by: Thomas Graf
> ---
> .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 280
> +++-
> src/settings/plugins/ifcfg-rh/writer.c | 61 +
> 2 files changed, 339 insertions(+), 2 deletions(-)
>
> 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 348e192..c385702 100644
> --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
> +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
> @@ -11914,6 +11914,145 @@ test_read_bond_main (void)
> g_object_unref (connection);
> }
>
> +static void
> +test_write_bond_main (void)
> +{
> + NMConnection *connection;
> + NMConnection *reread;
> + NMSettingConnection *s_con;
> + NMSettingBond *s_bond;
> + NMSettingIP4Config *s_ip4;
> + NMSettingIP6Config *s_ip6;
> + NMSettingWired *s_wired;
> + char *uuid;
> + const guint32 ip1 = htonl (0x01010103);
> + const guint32 gw = htonl (0x01010101);
> + const guint32 prefix = 24;
> + NMIP4Address *addr;
> + gboolean success;
> + GError *error = NULL;
> + char *testfile = NULL;
> + char *unmanaged = NULL;
> + char *keyfile = NULL;
> + char *routefile = NULL;
> + char *route6file = NULL;
> + gboolean ignore_error = FALSE;
> +
> + connection = nm_connection_new ();
> + ASSERT (connection != NULL,
> + "bond-main-write", "failed to allocate new connection");
> +
> + /* Connection setting */
> + s_con = (NMSettingConnection *) nm_setting_connection_new ();
> + ASSERT (s_con != NULL,
> + "bond-main-write", "failed to allocate new %s setting",
> + NM_SETTING_CONNECTION_SETTING_NAME);
> + nm_connection_add_setting (connection, NM_SETTING (s_con));
> +
> + uuid = nm_utils_uuid_generate ();
> + g_object_set (s_con,
> + NM_SETTING_CONNECTION_ID, "Test Write Bond Main",
> + NM_SETTING_CONNECTION_UUID, uuid,
> + NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
> + NM_SETTING_CONNECTION_TYPE, NM_SETTING_BOND_SETTING_NAME,
> + NULL);
> + g_free (uuid);
> +
> + /* Wired setting */
> + s_wired = (NMSettingWired *) nm_setting_wired_new ();
> + ASSERT (s_wired != NULL,
> + "bond-main-write", "failed to allocate new %s setting",
> + NM_SETTING_WIRED_SETTING_NAME);
> + nm_connection_add_setting (connection, NM_SETTING (s_wired));
> +
> + /* bond setting */
> + s_bond = (NMSettingBond *) nm_setting_bond_new ();
> + ASSERT (s_bond != NULL,
> + "bond-main-write", "failed to allocate new %s setting",
> + NM_SETTING_BOND_SETTING_NAME);
> + nm_connection_add_setting (connection, NM_SETTING (s_bond));
> +
> + g_object_set (s_bond,
> + NM_SETTING_BOND_INTERFACE_NAME, "bond0",
> + NULL);
> +
> + /* IP4 setting */
> + s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
> + ASSERT (s_ip4 != NULL,
> + "bond-main-write", "failed to allocate new %s setting",
> + NM_SETTING_IP4_CONFIG_SETTING_NAME);
> + nm_connection_add_setting (connection, NM_SETTING (s_ip4));
> +
> + g_object_set (s_ip4,
> + NM_SETTING_IP4_CONFIG_METHOD,
> NM_SETTING_IP4_CONFIG_METHOD_MANUAL,
> + NM_SETTING_IP4_CONFIG_MAY_FAIL, TRUE,
> + NULL);
> +
> + addr = nm_ip4_address_new ();
> + nm_ip4_address_set_address (addr, ip1);
> + nm_ip4_address_set_prefix (addr, prefix);
> + nm_ip4_address_set_gateway (addr, gw);
> + nm_setting_ip4_config_add_address (s_ip4, addr);
> + nm_ip4_address_unref (addr);
> +
> + /* IP6 setting */
> + s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
> + ASSERT (s_ip6 != NULL,
> + "bond-main-write", "failed to allocate new %s setting",
> + NM_SETTING_IP6_CONFIG_SETTING_NAME);
> + nm_connection_add_setting (connection, NM_SETTING (s_ip6));
> +
> + g_object_set (s_ip6,
> + NM_SETTING_IP6_CONFIG_METHOD,
> NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
> + NULL);
> +
> + ASSERT (nm_connection_verify (connection, &error) == TRUE,
> + "bond-main-write", "failed to verify connection: %s",
> + (error && error->message) ? error->message : "(unknown)");
> +
> + /* Save the ifcfg */
> + success = writer_new_connection (connection,
> + TEST_SCRATCH_DIR "/network-scripts/",
> + &testfile,
> +