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 {
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)
}
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
+ }
}
}
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
[
{
- "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"
}
},
{
- "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"