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

View file

@ -304,9 +304,18 @@ func createBridgeIface(name string) error {
// Allocate a network interface // Allocate a network interface
func Allocate(job *engine.Job) engine.Status { 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 { if err != nil {
job.Error(err) job.Error(err)
return engine.StatusErr return engine.StatusErr