Merge "Binding interface IP address for REST Server" v0.9.2
authorJuha Hyttinen <juha.hyttinen@nokia.com>
Mon, 27 Sep 2021 04:42:19 +0000 (04:42 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Mon, 27 Sep 2021 04:42:19 +0000 (04:42 +0000)
go.mod
go.sum
pkg/rnib/rNibWriter.go
pkg/xapp/config.go
pkg/xapp/db.go
pkg/xapp/xapp.go
pkg/xapp/xapp_test.go

diff --git a/go.mod b/go.mod
index a5b90af..18fa7cc 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -5,9 +5,9 @@ go 1.12
 require (
        gerrit.o-ran-sc.org/r/com/golog v0.0.2
        gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0
-       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35
-       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35
-       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35
+       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1
+       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1
+       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1
        gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.7.0
        github.com/fsnotify/fsnotify v1.4.9
        github.com/go-openapi/errors v0.19.3
@@ -31,10 +31,10 @@ replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdl
 
 replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.2
 
-replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35
+replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1
 
-replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35
+replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1
 
-replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35
+replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1
 
 replace gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm => gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0
diff --git a/go.sum b/go.sum
index 937605b..1caf2ec 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -3,12 +3,12 @@ gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 h1:Ix6SgFuzd6yW6Ur6+qDlGhDO65UYs8PiIk
 gerrit.o-ran-sc.org/r/com/golog.git v0.0.2/go.mod h1:A7hUL52YQSO4dFIZNcj76XQ09C9PftAe3LyL7kqBnok=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0 h1:OKDsIDlttbaoHwleyjflIWVZPgPvYbDhim6gWF0zf5E=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35 h1:TGXHb4DNY8on+ej4S9VUnk2HibIC/5chDy64OE+bQBQ=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35 h1:tkM3yE8UzmuH4nf9TqAmiNBSuIZ2CtcMRH2eBIYIzpQ=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35/go.mod h1:G+4sUBMbLfQ+RrGS65U15tKmbnP+/1b5oLTPmMfyfT4=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35 h1:LcxnUUDwsCzYEISKmkjkyYfg/lnLt8ofkPiGK69vNIA=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35/go.mod h1:2bSaXTpECbZieB8bMnubTqMwF3n+mMBxlTaAXvcduNg=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1 h1:3FFbXx55BODThXfyWAiz6cPXVELXFICDQUmJi13EoxM=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1 h1:8Z60JRsPgcS1Ona4fEh6d0/03nLq1WHoZcNnBsni5+g=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1/go.mod h1:YaQ+XEI4PcAoISxp9wUpUr2TP0J7JihpQTD0G1Lpd4A=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1 h1:BG3kste8PLVTG0m8CRB/VP2tAV5JImKueBGuOsUNcR8=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1/go.mod h1:zX8rW6YEsagHrRGVW5YO50Ku/Csrpzsuvblhr4DbYi4=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.7.0 h1:mxlBo54jxwHHFmGYzFI+fBIkOGwarQP4dx2KBxQ8ln8=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.7.0/go.mod h1:KCHu4JkWnw2Ro6P747wU9S2t7zxFLmBNCiYvGZo3CHo=
 github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
@@ -45,7 +45,6 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
 github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
 github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
 github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
-github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
 github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
@@ -119,8 +118,6 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er
 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
-github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
 github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
 github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
 github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@@ -130,11 +127,11 @@ github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0
 github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
 github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
-github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
 github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
-github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
 github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0=
+github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -146,7 +143,6 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
 github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
 github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
-github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
 github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
@@ -211,7 +207,6 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
-github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
 github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
 github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
 github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
@@ -264,7 +259,6 @@ golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
 golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0=
 golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
@@ -281,7 +275,6 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4=
 golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -317,7 +310,6 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
 gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
@@ -325,7 +317,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
 gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
 gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
index 74fb557..135b9a2 100755 (executable)
@@ -25,7 +25,9 @@ import (
 )
 
 type rNibWriterInstance struct {
-       sdl rnibcommon.ISdlInstance
+       sdl        rnibcommon.ISdlInstance //Deprecated: Will be removed in a future release and replaced by sdlStorage
+       sdlStorage rnibcommon.ISdlSyncStorage
+       ns         string
 }
 
 /*
@@ -36,11 +38,24 @@ type RNibWriter interface {
 }
 
 /*
-GetRNibWriter returns reference to RNibWriter
+GetNewRNibWriter returns reference to RNibWriter
 */
+func GetNewRNibWriter(sdlStorage rnibcommon.ISdlSyncStorage) RNibWriter {
+       return &rNibWriterInstance{
+               sdl:        nil,
+               sdlStorage: sdlStorage,
+               ns:         rnibcommon.GetRNibNamespace(),
+       }
+}
 
+//GetRNibWriter returns reference to RNibWriter
+//Deprecated: Will be removed in a future release, please use GetNewRNibWriter instead.
 func GetRNibWriter(sdl rnibcommon.ISdlInstance) RNibWriter {
-       return &rNibWriterInstance{sdl: sdl}
+       return &rNibWriterInstance{
+               sdl:        sdl,
+               sdlStorage: nil,
+               ns:         "",
+       }
 }
 
 /*
@@ -83,7 +98,11 @@ func (w *rNibWriterInstance) SaveNodeb(nbIdentity *rnibentities.NbIdentity, enti
                        return rNibErr
                }
        }
-       err = w.sdl.Set(pairs)
+       if w.sdlStorage != nil {
+               err = w.sdlStorage.Set(w.ns, pairs)
+       } else {
+               err = w.sdl.Set(pairs)
+       }
        if err != nil {
                return rnibcommon.NewInternalError(err)
        }
@@ -95,7 +114,11 @@ func (w *rNibWriterInstance) SaveNodeb(nbIdentity *rnibentities.NbIdentity, enti
                if err != nil {
                        return rnibcommon.NewInternalError(err)
                }
-               err = w.sdl.RemoveMember(rnibentities.Node_UNKNOWN.String(), nbIdData)
+               if w.sdlStorage != nil {
+                       err = w.sdlStorage.RemoveMember(w.ns, rnibentities.Node_UNKNOWN.String(), nbIdData)
+               } else {
+                       err = w.sdl.RemoveMember(rnibentities.Node_UNKNOWN.String(), nbIdData)
+               }
                if err != nil {
                        return rnibcommon.NewInternalError(err)
                }
@@ -107,7 +130,11 @@ func (w *rNibWriterInstance) SaveNodeb(nbIdentity *rnibentities.NbIdentity, enti
        if err != nil {
                return rnibcommon.NewInternalError(err)
        }
-       err = w.sdl.AddMember(entity.GetNodeType().String(), nbIdData)
+       if w.sdlStorage != nil {
+               err = w.sdlStorage.AddMember(w.ns, entity.GetNodeType().String(), nbIdData)
+       } else {
+               err = w.sdl.AddMember(entity.GetNodeType().String(), nbIdData)
+       }
        if err != nil {
                return rnibcommon.NewInternalError(err)
        }
index ac60ac5..56986d3 100755 (executable)
@@ -124,13 +124,17 @@ func AddConfigChangeListener(f ConfigChangeCB) {
 
 func PublishConfigChange(appName, eventJson string) error {
        channel := fmt.Sprintf("CM_UPDATE:%s", appName)
-       if err := Sdl.StoreAndPublish(channel, eventJson, appName, eventJson); err != nil {
+       if err := SdlStorage.StoreAndPublish(getCmSdlNs(), channel, eventJson, appName, eventJson); err != nil {
                Logger.Error("Sdl.Store failed: %v", err)
                return err
        }
        return nil
 }
 
+func ReadConfig(appName string) (map[string]interface{}, error) {
+       return SdlStorage.Read(getCmSdlNs(), appName)
+}
+
 func GetPortData(pname string) (d PortData) {
        var getPolicies = func(policies []interface{}) (plist []int) {
                for _, p := range policies {
@@ -178,8 +182,12 @@ func GetPortData(pname string) (d PortData) {
        return
 }
 
+func getCmSdlNs() string {
+       return fmt.Sprintf("cm/%s", viper.GetString("name"))
+}
+
 func (*Configurator) SetSDLNotificationCB(appName string, sdlNotificationCb SDLNotificationCB) error {
-       return Sdl.Subscribe(sdlNotificationCb, fmt.Sprintf("CM_UPDATE:%s", appName))
+       return SdlStorage.Subscribe(getCmSdlNs(), sdlNotificationCb, fmt.Sprintf("CM_UPDATE:%s", appName))
 }
 
 func (*Configurator) GetString(key string) string {
index e422cfd..0a37caa 100755 (executable)
@@ -20,6 +20,7 @@
 package xapp
 
 import (
+       rnibcommon "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
        rnibentities "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
        rnibreader "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
        sdl "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
@@ -36,13 +37,19 @@ var SDLCounterOpts = []CounterOpts{
        {Name: "StoreError", Help: "The total number of SDL store errors"},
 }
 
-type SDLClient struct {
-       db    *sdl.SdlInstance
+type SDLStorage struct {
+       db    *sdl.SyncStorage
        stat  map[string]Counter
        mux   sync.Mutex
        ready bool
 }
 
+//Deprecated: Will be removed in a future release, please use SDLStorage type
+type SDLClient struct {
+       db        *SDLStorage
+       nameSpace string
+}
+
 // Alias
 type RNIBNodeType = rnibentities.Node_Type
 type RNIBGlobalNbId = rnibentities.GlobalNbId
@@ -66,27 +73,24 @@ type RNIBServedNRCellInformation = rnibentities.ServedNRCellInformation
 type RNIBNrNeighbourInformation = rnibentities.NrNeighbourInformation
 
 type RNIBClient struct {
-       db     *sdl.SdlInstance
+       db     rnibcommon.ISdlSyncStorage
        reader rnibreader.RNibReader
        writer rnibwriter.RNibWriter
 }
 
-// NewSDLClient returns a new SDLClient.
-func NewSDLClient(ns string) *SDLClient {
-       if ns == "" {
-               ns = "sdl"
-       }
-       return &SDLClient{
-               db:    sdl.NewSdlInstance(ns, sdl.NewDatabase()),
+// NewSdlStorage returns a new instance of SDLStorage type.
+func NewSdlStorage() *SDLStorage {
+       return &SDLStorage{
+               db:    sdl.NewSyncStorage(),
                stat:  Metric.RegisterCounterGroup(SDLCounterOpts, "SDL"),
                ready: false,
        }
 }
 
-func (s *SDLClient) TestConnection() {
+func (s *SDLStorage) TestConnection(namespace string) {
        // Test DB connection, and wait until ready!
        for {
-               if _, err := s.db.GetAll(); err == nil {
+               if _, err := s.db.GetAll(namespace); err == nil {
                        break
                }
                Logger.Warn("Database connection not ready, waiting ...")
@@ -96,12 +100,12 @@ func (s *SDLClient) TestConnection() {
        Logger.Info("Connection to database established!")
 }
 
-func (s *SDLClient) IsReady() bool {
+func (s *SDLStorage) IsReady() bool {
        return s.ready
 }
 
-func (s *SDLClient) doSet(pairs ...interface{}) (err error) {
-       err = s.db.Set(pairs)
+func (s *SDLStorage) doSet(namespace string, pairs ...interface{}) (err error) {
+       err = s.db.Set(namespace, pairs)
        if err != nil {
                s.UpdateStatCounter("StoreError")
        } else {
@@ -110,113 +114,213 @@ func (s *SDLClient) doSet(pairs ...interface{}) (err error) {
        return
 }
 
+func (s *SDLStorage) Store(namespace string, key string, value interface{}) (err error) {
+       return s.doSet(namespace, key, value)
+}
+
+func (s *SDLStorage) MStore(namespace string, pairs ...interface{}) (err error) {
+       return s.doSet(namespace, pairs)
+}
+
+func (s *SDLStorage) Read(namespace string, key string) (value map[string]interface{}, err error) {
+       return s.db.Get(namespace, []string{key})
+}
+
+func (s *SDLStorage) MRead(namespace string, key []string) (value map[string]interface{}, err error) {
+       return s.db.Get(namespace, key)
+}
+
+func (s *SDLStorage) ReadAllKeys(namespace string) (value []string, err error) {
+       return s.db.GetAll(namespace)
+}
+
+func (s *SDLStorage) Subscribe(namespace string, cb func(string, ...string), channel string) error {
+       return s.db.SubscribeChannel(namespace, cb, channel)
+}
+
+func (s *SDLStorage) MSubscribe(namespace string, cb func(string, ...string), channels ...string) error {
+       return s.db.SubscribeChannel(namespace, cb, channels...)
+}
+
+func (s *SDLStorage) StoreAndPublish(namespace string, channel string, event string, pairs ...interface{}) error {
+       return s.db.SetAndPublish(namespace, []string{channel, event}, pairs...)
+}
+
+func (s *SDLStorage) MStoreAndPublish(namespace string, channelsAndEvents []string, pairs ...interface{}) error {
+       return s.db.SetAndPublish(namespace, channelsAndEvents, pairs...)
+}
+
+func (s *SDLStorage) Delete(namespace string, keys []string) (err error) {
+       return s.db.Remove(namespace, keys)
+}
+
+func (s *SDLStorage) Clear(namespace string) {
+       s.db.RemoveAll(namespace)
+}
+
+func (s *SDLStorage) RegisterMetrics() {
+       s.stat = Metric.RegisterCounterGroup(SDLCounterOpts, "SDL")
+}
+
+func (s *SDLStorage) UpdateStatCounter(name string) {
+       s.mux.Lock()
+       s.stat[name].Inc()
+       s.mux.Unlock()
+}
+
+func (s *SDLStorage) GetStat() (t SDLStatistics) {
+       return
+}
+
+//NewSDLClient returns a new SDLClient.
+//Deprecated: Will be removed in a future release, please use NewSdlStorage
+func NewSDLClient(ns string) *SDLClient {
+       if ns == "" {
+               ns = "sdl"
+       }
+       return &SDLClient{
+               db:        NewSdlStorage(),
+               nameSpace: ns,
+       }
+}
+
+//Deprecated: Will be removed in a future release, please use the TestConnection Receiver function of the SDLStorage type.
+func (s *SDLClient) TestConnection() {
+       s.db.TestConnection(s.nameSpace)
+}
+
+func (s *SDLClient) IsReady() bool {
+       return s.db.ready
+}
+
+//Deprecated: Will be removed in a future release, please use the Store Receiver function of the SDLStorage type.
 func (s *SDLClient) Store(key string, value interface{}) (err error) {
-       return s.doSet(key, value)
+       return s.db.Store(s.nameSpace, key, value)
 }
 
+//Deprecated: Will be removed in a future release, please use the MStore Receiver function of the SDLStorage type.
 func (s *SDLClient) MStore(pairs ...interface{}) (err error) {
-       return s.doSet(pairs)
+       return s.db.MStore(s.nameSpace, pairs)
 }
 
+//Deprecated: Will be removed in a future release, please use the Read Receiver function of the SDLStorage type.
 func (s *SDLClient) Read(key string) (value map[string]interface{}, err error) {
-       return s.db.Get([]string{key})
+       return s.db.Read(s.nameSpace, key)
 }
 
+//Deprecated: Will be removed in a future release, please use the MRead Receiver function of the SDLStorage type.
 func (s *SDLClient) MRead(key []string) (value map[string]interface{}, err error) {
-       return s.db.Get(key)
+       return s.db.MRead(s.nameSpace, key)
 }
 
+//Deprecated: Will be removed in a future release, please use the ReadAllKeys Receiver function of the SDLStorage type.
 func (s *SDLClient) ReadAllKeys(key string) (value []string, err error) {
-       return s.db.GetAll()
+       return s.db.ReadAllKeys(s.nameSpace)
 }
 
+//Deprecated: Will be removed in a future release, please use the Subscribe Receiver function of the SDLStorage type.
 func (s *SDLClient) Subscribe(cb func(string, ...string), channel string) error {
-       return s.db.SubscribeChannel(cb, channel)
+       return s.db.Subscribe(s.nameSpace, cb, channel)
 }
 
+//Deprecated: Will be removed in a future release, please use the MSubscribe Receiver function of the SDLStorage type.
 func (s *SDLClient) MSubscribe(cb func(string, ...string), channels ...string) error {
-       return s.db.SubscribeChannel(cb, channels...)
+       return s.db.MSubscribe(s.nameSpace, cb, channels...)
 }
 
+//Deprecated: Will be removed in a future release, please use the StoreAndPublish Receiver function of the SDLStorage type.
 func (s *SDLClient) StoreAndPublish(channel string, event string, pairs ...interface{}) error {
-       return s.db.SetAndPublish([]string{channel, event}, pairs...)
+       return s.db.StoreAndPublish(s.nameSpace, channel, event, pairs...)
 }
 
+//Deprecated: Will be removed in a future release, please use the MStoreAndPublish Receiver function of the SDLStorage type.
 func (s *SDLClient) MStoreAndPublish(channelsAndEvents []string, pairs ...interface{}) error {
-       return s.db.SetAndPublish(channelsAndEvents, pairs...)
+       return s.db.MStoreAndPublish(s.nameSpace, channelsAndEvents, pairs...)
 }
 
+//Deprecated: Will be removed in a future release, please use the Delete Receiver function of the SDLStorage type.
 func (s *SDLClient) Delete(keys []string) (err error) {
-       return s.db.Remove(keys)
+       return s.db.Delete(s.nameSpace, keys)
 }
 
+//Deprecated: Will be removed in a future release, please use the Clear Receiver function of the SDLStorage type.
 func (s *SDLClient) Clear() {
-       s.db.RemoveAll()
+       s.db.Clear(s.nameSpace)
 }
 
+//Deprecated: Will be removed in a future release, please use the RegisterMetrics Receiver function of the SDLStorage type.
 func (s *SDLClient) RegisterMetrics() {
-       s.stat = Metric.RegisterCounterGroup(SDLCounterOpts, "SDL")
+       s.db.RegisterMetrics()
 }
 
+//Deprecated: Will be removed in a future release, please use the UpdateStatCounter Receiver function of the SDLStorage type.
 func (s *SDLClient) UpdateStatCounter(name string) {
-       s.mux.Lock()
-       s.stat[name].Inc()
-       s.mux.Unlock()
+       s.db.UpdateStatCounter(name)
 }
 
+//Deprecated: Will be removed in a future release, please use the GetStat Receiver function of the SDLStorage type.
 func (c *SDLClient) GetStat() (t SDLStatistics) {
-       return
+       return c.db.GetStat()
+}
+
+func GetNewRnibClient(sdlStorage rnibcommon.ISdlSyncStorage) *RNIBClient {
+       return &RNIBClient{
+               db:     sdlStorage,
+               reader: rnibreader.GetNewRNibReader(sdlStorage),
+               writer: rnibwriter.GetNewRNibWriter(sdlStorage),
+       }
 }
 
+//Deprecated: Will be removed in a future release, please use GetNewRnibClient instead.
 func NewRNIBClient() *RNIBClient {
-       s := sdl.NewSdlInstance("e2Manager", sdl.NewDatabase())
+       s := sdl.NewSyncStorage()
        return &RNIBClient{
                db:     s,
-               reader: nil,
-               writer: nil,
+               reader: rnibreader.GetNewRNibReader(s),
+               writer: rnibwriter.GetNewRNibWriter(s),
        }
 }
 
 func (r *RNIBClient) Subscribe(cb func(string, ...string), channel string) error {
-       return r.db.SubscribeChannel(cb, channel)
+       return r.db.SubscribeChannel(rnibcommon.GetRNibNamespace(), cb, channel)
 }
 
 func (r *RNIBClient) StoreAndPublish(channel string, event string, pairs ...interface{}) error {
-       return r.db.SetAndPublish([]string{channel, event}, pairs...)
+       return r.db.SetAndPublish(rnibcommon.GetRNibNamespace(), []string{channel, event}, pairs...)
 }
 
 func (r *RNIBClient) GetNodeb(invName string) (*RNIBNodebInfo, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetNodeb(invName)
+       return r.reader.GetNodeb(invName)
 }
 
 func (r *RNIBClient) GetNodebByGlobalNbId(t RNIBNodeType, gid *RNIBGlobalNbId) (*RNIBNodebInfo, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetNodebByGlobalNbId(t, gid)
+       return r.reader.GetNodebByGlobalNbId(t, gid)
 }
 
 func (r *RNIBClient) GetCellList(invName string) (*RNIBCells, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetCellList(invName)
+       return r.reader.GetCellList(invName)
 }
 
 func (r *RNIBClient) GetListGnbIds() ([]*RNIBNbIdentity, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetListGnbIds()
+       return r.reader.GetListGnbIds()
 }
 
 func (r *RNIBClient) GetListEnbIds() ([]*RNIBNbIdentity, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetListEnbIds()
+       return r.reader.GetListEnbIds()
 }
 
 func (r *RNIBClient) GetCountGnbList() (int, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetCountGnbList()
+       return r.reader.GetCountGnbList()
 }
 
 func (r *RNIBClient) GetCell(invName string, pci uint32) (*RNIBCell, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetCell(invName, pci)
+       return r.reader.GetCell(invName, pci)
 }
 
 func (r *RNIBClient) GetCellById(cellType RNIBCellType, cellId string) (*RNIBCell, RNIBIRNibError) {
-       return rnibreader.GetRNibReader(r.db).GetCellById(cellType, cellId)
+       return r.reader.GetCellById(cellType, cellId)
 }
 
 func (r *RNIBClient) SaveNodeb(nbIdentity *RNIBNbIdentity, entity *RNIBNodebInfo) RNIBIRNibError {
-       return rnibwriter.GetRNibWriter(r.db).SaveNodeb(nbIdentity, entity)
+       return r.writer.SaveNodeb(nbIdentity, entity)
 }
index 0e85845..b87463b 100755 (executable)
@@ -49,6 +49,7 @@ var (
        // XApp is an application instance
        Rmr           *RMRClient
        Sdl           *SDLClient
+       SdlStorage    *SDLStorage
        Rnib          *RNIBClient
        Resource      *Router
        Metric        *Metrics
@@ -65,7 +66,7 @@ var (
 )
 
 func IsReady() bool {
-       return Rmr != nil && Rmr.IsReady() && Sdl != nil && Sdl.IsReady()
+       return Rmr != nil && Rmr.IsReady() && SdlStorage != nil && SdlStorage.IsReady()
 }
 
 func SetReadyCB(cb ReadyCB, params interface{}) {
@@ -263,8 +264,9 @@ func init() {
        Config = Configurator{}
        Metric = NewMetrics(viper.GetString("metrics.url"), viper.GetString("metrics.namespace"), Resource.router)
        Subscription = NewSubscriber(viper.GetString("controls.subscription.host"), viper.GetInt("controls.subscription.timeout"))
+       SdlStorage = NewSdlStorage()
        Sdl = NewSDLClient(viper.GetString("controls.db.namespace"))
-       Rnib = NewRNIBClient()
+       Rnib = GetNewRnibClient(SdlStorage.db)
        Util = NewUtils()
 
        InstallSignalHandler()
@@ -308,7 +310,7 @@ func RunWithParams(c MessageConsumer, sdlcheck bool) {
        Logger.Info(fmt.Sprintf("Xapp started, listening on: %s", host))
 
        if sdlcheck {
-               Sdl.TestConnection()
+               SdlStorage.TestConnection(viper.GetString("controls.db.namespace"))
        }
        go registerXapp()
 
index b9ea423..c4aec60 100755 (executable)
@@ -335,7 +335,7 @@ func TestAddConfigChangeListener(t *testing.T) {
 }
 
 func TestConfigAccess(t *testing.T) {
-       Logger.Info("CASE: AddConfigChangeListener")
+       Logger.Info("CASE: TestConfigAccess")
 
        assert.Equal(t, Config.GetString("name"), "xapp")
        assert.Equal(t, Config.GetInt("controls.logger.level"), 3)
@@ -348,8 +348,9 @@ func TestConfigAccess(t *testing.T) {
 }
 
 func TestPublishConfigChange(t *testing.T) {
-       Logger.Info("CASE: AddConfigChangeListener")
+       Logger.Info("CASE: TestPublishConfigChange")
        PublishConfigChange("testApp", "values")
+       ReadConfig("testApp")
 }
 
 func TestNewSubscriber(t *testing.T) {
@@ -391,11 +392,13 @@ func TestSdlInterfaces(t *testing.T) {
        Sdl.Store("myKey", "Values")
        Sdl.MStore("myKey", "Values")
        Sdl.RegisterMetrics()
+       Sdl.UpdateStatCounter("Stored")
 
        // Misc.
        var NotificationCb = func(ch string, events ...string) {}
        Sdl.Subscribe(NotificationCb, "channel1")
        Sdl.MSubscribe(NotificationCb, "channel1", "channel2")
+       Sdl.StoreAndPublish("channel1", "event", "key1", "data1")
        Sdl.MStoreAndPublish([]string{"channel1"}, "event", "key1", "data1")
 }