Enable Hot Add/Remove of Network Endpoints for Windows
Signed-off-by: Madhan Raj Mookkandy <madhanm@microsoft.com>
This commit is contained in:
parent
ef2e91707d
commit
b0888450a9
5 changed files with 43 additions and 17 deletions
|
@ -66,6 +66,7 @@ type hnsEndpoint struct {
|
|||
nid string
|
||||
profileID string
|
||||
Type string
|
||||
containerID string
|
||||
macAddress net.HardwareAddr
|
||||
epOption *endpointOption // User specified parameters
|
||||
epConnectivity *EndpointConnectivity // User specified parameters
|
||||
|
@ -730,7 +731,15 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
|
|||
return err
|
||||
}
|
||||
|
||||
// This is just a stub for now
|
||||
endpoint.containerID = sboxKey
|
||||
|
||||
err = hcsshim.HotAttachEndpoint(endpoint.containerID, endpoint.profileID)
|
||||
if err != nil {
|
||||
// If container doesn't exists in hcs, do not throw error for hot add/remove
|
||||
if err != hcsshim.ErrComputeSystemDoesNotExist {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
jinfo.DisableGatewayService()
|
||||
return nil
|
||||
|
@ -744,13 +753,18 @@ func (d *driver) Leave(nid, eid string) error {
|
|||
}
|
||||
|
||||
// Ensure that the endpoint exists
|
||||
_, err = network.getEndpoint(eid)
|
||||
endpoint, err := network.getEndpoint(eid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// This is just a stub for now
|
||||
|
||||
err = hcsshim.HotDetachEndpoint(endpoint.containerID, endpoint.profileID)
|
||||
if err != nil {
|
||||
// If container doesn't exists in hcs, do not throw error for hot add/remove
|
||||
if err != hcsshim.ErrComputeSystemDoesNotExist {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,7 @@ import "testing"
|
|||
// GenerateKey generates a sandbox key based on the passed
|
||||
// container id.
|
||||
func GenerateKey(containerID string) string {
|
||||
maxLen := 12
|
||||
if len(containerID) < maxLen {
|
||||
maxLen = len(containerID)
|
||||
}
|
||||
|
||||
return containerID[:maxLen]
|
||||
return containerID
|
||||
}
|
||||
|
||||
// NewSandbox provides a new sandbox instance created in an os specific way
|
||||
|
|
|
@ -144,13 +144,6 @@ func (sb *sandbox) ContainerID() string {
|
|||
return sb.containerID
|
||||
}
|
||||
|
||||
func (sb *sandbox) Key() string {
|
||||
if sb.config.useDefaultSandBox {
|
||||
return osl.GenerateKey("default")
|
||||
}
|
||||
return osl.GenerateKey(sb.id)
|
||||
}
|
||||
|
||||
func (sb *sandbox) Labels() map[string]interface{} {
|
||||
sb.Lock()
|
||||
defer sb.Unlock()
|
||||
|
|
12
libnetwork/sandbox_others.go
Normal file
12
libnetwork/sandbox_others.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
// +build !windows
|
||||
|
||||
package libnetwork
|
||||
|
||||
import "github.com/docker/libnetwork/osl"
|
||||
|
||||
func (sb *sandbox) Key() string {
|
||||
if sb.config.useDefaultSandBox {
|
||||
return osl.GenerateKey("default")
|
||||
}
|
||||
return osl.GenerateKey(sb.id)
|
||||
}
|
12
libnetwork/sandbox_windows.go
Normal file
12
libnetwork/sandbox_windows.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
// +build windows
|
||||
|
||||
package libnetwork
|
||||
|
||||
import "github.com/docker/libnetwork/osl"
|
||||
|
||||
func (sb *sandbox) Key() string {
|
||||
if sb.config.useDefaultSandBox {
|
||||
return osl.GenerateKey("default")
|
||||
}
|
||||
return osl.GenerateKey(sb.containerID)
|
||||
}
|
Loading…
Add table
Reference in a new issue