mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #82 from dave-tucker/simplebridge
Rename simplebridge to bridge
This commit is contained in:
commit
565a7daa7a
7 changed files with 24 additions and 24 deletions
|
@ -12,7 +12,7 @@ The goal of libnetwork is to deliver a robust Container Network Model that provi
|
||||||
Please watch this space for updates on the progress.
|
Please watch this space for updates on the progress.
|
||||||
|
|
||||||
Currently libnetwork is nothing more than an attempt to modularize the Docker platform's networking subsystem by moving it into libnetwork as a library.
|
Currently libnetwork is nothing more than an attempt to modularize the Docker platform's networking subsystem by moving it into libnetwork as a library.
|
||||||
|
|
||||||
Please refer to the [roadmap](ROADMAP.md) for more information.
|
Please refer to the [roadmap](ROADMAP.md) for more information.
|
||||||
|
|
||||||
#### Using libnetwork
|
#### Using libnetwork
|
||||||
|
@ -23,10 +23,10 @@ There are many networking solutions available to suit a broad range of use-cases
|
||||||
// Create a new controller instance
|
// Create a new controller instance
|
||||||
controller := libnetwork.New()
|
controller := libnetwork.New()
|
||||||
|
|
||||||
// This option is only needed for in-tree drivers. Plugins(in future) will get
|
// This option is only needed for in-tree drivers. Plugins(in future) will get
|
||||||
// their options through plugin infrastructure.
|
// their options through plugin infrastructure.
|
||||||
option := options.Generic{}
|
option := options.Generic{}
|
||||||
driver, err := controller.NewNetworkDriver("simplebridge", option)
|
driver, err := controller.NewNetworkDriver("bridge", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ There are many networking solutions available to suit a broad range of use-cases
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// For a new container: create a sandbox instance (providing a unique key).
|
// For a new container: create a sandbox instance (providing a unique key).
|
||||||
// For linux it is a filesystem path
|
// For linux it is a filesystem path
|
||||||
networkPath := "/var/lib/docker/.../4d23e"
|
networkPath := "/var/lib/docker/.../4d23e"
|
||||||
|
@ -45,7 +45,7 @@ There are many networking solutions available to suit a broad range of use-cases
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// For each new container: allocate IP and interfaces. The returned network
|
// For each new container: allocate IP and interfaces. The returned network
|
||||||
// settings will be used for container infos (inspect and such), as well as
|
// settings will be used for container infos (inspect and such), as well as
|
||||||
// iptables rules for port publishing. This info is contained or accessible
|
// iptables rules for port publishing. This info is contained or accessible
|
||||||
|
@ -62,7 +62,7 @@ There are many networking solutions available to suit a broad range of use-cases
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the gateway IP
|
// Set the gateway IP
|
||||||
if err := networkNamespace.SetGateway(sinfo.Gateway); err != nil {
|
if err := networkNamespace.SetGateway(sinfo.Gateway); err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -11,7 +11,7 @@ func main() {
|
||||||
controller := libnetwork.New()
|
controller := libnetwork.New()
|
||||||
|
|
||||||
option := options.Generic{}
|
option := options.Generic{}
|
||||||
driver, err := controller.NewNetworkDriver("simplebridge", option)
|
driver, err := controller.NewNetworkDriver("bridge", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ func main() {
|
||||||
|
|
||||||
options := options.Generic{"AddressIPv4": net}
|
options := options.Generic{"AddressIPv4": net}
|
||||||
controller := libnetwork.New()
|
controller := libnetwork.New()
|
||||||
driver, _ := controller.NewNetworkDriver("simplebridge", options)
|
driver, _ := controller.NewNetworkDriver("bridge", options)
|
||||||
netw, err := controller.NewNetwork(driver, "dummy", "")
|
netw, err := controller.NewNetwork(driver, "dummy", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
networkType = "simplebridge"
|
networkType = "bridge"
|
||||||
vethPrefix = "veth"
|
vethPrefix = "veth"
|
||||||
vethLen = 7
|
vethLen = 7
|
||||||
containerVeth = "eth0"
|
containerVeth = "eth0"
|
||||||
|
@ -27,7 +27,7 @@ var (
|
||||||
portMapper *portmapper.PortMapper
|
portMapper *portmapper.PortMapper
|
||||||
)
|
)
|
||||||
|
|
||||||
// Configuration info for the "simplebridge" driver.
|
// Configuration info for the "bridge" driver.
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
BridgeName string
|
BridgeName string
|
||||||
AddressIPv4 *net.IPNet
|
AddressIPv4 *net.IPNet
|
||||||
|
@ -111,7 +111,7 @@ func (d *driver) Config(option interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new network using simplebridge plugin
|
// Create a new network using bridge plugin
|
||||||
func (d *driver) CreateNetwork(id types.UUID, option interface{}) error {
|
func (d *driver) CreateNetwork(id types.UUID, option interface{}) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrConfigExists error is returned when driver already has a config applied.
|
// ErrConfigExists error is returned when driver already has a config applied.
|
||||||
ErrConfigExists = errors.New("configuration already exists, simplebridge configuration can be applied only once")
|
ErrConfigExists = errors.New("configuration already exists, bridge configuration can be applied only once")
|
||||||
|
|
||||||
// ErrInvalidConfig error is returned when a network is created on a driver without valid config.
|
// ErrInvalidConfig error is returned when a network is created on a driver without valid config.
|
||||||
ErrInvalidConfig = errors.New("trying to create a network on a driver without valid config")
|
ErrInvalidConfig = errors.New("trying to create a network on a driver without valid config")
|
||||||
|
|
||||||
// ErrNetworkExists error is returned when a network already exists and another network is created.
|
// ErrNetworkExists error is returned when a network already exists and another network is created.
|
||||||
ErrNetworkExists = errors.New("network already exists, simplebridge can only have one network")
|
ErrNetworkExists = errors.New("network already exists, bridge can only have one network")
|
||||||
|
|
||||||
// ErrIfaceName error is returned when a new name could not be generated.
|
// ErrIfaceName error is returned when a new name could not be generated.
|
||||||
ErrIfaceName = errors.New("failed to find name for new interface")
|
ErrIfaceName = errors.New("failed to find name for new interface")
|
||||||
|
|
|
@ -29,7 +29,7 @@ func createTestNetwork(networkType, networkName string, option options.Generic)
|
||||||
return network, nil
|
return network, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimplebridge(t *testing.T) {
|
func Testbridge(t *testing.T) {
|
||||||
defer netutils.SetupTestNetNS(t)()
|
defer netutils.SetupTestNetNS(t)()
|
||||||
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -49,7 +49,7 @@ func TestSimplebridge(t *testing.T) {
|
||||||
}
|
}
|
||||||
cidrv6.IP = ip
|
cidrv6.IP = ip
|
||||||
|
|
||||||
log.Debug("Adding a simple bridge")
|
log.Debug("Adding a bridge")
|
||||||
option := options.Generic{
|
option := options.Generic{
|
||||||
"BridgeName": bridgeName,
|
"BridgeName": bridgeName,
|
||||||
"AddressIPv4": subnet,
|
"AddressIPv4": subnet,
|
||||||
|
@ -62,7 +62,7 @@ func TestSimplebridge(t *testing.T) {
|
||||||
"EnableIPForwarding": true,
|
"EnableIPForwarding": true,
|
||||||
"AllowNonDefaultBridge": true}
|
"AllowNonDefaultBridge": true}
|
||||||
|
|
||||||
network, err := createTestNetwork("simplebridge", "testnetwork", option)
|
network, err := createTestNetwork("bridge", "testnetwork", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func TestDuplicateNetwork(t *testing.T) {
|
||||||
controller := libnetwork.New()
|
controller := libnetwork.New()
|
||||||
|
|
||||||
option := options.Generic{}
|
option := options.Generic{}
|
||||||
driver, err := controller.NewNetworkDriver("simplebridge", option)
|
driver, err := controller.NewNetworkDriver("bridge", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ func TestDuplicateNetwork(t *testing.T) {
|
||||||
func TestNetworkName(t *testing.T) {
|
func TestNetworkName(t *testing.T) {
|
||||||
networkName := "testnetwork"
|
networkName := "testnetwork"
|
||||||
|
|
||||||
n, err := createTestNetwork("simplebridge", networkName, options.Generic{})
|
n, err := createTestNetwork("bridge", networkName, options.Generic{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func TestNetworkName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkType(t *testing.T) {
|
func TestNetworkType(t *testing.T) {
|
||||||
networkType := "simplebridge"
|
networkType := "bridge"
|
||||||
|
|
||||||
n, err := createTestNetwork(networkType, "testnetwork", options.Generic{})
|
n, err := createTestNetwork(networkType, "testnetwork", options.Generic{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -182,7 +182,7 @@ func TestNetworkType(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkID(t *testing.T) {
|
func TestNetworkID(t *testing.T) {
|
||||||
networkType := "simplebridge"
|
networkType := "bridge"
|
||||||
|
|
||||||
n, err := createTestNetwork(networkType, "testnetwork", options.Generic{})
|
n, err := createTestNetwork(networkType, "testnetwork", options.Generic{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -200,7 +200,7 @@ func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
||||||
"BridgeName": bridgeName,
|
"BridgeName": bridgeName,
|
||||||
"AllowNonDefaultBridge": true}
|
"AllowNonDefaultBridge": true}
|
||||||
|
|
||||||
network, err := createTestNetwork("simplebridge", "testnetwork", option)
|
network, err := createTestNetwork("bridge", "testnetwork", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ func TestUnknownNetwork(t *testing.T) {
|
||||||
"BridgeName": bridgeName,
|
"BridgeName": bridgeName,
|
||||||
"AllowNonDefaultBridge": true}
|
"AllowNonDefaultBridge": true}
|
||||||
|
|
||||||
network, err := createTestNetwork("simplebridge", "testnetwork", option)
|
network, err := createTestNetwork("bridge", "testnetwork", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ func TestUnknownEndpoint(t *testing.T) {
|
||||||
"AddressIPv4": subnet,
|
"AddressIPv4": subnet,
|
||||||
"AllowNonDefaultBridge": true}
|
"AllowNonDefaultBridge": true}
|
||||||
|
|
||||||
network, err := createTestNetwork("simplebridge", "testnetwork", option)
|
network, err := createTestNetwork("bridge", "testnetwork", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ create network namespaces and allocate interfaces for containers to use.
|
||||||
// This option is only needed for in-tree drivers. Plugins(in future) will get
|
// This option is only needed for in-tree drivers. Plugins(in future) will get
|
||||||
// their options through plugin infrastructure.
|
// their options through plugin infrastructure.
|
||||||
option := options.Generic{}
|
option := options.Generic{}
|
||||||
driver, err := controller.NewNetworkDriver("simplebridge", option)
|
driver, err := controller.NewNetworkDriver("bridge", option)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue