From e67f9f4f79a0f3e62e1b6dd3b9d8ae875d6ea91a Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Sun, 24 May 2015 16:48:29 -0700 Subject: [PATCH] Copy default configs from default Bridge to new bridge if not user configured Also fixed a minor bug in client to choose bridge as the default driver. Signed-off-by: Madhu Venugopal --- libnetwork/client/network.go | 2 +- libnetwork/drivers/bridge/bridge.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libnetwork/client/network.go b/libnetwork/client/network.go index 7e54563cff..c02427b7cb 100644 --- a/libnetwork/client/network.go +++ b/libnetwork/client/network.go @@ -45,7 +45,7 @@ func (cli *NetworkCli) CmdNetwork(chain string, args ...string) error { // CmdNetworkCreate handles Network Create UI func (cli *NetworkCli) CmdNetworkCreate(chain string, args ...string) error { cmd := cli.Subcmd(chain, "create", "NETWORK-NAME", "Creates a new network with a name specified by the user", false) - flDriver := cmd.String([]string{"d", "-driver"}, "null", "Driver to manage the Network") + flDriver := cmd.String([]string{"d", "-driver"}, "bridge", "Driver to manage the Network") cmd.Require(flag.Min, 1) err := cmd.ParseFlags(args, true) if err != nil { diff --git a/libnetwork/drivers/bridge/bridge.go b/libnetwork/drivers/bridge/bridge.go index 760586c21f..e8306d43cb 100644 --- a/libnetwork/drivers/bridge/bridge.go +++ b/libnetwork/drivers/bridge/bridge.go @@ -175,8 +175,8 @@ func (c *networkConfiguration) Conflict(o *networkConfiguration) bool { return false } -// FromMap retrieve the configuration data from the map form. -func (c *networkConfiguration) FromMap(data map[string]interface{}) error { +// fromMap retrieve the configuration data from the map form. +func (c *networkConfiguration) fromMap(data map[string]interface{}) error { var err error if i, ok := data["BridgeName"]; ok && i != nil { @@ -393,8 +393,12 @@ func parseNetworkGenericOptions(data interface{}) (*networkConfiguration, error) case *networkConfiguration: config = opt case map[string]interface{}: - config = &networkConfiguration{} - err = config.FromMap(opt) + config = &networkConfiguration{ + EnableICC: true, + EnableIPTables: true, + EnableIPMasquerade: true, + } + err = config.fromMap(opt) case options.Generic: var opaqueConfig interface{} if opaqueConfig, err = options.GenerateFromModel(opt, config); err == nil {