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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user