VOL-1497 : Add more control to kv/memory access

- Added kv locking mechanism (etcd only)
- (watch) control path access whenever possible
- (watch) use a transaction for updates and merge with memory
- cleaned up vendoring
- misc changes to fix exceptions found along the way

Amendments:

- Copyright header got removed in auto-generated file
- Changed default locking to false for KV list operation
- Updated backend api to allow the passing of locking parameter

Change-Id: Ie1a55d3ca8b9d92ae71a85ce42bb22fcf1419e2c
diff --git a/db/model/backend.go b/db/model/backend.go
index dc0e6bd..981a1d5 100644
--- a/db/model/backend.go
+++ b/db/model/backend.go
@@ -82,26 +82,26 @@
 }
 
 // List retrieves one or more items that match the specified key
-func (b *Backend) List(key string) (map[string]*kvstore.KVPair, error) {
+func (b *Backend) List(key string, lock ...bool) (map[string]*kvstore.KVPair, error) {
 	b.Lock()
 	defer b.Unlock()
 
 	formattedPath := b.makePath(key)
-	log.Debugw("listing-key", log.Fields{"key": key, "path": formattedPath})
+	log.Debugw("listing-key", log.Fields{"key": key, "path": formattedPath, "lock": lock})
 
-	return b.Client.List(formattedPath, b.Timeout)
+	return b.Client.List(formattedPath, b.Timeout, lock...)
 }
 
 // Get retrieves an item that matches the specified key
-func (b *Backend) Get(key string) (*kvstore.KVPair, error) {
+func (b *Backend) Get(key string, lock ...bool) (*kvstore.KVPair, error) {
 	b.Lock()
 	defer b.Unlock()
 
 	formattedPath := b.makePath(key)
-	log.Debugw("getting-key", log.Fields{"key": key, "path": formattedPath})
+	log.Debugw("getting-key", log.Fields{"key": key, "path": formattedPath, "lock": lock})
 
 	start := time.Now()
-	err, pair := b.Client.Get(formattedPath, b.Timeout)
+	err, pair := b.Client.Get(formattedPath, b.Timeout, lock...)
 	stop := time.Now()
 
 	GetProfiling().AddToDatabaseRetrieveTime(stop.Sub(start).Seconds())
@@ -110,25 +110,25 @@
 }
 
 // Put stores an item value under the specifed key
-func (b *Backend) Put(key string, value interface{}) error {
+func (b *Backend) Put(key string, value interface{}, lock ...bool) error {
 	b.Lock()
 	defer b.Unlock()
 
 	formattedPath := b.makePath(key)
-	log.Debugw("putting-key", log.Fields{"key": key, "value": string(value.([]byte)), "path": formattedPath})
+	log.Debugw("putting-key", log.Fields{"key": key, "value": string(value.([]byte)), "path": formattedPath, "lock": lock})
 
-	return b.Client.Put(formattedPath, value, b.Timeout)
+	return b.Client.Put(formattedPath, value, b.Timeout, lock...)
 }
 
 // Delete removes an item under the specified key
-func (b *Backend) Delete(key string) error {
+func (b *Backend) Delete(key string, lock ...bool) error {
 	b.Lock()
 	defer b.Unlock()
 
 	formattedPath := b.makePath(key)
-	log.Debugw("deleting-key", log.Fields{"key": key, "path": formattedPath})
+	log.Debugw("deleting-key", log.Fields{"key": key, "path": formattedPath, "lock": lock})
 
-	return b.Client.Delete(formattedPath, b.Timeout)
+	return b.Client.Delete(formattedPath, b.Timeout, lock...)
 }
 
 // CreateWatch starts watching events for the specified key