Merge pull request #16968 from MHBauer/network-refactor

refactor use of container struct from daemon
Upstream-commit: aaa8cae34537eb9bddacacc8bce61c91ca76d7d2
Component: engine
This commit is contained in:
Vincent Demeester
2015-10-14 17:48:08 +02:00
3 changed files with 29 additions and 10 deletions
+21
View File
@@ -120,3 +120,24 @@ func getIpamConfig(data []network.IPAMConfig) ([]*libnetwork.IpamConf, []*libnet
}
return ipamV4Cfg, ipamV6Cfg, nil
}
// ConnectContainerToNetwork connects the given container to the given
// network. If either cannot be found, an err is returned. If the
// network cannot be set up, an err is returned.
func (daemon *Daemon) ConnectContainerToNetwork(containerName, networkName string) error {
container, err := daemon.Get(containerName)
if err != nil {
return err
}
return container.ConnectToNetwork(networkName)
}
// DisconnectContainerFromNetwork disconnects the given container from
// the given network. If either cannot be found, an err is returned.
func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, network libnetwork.Network) error {
container, err := daemon.Get(containerName)
if err != nil {
return err
}
return container.DisconnectFromNetwork(network)
}