Merge "Use non-root user for Dockerfile of helm-manager"
authorJohn Keeney <john.keeney@est.tech>
Wed, 26 Jan 2022 16:36:02 +0000 (16:36 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Wed, 26 Jan 2022 16:36:02 +0000 (16:36 +0000)
14 files changed:
onap/oran
test/common/pa_api_functions.sh
test/usecases/odusliceassurance/goversion/go.mod
test/usecases/odusliceassurance/goversion/internal/config/config_test.go [new file with mode: 0644]
test/usecases/odusliceassurance/goversion/internal/restclient/client.go
test/usecases/odusliceassurance/goversion/internal/restclient/client_test.go [new file with mode: 0644]
test/usecases/odusliceassurance/goversion/internal/sliceassurance/app.go
test/usecases/odusliceassurance/goversion/internal/structures/sliceassurance.go
test/usecases/odusliceassurance/goversion/internal/structures/sliceassurance_test.go [new file with mode: 0644]
test/usecases/odusliceassurance/goversion/messages/stdVesMessage_test.go [new file with mode: 0644]
test/usecases/oruclosedlooprecovery/apexpolicyversion/LinkMonitor/config/LinkMonitorConfigDmaap2RestJsonEvent.json [changed mode: 0644->0755]
test/usecases/oruclosedlooprecovery/apexpolicyversion/LinkMonitor/deployment/ToscaPolicy.json
test/usecases/oruclosedlooprecovery/apexpolicyversion/LinkMonitor/models/LinkFailureLogic.js [changed mode: 0644->0755]
test/usecases/oruclosedlooprecovery/apexpolicyversion/LinkMonitor/schemas/LinkFailureOutputSchema.avsc [changed mode: 0644->0755]

index 0f8b205..3d2a09b 160000 (submodule)
--- a/onap/oran
+++ b/onap/oran
@@ -1 +1 @@
-Subproject commit 0f8b20544745afaf9c7b38140b9516667d9c4752
+Subproject commit 3d2a09b1bc7d6798c8083bfc3dc04c69a1b709c7
index a5a51c0..9076bab 100644 (file)
@@ -1752,7 +1752,7 @@ api_get_policy_status() {
                        return 1
                fi
        fi
-       __collect_endpoint_stats "PMS" 08 "GET" $PMS_API_PREFIX"/policies/{policy_id}/status" $status
+       __collect_endpoint_stats "PMS" 08 "GET" $PMS_API_PREFIX"/v2/policies/{policy_id}/status" $status
        __log_test_pass
        return 0
 }
index e2fb61d..d0c4dc2 100644 (file)
@@ -4,6 +4,13 @@ go 1.17
 
 require github.com/sirupsen/logrus v1.8.1
 
-require github.com/gorilla/mux v1.8.0
+require (
+       github.com/gorilla/mux v1.8.0
+       github.com/stretchr/testify v1.3.0
+)
 
-require golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect
+require (
+       github.com/davecgh/go-spew v1.1.1 // indirect
+       github.com/pmezard/go-difflib v1.0.0 // indirect
+       golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect
+)
diff --git a/test/usecases/odusliceassurance/goversion/internal/config/config_test.go b/test/usecases/odusliceassurance/goversion/internal/config/config_test.go
new file mode 100644 (file)
index 0000000..1005946
--- /dev/null
@@ -0,0 +1,108 @@
+// -
+//   ========================LICENSE_START=================================
+//   O-RAN-SC
+//   %%
+//   Copyright (C) 2021: Nordix Foundation
+//   %%
+//   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.
+//   ========================LICENSE_END===================================
+//
+
+package config
+
+import (
+       "bytes"
+       "os"
+       "testing"
+
+       log "github.com/sirupsen/logrus"
+       "github.com/stretchr/testify/require"
+)
+
+func TestNewEnvVarsSetConfigContainSetValues(t *testing.T) {
+       assertions := require.New(t)
+       os.Setenv("MR_HOST", "consumerHost")
+       os.Setenv("MR_PORT", "8095")
+       os.Setenv("SDNR_ADDR", "http://localhost:3904")
+       os.Setenv("SDNR_USER", "admin")
+       os.Setenv("SDNR_PASSWORD", "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U")
+       os.Setenv("Polltime", "30")
+       os.Setenv("LOG_LEVEL", "Debug")
+       t.Cleanup(func() {
+               os.Clearenv()
+       })
+       wantConfig := Config{
+               MRHost:      "consumerHost",
+               MRPort:      "8095",
+               SDNRAddress: "http://localhost:3904",
+               SDNRUser:    "admin",
+               SDNPassword: "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U",
+               Polltime:    30,
+               LogLevel:    log.DebugLevel,
+       }
+
+       got := New()
+       assertions.Equal(&wantConfig, got)
+}
+
+func TestNewFaultyIntValueSetConfigContainDefaultValueAndWarnInLog(t *testing.T) {
+       assertions := require.New(t)
+       var buf bytes.Buffer
+       log.SetOutput(&buf)
+
+       os.Setenv("Polltime", "wrong")
+       t.Cleanup(func() {
+               log.SetOutput(os.Stderr)
+               os.Clearenv()
+       })
+       wantConfig := Config{
+               MRHost:      "",
+               MRPort:      "",
+               SDNRAddress: "http://localhost:3904",
+               SDNRUser:    "admin",
+               SDNPassword: "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U",
+               Polltime:    30,
+               LogLevel:    log.InfoLevel,
+       }
+
+       got := New()
+       assertions.Equal(&wantConfig, got)
+
+       logString := buf.String()
+       assertions.Contains(logString, "Invalid int value: wrong for variable: Polltime. Default value: 30 will be used")
+}
+
+func TestNewEnvFaultyLogLevelConfigContainDefaultValues(t *testing.T) {
+       assertions := require.New(t)
+       var buf bytes.Buffer
+       log.SetOutput(&buf)
+
+       os.Setenv("LOG_LEVEL", "wrong")
+       t.Cleanup(func() {
+               log.SetOutput(os.Stderr)
+               os.Clearenv()
+       })
+       wantConfig := Config{
+               MRHost:      "",
+               MRPort:      "",
+               SDNRAddress: "http://localhost:3904",
+               SDNRUser:    "admin",
+               SDNPassword: "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U",
+               Polltime:    30,
+               LogLevel:    log.InfoLevel,
+       }
+       got := New()
+       assertions.Equal(&wantConfig, got)
+       logString := buf.String()
+       assertions.Contains(logString, "Invalid log level: wrong. Log level will be Info!")
+}
index 61cf614..3983840 100644 (file)
@@ -40,11 +40,6 @@ func New(httpClient *http.Client) *Client {
        }
 }
 
-type HTTPClient interface {
-       Get(path string, v interface{}) error
-       Post(path string, payload interface{}, v interface{}) error
-}
-
 func (c *Client) Get(path string, v interface{}) error {
        req, err := c.newRequest(http.MethodGet, path, nil)
        if err != nil {
diff --git a/test/usecases/odusliceassurance/goversion/internal/restclient/client_test.go b/test/usecases/odusliceassurance/goversion/internal/restclient/client_test.go
new file mode 100644 (file)
index 0000000..f2899df
--- /dev/null
@@ -0,0 +1,210 @@
+// -
+//   ========================LICENSE_START=================================
+//   O-RAN-SC
+//   %%
+//   Copyright (C) 2021: Nordix Foundation
+//   %%
+//   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.
+//   ========================LICENSE_END===================================
+//
+
+package restclient
+
+import (
+       "bytes"
+       "encoding/json"
+       "fmt"
+       "net/http"
+       "net/http/httptest"
+       "testing"
+
+       "github.com/stretchr/testify/require"
+)
+
+func TestNewRequest(t *testing.T) {
+       assertions := require.New(t)
+
+       bodyBytes, _ := json.Marshal("body")
+       succesfullReq, _ := http.NewRequest(http.MethodGet, "url", bytes.NewReader(bodyBytes))
+
+       type args struct {
+               method  string
+               path    string
+               payload interface{}
+       }
+       tests := []struct {
+               name    string
+               args    args
+               want    *http.Request
+               wantErr error
+       }{
+               {
+                       name: "succesfull newRequest",
+                       args: args{
+                               method:  http.MethodGet,
+                               path:    "url",
+                               payload: "body",
+                       },
+                       want:    succesfullReq,
+                       wantErr: nil,
+               },
+               {
+                       name: "request failed json marshal",
+                       args: args{
+                               method: http.MethodGet,
+                               path:   "url",
+                               payload: map[string]interface{}{
+                                       "foo": make(chan int),
+                               },
+                       },
+                       want:    nil,
+                       wantErr: fmt.Errorf("failed to marshal request body: json: unsupported type: chan int"),
+               },
+               {
+                       name: "request failed calling newRequest",
+                       args: args{
+                               method:  "*?",
+                               path:    "url",
+                               payload: "body",
+                       },
+                       want:    nil,
+                       wantErr: fmt.Errorf("failed to create HTTP request: net/http: invalid method \"*?\""),
+               },
+       }
+
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       client := New(&http.Client{})
+
+                       req, err := client.newRequest(tt.args.method, tt.args.path, tt.args.payload)
+                       if tt.wantErr != nil {
+                               assertions.Equal(tt.want, req)
+                               assertions.EqualError(tt.wantErr, err.Error())
+                       } else {
+                               assertions.Equal("url", req.URL.Path)
+                               assertions.Equal("application/json; charset=utf-8", req.Header.Get("Content-Type"))
+                               assertions.Empty(req.Header.Get("Authorization"))
+                               assertions.Nil(err)
+                       }
+
+               })
+       }
+}
+
+func TestGet(t *testing.T) {
+       assertions := require.New(t)
+       type args struct {
+               header   string
+               respCode int
+               resp     interface{}
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantErr string
+       }{
+               {
+                       name: "successful GET request",
+                       args: args{
+                               header:   "application/json",
+                               respCode: http.StatusOK,
+                               resp:     "Success!",
+                       },
+                       wantErr: "",
+               },
+               {
+                       name: "error GET request",
+                       args: args{
+                               header:   "application/json",
+                               respCode: http.StatusBadRequest,
+                               resp:     nil,
+                       },
+                       wantErr: "failed to do request, 400 status code received",
+               },
+       }
+
+       for _, tt := range tests {
+
+               t.Run(tt.name, func(t *testing.T) {
+                       srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+                               response, _ := json.Marshal(tt.args.resp)
+                               w.Header().Set("Content-Type", tt.args.header)
+                               w.WriteHeader(tt.args.respCode)
+                               w.Write(response)
+                       }))
+                       defer srv.Close()
+
+                       client := New(&http.Client{})
+                       var res interface{}
+                       err := client.Get(srv.URL, &res)
+
+                       if err != nil {
+                               assertions.Equal(tt.wantErr, err.Error())
+                       }
+                       assertions.Equal(tt.args.resp, res)
+               })
+       }
+}
+
+func TestPost(t *testing.T) {
+       assertions := require.New(t)
+       type args struct {
+               header   string
+               respCode int
+               resp     interface{}
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantErr string
+       }{
+               {
+                       name: "successful Post request",
+                       args: args{
+                               header:   "application/json",
+                               respCode: http.StatusOK,
+                               resp:     "Success!",
+                       },
+                       wantErr: "",
+               },
+       }
+
+       for _, tt := range tests {
+
+               t.Run(tt.name, func(t *testing.T) {
+                       srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+
+                               assertions.Equal(http.MethodPost, r.Method)
+                               assertions.Contains(r.Header.Get("Content-Type"), "application/json")
+
+                               var reqBody interface{}
+                               decoder := json.NewDecoder(r.Body)
+                               decoder.Decode(&reqBody)
+                               assertions.Equal(reqBody, `json:"example"`)
+
+                               response, _ := json.Marshal(tt.args.resp)
+                               w.Header().Set("Content-Type", tt.args.header)
+                               w.WriteHeader(tt.args.respCode)
+                               w.Write(response)
+                       }))
+                       defer srv.Close()
+
+                       client := New(&http.Client{})
+                       payload := `json:"example"`
+                       err := client.Post(srv.URL, payload, nil)
+
+                       if err != nil {
+                               assertions.Equal(tt.wantErr, err.Error())
+                       }
+               })
+       }
+}
index 7dc84b1..2cef277 100644 (file)
@@ -39,7 +39,7 @@ const (
 )
 
 type App struct {
-       client          restclient.HTTPClient
+       client          *restclient.Client
        metricsPolicies *structures.SliceAssuranceMeas
 }
 
index c243d18..7cefcaf 100644 (file)
@@ -73,19 +73,19 @@ func (sa *SliceAssuranceMeas) AddOrUpdateMetric(meas messages.Measurement) (stri
        var duid string
        var sd, sst int
 
-       regex := *regexp.MustCompile(`\/network-function\/distributed-unit-functions\[id=\'(.*)\'\]/cell\[id=\'(.*)\'\]/supported-measurements\/performance-measurement-type\[\.=\'(.*)\'\]\/supported-snssai-subcounter-instances\/slice-differentiator\[\.=(\d)\]\[slice-service-type=(\d+)\]`)
+       regex := *regexp.MustCompile(`\/(.*)network-function\/distributed-unit-functions\[id=\'(.*)\'\]\/cell\[id=\'(.*)\'\]\/supported-measurements\[performance-measurement-type=\'(.*)\'\]\/supported-snssai-subcounter-instances\[slice-differentiator=\'(\d+)\'\]\[slice-service-type=\'(\d+)\'\]`)
        res := regex.FindAllStringSubmatch(meas.MeasurementTypeInstanceReference, -1)
 
-       if res != nil && len(res[0]) == 6 {
-               duid = res[0][1]
-               sd = toInt(res[0][4])
-               sst = toInt(res[0][5])
+       if res != nil && len(res[0]) == 7 {
+               duid = res[0][2]
+               sd = toInt(res[0][5])
+               sst = toInt(res[0][6])
 
                key := MapKey{duid, sd, sst}
                value, check := sa.Metrics[key]
 
                if check {
-                       sa.updateMetric(key, value, res[0][3], meas.Value)
+                       sa.updateMetric(key, value, res[0][4], meas.Value)
                } else {
                        // Only add new one if value exceeds threshold
                        sa.addMetric(res, meas.Value)
@@ -98,9 +98,9 @@ func (sa *SliceAssuranceMeas) AddOrUpdateMetric(meas messages.Measurement) (stri
 
 func (sa *SliceAssuranceMeas) addMetric(res [][]string, metricValue int) {
        if metricValue > 700 {
-               metric := NewSliceMetric(res[0][1], res[0][2], toInt(res[0][4]), toInt(res[0][5]))
+               metric := NewSliceMetric(res[0][2], res[0][3], toInt(res[0][5]), toInt(res[0][6]))
                metric.PM[res[0][3]] = metricValue
-               key := MapKey{res[0][1], toInt(res[0][4]), toInt(res[0][5])}
+               key := MapKey{res[0][2], toInt(res[0][5]), toInt(res[0][6])}
                sa.Metrics[key] = metric
        }
 }
diff --git a/test/usecases/odusliceassurance/goversion/internal/structures/sliceassurance_test.go b/test/usecases/odusliceassurance/goversion/internal/structures/sliceassurance_test.go
new file mode 100644 (file)
index 0000000..9ed35fb
--- /dev/null
@@ -0,0 +1,172 @@
+// -
+//   ========================LICENSE_START=================================
+//   O-RAN-SC
+//   %%
+//   Copyright (C) 2021: Nordix Foundation
+//   %%
+//   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.
+//   ========================LICENSE_END===================================
+//
+
+package structures
+
+import (
+       "testing"
+
+       "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/require"
+       "oransc.org/usecase/oduclosedloop/messages"
+)
+
+func TestAddMetric(t *testing.T) {
+       assertions := require.New(t)
+       type args struct {
+               meas messages.Measurement
+       }
+       tests := []struct {
+               name string
+               args args
+       }{
+               {
+                       name: "Test adding new metric",
+                       args: args{
+                               meas: messages.Measurement{
+                                       MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+                                       Value:                            51232,
+                                       Unit:                             "kbit/s",
+                               },
+                       },
+               },
+               {
+                       name: "Test with invalid input",
+                       args: args{
+                               meas: messages.Measurement{
+                                       MeasurementTypeInstanceReference: "/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+                                       Value:                            51232,
+                                       Unit:                             "kbit/s",
+                               },
+                       },
+               },
+       }
+
+       sliceAssuranceMeas := NewSliceAssuranceMeas()
+       assertions.Equal(0, len(sliceAssuranceMeas.Metrics), "Metrics is not empty, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 0)
+
+       for i, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+
+                       if i == 0 {
+                               sliceAssuranceMeas.AddOrUpdateMetric(tt.args.meas)
+                               assertions.Equal(1, len(sliceAssuranceMeas.Metrics), "Metrics must have one new metric, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 1)
+
+                               testMapKey := MapKey{"O-DU-1211", 1, 1}
+                               assertions.Contains(sliceAssuranceMeas.Metrics, testMapKey, "Metric added with wrong values , got: %v.", sliceAssuranceMeas.Metrics[testMapKey])
+                       }
+                       if i == 1 {
+                               _, got := sliceAssuranceMeas.AddOrUpdateMetric(tt.args.meas)
+                               assertions.EqualError(got, " wrong format for MeasurementTypeInstanceReference")
+                       }
+               })
+       }
+}
+
+func TestUpdateExistingMetric(t *testing.T) {
+       assertions := require.New(t)
+       meas := messages.Measurement{
+               MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+               Value:                            51232,
+               Unit:                             "kbit/s",
+       }
+
+       updateMeas := messages.Measurement{
+               MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+               Value:                            897,
+               Unit:                             "kbit/s",
+       }
+
+       sliceAssuranceMeas := NewSliceAssuranceMeas()
+       assertions.Equal(0, len(sliceAssuranceMeas.Metrics), "Metrics is not empty, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 0)
+
+       sliceAssuranceMeas.AddOrUpdateMetric(meas)
+       assertions.Equal(1, len(sliceAssuranceMeas.Metrics), "Metrics must have one new metric, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 1)
+
+       sliceAssuranceMeas.AddOrUpdateMetric(updateMeas)
+       assertions.Equal(1, len(sliceAssuranceMeas.Metrics), "Metrics must have one updated metric, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 1)
+
+       testMapKey := MapKey{"O-DU-1211", 1, 1}
+       metricName := "user-equipment-average-throughput-uplink"
+       newMetricValue := 897
+       if sliceAssuranceMeas.Metrics[testMapKey].PM[metricName] != newMetricValue {
+               t.Errorf("Metric value was not update properly, got: %d, want: %d.", sliceAssuranceMeas.Metrics[testMapKey].PM[metricName], newMetricValue)
+       }
+
+}
+
+func TestDeleteMetricWhenValueLessThanThreshold(t *testing.T) {
+
+       meas := messages.Measurement{
+               MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+               Value:                            51232,
+               Unit:                             "kbit/s",
+       }
+
+       newMeas := messages.Measurement{
+               MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+               Value:                            50,
+               Unit:                             "kbit/s",
+       }
+
+       sliceAssuranceMeas := NewSliceAssuranceMeas()
+       assert.Equal(t, 0, len(sliceAssuranceMeas.Metrics), "Metrics is not empty, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 0)
+
+       sliceAssuranceMeas.AddOrUpdateMetric(meas)
+       assert.Equal(t, 1, len(sliceAssuranceMeas.Metrics), "Metrics must have one new metric, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 1)
+
+       sliceAssuranceMeas.AddOrUpdateMetric(newMeas)
+       assert.Equal(t, 0, len(sliceAssuranceMeas.Metrics), "Metrics must have been deleted, got: %d, want: %d.", len(sliceAssuranceMeas.Metrics), 0)
+
+}
+
+func TestAddPolicy(t *testing.T) {
+
+       meas := messages.Measurement{
+               MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+               Value:                            51232,
+               Unit:                             "kbit/s",
+       }
+       sliceAssuranceMeas := NewSliceAssuranceMeas()
+       sliceAssuranceMeas.AddOrUpdateMetric(meas)
+
+       duid := "O-DU-1211"
+       rrmPolicyRatio := messages.RRMPolicyRatio{
+               Id:                      "id",
+               AdmState:                "locked",
+               UserLabel:               "user_label",
+               RRMPolicyMaxRatio:       0,
+               RRMPolicyMinRatio:       0,
+               RRMPolicyDedicatedRatio: 0,
+               ResourceType:            "prb",
+               RRMPolicyMembers: []messages.RRMPolicyMember{{
+                       MobileCountryCode:   "046",
+                       MobileNetworkCode:   "651",
+                       SliceDifferentiator: 1,
+                       SliceServiceType:    1,
+               }},
+       }
+       assert.Equal(t, 0, len(sliceAssuranceMeas.Policies), "Policies is not empty, got: %d, want: %d.", len(sliceAssuranceMeas.Policies), 0)
+
+       sliceAssuranceMeas.AddNewPolicy(duid, rrmPolicyRatio)
+       assert.Equal(t, 1, len(sliceAssuranceMeas.Policies), "Policies must have one new policy, got: %d, want: %d.", len(sliceAssuranceMeas.Policies), 1)
+
+       sliceAssuranceMeas.PrintStructures()
+}
diff --git a/test/usecases/odusliceassurance/goversion/messages/stdVesMessage_test.go b/test/usecases/odusliceassurance/goversion/messages/stdVesMessage_test.go
new file mode 100644 (file)
index 0000000..2904d49
--- /dev/null
@@ -0,0 +1,76 @@
+// -
+//   ========================LICENSE_START=================================
+//   O-RAN-SC
+//   %%
+//   Copyright (C) 2021: Nordix Foundation
+//   %%
+//   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.
+//   ========================LICENSE_END===================================
+//
+
+package messages
+
+import (
+       "testing"
+)
+
+func TestGetMeasurements(t *testing.T) {
+       type fields struct {
+               Event Event
+       }
+       tests := []struct {
+               name   string
+               fields fields
+               want   []Measurement
+       }{
+               {
+                       name: "get measurements message",
+                       fields: fields{
+                               Event: Event{
+                                       CommonEventHeader: CommonEventHeader{
+                                               Domain:               "stndDefined",
+                                               StndDefinedNamespace: "o-ran-sc-du-hello-world-pm-streaming-oas3",
+                                       },
+                                       StndDefinedFields: StndDefinedFields{
+                                               StndDefinedFieldsVersion: "1.0",
+                                               SchemaReference:          "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/oas3/experimental/o-ran-sc-du-hello-world-oas3.json;hb=refs/heads/master",
+                                               Data: Data{
+                                                       DataId: "id",
+                                                       Measurements: []Measurement{{
+                                                               MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+                                                               Value:                            51232,
+                                                               Unit:                             "kbit/s",
+                                                       }},
+                                               },
+                                       },
+                               },
+                       },
+                       want: []Measurement{{
+                               MeasurementTypeInstanceReference: "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='O-DU-1211']/cell[id='cell-1']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances[slice-differentiator='1'][slice-service-type='1']",
+                               Value:                            51232,
+                               Unit:                             "kbit/s",
+                       }},
+               },
+       }
+
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       message := StdDefinedMessage{
+                               Event: tt.fields.Event,
+                       }
+                       if got := message.GetMeasurements(); len(got) != len(tt.want) {
+                               t.Errorf("Message.GetMeasurements() = %v, want %v", got, tt.want)
+                       }
+               })
+       }
+}
old mode 100644 (file)
new mode 100755 (executable)
index 837d187..56d204b
             "taskParameters": [
                 {
                     "key": "ORU-ODU-Map",
-                    "value": "{\"ERICSSON-O-RU-11220\": \"HCL-O-DU-1122\",
-                               \"ERICSSON-O-RU-11221\": \"HCL-O-DU-1122\",
-                               \"ERICSSON-O-RU-11222\": \"HCL-O-DU-1122\",
-                               \"ERICSSON-O-RU-11223\": \"HCL-O-DU-1122\",
-                               \"ERICSSON-O-RU-11224\": \"HCL-O-DU-1123\",
-                               \"ERICSSON-O-RU-11225\": \"HCL-O-DU-1123\",
-                               \"ERICSSON-O-RU-11226\": \"HCL-O-DU-1123\",
-                               \"ERICSSON-O-RU-11227\": \"HCL-O-DU-1124\",
-                               \"ERICSSON-O-RU-11228\": \"HCL-O-DU-1125\",
-                               \"ERICSSON-O-RU-11229\": \"HCL-O-DU-1125\"}"
+                    "value": "{\"ERICSSON-O-RU-11220\": \"O-DU-1122\",
+                               \"ERICSSON-O-RU-11221\": \"O-DU-1122\",
+                               \"ERICSSON-O-RU-11222\": \"O-DU-1122\",
+                               \"ERICSSON-O-RU-11223\": \"O-DU-1122\",
+                               \"ERICSSON-O-RU-11224\": \"O-DU-1123\",
+                               \"ERICSSON-O-RU-11225\": \"O-DU-1123\",
+                               \"ERICSSON-O-RU-11226\": \"O-DU-1123\",
+                               \"ERICSSON-O-RU-11227\": \"O-DU-1124\",
+                               \"ERICSSON-O-RU-11228\": \"O-DU-1125\",
+                               \"ERICSSON-O-RU-11229\": \"O-DU-1125\"}"
                 }
             ]
         }
@@ -42,7 +42,7 @@
                 "carrierTechnology": "RESTCLIENT",
                 "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
                 "parameters": {
-                    "url": "http://sdnr-sim:9990/rests/data/network-topology:network-topology/topology=topology-netconf/node={OduId}/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection={OruId}",
+                    "url": "http://sdnr-sim:9990/rests/data/network-topology:network-topology/topology=topology-netconf/node={OduId}/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions={OduId}/radio-resource-management-policy-ratio=rrm-pol-1",
                     "httpMethod" : "PUT",
                     "httpHeaders" : [
                         ["Authorization", "Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ=="]
index 43af8ce..f2fea50 100644 (file)
@@ -1 +1 @@
-{"tosca_definitions_version":"tosca_simple_yaml_1_1_0","topology_template":{"policies":[{"onap.policies.native.apex.LinkMonitor":{"type":"onap.policies.native.Apex","type_version":"1.0.0","name":"onap.policies.native.apex.LinkMonitor","version":"1.0.0","properties":{"engineServiceParameters":{"name":"LinkMonitorApexEngine","version":"0.0.1","id":101,"instanceCount":1,"deploymentPort":12345,"engineParameters":{"executorParameters":{"JAVASCRIPT":{"parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"}},"contextParameters":{"parameterClassName":"org.onap.policy.apex.context.parameters.ContextParameters","schemaParameters":{"Avro":{"parameterClassName":"org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"}}},"taskParameters":[{"key":"ORU-ODU-Map","value":"{\"ERICSSON-O-RU-11220\": \"HCL-O-DU-1122\",\n                               \"ERICSSON-O-RU-11221\": \"HCL-O-DU-1122\",\n                               \"ERICSSON-O-RU-11222\": \"HCL-O-DU-1122\",\n                               \"ERICSSON-O-RU-11223\": \"HCL-O-DU-1122\",\n                               \"ERICSSON-O-RU-11224\": \"HCL-O-DU-1123\",\n                               \"ERICSSON-O-RU-11225\": \"HCL-O-DU-1123\",\n                               \"ERICSSON-O-RU-11226\": \"HCL-O-DU-1123\",\n                               \"ERICSSON-O-RU-11227\": \"HCL-O-DU-1124\",\n                               \"ERICSSON-O-RU-11228\": \"HCL-O-DU-1125\",\n                               \"ERICSSON-O-RU-11229\": \"HCL-O-DU-1125\"}"}]},"policy_type_impl":{"apexPolicyModel":{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"keyInformation":{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"keyInfoMap":{"entry":[{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"value":{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"UUID":"cca47d74-7754-4a61-b163-ca31f66b157b","description":"Generated description for concept referred to by key \"ApexMessageOutputEvent:0.0.1\""}},{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"UUID":"a295d6a3-1b73-387e-abba-b41e9b608802","description":"Generated description for concept referred to by key \"CreateLinkClearedOutfieldsEvent:0.0.1\""}},{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"UUID":"fd594e88-411d-4a94-b2be-697b3a0d7adf","description":"This task creates the output fields when link failure is cleared."}},{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"UUID":"02be2b5d-45b7-3c54-ae54-97f2b5c30125","description":"Generated description for concept referred to by key \"CreateLinkFailureOutfieldsEvent:0.0.1\""}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"UUID":"ac3d9842-80af-4a98-951c-bd79a431c613","description":"This task the output fields when link failure is detected."}},{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"name":"LinkClearedTask","version":"0.0.1"},"UUID":"eecfde90-896c-4343-8f9c-2603ced94e2d","description":"This task sends a message to the output when link failure is cleared."}},{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"UUID":"c4500941-3f98-4080-a9cc-5b9753ed050b","description":"Generated description for concept referred to by key \"LinkFailureInputEvent:0.0.1\""}},{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"UUID":"3b3974fc-3012-3b02-9f33-c9d8eefe4dc1","description":"Generated description for concept referred to by key \"LinkFailureInputSchema:0.0.1\""}},{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"UUID":"4f04aa98-e917-4f4a-882a-c75ba5a99374","description":"Generated description for concept referred to by key \"LinkFailureOutputEvent:0.0.1\""}},{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"UUID":"2d1a7f6e-eb9a-3984-be1f-283d98111b84","description":"Generated description for concept referred to by key \"LinkFailureOutputSchema:0.0.1\""}},{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"name":"LinkFailureTask","version":"0.0.1"},"UUID":"3351b0f4-cf06-4fa2-8823-edf67bd30223","description":"This task updates the config for O-RU when link failure is detected."}},{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"UUID":"540226fb-55ee-4f0e-a444-983a0494818e","description":"This is the Apex Policy Model for link monitoring."}},{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"UUID":"27ad3e7e-fe3b-3bd6-9081-718705c2bcea","description":"Generated description for concept referred to by key \"LinkMonitorModel_Events:0.0.1\""}},{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"UUID":"ea0b5f58-eefd-358a-9660-840c640bf981","description":"Generated description for concept referred to by key \"LinkMonitorModel_KeyInfo:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"UUID":"ee9e0b0f-2b7d-3ab7-9a98-c5ec05ed823d","description":"Generated description for concept referred to by key \"LinkMonitorModel_Policies:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"UUID":"fa5f9b8f-796c-3c70-84e9-5140c958c4bb","description":"Generated description for concept referred to by key \"LinkMonitorModel_Schemas:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"UUID":"eec592f7-69d5-39a9-981a-e552f787ed01","description":"Generated description for concept referred to by key \"LinkMonitorModel_Tasks:0.0.1\""}},{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"UUID":"6c5e410f-489a-46ff-964e-982ce6e8b6d0","description":"Generated description for concept referred to by key \"LinkMonitorPolicy:0.0.1\""}},{"key":{"name":"MessageSchema","version":"0.0.1"},"value":{"key":{"name":"MessageSchema","version":"0.0.1"},"UUID":"ac4b34ac-39d6-3393-a267-8d5b84854018","description":"A schema for messages from apex"}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"UUID":"d48b619e-d00d-4008-b884-02d76ea4350b","description":"This task sends a message to the output when an event is received for which no policy has been defined."}},{"key":{"name":"OduIdSchema","version":"0.0.1"},"value":{"key":{"name":"OduIdSchema","version":"0.0.1"},"UUID":"50662174-a88b-3cbd-91bd-8e91b40b2660","description":"A schema for O-DU-ID"}},{"key":{"name":"OruIdSchema","version":"0.0.1"},"value":{"key":{"name":"OruIdSchema","version":"0.0.1"},"UUID":"54daf32b-015f-39cd-8530-a1175c5553e9","description":"A schema for O-RU-ID"}}]}},"policies":{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"policyMap":{"entry":[{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"value":{"policyKey":{"name":"LinkMonitorPolicy","version":"0.0.1"},"template":"Freestyle","state":{"entry":[{"key":"LinkClearedState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkClearedState"},"trigger":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"LinkClearedLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedLogic_Output_Direct"},"outgoingEvent":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"LinkClearedTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedLogic_Output_Direct"}}}]}}},{"key":"LinkFailureOrClearedState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureOrClearedState"},"trigger":{"name":"LinkFailureInputEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"CreateLinkClearedOutfieldsLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsLogic_Output_Direct"},"outgoingEvent":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"nextState":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkClearedState"}}},{"key":"CreateLinkFailureOutfieldsLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsLogic_Output_Direct"},"outgoingEvent":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"nextState":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureState"}}},{"key":"NoPolicyDefinedLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedLogic_Output_Direct"},"outgoingEvent":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"TaskSelectionLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Selection Execution: '\"+executor.subject.id+\n    \"'. InputFields: '\"+executor.inFields+\"'\");\n\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar commonEventHeader = linkFailureInput.get(\"event\").get(\"commonEventHeader\");\nvar domain = commonEventHeader.get(\"domain\");\n\ntaskFailure = executor.subject.getTaskKey(\"CreateLinkFailureOutfieldsTask\");\ntaskCleared = executor.subject.getTaskKey(\"CreateLinkClearedOutfieldsTask\");\ntaskDefault = executor.subject.getDefaultTaskKey();\n\nif (domain == \"fault\") {\n    var faultFields = linkFailureInput.get(\"event\").get(\"faultFields\");\n    var alarmCondition = faultFields.get(\"alarmCondition\");\n    var eventSeverity = faultFields.get(\"eventSeverity\");\n    if (alarmCondition == \"28\" && eventSeverity != \"NORMAL\") {\n        taskFailure.copyTo(executor.selectedTask);\n    } else if (alarmCondition == \"28\" && eventSeverity == \"NORMAL\") {\n        taskCleared.copyTo(executor.selectedTask);\n    } else {\n        taskDefault.copyTo(executor.selectedTask);\n    }\n} else {\n    taskDefault.copyTo(executor.selectedTask);\n}\n\ntrue;"},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsLogic_Output_Direct"}}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsLogic_Output_Direct"}}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedLogic_Output_Direct"}}}]}}},{"key":"LinkFailureState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureState"},"trigger":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"LinkFailureLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureLogic_Output_Direct"},"outgoingEvent":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"LinkFailureTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureLogic_Output_Direct"}}}]}}}]},"firstState":"LinkFailureOrClearedState"}}]}},"tasks":{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"taskMap":{"entry":[{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar oruId = linkFailureInput.get(\"event\").get(\"commonEventHeader\").get(\"sourceName\");\n\nexecutor.outFields.put(\"OruId\", oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar returnValue = true;\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar oruId = linkFailureInput.get(\"event\").get(\"commonEventHeader\").get(\"sourceName\");\nvar oruOduMap = JSON.parse(executor.parameters.get(\"ORU-ODU-Map\"));\n\nif (oruId in oruOduMap) {\n    var oduId = oruOduMap[oruId];\n    executor.outFields.put(\"OruId\", oruId);\n    executor.outFields.put(\"OduId\", oduId);\n    executor.logger.info(executor.outFields);\n} else {\n    executor.message = \"No O-RU found in the config with this ID: \" + oruId;\n    returnValue = false;\n}\n\nreturnValue;"}}},{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"name":"LinkClearedTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar oruId = executor.inFields.get(\"OruId\");\n\nexecutor.outFields.put(\"message\", \"CLEARED link failure for O-RU: \" + oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"name":"LinkFailureTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"LinkFailureOutput","value":{"key":"LinkFailureOutput","fieldSchemaKey":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar linkFailureOutput = executor.subject.getOutFieldSchemaHelper(\"LinkFailureOutput\").createNewInstance();\n\nvar oruId = executor.inFields.get(\"OruId\");\nvar oduId = executor.inFields.get(\"OduId\");\n\nvar unlockMessageArray = new java.util.ArrayList();\nfor (var i = 0; i < 1; i++) {\n    unlockMessageArray.add({\n        \"name\" : oruId,\n        \"administrative_DasH_state\" : \"UNLOCKED\"\n    });\n}\n\nlinkFailureOutput.put(\"o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_du_DasH_to_DasH_ru_DasH_connection\", unlockMessageArray);\nexecutor.outFields.put(\"LinkFailureOutput\", linkFailureOutput.toString());\n\nexecutor.getExecutionProperties().setProperty(\"OduId\", oduId);\nexecutor.getExecutionProperties().setProperty(\"OruId\", oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nexecutor.outFields.put(\"message\", \"No policy defined for this event\");\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}}]}},"events":{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"eventMap":{"entry":[{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"value":{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"DMAAP","target":"APEX","parameter":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"OAM","parameter":{"entry":[{"key":"LinkFailureOutput","value":{"key":"LinkFailureOutput","fieldSchemaKey":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"optional":false}}]}}}]}},"schemas":{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"schemas":{"entry":[{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"schemaFlavour":"Avro","schemaDefinition":"{\n    \"type\": \"record\",\n    \"name\": \"Link_Failure_Input\",\n    \"fields\": [\n        {\n            \"name\": \"event\",\n            \"type\": {\n                \"type\": \"record\",\n                \"name\": \"Event_Type\",\n                \"fields\": [\n                    {\n                        \"name\": \"commonEventHeader\",\n                        \"type\": {\n                            \"type\": \"record\",\n                            \"name\": \"Common_Event_Header_Type\",\n                            \"fields\": [\n                                {\n                                    \"name\": \"domain\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventType\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sequence\",\n                                    \"type\": \"int\"\n                                },\n                                {\n                                    \"name\": \"priority\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"reportingEntityId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"reportingEntityName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sourceId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sourceName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"startEpochMicrosec\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"lastEpochMicrosec\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"nfNamingCode\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"nfVendorName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"timeZoneOffset\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"version\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"vesEventListenerVersion\",\n                                    \"type\": \"string\"\n                                }\n                            ]\n                        }\n                    },\n                    {\n                        \"name\": \"faultFields\",\n                        \"type\": {\n                            \"type\": \"record\",\n                            \"name\": \"Fault_Fields_Type\",\n                            \"fields\": [\n                                {\n                                    \"name\": \"faultFieldsVersion\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmCondition\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmInterfaceA\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventSourceType\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"specificProblem\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventSeverity\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"vfStatus\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmAdditionalInformation\",\n                                    \"type\": {\n                                        \"type\": \"record\",\n                                        \"name\": \"Alarm_Additional_Information_Type\",\n                                        \"fields\": [\n                                            {\n                                                \"name\": \"eventTime\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"equipType\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"vendor\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"model\",\n                                                \"type\": \"string\"\n                                            }\n                                        ]\n                                    }\n                                }\n                            ]\n                        }\n                    }\n                ]\n            }\n        }\n    ]\n}"}},{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"schemaFlavour":"Avro","schemaDefinition":"{\n    \"type\": \"record\",\n    \"name\": \"Link_Failure_Output\",\n    \"fields\": [\n        {\n            \"name\": \"o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_du_DasH_to_DasH_ru_DasH_connection\",\n            \"type\": {\n        \t\"type\": \"array\",\n        \t\"items\": {\n\t\t    \"name\": \"Config_Change_Message\",\n                    \"type\": \"record\",\n                    \"fields\": [\n                        {\n                            \"name\": \"name\",\n                            \"type\": \"string\"\n                        },\n\t\t\t{\n                            \"name\": \"administrative_DasH_state\",\n                            \"type\": \"string\"\n                        }\n                    ]\n                }\n\t    }\n        }\n    ]\n}"}},{"key":{"name":"MessageSchema","version":"0.0.1"},"value":{"key":{"name":"MessageSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"OduIdSchema","version":"0.0.1"},"value":{"key":{"name":"OduIdSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"OruIdSchema","version":"0.0.1"},"value":{"key":{"name":"OruIdSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}}]}}}}},"eventOutputParameters":{"RestProducer":{"carrierTechnologyParameters":{"carrierTechnology":"RESTCLIENT","parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters","parameters":{"url":"http://sdnr-sim:9990/rests/data/network-topology:network-topology/topology=topology-netconf/node={OduId}/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection={OruId}","httpMethod":"PUT","httpHeaders":[["Authorization","Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ=="]]}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"pojoField":"LinkFailureOutput"}},"eventNameFilter":"LinkFailureOutputEvent"},"StdOutProducer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"pojoField":"message"}},"eventNameFilter":"ApexMessageOutputEvent"}},"eventInputParameters":{"DMaaPConsumer":{"carrierTechnologyParameters":{"carrierTechnology":"RESTCLIENT","parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters","parameters":{"url":"http://onap-dmaap:3904/events/unauthenticated.SEC_FAULT_OUTPUT/users/link-monitor-nonrtric?timeout=15000&limit=100"}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"versionAlias":"version","pojoField":"LinkFailureInput"}},"eventName":"LinkFailureInputEvent"}}}}}]}}
\ No newline at end of file
+{"tosca_definitions_version":"tosca_simple_yaml_1_1_0","topology_template":{"policies":[{"onap.policies.native.apex.LinkMonitor":{"type":"onap.policies.native.Apex","type_version":"1.0.0","name":"onap.policies.native.apex.LinkMonitor","version":"1.0.0","properties":{"engineServiceParameters":{"name":"LinkMonitorApexEngine","version":"0.0.1","id":101,"instanceCount":1,"deploymentPort":12345,"engineParameters":{"executorParameters":{"JAVASCRIPT":{"parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"}},"contextParameters":{"parameterClassName":"org.onap.policy.apex.context.parameters.ContextParameters","schemaParameters":{"Avro":{"parameterClassName":"org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"}}},"taskParameters":[{"key":"ORU-ODU-Map","value":"{\"ERICSSON-O-RU-11220\": \"O-DU-1122\",\r\n                               \"ERICSSON-O-RU-11221\": \"O-DU-1122\",\r\n                               \"ERICSSON-O-RU-11222\": \"O-DU-1122\",\r\n                               \"ERICSSON-O-RU-11223\": \"O-DU-1122\",\r\n                               \"ERICSSON-O-RU-11224\": \"O-DU-1123\",\r\n                               \"ERICSSON-O-RU-11225\": \"O-DU-1123\",\r\n                               \"ERICSSON-O-RU-11226\": \"O-DU-1123\",\r\n                               \"ERICSSON-O-RU-11227\": \"O-DU-1124\",\r\n                               \"ERICSSON-O-RU-11228\": \"O-DU-1125\",\r\n                               \"ERICSSON-O-RU-11229\": \"O-DU-1125\"}"}]},"policy_type_impl":{"apexPolicyModel":{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"keyInformation":{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"keyInfoMap":{"entry":[{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"value":{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"UUID":"cca47d74-7754-4a61-b163-ca31f66b157b","description":"Generated description for concept referred to by key \"ApexMessageOutputEvent:0.0.1\""}},{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"UUID":"a295d6a3-1b73-387e-abba-b41e9b608802","description":"Generated description for concept referred to by key \"CreateLinkClearedOutfieldsEvent:0.0.1\""}},{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"UUID":"fd594e88-411d-4a94-b2be-697b3a0d7adf","description":"This task creates the output fields when link failure is cleared."}},{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"UUID":"02be2b5d-45b7-3c54-ae54-97f2b5c30125","description":"Generated description for concept referred to by key \"CreateLinkFailureOutfieldsEvent:0.0.1\""}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"UUID":"ac3d9842-80af-4a98-951c-bd79a431c613","description":"This task the output fields when link failure is detected."}},{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"name":"LinkClearedTask","version":"0.0.1"},"UUID":"eecfde90-896c-4343-8f9c-2603ced94e2d","description":"This task sends a message to the output when link failure is cleared."}},{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"UUID":"c4500941-3f98-4080-a9cc-5b9753ed050b","description":"Generated description for concept referred to by key \"LinkFailureInputEvent:0.0.1\""}},{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"UUID":"3b3974fc-3012-3b02-9f33-c9d8eefe4dc1","description":"Generated description for concept referred to by key \"LinkFailureInputSchema:0.0.1\""}},{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"UUID":"4f04aa98-e917-4f4a-882a-c75ba5a99374","description":"Generated description for concept referred to by key \"LinkFailureOutputEvent:0.0.1\""}},{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"UUID":"2d1a7f6e-eb9a-3984-be1f-283d98111b84","description":"Generated description for concept referred to by key \"LinkFailureOutputSchema:0.0.1\""}},{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"name":"LinkFailureTask","version":"0.0.1"},"UUID":"3351b0f4-cf06-4fa2-8823-edf67bd30223","description":"This task updates the config for O-RU when link failure is detected."}},{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"UUID":"540226fb-55ee-4f0e-a444-983a0494818e","description":"This is the Apex Policy Model for link monitoring."}},{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"UUID":"27ad3e7e-fe3b-3bd6-9081-718705c2bcea","description":"Generated description for concept referred to by key \"LinkMonitorModel_Events:0.0.1\""}},{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"UUID":"ea0b5f58-eefd-358a-9660-840c640bf981","description":"Generated description for concept referred to by key \"LinkMonitorModel_KeyInfo:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"UUID":"ee9e0b0f-2b7d-3ab7-9a98-c5ec05ed823d","description":"Generated description for concept referred to by key \"LinkMonitorModel_Policies:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"UUID":"fa5f9b8f-796c-3c70-84e9-5140c958c4bb","description":"Generated description for concept referred to by key \"LinkMonitorModel_Schemas:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"UUID":"eec592f7-69d5-39a9-981a-e552f787ed01","description":"Generated description for concept referred to by key \"LinkMonitorModel_Tasks:0.0.1\""}},{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"UUID":"6c5e410f-489a-46ff-964e-982ce6e8b6d0","description":"Generated description for concept referred to by key \"LinkMonitorPolicy:0.0.1\""}},{"key":{"name":"MessageSchema","version":"0.0.1"},"value":{"key":{"name":"MessageSchema","version":"0.0.1"},"UUID":"ac4b34ac-39d6-3393-a267-8d5b84854018","description":"A schema for messages from apex"}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"UUID":"d48b619e-d00d-4008-b884-02d76ea4350b","description":"This task sends a message to the output when an event is received for which no policy has been defined."}},{"key":{"name":"OduIdSchema","version":"0.0.1"},"value":{"key":{"name":"OduIdSchema","version":"0.0.1"},"UUID":"50662174-a88b-3cbd-91bd-8e91b40b2660","description":"A schema for O-DU-ID"}},{"key":{"name":"OruIdSchema","version":"0.0.1"},"value":{"key":{"name":"OruIdSchema","version":"0.0.1"},"UUID":"54daf32b-015f-39cd-8530-a1175c5553e9","description":"A schema for O-RU-ID"}}]}},"policies":{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"policyMap":{"entry":[{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"value":{"policyKey":{"name":"LinkMonitorPolicy","version":"0.0.1"},"template":"Freestyle","state":{"entry":[{"key":"LinkClearedState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkClearedState"},"trigger":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"LinkClearedLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedLogic_Output_Direct"},"outgoingEvent":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"LinkClearedTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedLogic_Output_Direct"}}}]}}},{"key":"LinkFailureOrClearedState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureOrClearedState"},"trigger":{"name":"LinkFailureInputEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"CreateLinkClearedOutfieldsLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsLogic_Output_Direct"},"outgoingEvent":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"nextState":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkClearedState"}}},{"key":"CreateLinkFailureOutfieldsLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsLogic_Output_Direct"},"outgoingEvent":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"nextState":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureState"}}},{"key":"NoPolicyDefinedLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedLogic_Output_Direct"},"outgoingEvent":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"TaskSelectionLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Selection Execution: '\"+executor.subject.id+\n    \"'. InputFields: '\"+executor.inFields+\"'\");\n\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar commonEventHeader = linkFailureInput.get(\"event\").get(\"commonEventHeader\");\nvar domain = commonEventHeader.get(\"domain\");\n\ntaskFailure = executor.subject.getTaskKey(\"CreateLinkFailureOutfieldsTask\");\ntaskCleared = executor.subject.getTaskKey(\"CreateLinkClearedOutfieldsTask\");\ntaskDefault = executor.subject.getDefaultTaskKey();\n\nif (domain == \"fault\") {\n    var faultFields = linkFailureInput.get(\"event\").get(\"faultFields\");\n    var alarmCondition = faultFields.get(\"alarmCondition\");\n    var eventSeverity = faultFields.get(\"eventSeverity\");\n    if (alarmCondition == \"28\" && eventSeverity != \"NORMAL\") {\n        taskFailure.copyTo(executor.selectedTask);\n    } else if (alarmCondition == \"28\" && eventSeverity == \"NORMAL\") {\n        taskCleared.copyTo(executor.selectedTask);\n    } else {\n        taskDefault.copyTo(executor.selectedTask);\n    }\n} else {\n    taskDefault.copyTo(executor.selectedTask);\n}\n\ntrue;"},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsLogic_Output_Direct"}}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsLogic_Output_Direct"}}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedLogic_Output_Direct"}}}]}}},{"key":"LinkFailureState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureState"},"trigger":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"LinkFailureLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureLogic_Output_Direct"},"outgoingEvent":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"LinkFailureTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureLogic_Output_Direct"}}}]}}}]},"firstState":"LinkFailureOrClearedState"}}]}},"tasks":{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"taskMap":{"entry":[{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar oruId = linkFailureInput.get(\"event\").get(\"commonEventHeader\").get(\"sourceName\");\n\nexecutor.outFields.put(\"OruId\", oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar returnValue = true;\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar oruId = linkFailureInput.get(\"event\").get(\"commonEventHeader\").get(\"sourceName\");\nvar oruOduMap = JSON.parse(executor.parameters.get(\"ORU-ODU-Map\"));\n\nif (oruId in oruOduMap) {\n    var oduId = oruOduMap[oruId];\n    executor.outFields.put(\"OruId\", oruId);\n    executor.outFields.put(\"OduId\", oduId);\n    executor.logger.info(executor.outFields);\n} else {\n    executor.message = \"No O-RU found in the config with this ID: \" + oruId;\n    returnValue = false;\n}\n\nreturnValue;"}}},{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"name":"LinkClearedTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar oruId = executor.inFields.get(\"OruId\");\n\nexecutor.outFields.put(\"message\", \"CLEARED link failure for O-RU: \" + oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"name":"LinkFailureTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"LinkFailureOutput","value":{"key":"LinkFailureOutput","fieldSchemaKey":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar linkFailureOutput = executor.subject.getOutFieldSchemaHelper(\"LinkFailureOutput\").createNewInstance();\n\nvar oruId = executor.inFields.get(\"OruId\");\nvar oduId = executor.inFields.get(\"OduId\");\n\nvar unlockMessageArray = new java.util.ArrayList();\nfor (var i = 0; i < 1; i++) {\n    unlockMessageArray.add({\n            \"id\":\"rrm-pol-1\",\n            \"radio_DasH_resource_DasH_management_DasH_policy_DasH_max_DasH_ratio\":25,\n            \"radio_DasH_resource_DasH_management_DasH_policy_DasH_members\":\n                [\n                    {\n                        \"mobile_DasH_country_DasH_code\":\"310\",\n                        \"mobile_DasH_network_DasH_code\":\"150\",\n                        \"slice_DasH_differentiator\":1,\n                        \"slice_DasH_service_DasH_type\":1\n                    }\n                ],\n            \"radio_DasH_resource_DasH_management_DasH_policy_DasH_min_DasH_ratio\":15,\n            \"user_DasH_label\":\"rrm-pol-1\",\n            \"resource_DasH_type\":\"prb\",\n            \"radio_DasH_resource_DasH_management_DasH_policy_DasH_dedicated_DasH_ratio\":20,\n            \"administrative_DasH_state\":\"unlocked\"\n        });\n}\n\nlinkFailureOutput.put(\"o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_radio_DasH_resource_DasH_management_DasH_policy_DasH_ratio\", unlockMessageArray);\nexecutor.outFields.put(\"LinkFailureOutput\", linkFailureOutput.toString());\n\nexecutor.getExecutionProperties().setProperty(\"OduId\", oduId);\nexecutor.getExecutionProperties().setProperty(\"OruId\", oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nexecutor.outFields.put(\"message\", \"No policy defined for this event\");\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}}]}},"events":{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"eventMap":{"entry":[{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"value":{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"DMAAP","target":"APEX","parameter":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"OAM","parameter":{"entry":[{"key":"LinkFailureOutput","value":{"key":"LinkFailureOutput","fieldSchemaKey":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"optional":false}}]}}}]}},"schemas":{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"schemas":{"entry":[{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"schemaFlavour":"Avro","schemaDefinition":"{\n    \"type\": \"record\",\n    \"name\": \"Link_Failure_Input\",\n    \"fields\": [\n        {\n            \"name\": \"event\",\n            \"type\": {\n                \"type\": \"record\",\n                \"name\": \"Event_Type\",\n                \"fields\": [\n                    {\n                        \"name\": \"commonEventHeader\",\n                        \"type\": {\n                            \"type\": \"record\",\n                            \"name\": \"Common_Event_Header_Type\",\n                            \"fields\": [\n                                {\n                                    \"name\": \"domain\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventType\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sequence\",\n                                    \"type\": \"int\"\n                                },\n                                {\n                                    \"name\": \"priority\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"reportingEntityId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"reportingEntityName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sourceId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sourceName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"startEpochMicrosec\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"lastEpochMicrosec\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"nfNamingCode\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"nfVendorName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"timeZoneOffset\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"version\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"vesEventListenerVersion\",\n                                    \"type\": \"string\"\n                                }\n                            ]\n                        }\n                    },\n                    {\n                        \"name\": \"faultFields\",\n                        \"type\": {\n                            \"type\": \"record\",\n                            \"name\": \"Fault_Fields_Type\",\n                            \"fields\": [\n                                {\n                                    \"name\": \"faultFieldsVersion\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmCondition\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmInterfaceA\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventSourceType\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"specificProblem\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventSeverity\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"vfStatus\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmAdditionalInformation\",\n                                    \"type\": {\n                                        \"type\": \"record\",\n                                        \"name\": \"Alarm_Additional_Information_Type\",\n                                        \"fields\": [\n                                            {\n                                                \"name\": \"eventTime\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"equipType\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"vendor\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"model\",\n                                                \"type\": \"string\"\n                                            }\n                                        ]\n                                    }\n                                }\n                            ]\n                        }\n                    }\n                ]\n            }\n        }\n    ]\n}"}},{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"schemaFlavour":"Avro","schemaDefinition":"{\n  \"name\": \"Link_Failure_Output\",\n  \"type\": \"record\",\n  \"fields\": [\n    {\n      \"name\": \"o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_radio_DasH_resource_DasH_management_DasH_policy_DasH_ratio\",\n      \"type\": {\n        \"type\": \"array\",\n        \"items\": {\n          \"name\": \"o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_radio_DasH_resource_DasH_management_DasH_policy_DasH_ratio_record\",\n          \"type\": \"record\",\n          \"fields\": [\n            {\n              \"name\": \"id\",\n              \"type\": \"string\"\n            },\n            {\n              \"name\": \"radio_DasH_resource_DasH_management_DasH_policy_DasH_max_DasH_ratio\",\n              \"type\": \"int\"\n            },\n            {\n              \"name\": \"radio_DasH_resource_DasH_management_DasH_policy_DasH_members\",\n              \"type\": {\n                \"type\": \"array\",\n                \"items\": {\n                  \"name\": \"radio_DasH_resource_DasH_management_DasH_policy_DasH_members_record\",\n                  \"type\": \"record\",\n                  \"fields\": [\n                    {\n                      \"name\": \"mobile_DasH_country_DasH_code\",\n                      \"type\": \"string\"\n                    },\n                    {\n                      \"name\": \"mobile_DasH_network_DasH_code\",\n                      \"type\": \"string\"\n                    },\n                    {\n                      \"name\": \"slice_DasH_differentiator\",\n                      \"type\": \"int\"\n                    },\n                    {\n                      \"name\": \"slice_DasH_service_DasH_type\",\n                      \"type\": \"int\"\n                    }\n                  ]\n                }\n              }\n            },\n            {\n              \"name\": \"radio_DasH_resource_DasH_management_DasH_policy_DasH_min_DasH_ratio\",\n              \"type\": \"int\"\n            },\n            {\n              \"name\": \"user_DasH_label\",\n              \"type\": \"string\"\n            },\n            {\n              \"name\": \"resource_DasH_type\",\n              \"type\": \"string\"\n            },\n            {\n              \"name\": \"radio_DasH_resource_DasH_management_DasH_policy_DasH_dedicated_DasH_ratio\",\n              \"type\": \"int\"\n            },\n            {\n              \"name\": \"administrative_DasH_state\",\n              \"type\": \"string\"\n            }\n          ]\n        }\n      }\n    }\n  ]\n}"}},{"key":{"name":"MessageSchema","version":"0.0.1"},"value":{"key":{"name":"MessageSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"OduIdSchema","version":"0.0.1"},"value":{"key":{"name":"OduIdSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"OruIdSchema","version":"0.0.1"},"value":{"key":{"name":"OruIdSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}}]}}}}},"eventOutputParameters":{"RestProducer":{"carrierTechnologyParameters":{"carrierTechnology":"RESTCLIENT","parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters","parameters":{"url":"http://sdnr-sim:9990/rests/data/network-topology:network-topology/topology=topology-netconf/node={OduId}/yang-ext:mount/o-ran-sc-du-hello-world:network-function/distributed-unit-functions={OduId}/radio-resource-management-policy-ratio=rrm-pol-1","httpMethod":"PUT","httpHeaders":[["Authorization","Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ=="]]}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"pojoField":"LinkFailureOutput"}},"eventNameFilter":"LinkFailureOutputEvent"},"StdOutProducer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"pojoField":"message"}},"eventNameFilter":"ApexMessageOutputEvent"}},"eventInputParameters":{"DMaaPConsumer":{"carrierTechnologyParameters":{"carrierTechnology":"RESTCLIENT","parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters","parameters":{"url":"http://onap-dmaap:3904/events/unauthenticated.SEC_FAULT_OUTPUT/users/link-monitor-nonrtric?timeout=15000&limit=100"}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"versionAlias":"version","pojoField":"LinkFailureInput"}},"eventName":"LinkFailureInputEvent"}}}}}]}}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 16fd06a..ea79c33
@@ -28,12 +28,26 @@ var oduId = executor.inFields.get("OduId");
 var unlockMessageArray = new java.util.ArrayList();
 for (var i = 0; i < 1; i++) {
     unlockMessageArray.add({
-        "name" : oruId,
-        "administrative_DasH_state" : "UNLOCKED"
-    });
+            "id":"rrm-pol-1",
+            "radio_DasH_resource_DasH_management_DasH_policy_DasH_max_DasH_ratio":25,
+            "radio_DasH_resource_DasH_management_DasH_policy_DasH_members":
+                [
+                    {
+                        "mobile_DasH_country_DasH_code":"310",
+                        "mobile_DasH_network_DasH_code":"150",
+                        "slice_DasH_differentiator":1,
+                        "slice_DasH_service_DasH_type":1
+                    }
+                ],
+            "radio_DasH_resource_DasH_management_DasH_policy_DasH_min_DasH_ratio":15,
+            "user_DasH_label":"rrm-pol-1",
+            "resource_DasH_type":"prb",
+            "radio_DasH_resource_DasH_management_DasH_policy_DasH_dedicated_DasH_ratio":20,
+            "administrative_DasH_state":"unlocked"
+        });
 }
 
-linkFailureOutput.put("o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_du_DasH_to_DasH_ru_DasH_connection", unlockMessageArray);
+linkFailureOutput.put("o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_radio_DasH_resource_DasH_management_DasH_policy_DasH_ratio", unlockMessageArray);
 executor.outFields.put("LinkFailureOutput", linkFailureOutput.toString());
 
 executor.getExecutionProperties().setProperty("OduId", oduId);
old mode 100644 (file)
new mode 100755 (executable)
index fb144a1..c423047
@@ -1,26 +1,74 @@
 {
-    "type": "record",
-    "name": "Link_Failure_Output",
-    "fields": [
-        {
-            "name": "o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_du_DasH_to_DasH_ru_DasH_connection",
-            "type": {
-               "type": "array",
-               "items": {
-                   "name": "Config_Change_Message",
-                    "type": "record",
-                    "fields": [
-                        {
-                            "name": "name",
-                            "type": "string"
-                        },
-                       {
-                            "name": "administrative_DasH_state",
-                            "type": "string"
-                        }
-                    ]
+  "name": "Link_Failure_Output",
+  "type": "record",
+  "fields": [
+    {
+      "name": "o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_radio_DasH_resource_DasH_management_DasH_policy_DasH_ratio",
+      "type": {
+        "type": "array",
+        "items": {
+          "name": "o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_radio_DasH_resource_DasH_management_DasH_policy_DasH_ratio_record",
+          "type": "record",
+          "fields": [
+            {
+              "name": "id",
+              "type": "string"
+            },
+            {
+              "name": "radio_DasH_resource_DasH_management_DasH_policy_DasH_max_DasH_ratio",
+              "type": "int"
+            },
+            {
+              "name": "radio_DasH_resource_DasH_management_DasH_policy_DasH_members",
+              "type": {
+                "type": "array",
+                "items": {
+                  "name": "radio_DasH_resource_DasH_management_DasH_policy_DasH_members_record",
+                  "type": "record",
+                  "fields": [
+                    {
+                      "name": "mobile_DasH_country_DasH_code",
+                      "type": "string"
+                    },
+                    {
+                      "name": "mobile_DasH_network_DasH_code",
+                      "type": "string"
+                    },
+                    {
+                      "name": "slice_DasH_differentiator",
+                      "type": "int"
+                    },
+                    {
+                      "name": "slice_DasH_service_DasH_type",
+                      "type": "int"
+                    }
+                  ]
                 }
-           }
+              }
+            },
+            {
+              "name": "radio_DasH_resource_DasH_management_DasH_policy_DasH_min_DasH_ratio",
+              "type": "int"
+            },
+            {
+              "name": "user_DasH_label",
+              "type": "string"
+            },
+            {
+              "name": "resource_DasH_type",
+              "type": "string"
+            },
+            {
+              "name": "radio_DasH_resource_DasH_management_DasH_policy_DasH_dedicated_DasH_ratio",
+              "type": "int"
+            },
+            {
+              "name": "administrative_DasH_state",
+              "type": "string"
+            }
+          ]
         }
-    ]
-}
+      }
+    }
+  ]
+}
\ No newline at end of file