VOL-2145 - update to voltha-lib-go@v2.2.5

Change-Id: I9a16df88aed7798d9fc5519107f4f16baa1a7a7f
diff --git a/go.mod b/go.mod
index 91d0a3b..557d98e 100644
--- a/go.mod
+++ b/go.mod
@@ -5,13 +5,11 @@
 require (
 	github.com/gogo/protobuf v1.3.0
 	github.com/golang/protobuf v1.3.2
-	github.com/jstemmer/go-junit-report v0.9.1 // indirect
 	github.com/onsi/ginkgo v1.8.0 // indirect
 	github.com/onsi/gomega v1.5.0 // indirect
 	github.com/opencord/voltha-go v0.0.0-20191018170815-cb7c88a83125
-	github.com/opencord/voltha-lib-go v0.0.0-20191017201200-e73f91e306e9
+	github.com/opencord/voltha-lib-go v0.0.0-20191023185531-80258b36a64b
 	github.com/opencord/voltha-protos v1.0.3
-	github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
 	go.etcd.io/etcd v0.0.0-20190930204107-236ac2a90522
 	google.golang.org/grpc v1.24.0
 )
diff --git a/go.sum b/go.sum
index c02d9a7..ee454b9 100644
--- a/go.sum
+++ b/go.sum
@@ -147,8 +147,6 @@
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
 github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
 github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
-github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
-github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
@@ -198,6 +196,8 @@
 github.com/opencord/voltha-go v0.0.0-20191018170815-cb7c88a83125/go.mod h1:98NCXBPUxv60BA5dkLBwDSfsE9vbxORz2mACL1WlDB0=
 github.com/opencord/voltha-lib-go v0.0.0-20191017201200-e73f91e306e9 h1:/CA9esQ/L41vhvwCIDI+cLjrawry5+1fQWt/O91KFXU=
 github.com/opencord/voltha-lib-go v0.0.0-20191017201200-e73f91e306e9/go.mod h1:+bjwfm5bbP1j6liscpn3UFqbh6hHDkmLDWU3AdYLDY4=
+github.com/opencord/voltha-lib-go v0.0.0-20191023185531-80258b36a64b h1:s3zvCa27RhpVy+wCk5R4iKa9H61B1MzbSL2164B1w68=
+github.com/opencord/voltha-lib-go v0.0.0-20191023185531-80258b36a64b/go.mod h1:+bjwfm5bbP1j6liscpn3UFqbh6hHDkmLDWU3AdYLDY4=
 github.com/opencord/voltha-protos v1.0.3 h1:9v+R/QGF1xK+HKTqFM0IqCABoGCAxC8iKH4VzNBJDto=
 github.com/opencord/voltha-protos v1.0.3/go.mod h1:myfFIkJdA+rCXmKdLImhh79MfabN4ZOKQ4grk32DnPQ=
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
@@ -248,8 +248,6 @@
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c h1:+aPplBwWcHBo6q9xrfWdMrT9o4kltkmmvpemgIjep/8=
-github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c/go.mod h1:SbErYREK7xXdsRiigaQiQkI9McGRzYMvlKYaP3Nimdk=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8 h1:ndzgwNDnKIqyCvHTXaCqh9KlOWKvBry6nuXMJmonVsE=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
diff --git a/mocks/mockCoreProxy.go b/mocks/mockCoreProxy.go
index 08bf2ac..db3171a 100644
--- a/mocks/mockCoreProxy.go
+++ b/mocks/mockCoreProxy.go
@@ -193,3 +193,11 @@
 	}
 	return nil
 }
+
+// DeviceReasonUpdate  implements mock SendPacketIn
+func (mcp *MockCoreProxy) DeviceReasonUpdate(ctx context.Context, deviceID string, reason string) error {
+	if deviceID == "" {
+		return errors.New("no Device ID")
+	}
+	return nil
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/adapterif/core_proxy_if.go b/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/adapterif/core_proxy_if.go
index 26d021f..196f356 100644
--- a/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/adapterif/core_proxy_if.go
+++ b/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/adapterif/core_proxy_if.go
@@ -46,4 +46,5 @@
 	GetChildDevice(ctx context.Context, parentDeviceID string, kwargs map[string]interface{}) (*voltha.Device, error)
 	GetChildDevices(ctx context.Context, parentDeviceID string) (*voltha.Devices, error)
 	SendPacketIn(ctx context.Context, deviceID string, port uint32, pktPayload []byte) error
+	DeviceReasonUpdate(ctx context.Context, deviceID string, deviceReason string) error
 }
diff --git a/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/common/core_proxy.go b/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/common/core_proxy.go
index 30117ca..1daeacb 100644
--- a/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/common/core_proxy.go
+++ b/vendor/github.com/opencord/voltha-lib-go/pkg/adapters/common/core_proxy.go
@@ -500,6 +500,30 @@
 	return unPackResponse(rpc, deviceId, success, result)
 }
 
+func (ap *CoreProxy) DeviceReasonUpdate(ctx context.Context, deviceId string, deviceReason string) error {
+	log.Debugw("DeviceReasonUpdate", log.Fields{"deviceId": deviceId, "deviceReason": deviceReason})
+	rpc := "DeviceReasonUpdate"
+	// Use a device specific topic to send the request.  The adapter handling the device creates a device
+	// specific topic
+	toTopic := ap.getCoreTopic(deviceId)
+	replyToTopic := ap.getAdapterTopic()
+
+	args := make([]*kafka.KVArg, 2)
+	id := &voltha.ID{Id: deviceId}
+	args[0] = &kafka.KVArg{
+		Key:   "device_id",
+		Value: id,
+	}
+	reason := &ic.StrType{Val: deviceReason}
+	args[1] = &kafka.KVArg{
+		Key:   "device_reason",
+		Value: reason,
+	}
+	success, result := ap.kafkaICProxy.InvokeRPC(nil, rpc, &toTopic, &replyToTopic, true, deviceId, args...)
+	log.Debugw("DeviceReason-response", log.Fields{"pDeviceId": deviceId, "success": success})
+	return unPackResponse(rpc, deviceId, success, result)
+}
+
 func (ap *CoreProxy) DevicePMConfigUpdate(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
 	log.Debugw("DevicePMConfigUpdate", log.Fields{"pmConfigs": pmConfigs})
 	rpc := "DevicePMConfigUpdate"
diff --git a/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/non_persisted_revision.go b/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/non_persisted_revision.go
index 88320cb..514b3b3 100644
--- a/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/non_persisted_revision.go
+++ b/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/non_persisted_revision.go
@@ -25,6 +25,7 @@
 	"github.com/opencord/voltha-lib-go/pkg/log"
 	"reflect"
 	"sort"
+	"strings"
 	"sync"
 	"time"
 )
@@ -284,12 +285,7 @@
 	npr.mutex.Lock()
 	defer npr.mutex.Unlock()
 
-	if ctx != nil {
-		if ctxTS, ok := ctx.Value(RequestTimestamp).(int64); ok && npr.lastUpdate.UnixNano() > ctxTS {
-			log.Warnw("data-is-older-than-current", log.Fields{"ctx-ts": ctxTS, "rev-ts": npr.lastUpdate.UnixNano()})
-			return npr
-		}
-	}
+	log.Debugw("update-data", log.Fields{"hash": npr.GetHash(), "current": npr.Config.Data, "provided": data})
 
 	// Do not update the revision if data is the same
 	if npr.Config.Data != nil && npr.Config.hashData(npr.Root, data) == npr.Config.Hash {
@@ -313,6 +309,8 @@
 
 	newRev.Finalize(false)
 
+	log.Debugw("update-data-complete", log.Fields{"updated": newRev.Config.Data, "provided": data})
+
 	return &newRev
 }
 
@@ -461,6 +459,25 @@
 	}
 }
 
+/// ChildDropByName will remove a child entry matching the type and name
+func (npr *NonPersistedRevision) ChildDropByName(childName string) {
+	// Extract device type
+	parts := strings.SplitN(childName, "/", 2)
+	childType := parts[0]
+
+	if childType != "" {
+		children := make([]Revision, len(npr.GetChildren(childType)))
+		copy(children, npr.GetChildren(childType))
+		for i, child := range children {
+			if child.GetName() == childName {
+				children = append(children[:i], children[i+1:]...)
+				npr.SetChildren(childType, children)
+				break
+			}
+		}
+	}
+}
+
 func (npr *NonPersistedRevision) SetLastUpdate(ts ...time.Time) {
 	npr.mutex.Lock()
 	defer npr.mutex.Unlock()
diff --git a/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/persisted_revision.go b/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/persisted_revision.go
index c644e14..8ab182b 100644
--- a/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/persisted_revision.go
+++ b/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/persisted_revision.go
@@ -162,7 +162,14 @@
 			switch event.EventType {
 			case kvstore.DELETE:
 				log.Debugw("delete-from-memory", log.Fields{"key": latestRev.GetHash(), "watch": latestRev.GetName()})
-				pr.Revision.Drop("", true)
+
+				// Remove reference from cache
+				GetRevCache().Delete(latestRev.GetName())
+
+				// Remove reference from parent
+				parent := pr.GetBranch().Node.GetRoot()
+				parent.GetBranch(NONE).Latest.ChildDropByName(latestRev.GetName())
+
 				break StopWatchLoop
 
 			case kvstore.PUT:
@@ -382,10 +389,11 @@
 		// Also check if we are treating a newer revision of the data or not
 		if childRev.GetData().(proto.Message).String() != data.(proto.Message).String() && childRev.getVersion() < version {
 			log.Debugw("revision-data-is-different", log.Fields{
-				"key":     childRev.GetHash(),
-				"name":    childRev.GetName(),
-				"data":    childRev.GetData(),
-				"version": childRev.getVersion(),
+				"key":               childRev.GetHash(),
+				"name":              childRev.GetName(),
+				"data":              childRev.GetData(),
+				"in-memory-version": childRev.getVersion(),
+				"persisted-version": version,
 			})
 
 			//
@@ -436,9 +444,11 @@
 		} else {
 			if childRev != nil {
 				log.Debugw("keeping-revision-data", log.Fields{
-					"key":  childRev.GetHash(),
-					"name": childRev.GetName(),
-					"data": childRev.GetData(),
+					"key":                 childRev.GetHash(),
+					"name":                childRev.GetName(),
+					"data":                childRev.GetData(),
+					"in-memory-version":   childRev.getVersion(),
+					"persistence-version": version,
 				})
 
 				// Update timestamp to reflect when it was last read and to reset tracked timeout
@@ -455,9 +465,10 @@
 		// There is no available child with that key value.
 		// Create a new child and update the parent revision.
 		log.Debugw("no-such-revision-entry", log.Fields{
-			"key":  keyValue,
-			"name": typeName,
-			"data": data,
+			"key":     keyValue,
+			"name":    typeName,
+			"data":    data,
+			"version": version,
 		})
 
 		// BEGIN child lock
diff --git a/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/revision.go b/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/revision.go
index bb61355..71c5d0c 100644
--- a/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/revision.go
+++ b/vendor/github.com/opencord/voltha-lib-go/pkg/db/model/revision.go
@@ -28,6 +28,7 @@
 	Drop(txid string, includeConfig bool)
 	StorageDrop(txid string, includeConfig bool)
 	ChildDrop(childType string, childHash string)
+	ChildDropByName(childName string)
 	SetChildren(name string, children []Revision)
 	GetChildren(name string) []Revision
 	SetAllChildren(children map[string][]Revision)
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 2ceee28..ff0f299 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -62,7 +62,7 @@
 github.com/mitchellh/mapstructure
 # github.com/opencord/voltha-go v0.0.0-20191018170815-cb7c88a83125
 github.com/opencord/voltha-go/rw_core/utils
-# github.com/opencord/voltha-lib-go v0.0.0-20191017201200-e73f91e306e9
+# github.com/opencord/voltha-lib-go v0.0.0-20191023185531-80258b36a64b
 github.com/opencord/voltha-lib-go/pkg/adapters
 github.com/opencord/voltha-lib-go/pkg/adapters/adapterif
 github.com/opencord/voltha-lib-go/pkg/adapters/common