github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/container/network.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package container
     5  
     6  import (
     7  	"github.com/juju/juju/network"
     8  )
     9  
    10  const (
    11  	// BridgeNetwork will have the container use the network bridge.
    12  	BridgeNetwork = "bridge"
    13  	// PhyscialNetwork will have the container use a specified network device.
    14  	PhysicalNetwork = "physical"
    15  	// DefaultLxdBridge is the default name for the lxd bridge.
    16  	DefaultLxdBridge = "lxdbr0"
    17  	// DefaultLxcBridge is the package created container bridge.
    18  	DefaultLxcBridge = "lxcbr0"
    19  	// DefaultKvmBridge is the default bridge for KVM instances.
    20  	DefaultKvmBridge = "virbr0"
    21  )
    22  
    23  // NetworkConfig defines how the container network will be configured.
    24  type NetworkConfig struct {
    25  	NetworkType string
    26  	Device      string
    27  	MTU         int
    28  
    29  	Interfaces []network.InterfaceInfo
    30  }
    31  
    32  // BridgeNetworkConfig returns a valid NetworkConfig to use the
    33  // specified device as a network bridge for the container. It also
    34  // allows passing in specific configuration for the container's
    35  // network interfaces and default MTU to use. If interfaces is nil the
    36  // default configuration is used for the respective container type.
    37  func BridgeNetworkConfig(device string, mtu int, interfaces []network.InterfaceInfo) *NetworkConfig {
    38  	return &NetworkConfig{BridgeNetwork, device, mtu, interfaces}
    39  }
    40  
    41  // PhysicalNetworkConfig returns a valid NetworkConfig to use the
    42  // specified device as the network device for the container. It also
    43  // allows passing in specific configuration for the container's
    44  // network interfaces and default MTU to use. If interfaces is nil the
    45  // default configuration is used for the respective container type.
    46  func PhysicalNetworkConfig(device string, mtu int, interfaces []network.InterfaceInfo) *NetworkConfig {
    47  	return &NetworkConfig{PhysicalNetwork, device, mtu, interfaces}
    48  }