github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/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  )
    16  
    17  // NetworkConfig defines how the container network will be configured.
    18  type NetworkConfig struct {
    19  	NetworkType string
    20  	Device      string
    21  
    22  	Interfaces []network.InterfaceInfo
    23  }
    24  
    25  // BridgeNetworkConfig returns a valid NetworkConfig to use the
    26  // specified device as a network bridge for the container. It also
    27  // allows passing in specific configuration for the container's
    28  // network interfaces. If interfaces is nil the default configuration
    29  // is used for the respective container type.
    30  func BridgeNetworkConfig(device string, interfaces []network.InterfaceInfo) *NetworkConfig {
    31  	return &NetworkConfig{BridgeNetwork, device, interfaces}
    32  }
    33  
    34  // PhysicalNetworkConfig returns a valid NetworkConfig to use the
    35  // specified device as the network device for the container. It also
    36  // allows passing in specific configuration for the container's
    37  // network interfaces. If interfaces is nil the default configuration
    38  // is used for the respective container type.
    39  func PhysicalNetworkConfig(device string, interfaces []network.InterfaceInfo) *NetworkConfig {
    40  	return &NetworkConfig{PhysicalNetwork, device, interfaces}
    41  }