1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Implement requesting the name ip

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-01-30 12:02:56 -08:00
parent 49b9813035
commit 2df0166107
2 changed files with 27 additions and 22 deletions

View file

@ -1109,36 +1109,32 @@ func (container *Container) allocateNetwork() error {
var (
env *engine.Env
err error
eng = container.runtime.eng
)
if container.State.IsGhost() {
if container.runtime.config.DisableNetwork {
env = &engine.Env{}
} else {
// TODO: @crosbymichael
panic("not implemented")
/*
iface = &NetworkInterface{
IPNet: net.IPNet{IP: net.ParseIP(container.NetworkSettings.IPAddress), Mask: manager.bridgeNetwork.Mask},
Gateway: manager.bridgeNetwork.IP,
}
currentIP := container.NetworkSettings.IPAddress
// request an existing ip
if iface != nil && iface.IPNet.IP != nil {
if _, err := ipallocator.RequestIP(manager.bridgeNetwork, &iface.IPNet.IP); err != nil {
return err
}
} else {
job = eng.Job("allocate_interface", container.ID)
if err := job.Run(); err != nil {
return err
}
}
*/
job := eng.Job("allocate_interface", container.ID)
if currentIP != "" {
job.Setenv("RequestIP", currentIP)
}
env, err = job.Stdout.AddEnv()
if err != nil {
return err
}
if err := job.Run(); err != nil {
return err
}
}
} else {
job := eng.Job("allocate_interface", container.ID)
var err error
env, err = job.Stdout.AddEnv()
if err != nil {
return err

View file

@ -304,9 +304,18 @@ func createBridgeIface(name string) error {
// Allocate a network interface
func Allocate(job *engine.Job) engine.Status {
id := job.Args[0]
var (
ip *net.IP
err error
id = job.Args[0]
requestedIP = net.ParseIP(job.Getenv("RequestedIP"))
)
ip, err := ipallocator.RequestIP(bridgeNetwork, nil)
if requestedIP != nil {
ip, err = ipallocator.RequestIP(bridgeNetwork, &requestedIP)
} else {
ip, err = ipallocator.RequestIP(bridgeNetwork, nil)
}
if err != nil {
job.Error(err)
return engine.StatusErr