aboutsummaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-07-12 09:51:31 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-12 21:45:47 +0000
commit4f699db8dad05b770b4e02d3de67137517c3463b (patch)
treea7f474b248d283dd8805da73bf2b63ca56e4fd67 /libpod/container.go
parente615b7d67124c548a3c7b422348821204ce32775 (diff)
downloadpodman-4f699db8dad05b770b4e02d3de67137517c3463b.tar.gz
podman-4f699db8dad05b770b4e02d3de67137517c3463b.tar.bz2
podman-4f699db8dad05b770b4e02d3de67137517c3463b.zip
Support multiple networks
This is a refresh of Dan William's PR #974 with a rebase and proper vendoring of ocicni and containernetworking/cni. It adds the ability to define multiple networks as so: podman run --network=net1,net2,foobar ... Signed-off-by: baude <bbaude@redhat.com> Closes: #1082 Approved by: baude
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go42
1 files changed, 20 insertions, 22 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 9486986ab..f882868ed 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -143,18 +143,11 @@ type containerState struct {
// ExecSessions contains active exec sessions for container
// Exec session ID is mapped to PID of exec process
ExecSessions map[string]*ExecSession `json:"execSessions,omitempty"`
- // IPs contains IP addresses assigned to the container
- // Only populated if we created a network namespace for the container,
- // and the network namespace is currently active
- IPs []*cnitypes.IPConfig `json:"ipAddresses,omitempty"`
- // Interfaces contains interface information about the container
- // Only populated if we created a network namespace for the container,
- // and the network namespace is currently active
- Interfaces []*cnitypes.Interface `json:"interfaces,omitempty"`
- // Routes contains network routes present in the container
- // Only populated if we created a network namespace for the container,
- // and the network namespace is currently active
- Routes []*types.Route `json:"routes,omitempty"`
+ // NetworkStatus contains the configuration results for all networks
+ // the pod is attached to. Only populated if we created a network
+ // namespace for the container, and the network namespace is currently
+ // active
+ NetworkStatus []*cnitypes.Result `json:"networkResults,omitempty"`
// BindMounts contains files that will be bind-mounted into the
// container when it is mounted.
// These include /etc/hosts and /etc/resolv.conf
@@ -268,6 +261,8 @@ type ContainerConfig struct {
// Hosts to add in container
// Will be appended to host's host file
HostAdd []string `json:"hostsAdd,omitempty"`
+ // Network names (CNI) to add container to. Empty to use default network.
+ Networks []string `json:"networks,omitempty"`
// Image Config
@@ -773,10 +768,12 @@ func (c *Container) IPs() ([]net.IPNet, error) {
return nil, errors.Wrapf(ErrInvalidArg, "container %s network namespace is not managed by libpod")
}
- ips := make([]net.IPNet, 0, len(c.state.IPs))
+ ips := make([]net.IPNet, 0)
- for _, ip := range c.state.IPs {
- ips = append(ips, ip.Address)
+ for _, r := range c.state.NetworkStatus {
+ for _, ip := range r.IPs {
+ ips = append(ips, ip.Address)
+ }
}
return ips, nil
@@ -799,15 +796,16 @@ func (c *Container) Routes() ([]types.Route, error) {
return nil, errors.Wrapf(ErrInvalidArg, "container %s network namespace is not managed by libpod")
}
- routes := make([]types.Route, 0, len(c.state.Routes))
+ routes := make([]types.Route, 0)
- for _, route := range c.state.Routes {
- newRoute := types.Route{
- Dst: route.Dst,
- GW: route.GW,
+ for _, r := range c.state.NetworkStatus {
+ for _, route := range r.Routes {
+ newRoute := types.Route{
+ Dst: route.Dst,
+ GW: route.GW,
+ }
+ routes = append(routes, newRoute)
}
-
- routes = append(routes, newRoute)
}
return routes, nil