Initial kv store integration and datastore implementation

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal
2015-05-25 16:29:34 -07:00
parent d9f944560b
commit 83916aeab7
5 changed files with 482 additions and 0 deletions
+16
View File
@@ -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