VOL-1845 : Support for delete device in openolt adapter
This commit is for the handling of delete device.
The changes are done to handle the request for delete
device. This includes the clearing of all data related
to the device in KV store and reboot of device to reset
the device.
This commit has dependency in voltha-go so that needs to
be merged first. Please refer this review link
https://gerrit.opencord.org/#/c/15084/
Updated to dep ensure above voltha-go patch set. Also typo
and make lint/sca fixes.
Change-Id: I53f16022c6902d498dad30e9b7d0ff50bf156347
diff --git a/vendor/github.com/opencord/voltha-go/db/kvstore/client.go b/vendor/github.com/opencord/voltha-go/db/kvstore/client.go
index 937eefe..67c9219 100644
--- a/vendor/github.com/opencord/voltha-go/db/kvstore/client.go
+++ b/vendor/github.com/opencord/voltha-go/db/kvstore/client.go
@@ -77,7 +77,7 @@
return evnt
}
-// Client represents the set of APIs a KV Client must implement
+// Client represents the set of APIs a KV Client must implement
type Client interface {
List(key string, timeout int, lock ...bool) (map[string]*KVPair, error)
Get(key string, timeout int, lock ...bool) (*KVPair, error)
@@ -90,6 +90,7 @@
Watch(key string) chan *Event
AcquireLock(lockName string, timeout int) error
ReleaseLock(lockName string) error
+ IsConnectionUp(timeout int) bool // timeout in second
CloseWatch(key string, ch chan *Event)
Close()
}
diff --git a/vendor/github.com/opencord/voltha-go/db/kvstore/consulclient.go b/vendor/github.com/opencord/voltha-go/db/kvstore/consulclient.go
index 4b25b5f..c4fa0af 100644
--- a/vendor/github.com/opencord/voltha-go/db/kvstore/consulclient.go
+++ b/vendor/github.com/opencord/voltha-go/db/kvstore/consulclient.go
@@ -63,6 +63,12 @@
return &ConsulClient{consul: consul, doneCh: &doneCh, watchedChannelsContext: wChannelsContext, keyReservations: reservations}, nil
}
+// IsConnectionUp returns whether the connection to the Consul KV store is up
+func (c *ConsulClient) IsConnectionUp(timeout int) bool {
+ log.Error("Unimplemented function")
+ return false
+}
+
// List returns an array of key-value pairs with key as a prefix. Timeout defines how long the function will
// wait for a response
func (c *ConsulClient) List(key string, timeout int, lock ...bool) (map[string]*KVPair, error) {
diff --git a/vendor/github.com/opencord/voltha-go/db/kvstore/etcdclient.go b/vendor/github.com/opencord/voltha-go/db/kvstore/etcdclient.go
index 7f6940a..f19f365 100644
--- a/vendor/github.com/opencord/voltha-go/db/kvstore/etcdclient.go
+++ b/vendor/github.com/opencord/voltha-go/db/kvstore/etcdclient.go
@@ -59,6 +59,16 @@
lockToSessionMap: lockSessionMap}, nil
}
+// IsConnectionUp returns whether the connection to the Etcd KV store is up. If a timeout occurs then
+// it is assumed the connection is down or unreachable.
+func (c *EtcdClient) IsConnectionUp(timeout int) bool {
+ // Let's try to get a non existent key. If the connection is up then there will be no error returned.
+ if _, err := c.Get("non-existent-key", timeout); err != nil {
+ return false
+ }
+ return true
+}
+
// List returns an array of key-value pairs with key as a prefix. Timeout defines how long the function will
// wait for a response
func (c *EtcdClient) List(key string, timeout int, lock ...bool) (map[string]*KVPair, error) {
diff --git a/vendor/github.com/opencord/voltha-go/db/model/node.go b/vendor/github.com/opencord/voltha-go/db/model/node.go
index fcd3b5f..c9815fa 100644
--- a/vendor/github.com/opencord/voltha-go/db/model/node.go
+++ b/vendor/github.com/opencord/voltha-go/db/model/node.go
@@ -457,7 +457,7 @@
n.mutex.Lock()
defer n.mutex.Unlock()
- log.Debugw("node-update-request", log.Fields{"path": path, "strict": strict, "txid": txid, "makeBranch": makeBranch})
+ log.Debugw("node-update-request", log.Fields{"path": path, "strict": strict, "txid": txid})
for strings.HasPrefix(path, "/") {
path = path[1:]
@@ -626,7 +626,7 @@
n.mutex.Lock()
defer n.mutex.Unlock()
- log.Debugw("node-add-request", log.Fields{"path": path, "txid": txid, "makeBranch": makeBranch})
+ log.Debugw("node-add-request", log.Fields{"path": path, "txid": txid})
for strings.HasPrefix(path, "/") {
path = path[1:]