From 33423f936483c08fe84b6c327c4a148c68863f3b Mon Sep 17 00:00:00 2001 From: Mohamed Abukar Date: Wed, 9 Dec 2020 14:16:55 +0200 Subject: [PATCH] Update RMR version v4.4.6 Change-Id: Ib269fd3d336a02b7dd2d757321da46bc5f03222e Signed-off-by: Mohamed Abukar --- build_vesmgr.sh | 4 +- cmd/vespamgr/config.go | 6 +- cmd/vespamgr/types.go | 1 + cmd/vespamgr/vespamgr.go | 9 +- config/config-file-ut.json | 1 + config/config-file.json | 3 +- container-tag.yaml | 2 +- test/xApp_config_test_output.json | 238 +------------------------------------- 8 files changed, 18 insertions(+), 246 deletions(-) diff --git a/build_vesmgr.sh b/build_vesmgr.sh index 6166a6a..a9c03d5 100755 --- a/build_vesmgr.sh +++ b/build_vesmgr.sh @@ -20,11 +20,11 @@ # # Install RMR from deb packages at packagecloud.io -rmr=rmr_4.1.2_amd64.deb +rmr=rmr_4.4.6_amd64.deb wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmr/download.deb sudo dpkg -i $rmr rm $rmr -rmrdev=rmr-dev_4.1.2_amd64.deb +rmrdev=rmr-dev_4.4.6_amd64.deb wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmrdev/download.deb sudo dpkg -i $rmrdev rm $rmrdev diff --git a/cmd/vespamgr/config.go b/cmd/vespamgr/config.go index b7779f2..a62b3a4 100755 --- a/cmd/vespamgr/config.go +++ b/cmd/vespamgr/config.go @@ -188,8 +188,8 @@ func (v *VespaMgr) GetRules(vespaconf *VESAgentConfiguration, xAppConfig []byte) appMetrics := make(AppMetrics) metrics := v.ParseMetricsFromDescriptor(xAppConfig, appMetrics) - if pltFile := os.Getenv("VESMGR_PLT_CFG_FILE"); pltFile != "" { - pltConfig, err := ioutil.ReadFile(pltFile) + if v.pltFileCreated { + pltConfig, err := ioutil.ReadFile(app.Config.GetString("controls.pltFile")) if err != nil { app.Logger.Error("Unable to read platform config file: %v", err) } else { @@ -221,9 +221,7 @@ func (v *VespaMgr) GetCollectorConfiguration(vespaconf *VESAgentConfiguration) { func (v *VespaMgr) CreateConfig(writer io.Writer, xAppStatus []byte) { vespaconf := v.BasicVespaConf() - v.GetRules(&vespaconf, xAppStatus) - v.GetCollectorConfiguration(&vespaconf) err := yaml.NewEncoder(writer).Encode(vespaconf) diff --git a/cmd/vespamgr/types.go b/cmd/vespamgr/types.go index c364196..88b675f 100755 --- a/cmd/vespamgr/types.go +++ b/cmd/vespamgr/types.go @@ -39,6 +39,7 @@ type VespaMgr struct { prometheusAddr string alertManagerBindAddr string subscriptionId string + pltFileCreated bool } // Structs are copied from https://github.com/nokia/ONAP-VESPA/tree/master/ves-agent/config diff --git a/cmd/vespamgr/vespamgr.go b/cmd/vespamgr/vespamgr.go index 1a5246f..4cc6c8e 100755 --- a/cmd/vespamgr/vespamgr.go +++ b/cmd/vespamgr/vespamgr.go @@ -144,9 +144,11 @@ func (v *VespaMgr) HandleSupervision(w http.ResponseWriter, r *http.Request) { } func (v *VespaMgr) HandleMeasurements(w http.ResponseWriter, r *http.Request) { - app.Logger.Info("HandleMeasurements called!") if appConfig, err := v.ReadPayload(w, r); err == nil { - v.CreateConf(app.Config.GetString("controls.vesagent.configFile"), appConfig) + filePath := app.Config.GetString("controls.pltFile") + if err := ioutil.WriteFile(filePath, appConfig, 0666); err == nil { + v.pltFileCreated = true + } } } @@ -190,9 +192,8 @@ func (v *VespaMgr) SubscribeXappNotif(appmgrUrl string) { targetUrl := fmt.Sprintf("%s%s", app.Config.GetString("controls.host"), v.appmgrNotifUrl) subscriptionData := []byte(fmt.Sprintf(`{"Data": {"maxRetries": 5, "retryTimer": 5, "eventType":"all", "targetUrl": "%v"}}`, targetUrl)) - for { + for i := 0; i < v.appmgrRetry; i++ { app.Logger.Info("Subscribing xApp notification from: %v", appmgrUrl) - if id := v.DoSubscribe(appmgrUrl, subscriptionData); id != "" { app.Logger.Info("Subscription done, id=%s", id) break diff --git a/config/config-file-ut.json b/config/config-file-ut.json index 497242f..e13f086 100755 --- a/config/config-file-ut.json +++ b/config/config-file-ut.json @@ -54,6 +54,7 @@ }, "host": "localhost:8080", "measurementUrl": "/ric/v1/measurements", + "pltFile": "/tmp/vespa-plt-meas.json", "appManager": { "host": "http://localhost:8080", "path": "/ric/v1/config", diff --git a/config/config-file.json b/config/config-file.json index eead269..455cf8f 100755 --- a/config/config-file.json +++ b/config/config-file.json @@ -54,12 +54,13 @@ }, "host": "http://service-ricplt-vespamgr-http.ricplt.svc.cluster.local:8080", "measurementUrl": "/ric/v1/measurements", + "pltFile": "/tmp/vespa-plt-meas.json", "appManager": { "host": "http://service-ricplt-appmgr-http.ricplt.svc.cluster.local:8080", "path": "/ric/v1/config", "notificationUrl": "/ric/v1/xappnotif", "subscriptionUrl": "/ric/v1/subscriptions", - "appmgrRetry": 2 + "appmgrRetry": 100 }, "vesagent": { "configFile": "/etc/ves-agent/ves-agent.yaml", diff --git a/container-tag.yaml b/container-tag.yaml index 31badd2..2576d0b 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -1,4 +1,4 @@ # The Jenkins job uses this string for the tag in the image name # for example nexus3.o-ran-sc.org:10004/my-image-name:0.0.1 --- -tag: 0.7.0 +tag: 0.7.1 diff --git a/test/xApp_config_test_output.json b/test/xApp_config_test_output.json index 204398b..663e7b3 100755 --- a/test/xApp_config_test_output.json +++ b/test/xApp_config_test_output.json @@ -1,122 +1,7 @@ [ { - "metadata": { - "name": "xApp1", - "configName": "xApp1-appconfig", - "namespace": "default" - }, - "descriptor": { - "$id": "http://example.com/root.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - - }, - "properties": { - "local": { - "$id": "#/properties/local", - "properties": { - "host": { - "$id": "#/properties/local/properties/host", - "default": "", - "examples": [ - ":8080" - ], - "pattern": "^(.*)$", - "title": "The Host Schema", - "type": "string" - } - }, - "required": [ - "host" - ], - "title": "The Local Schema", - "type": "object" - }, - "logger": { - "$id": "#/properties/logger", - "properties": { - "level": { - "$id": "#/properties/logger/properties/level", - "default": 0, - "examples": [ - 3 - ], - "title": "The Level Schema", - "type": "integer" - } - }, - "required": [ - "level" - ], - "title": "The Logger Schema", - "type": "object" - }, - "metrics": { - "$id": "#/properties/metrics", - "items": { - "$id": "#/properties/metrics/items", - "properties": { - "description": { - "$id": "#/properties/metrics/items/properties/description", - "default": "", - "examples": [ - "Example counter 1" - ], - "pattern": "^(.*)$", - "title": "The Description Schema", - "type": "string" - }, - "enabled": { - "$id": "#/properties/metrics/items/properties/enabled", - "default": false, - "examples": [ - true - ], - "title": "The Enabled Schema", - "type": "boolean" - }, - "name": { - "$id": "#/properties/metrics/items/properties/name", - "default": "", - "examples": [ - "App1ExampleCounterOne" - ], - "pattern": "^(.*)$", - "title": "The Name Schema", - "type": "string" - }, - "type": { - "$id": "#/properties/metrics/items/properties/type", - "default": "", - "examples": [ - "counter" - ], - "pattern": "^(.*)$", - "title": "The Type Schema", - "type": "string" - } - }, - "required": [ - "name", - "type", - "enabled", - "description" - ], - "title": "The Items Schema", - "type": "object" - }, - "title": "The Metrics Schema", - "type": "array" - } - }, - "required": [ - "local", - "logger", - "metrics" - ], - "title": "ANR Descriptor Schema", - "type": "object" - }, + "metadata": { }, + "descriptor": { }, "config": { "local": { "host": ":8080" @@ -153,123 +38,8 @@ } }, { - "metadata": { - "name": "xApp2", - "configName": "xApp2-appconfig", - "namespace": "default" - }, - "descriptor": { - "$id": "http://example.com/root.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - - }, - "properties": { - "local": { - "$id": "#/properties/local", - "properties": { - "host": { - "$id": "#/properties/local/properties/host", - "default": "", - "examples": [ - ":8080" - ], - "pattern": "^(.*)$", - "title": "The Host Schema", - "type": "string" - } - }, - "required": [ - "host" - ], - "title": "The Local Schema", - "type": "object" - }, - "logger": { - "$id": "#/properties/logger", - "properties": { - "level": { - "$id": "#/properties/logger/properties/level", - "default": 0, - "examples": [ - 3 - ], - "title": "The Level Schema", - "type": "integer" - } - }, - "required": [ - "level" - ], - "title": "The Logger Schema", - "type": "object" - }, - "metrics": { - "$id": "#/properties/metrics", - "items": { - "$id": "#/properties/metrics/items", - "properties": { - "description": { - "$id": "#/properties/metrics/items/properties/description", - "default": "", - "examples": [ - "" - ], - "pattern": "^(.*)$", - "title": "The Description Schema", - "type": "string" - }, - "enabled": { - "$id": "#/properties/metrics/items/properties/enabled", - "default": false, - "examples": [ - true - ], - "title": "The Enabled Schema", - "type": "boolean" - }, - "name": { - "$id": "#/properties/metrics/items/properties/name", - "default": "", - "examples": [ - "UEContextCreated" - ], - "pattern": "^(.*)$", - "title": "The Name Schema", - "type": "string" - }, - "type": { - "$id": "#/properties/metrics/items/properties/type", - "default": "", - "examples": [ - "counter" - ], - "pattern": "^(.*)$", - "title": "The Type Schema", - "type": "string" - } - }, - "required": [ - "name", - "type", - "enabled", - "description" - ], - "title": "The Items Schema", - "type": "object" - }, - "title": "The Metrics Schema", - "type": "array" - } - }, - "required": [ - "local", - "logger", - "metrics" - ], - "title": "The Root Schema", - "type": "object" - }, + "metadata": {}, + "descriptor": {}, "config": { "local": { "host": ":8080" -- 2.16.6