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

Docker: Network manager integration

This commit is contained in:
Andrea Luzzardi 2013-02-28 11:52:07 -08:00
parent 09eacdfade
commit bd2f51290f

View file

@ -11,10 +11,10 @@ import (
) )
type Docker struct { type Docker struct {
root string root string
repository string repository string
containers *list.List containers *list.List
networkAllocator *NetworkAllocator networkManager *NetworkManager
} }
func (docker *Docker) List() []*Container { func (docker *Docker) List() []*Container {
@ -52,7 +52,7 @@ func (docker *Docker) Create(id string, command string, args []string, layers []
return nil, fmt.Errorf("Container %v already exists", id) return nil, fmt.Errorf("Container %v already exists", id)
} }
root := path.Join(docker.repository, id) root := path.Join(docker.repository, id)
container, err := createContainer(id, root, command, args, layers, config, docker.networkAllocator) container, err := createContainer(id, root, command, args, layers, config, docker.networkManager)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -87,7 +87,7 @@ func (docker *Docker) restore() error {
return err return err
} }
for _, v := range dir { for _, v := range dir {
container, err := loadContainer(path.Join(docker.repository, v.Name()), docker.networkAllocator) container, err := loadContainer(path.Join(docker.repository, v.Name()), docker.networkManager)
if err != nil { if err != nil {
log.Printf("Failed to load container %v: %v", v.Name(), err) log.Printf("Failed to load container %v: %v", v.Name(), err)
continue continue
@ -102,15 +102,15 @@ func New() (*Docker, error) {
} }
func NewFromDirectory(root string) (*Docker, error) { func NewFromDirectory(root string) (*Docker, error) {
alloc, err := newNetworkAllocator(networkBridgeIface) netManager, err := newNetworkManager(networkBridgeIface)
if err != nil { if err != nil {
return nil, err return nil, err
} }
docker := &Docker{ docker := &Docker{
root: root, root: root,
repository: path.Join(root, "containers"), repository: path.Join(root, "containers"),
containers: list.New(), containers: list.New(),
networkAllocator: alloc, networkManager: netManager,
} }
if err := os.MkdirAll(docker.repository, 0700); err != nil && !os.IsExist(err) { if err := os.MkdirAll(docker.repository, 0700); err != nil && !os.IsExist(err) {