Allow specification of initial IPAM ring via --ipam-seed

This commit is contained in:
Adam Harrison committed 2016-03-21 09:49:54 +00:00
1 parent 18ddf50b4c
commit e9081c6607
8 files changed
+126 -28

No files matched your search

+6 -3
View File
@@ -9,7 +9,7 @@ import (
)
type DB interface {
Load(string, interface{}) error
Load(string, interface{}) (bool, error)
Save(string, interface{}) error
}
@@ -50,11 +50,13 @@ func NewBoltDB(dbPathname string) (*BoltDB, error) {
return &BoltDB{db: db}, err
}
func (d *BoltDB) Load(ident string, data interface{}) error {
return d.db.View(func(tx *bolt.Tx) error {
func (d *BoltDB) Load(ident string, data interface{}) (bool, error) {
found := true
err := d.db.View(func(tx *bolt.Tx) error {
b := tx.Bucket(topBucket)
v := b.Get([]byte(ident))
if v == nil {
found = false
return nil
}
reader := bytes.NewReader(v)
@@ -62,6 +64,7 @@ func (d *BoltDB) Load(ident string, data interface{}) error {
err := decoder.Decode(data)
return err
})
return found, err
}
func (d *BoltDB) Save(ident string, data interface{}) error {