Remove utils module 37/6237/1
authorMohamed Abukar <abukar.mohamed@nokia.com>
Sun, 6 Jun 2021 13:45:30 +0000 (13:45 +0000)
committerMohamed Abukar <abukar.mohamed@nokia.com>
Sun, 6 Jun 2021 13:47:41 +0000 (13:47 +0000)
Change-Id: I8020ab08342f49ef54675a544226ce38bb0ca9da
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
go.mod
go.sum
manager/cmd/restapi.go
manager/cmd/restapi_test.go
manager/cmd/types.go
manager/cmd/utils.go [deleted file]

diff --git a/go.mod b/go.mod
index a16cebe..345bf33 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -11,7 +11,6 @@ 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
 
 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.4.2 // indirect
        gerrit.o-ran-sc.org/r/ric-plt/alarm-go/alarm v0.0.0-00010101000000-000000000000
        gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.0.0-00010101000000-000000000000
@@ -20,6 +19,8 @@ require (
        github.com/gorilla/mux v1.7.1
        github.com/jedib0t/go-pretty v4.3.0+incompatible
        github.com/mattn/go-runewidth v0.0.9 // indirect
+       github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+       github.com/modern-go/reflect2 v1.0.1 // indirect
        github.com/prometheus/alertmanager v0.20.0
        github.com/spf13/viper v1.6.2
        github.com/stretchr/testify v1.5.1
diff --git a/go.sum b/go.sum
index 99e1f09..a9125bd 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -1,33 +1,19 @@
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-gerrit.o-ran-sc.org/r/com/golog.git v0.0.1 h1:9RfO/Whehaaq5KiJTT7s+YOzmi9mT1C3HktfhwwMEmw=
-gerrit.o-ran-sc.org/r/com/golog.git v0.0.1/go.mod h1:b8YB31U8/4iRpABioeSzGi/YMzOQ/Zq7hrJmmXKqlJk=
 gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 h1:Ix6SgFuzd6yW6Ur6+qDlGhDO65UYs8PiIkeAL1VaQ2o=
 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 v0.4.4 h1:wsKF+QGufeunr8r1ptVeQzPnQhcF2scv1RPBssiq3Hw=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2 h1:XNfkp3PwZ7pfkPszX7NaX6DzToCGjcWTLbIHYqCFNu0=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21 h1:eK9nUZOTMJ/EnMpH9bkWtMgOvCn3u4+PNCb9gu10s6w=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
 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.21 h1:PQ/Mu2ol+8Oh/0BqCWWhPlVVoRCg5dQDEGm4+Opp5w4=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.21/go.mod h1:GXiXLz4ORBeIr0FLIbzENRykgh3Po5uPkX2jICxnRF0=
 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.21 h1:N3UbqJ9WqC8JEz/TwHHwZwCFAW6VTlZLpD5lnbdD+Y8=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.21/go.mod h1:SQBZLy1HP94i1vQ3y730wGFsrHqZtgPaEkzPgtqBNw0=
 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/sdlgo.git v0.5.0 h1:+P3XuWKSaMbzh5PNtrW9gkZlCN0hKrZq+Cn8JetwBys=
-gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.0/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2 h1:UK7awyRKIkVdokWvvkYvazlg3EWIfMnIqCcJxTnLlDA=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc=
-gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.30 h1:7fGZ2ASjHWs9FVYE8tNBVXpnbu4YKFs43pfh5B8tROc=
-gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.30/go.mod h1:lW3UYpVXwPiOR39t6JgNCE4kdmMSdPVelMPC/Pp9fQM=
-gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.0 h1:FGQY+g9r+xxqNrU2V0VvwcpibAEgRnIAN43+4ULC8qE=
-gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.0/go.mod h1:lW3UYpVXwPiOR39t6JgNCE4kdmMSdPVelMPC/Pp9fQM=
 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.2-1 h1:SU7zrZq1KPJk8RXK/8OSk4lCyYQSUs9OpLLplB06ra4=
 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.2-1/go.mod h1:YB6UW0gA6CTe1QfHQ/QTymVIiIjXJWkTaYBl18d4Zac=
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
 github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
@@ -163,10 +149,13 @@ github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaW
 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 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/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 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=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
 github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU=
 github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
@@ -185,6 +174,7 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
 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/hashicorp/memberlist v0.1.4/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/jedib0t/go-pretty v4.3.0+incompatible h1:CGs8AVhEKg/n9YbUenWmNStRW2PHJzaeDodcfvRAbIo=
 github.com/jedib0t/go-pretty v4.3.0+incompatible/go.mod h1:XemHduiw8R651AF9Pt4FwCTKeG3oo7hrHJAoznj9nag=
@@ -193,6 +183,7 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS
 github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
 github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
@@ -200,9 +191,11 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
@@ -234,13 +227,16 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
 github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
 github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
 github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
 github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
 github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -277,7 +273,9 @@ github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJ
 github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
 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=
@@ -309,6 +307,7 @@ github.com/thatisuday/clapper v1.0.10 h1:1EkqE/nb4npp8DuTKnpvVzO/Mcac9lOPND34uUK
 github.com/thatisuday/clapper v1.0.10/go.mod h1:FQGIg8q2uzeI+3SUS82YKF4E3KexkHStbiK4qTfDknM=
 github.com/thatisuday/commando v1.0.4 h1:aNdH9tvmx2EPG6rT3NTQOV/qFYPf4Ap4Spo+q+n9Ois=
 github.com/thatisuday/commando v1.0.4/go.mod h1:ODGz6jwJs4QqhLJtCjRRs8xIrmLLMdatYYddP+v1b4E=
+github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
 github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
 github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
@@ -389,11 +388,14 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
 google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 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/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
 gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
 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=
index 7d2a55c..df0ac2b 100755 (executable)
@@ -22,12 +22,13 @@ package main
 
 import (
        "encoding/json"
-       "gerrit.o-ran-sc.org/r/ric-plt/alarm-go/alarm"
-       app "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-       "github.com/gorilla/mux"
        "net/http"
        "strconv"
        "time"
+
+       "gerrit.o-ran-sc.org/r/ric-plt/alarm-go/alarm"
+       app "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+       "github.com/gorilla/mux"
 )
 
 func (a *AlarmManager) InjectRoutes() {
@@ -43,8 +44,6 @@ func (a *AlarmManager) InjectRoutes() {
        app.Resource.InjectRoute("/ric/v1/alarms/define/{alarmId}", a.GetAlarmDefinition, "GET")
 
        app.Resource.InjectRoute("/ric/v1/symptomdata", a.SymptomDataHandler, "GET")
-
-       a.utils = NewUtils()
 }
 
 func (a *AlarmManager) respondWithError(w http.ResponseWriter, code int, message string) {
@@ -246,21 +245,21 @@ func (a *AlarmManager) GetAlarmConfig(w http.ResponseWriter, r *http.Request) {
 
 func (a *AlarmManager) SymptomDataHandler(w http.ResponseWriter, r *http.Request) {
        baseDir := "/tmp/symptomdata/"
-       if err := a.utils.CreateDir(baseDir); err != nil {
-               a.utils.SendSymptomDataError(w, r, "CreateDir failed: "+err.Error())
+       if err := app.Util.CreateDir(baseDir); err != nil {
+               app.Resource.SendSymptomDataError(w, r, "CreateDir failed: "+err.Error())
                return
        }
 
        if b, err := json.Marshal(a.activeAlarms); err == nil {
-               if err := a.utils.WriteToFile(baseDir+"active_alarms.json", string(b)); err != nil {
-                       a.utils.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
+               if err := app.Util.WriteToFile(baseDir+"active_alarms.json", string(b)); err != nil {
+                       app.Resource.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
                        return
                }
        }
 
        if b, err := json.Marshal(a.alarmHistory); err == nil {
-               if err := a.utils.WriteToFile(baseDir+"alarm_history.json", string(b)); err != nil {
-                       a.utils.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
+               if err := app.Util.WriteToFile(baseDir+"alarm_history.json", string(b)); err != nil {
+                       app.Resource.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
                        return
                }
        }
@@ -270,8 +269,8 @@ func (a *AlarmManager) SymptomDataHandler(w http.ResponseWriter, r *http.Request
        ac.MaxAlarmHistory = a.maxAlarmHistory
 
        if b, err := json.Marshal(ac); err == nil {
-               if err := a.utils.WriteToFile(baseDir+"alarm_config.json", string(b)); err != nil {
-                       a.utils.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
+               if err := app.Util.WriteToFile(baseDir+"alarm_config.json", string(b)); err != nil {
+                       app.Resource.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
                        return
                }
        }
@@ -281,11 +280,11 @@ func (a *AlarmManager) SymptomDataHandler(w http.ResponseWriter, r *http.Request
                ad.AlarmDefinitions = append(ad.AlarmDefinitions, alarmDefinition)
        }
        if b, err := json.Marshal(ad); err == nil {
-               if err := a.utils.WriteToFile(baseDir+"alarm_defs.json", string(b)); err != nil {
-                       a.utils.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
+               if err := app.Util.WriteToFile(baseDir+"alarm_defs.json", string(b)); err != nil {
+                       app.Resource.SendSymptomDataError(w, r, "writeToFile failed: "+err.Error())
                        return
                }
        }
 
-       a.utils.SendSymptomDataFile(w, r, baseDir, "symptomdata.zip")
+       app.Resource.SendSymptomDataFile(w, r, baseDir, "symptomdata.zip")
 }
index 90954af..bc3a79f 100755 (executable)
@@ -23,11 +23,12 @@ package main
 import (
        "bytes"
        "encoding/json"
-       "github.com/stretchr/testify/assert"
        "net/http"
        "net/http/httptest"
        "testing"
 
+       "github.com/stretchr/testify/assert"
+
        "gerrit.o-ran-sc.org/r/ric-plt/alarm-go/alarm"
 )
 
@@ -85,3 +86,17 @@ func TestClearAlarmRESTInterface(t *testing.T) {
        assert.Equal(t, true, rr != nil)
        assert.Equal(t, rr.Code, http.StatusOK)
 }
+
+func TestSymptomDataHandler(t *testing.T) {
+       req, err := http.NewRequest("POST", "/ric/v1/symptomdata", nil)
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       rr := httptest.NewRecorder()
+       handler := http.HandlerFunc(alarmManager.SymptomDataHandler)
+       handler.ServeHTTP(rr, req)
+
+       assert.Equal(t, true, rr != nil)
+       assert.Equal(t, rr.Code, http.StatusOK)
+}
index 1b5aaed..27376e9 100755 (executable)
@@ -43,7 +43,6 @@ type AlarmManager struct {
        exceededActiveAlarmOn  bool
        exceededAlarmHistoryOn bool
        alarmInfoPvFile        string
-       utils                  *Utils
 }
 
 type AlarmNotification struct {
diff --git a/manager/cmd/utils.go b/manager/cmd/utils.go
deleted file mode 100755 (executable)
index 5977f58..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
-==================================================================================
-  Copyright (c) 2019 AT&T Intellectual Property.
-  Copyright (c) 2019 Nokia
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
-*/
-
-package main
-
-import (
-       "archive/zip"
-       "encoding/json"
-       "io"
-       "io/ioutil"
-       "net/http"
-       "os"
-       "path/filepath"
-       "strings"
-
-       app "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-)
-
-type Utils struct {
-       baseDir string
-       status  string
-}
-
-func NewUtils() *Utils {
-       b := app.Config.GetString("controls.symptomdata.baseDir")
-       if b == "" {
-               b = "/tmp/symptomdata/"
-       }
-
-       return &Utils{
-               baseDir: b,
-       }
-}
-
-func (u *Utils) FileExists(f string) bool {
-       _, err := os.Stat(f)
-       return err == nil || os.IsExist(err)
-}
-
-func (u *Utils) CreateDir(path string) error {
-       if u.FileExists(path) {
-               os.RemoveAll(path)
-       }
-       err := os.MkdirAll(path, os.ModePerm)
-       if err != nil {
-               return err
-       }
-       os.Chmod(path, os.ModePerm)
-       return nil
-}
-
-func (u *Utils) DeleteFile(fileName string) {
-       os.Remove(fileName)
-}
-
-func (u *Utils) AddFileToZip(zipWriter *zip.Writer, filePath string, filename string) error {
-       fileToZip, err := os.Open(filename)
-       if err != nil {
-               return err
-       }
-       defer fileToZip.Close()
-
-       info, err := fileToZip.Stat()
-       if err != nil {
-               return err
-       }
-
-       header, err := zip.FileInfoHeader(info)
-       if err != nil {
-               return err
-       }
-
-       if strings.HasPrefix(filename, filePath) {
-               filename = strings.TrimPrefix(filename, filePath)
-       }
-       header.Name = filename
-       header.Method = zip.Deflate
-
-       writer, err := zipWriter.CreateHeader(header)
-       if err != nil {
-               return err
-       }
-       if info.Size() > 0 {
-               _, err = io.Copy(writer, fileToZip)
-       }
-       return err
-}
-
-func (u *Utils) ZipFiles(newZipFile *os.File, filePath string, files []string) error {
-       defer newZipFile.Close()
-       zipWriter := zip.NewWriter(newZipFile)
-       defer zipWriter.Close()
-       for _, file := range files {
-               if err := u.AddFileToZip(zipWriter, filePath, file); err != nil {
-                       app.Logger.Error("AddFileToZip() failed: %+v", err.Error())
-                       return err
-               }
-       }
-
-       return nil
-}
-
-func (u *Utils) FetchFiles(filePath string, fileList []string) []string {
-       files, err := ioutil.ReadDir(filePath)
-       if err != nil {
-               app.Logger.Error("ioutil.ReadDir failed: %+v", err)
-               return nil
-       }
-       for _, file := range files {
-               if !file.IsDir() {
-                       fileList = append(fileList, filepath.Join(filePath, file.Name()))
-               } else {
-                       subPath := filepath.Join(filePath, file.Name())
-                       subFiles, _ := ioutil.ReadDir(subPath)
-                       for _, subFile := range subFiles {
-                               if !subFile.IsDir() {
-                                       fileList = append(fileList, filepath.Join(subPath, subFile.Name()))
-                               } else {
-                                       fileList = u.FetchFiles(filepath.Join(subPath, subFile.Name()), fileList)
-                               }
-                       }
-               }
-       }
-       return fileList
-}
-
-func (u *Utils) WriteToFile(fileName string, data string) error {
-       f, err := os.Create(fileName)
-       defer f.Close()
-
-       if err != nil {
-               app.Logger.Error("Unable to create file %s': %+v", fileName, err)
-       } else {
-               _, err := io.WriteString(f, data)
-               if err != nil {
-                       app.Logger.Error("Unable to write to file '%s': %+v", fileName, err)
-                       u.DeleteFile(fileName)
-               }
-       }
-       return err
-}
-
-func (u *Utils) SendSymptomDataJson(w http.ResponseWriter, req *http.Request, data interface{}, n string) {
-       w.Header().Set("Content-Type", "application/json")
-       w.Header().Set("Content-Disposition", "attachment; filename="+n)
-       w.WriteHeader(http.StatusOK)
-       if data != nil {
-               response, _ := json.Marshal(data)
-               w.Write(response)
-       }
-}
-
-func (u *Utils) SendSymptomDataFile(w http.ResponseWriter, req *http.Request, baseDir, zipFile string) {
-       // Compress and reply with attachment
-       tmpFile, err := ioutil.TempFile("", "symptom")
-       if err != nil {
-               u.SendSymptomDataError(w, req, "Failed to create a tmp file: "+err.Error())
-               return
-       }
-       defer os.Remove(tmpFile.Name())
-
-       var fileList []string
-       fileList = u.FetchFiles(baseDir, fileList)
-       err = u.ZipFiles(tmpFile, baseDir, fileList)
-       if err != nil {
-               u.SendSymptomDataError(w, req, "Failed to zip the files: "+err.Error())
-               return
-       }
-
-       w.Header().Set("Content-Disposition", "attachment; filename="+zipFile)
-       http.ServeFile(w, req, tmpFile.Name())
-}
-
-func (u *Utils) SendSymptomDataError(w http.ResponseWriter, req *http.Request, message string) {
-       w.Header().Set("Content-Disposition", "attachment; filename=error_status.txt")
-       http.Error(w, message, http.StatusInternalServerError)
-}