mirror of
https://github.com/clearlinux/libnetwork.git
synced 2026-09-03 20:31:30 +00:00
Initial kv store integration and datastore implementation
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
@@ -48,8 +48,10 @@ package libnetwork
|
||||
import (
|
||||
"sync"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/libnetwork/datastore"
|
||||
"github.com/docker/libnetwork/driverapi"
|
||||
"github.com/docker/libnetwork/sandbox"
|
||||
"github.com/docker/libnetwork/types"
|
||||
@@ -95,6 +97,7 @@ type controller struct {
|
||||
networks networkTable
|
||||
drivers driverTable
|
||||
sandboxes sandboxTable
|
||||
store datastore.DataStore
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
@@ -107,6 +110,18 @@ func New() (NetworkController, error) {
|
||||
if err := initDrivers(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
/* TODO : Duh ! make this configurable :-) */
|
||||
config := &datastore.StoreConfiguration{}
|
||||
config.Provider = "consul"
|
||||
config.Addrs = []string{"localhost:8500"}
|
||||
|
||||
store, err := datastore.NewDataStore(config)
|
||||
if err != nil {
|
||||
log.Error("Failed to connect with Consul server")
|
||||
}
|
||||
c.store = store
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
@@ -176,6 +191,7 @@ func (c *controller) NewNetwork(networkType, name string, options ...NetworkOpti
|
||||
// Store the network handler in controller
|
||||
c.Lock()
|
||||
c.networks[network.id] = network
|
||||
c.store.PutObjectAtomic(network)
|
||||
c.Unlock()
|
||||
|
||||
return network, nil
|
||||
|
||||
Reference in New Issue
Block a user