--- /dev/null
+#==================================================================================
+# Copyright (C) 2022: 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.
+#
+#==================================================================================
+##
+## Build
+##
+FROM nexus3.o-ran-sc.org:10001/golang:1.17-bullseye AS build
+
+WORKDIR /app
+
+COPY go.mod ./
+COPY go.sum ./
+RUN go mod download
+
+COPY . ./
+
+RUN go build -o /rappconsumer-sliceassurance
+
+##
+## Deploy
+##
+FROM gcr.io/distroless/base-debian10
+
+WORKDIR /
+
+## Copy from "build" stage
+COPY --from=build /rappconsumer-sliceassurance .
+
+USER nonroot:nonroot
+
+ENTRYPOINT ["/rappconsumer-sliceassurance"]
\ No newline at end of file
--- /dev/null
+# Copyright (C) 2022 Nordix Foundation. All rights reserved.
+# ========================================================================
+# 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=================================================
+#
+
+##
+## Build
+##
+FROM golang:1.17.1-bullseye AS build
+
+WORKDIR /app
+
+COPY . ./
+
+RUN go build -o /prod-sdnr-sim ./stub/prodSdnc
+
+##
+## Deploy
+##
+FROM gcr.io/distroless/base-debian10
+
+WORKDIR /
+
+## Copy from "build" stage
+COPY --from=build /prod-sdnr-sim .
+COPY --from=build /app/stub/prodSdnc/test-data.csv .
+
+USER nonroot:nonroot
+
+ENTRYPOINT ["/prod-sdnr-sim"]
--- /dev/null
+# Copyright (C) 2022 Nordix Foundation. All rights reserved.
+# ========================================================================
+# 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=================================================
+#
+
+##
+## Build
+##
+FROM golang:1.17.1-bullseye AS build
+
+WORKDIR /app
+
+COPY . ./
+
+RUN go build -o /ics ./stub/ics/
+
+##
+## Deploy
+##
+FROM gcr.io/distroless/base-debian10
+
+WORKDIR /
+
+## Copy from "build" stage
+COPY --from=build /ics .
+
+USER nonroot:nonroot
+
+ENTRYPOINT ["/ics"]
--- /dev/null
+# Copyright (C) 2022 Nordix Foundation. All rights reserved.
+# ========================================================================
+# 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=================================================
+#
+version: '3.5'
+
+networks:
+ default:
+ driver: bridge
+ name: nonrtric-docker-net
+
+services:
+ ics:
+ build:
+ context: .
+ dockerfile: Dockerfile-ics
+ container_name: ics-sim
+ networks:
+ default:
+ aliases:
+ - ics-sim
+ ports:
+ - 8083:8083
+ environment:
+ - PRODUCER_ADDR=http://prod-sdnr-sim:3905/
+
+ prod-sdnr-sim:
+ build:
+ context: .
+ dockerfile: Dockerfile-ProdSdnc
+ container_name: prod-sdnr-sim
+ networks:
+ default:
+ aliases:
+ - prod-sdnr-sim
+ ports:
+ - 3904:3904
+ - 3905:3905
+ environment:
+ - ODU_ADDR=http://consumer-sa:8095
+
+ consumer-sa:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ container_name: consumer-sa
+ networks:
+ default:
+ aliases:
+ - consumer-sa
+ ports:
+ - 8095:8095
+ environment:
+ - SDNR_USER=admin
+ - SDNR_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+ - CONSUMER_HOST=http://consumer-sa
+ - CONSUMER_PORT=8095
+ - INFO_COORD_ADDR=http://ics-sim:8083
+ - SDNR_ADDR=http://prod-sdnr-sim:3904
+ - LOG_LEVEL=Debug
\ No newline at end of file
require (
github.com/gorilla/mux v1.8.0
github.com/sirupsen/logrus v1.8.1
+ github.com/stretchr/testify v1.2.2
)
-require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // 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-20191026070338-33540a1f6037 // indirect
+)
jobId = "14e7bb84-a44d-44c1-90b7-6995a92ad83d"
)
+var jobRegistrationInfo = struct {
+ InfoTypeID string `json:"info_type_id"`
+ JobResultURI string `json:"job_result_uri"`
+ JobOwner string `json:"job_owner"`
+ JobDefinition interface{} `json:"job_definition"`
+}{
+ InfoTypeID: "Performance_Measurement_Streaming",
+ JobResultURI: "",
+ JobOwner: "O-DU Slice Assurance Usecase",
+ JobDefinition: "{}",
+}
+
type App struct {
client *restclient.Client
data *structures.SliceAssuranceMeas
func (a *App) Initialize(config *config.Configuration) {
consumerPort = fmt.Sprint(config.ConsumerPort)
+ jobRegistrationInfo.JobResultURI = config.ConsumerHost + ":" + consumerPort
sdnrConfig = SdnrConfiguration{
SDNRAddress: config.SDNRAddress,
func (a *App) startHandler(w http.ResponseWriter, r *http.Request) {
log.Debug("startHandler: Register job in ICS.")
- jobRegistrationInfo := struct {
- InfoTypeID string `json:"info_type_id"`
- JobResultURI string `json:"job_result_uri"`
- JobOwner string `json:"job_owner"`
- JobDefinition interface{} `json:"job_definition"`
- }{
- InfoTypeID: "Performance_Measurement_Streaming",
- JobResultURI: "",
- JobOwner: "O-DU Slice Assurance Usecase",
- JobDefinition: "{}",
- }
+
putErr := a.client.Put(icsAddr+"/data-consumer/v1/info-jobs/"+jobId, jobRegistrationInfo, nil)
if putErr != nil {
http.Error(w, fmt.Sprintf("Unable to register consumer job due to: %v.", putErr), http.StatusBadRequest)
var configuration *config.Configuration
var a sliceassurance.App
-const TOPIC string = "/events/unauthenticated.VES_O_RAN_SC_HELLO_WORLD_PM_STREAMING_OUTPUT/myG/C1"
-
func main() {
configuration = config.New()
}
func handleCalls(w http.ResponseWriter, r *http.Request) {
- producer_addr := getEnv("PRODUCER_ADDR", "http://localhost:3905/")
+ producer_addr := getEnv("PRODUCER_ADDR", "http://prod-sdnr-sim:3905/")
vars := mux.Vars(r)
id, ok := vars["jobId"]
if ok {
rand.Seed(time.Now().UnixNano())
portSdnr := flag.Int("sdnr-port", 3904, "The port this SDNR stub will listen on")
- dmaapProducerPort := flag.Int("dmaap-port", 3905, "The port this Dmaap mediator will listen on")
+ producerPort := flag.Int("prod-port", 3905, "The port this Producer mediator will listen on")
flag.Parse()
loadData()
r.HandleFunc("/create/{jobId}", createJobHandler).Methods(http.MethodPut)
r.HandleFunc("/delete/{jobId}", deleteJobHandler).Methods(http.MethodDelete)
- fmt.Println("Producer listening on port: ", *dmaapProducerPort)
+ fmt.Println("Producer listening on port: ", *producerPort)
- log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", *dmaapProducerPort), r))
+ log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", *producerPort), r))
wg.Done()
}()
}
func createJobHandler(w http.ResponseWriter, r *http.Request) {
- fmt.Println("createJobHandler:: ", r)
vars := mux.Vars(r)
id, ok := vars["jobId"]
if !ok {
time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
- oru_addr := getEnv("ORU_ADDR", "http://localhost:8095")
- req, _ := http.NewRequest(http.MethodPost, oru_addr, bytes.NewBuffer(msgToSend))
+ odu_addr := getEnv("ODU_ADDR", "http://consumer-sa:8095")
+ req, _ := http.NewRequest(http.MethodPost, odu_addr, bytes.NewBuffer(msgToSend))
req.Header.Set("Content-Type", "application/json; charset=utf-8")
_, err := client.Do(req)