From: Balint Uveges Date: Tue, 2 Apr 2019 20:31:11 +0000 (+0000) Subject: Seed code for Routing Manager (ric-plt/rtmgr). X-Git-Tag: v0.1.0~2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=871fa393844ce1b61b8d5218d27687d9fc05803a;p=ric-plt%2Frtmgr.git Seed code for Routing Manager (ric-plt/rtmgr). Change-Id: I2f255043d81564550ea9bbc5f3d082346910eb0d Signed-off-by: Balint Uveges --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..70b84df --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.gitreview diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6b47299 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,18 @@ +# Conntribution milestones + +_NOTE: recommendations for developing internally. should be updated accordingly after opensourcing_ + +## RECOMMENDATIONS + +* **Try to keep workig code in master** +* **Use gofmt** +* **In case of upstream import, try to use exact release instead of master code** + +## WORKFLOW + +* Create branch from master for your feature/bugfix +* Apply changes +* Add tests +* Update corresponding README.md +* Open a merge request to master +* Provide the RLEASE NOTES in the request diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..593a0ef --- /dev/null +++ b/LICENSE @@ -0,0 +1,31 @@ +================================================================================== +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the "Software License"); +you may not use this software except in compliance with the Software +License. You may obtain a copy of the Software License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the Software License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the Software License for the specific language governing permissions +and limitations under the Software License. + +================================================================================== + +Unless otherwise specified, all documentation contained herein is licensed +under the Creative Commons License, Attribution 4.0 Intl. (the +"Documentation License"); you may not use this documentation except in +compliance with the Documentation License. You may obtain a copy of the +Documentation License at + +https://creativecommons.org/licenses/by/4.0/ + +Unless required by applicable law or agreed to in writing, documentation +distributed under the Documentation License is distributed on an "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied. See the Documentation License for the specific language governing +permissions and limitations under the Documentation License. +================================================================================== + diff --git a/README.md b/README.md new file mode 100644 index 0000000..41a767d --- /dev/null +++ b/README.md @@ -0,0 +1,114 @@ +# Routing Manager + +## Table of contents +* [Introduction](#introduction) +* [Release notes](#release-notes) +* [Prerequisites](#prerequisites) +* [Project folders structure](#project-folders-structure) +* [Installation guide](#installation-guide) + * [Compiling code](#compiling-code) + * [Building docker container](#building-docker-container) + * [Installing Routing Manager](#installing-routing-manager) + * [Testing and Troubleshoting](#testing-and-troubleshoting) +* [Upcoming changes](#upcoming-changes) +* [License](#license) + +## Introduction +__Routing Manager__ is a basic platform serive of RIC. It is responsible for distributing routing policies among the other platform components and xApps. + +The implemented logic periodically queries the xApp Manager component for xApps' list. Stores the data then processes it to create routing policies and distributes them to all xApps. +The architecture consists of the following five well defined functions: +* NorthBound Interface (__NBI__): Maintains the communication channels towards RIC manager components +* Routing Policy Engine (__RPE__): Provides the logic to calculate routing policies +* Shared Data Layer (__SDL__): Provides access to different kind persistent data stores +* SouthBound Interface (__SBI__): Maintains the communication channels towards RIC tenants and control components +* Controll Logic (__RTMGR__): Controls the operatin of above functions + +Current implementation provides support for the followings: +* NBI: + * __httpGet__: simple HTTP GET interface. Expects an URL where it gets the xApps' list in JSON format + * (WIP) __httRESTful__: provides REST API endpoints towards RIC manager components +* RPE: + * __rmr__: creates routing policies formatted for RIC RMR +* SDL: + * __file__: stores xApp data in container's local filesystem (or in a mountpoint) + * (backlog) __sdl__: Shared Data Library to Redis database +* SBI: + * __nngpub__: distributes RPE created policies via NNG Pub channel + * (WIP) __nngpipe__: distributes RPE created policies via NNG Pipeline channel + +## Release notes +Check the separated `RELNOTES` file. + +## Prerequisites +* Healthy kubernetes cluster +* Access to the common docker registry + +## Project folder structure +* /api: contains swagger source files +* /build: contains build tools (scripts, Dockerfiles, etc.) +* /manifest: contains deployment files (kubernetes manifests, helm chart) +* /cmd: contains go project's main file +* /pkg: contains go project's internal packages +* /test: contains CI/CD testing files (scripts, mocks, manifests) + +## Installation guide + +### Compiling code +Enter the project root and execute `./build.sh` script. +The build script has two main phases. First is the code compilation, where it creates a temporary container for downloading all dependencies then compiles the code. In the second phase it builds the production ready container and taggs it to `rtmgr:builder` +**NOTE:** The script puts a copy of the binary into the `./bin` folder for further use cases + +### Installing Routing Manager +#### Preparing environment +Re-Tag the `rtmgr` container according to the project release and push it to a registry accessible from all minions of the kubernetes cluster. +Edit the container image section of `rtmgr-dep.yaml` file according to the `rtmgr` image tag + +#### Deploying Routing Manager +Issue the `kubectl create -f {manifest.yaml}` command in the following order + 1. `manifests/namespaces.yaml`: creates the `example` namespace for routing-manager resources + 2. `manifests/rtmgr/rtmgr-dep.yaml`: instantiates the `rtmgr` deployment in the `example` namespace + 3. `manifests/rtmgr/rtmgr-svc.yaml`: creates the `rtmgr` service in `example` namespace + +### Testing and Troubleshoting +Routing Manager's behaviour can be tested using the mocked xApp Manager, traffic generator xApp and receiver xApp. + + 1. Checkout and compile both xApp receiver and xApp Tx generator of RIC admission control project + 2. Copy the `adm-ctrl-xapp` binary to `./test/docker/xapp.build` folder. Enter the folder and issue `docker build .`. Tag the recently created docker image and push it to the common registry. + 3. Copy the `test-tx` binary to `./test/docker/xapp-tx.build` folder. Enter the folder and issue `docker build .`. Tag the recently created docker image and push it to the common registry. + 4. Enter the `./test/docker/xmgr.build` folder and issue `docker build .`. Tag the recently created docker image and push it to the common registry. + 5. Modify the the docker image version in each kuberbetes manifest files under `./test/kubernetes/` folder accordingly then issue the `kubectl create -f {manifest.yaml}` on each file. + 6. [Compile](#compiling-code) and [Install routing manager](#installing-routing-manager) + +#### Command line arguments +Routing manager binary can be called with `-h` flag when it displays the available command line arguments and it's default value. + +Example: + +```bash +root@a3684ff4cdb0:/# ./rtmgr -h +Usage of ./rtmgr: + -loglevel string + INFO | WARN | ERROR | DEBUG (default "INFO") + -nbi-httpget string + xApp Manager URL (default "http://localhost:3000/xapps") + -rpe string + Policy Engine Module name (default "rmr") + -sbi-nngsub string + NNG Subsciption Socket URI (default "tcp://0.0.0.0:4560") + -sdl-file string + Local file store location (default "/db/rt.json") +``` + +For troubleshooting purpose the default logging level can be increased to `DEBUG`. + +## Upcoming changes +[] Add RESTful NBI based on swagger api definition + +[] Support RMR Pipeline + +[] Add unit tests + +## License +This project is licensed under the Apache License, Version 2.0 - see the [LICENSE](LICENSE) + diff --git a/RELNOTES b/RELNOTES new file mode 100644 index 0000000..51808fb --- /dev/null +++ b/RELNOTES @@ -0,0 +1,15 @@ +### v0.0.3 +* RMR Policy Engine has been refactored to handle receiving groups properly +* Debugging feature has been added +* Multi level logging +* A complex JSON file has been added to xApp Manager to test new behavior + +### v0.0.2 +* RTMGR (Routing Manager) implementation in Golang +* Updated project folder structure +* Integration manifests + +### v0.0.1 +* Initial version of Routing Manager for CI/CD pipeline +* Dummy solution: still has no real routing capability +* Container is based on the _**tx**_ version of [admin xApp](http://gerrit.ranco-dev-tools.eastus.cloudapp.azure.com/ric-app/admin.git) which already implements [RMR library]( http://gerrit.ranco-dev-tools.eastus.cloudapp.azure.com/ric-plt/lib/rmr.git) \ No newline at end of file diff --git a/api/routing_manager.yaml b/api/routing_manager.yaml new file mode 100644 index 0000000..11f09a3 --- /dev/null +++ b/api/routing_manager.yaml @@ -0,0 +1,317 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Routing Manager's RESTful API definition +# Date: 29 March 2019 +# +swagger: "2.0" +info: + title: Routing Manager + description: "This is the Swagger/OpenAPI 2.0 definition of Routing Manager's Northbound API." + version: "0.2.2" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +host: "rtmgr" +basePath: "/v1" +tags: +- name: "handle" + description: "Available handles" +# externalDocs: +# description: "Find out more" +# url: "http://127.0.0.1" +- name: "route" + description: "Available routes" +- name: "health" + description: "Health of the system" +schemes: +- "https" +- "http" +paths: + /health: + get: + tags: + - "health" + summary: "Retrive the health of Routing Manager" + description: "By performing a GET method on the health resource, the API caller is able to retrieve the health of Routing Manager" + operationId: "get_health" + consumes: + - "application/json" +# - "application/yaml" + produces: + - "application/json" +# - "application/yaml" + responses: + 200: + description: "The health of the system" + schema: + "$ref": "#/definitions/health-status" + /handles: + get: + tags: + - "handle" + summary: "Placeholder for further usage" + description: "Placeholder for further usage." + operationId: "get_handles" + consumes: + - "application/json" +# - "application/yaml" + produces: + - "application/json" +# - "application/yaml" + responses: + 200: + description: "Dummy response" + /handles/xapp-handle: + post: + tags: + - "handle" + summary: "Provide callback" + description: "By performing a POST method on the xapp-handle resource, the API caller is able to perform a callback on Routing Manager." + operationId: "provide_xapp_handle" + consumes: + - "application/json" +# - "application/yaml" + produces: + - "application/json" +# - "application/yaml" + parameters: + - in: "body" + name: "xapp-callback-data" + description: "xApp related callback data" + required: true + schema: + $ref: "#/definitions/xapp-callback-data" + responses: + 400: + description: "Invalid data" + 201: + description: "Callback received" + /routes: + post: + tags: + - "route" + summary: "Add new route" + description: "By performing a POST method on the routes resource, the API caller is able to create a new route." + operationId: "add_route" + consumes: + - "application/json" +# - "application/yaml" + produces: + - "application/json" +# - "application/yaml" + parameters: + - in: "body" + name: "route" + description: "Route object that needs to be created" + required: true + schema: + $ref: "#/definitions/route" + responses: + 400: + description: "Invalid route" + 201: + description: "Route created" + put: + tags: + - "route" + summary: "Update an existing route" + description: "By performing a PUT method on the routes resource, the API caller is able to update an already existing route." + operationId: "update_route" + consumes: + - "application/json" +# - "application/yaml" + produces: + - "application/json" +# - "application/yaml" + parameters: + - in: "body" + name: "route" + description: "Route object that needs to be updated or created" + required: true + schema: + $ref: "#/definitions/route" + responses: + 400: + description: "Invalid route ID supplied" + 404: + description: "Route not found" + 204: + description: "Route updated" + get: + tags: + - "route" + summary: "Retrieve the list of routes" + description: "By performing a GET method on the routes resource, the API caller is able to retrieve all routes" + operationId: "get_routes" + consumes: + - "application/json" +# - "application/yaml" + produces: + - "application/json" +# - "application/yaml" + responses: + 200: + description: "All the routes" + schema: + $ref: "#/definitions/routes" + + /routes/{route-id}: + get: + tags: + - "route" + summary: "Find route by ID" + description: "Returns a single route" + operationId: "get_route_by_id" + produces: + - "application/json" + parameters: + - name: "route-id" + in: "path" + description: "ID of route to return" + required: true + type: "integer" + format: "int64" + responses: + 200: + description: "successful operation" + schema: + $ref: "#/definitions/route" + 400: + description: "Invalid route ID supplied" + 404: + description: "Route not found" + put: + tags: + - "route" + summary: "Updates a route by explicitly referencing it by route-id" + description: "By performing a PUT method on a specific route referenced by the route-id the API caller is able to update that specific route" + operationId: "update-route-by-id" + consumes: + - "application/json" +# - "application/yaml" + produces: + - "application/json" +# - "application/yaml" + parameters: + - name: "route-id" + in: "path" + description: "ID of route that needs to be updated" + required: true + type: "integer" + format: "int64" + - name: "route" + in: "body" + description: "The updated route instance" + required: false + schema: + $ref: "#/definitions/route" + responses: + 400: + description: "Invalid route ID supplied" + 204: + description: "Route updated" + delete: + tags: + - "route" + summary: "Deletes a route" + description: "By performing a DELETE method on a specific route referenced by the route-id, the API caller is able to delete that specific route" + operationId: "delete_route_by_id" + produces: + - "application/json" +# - "application/yaml" + parameters: + - name: "route-id" + in: "path" + description: "ID of the route that needs to be deleted" + required: true + type: "integer" + format: "int64" + responses: + 400: + description: "Invalid route ID supplied" + 404: + description: "Route not found" + 204: + description: "Route deleted" +definitions: + health-status: + type: "object" + properties: + status: + type: string + enum: + - healthy + - unhealthy + routes: + type: "array" + items: + $ref: "#/definitions/route" + route: + type: "object" + required: + - "id" # not so sure about that + properties: + id: + type: "integer" + format: "int64" + senders: + type: "array" + items: + "$ref": "#/definitions/xapp-instance" + message-type: + type: "integer" + format: "int64" + receiver-groups: + type: "array" + items: + "$ref": "#/definitions/xapp-group" + xapp-instance: + type: "object" + required: + - "address" + - "port" + properties: + address: + type: "string" # I know... + port: + type: "integer" + format: "int32" + minimum: 0 + maximum: 65535 + xapp-group: + type: "array" + items: + "$ref": "#/definitions/xapp-instance" + xapp-callback-data: + type: "object" + properties: + id: + type: "integer" + format: "int64" + event: + type: "string" + data-version: + type: "integer" + format: "int64" + data: + type: "string" #This should be a JSON object, array of xapps +externalDocs: + description: "Routing Manager" + url: "http://placeholder" diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..e8482e9 --- /dev/null +++ b/build.sh @@ -0,0 +1,39 @@ +#!/bin/sh -e +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Mnemonic: build.sh +# Abstract: Compiles the rtmgr source and builds the docker container +# Date: 12 March 2019 +# + +echo 'Creating compiler container' +docker build --no-cache --tag=rtmgr_compiler:0.1 build/binary/ + +echo 'Running rtmgr compiler' +docker run --rm --name=rtmgr_compiler -v ${PWD}:/opt/ rtmgr_compiler:0.1 + +echo 'Cleaning up compiler container' +docker rmi -f rtmgr_compiler:0.1 + +echo 'rtmgr binary successfully built!' + +echo 'Creating rtmgr container' +cp ${PWD}/bin/* ${PWD}/build/container/ +docker build --no-cache --tag=rtmgr:builder build/container/ diff --git a/build/binary/Dockerfile b/build/binary/Dockerfile new file mode 100644 index 0000000..7930f00 --- /dev/null +++ b/build/binary/Dockerfile @@ -0,0 +1,32 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Builds a container to compile Routing Manager's code +# Date: 29 March 2019 +# +FROM golang:1.11 + +ENV GOPATH /opt + +RUN apt-get update \ + && apt-get install golang-glide + +COPY compile.sh / + +ENTRYPOINT /compile.sh diff --git a/build/binary/compile.sh b/build/binary/compile.sh new file mode 100755 index 0000000..35d8640 --- /dev/null +++ b/build/binary/compile.sh @@ -0,0 +1,31 @@ +#!/bin/sh -e +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Mnemonic: compile.sh +# Abstract: Compiles the rtmgr source +# Date: 19 March 2019 +# +mkdir -p $GOPATH/bin +ln -s -f $GOPATH/pkg $GOPATH/src +cd $GOPATH/src +glide install --strip-vendor +cd $GOPATH/cmd +go build rtmgr.go +mv $GOPATH/cmd/rtmgr $GOPATH/bin diff --git a/build/container/Dockerfile b/build/container/Dockerfile new file mode 100644 index 0000000..98582b9 --- /dev/null +++ b/build/container/Dockerfile @@ -0,0 +1,29 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Builds the Routing Manager's production ready container image +# Date: 29 March 2019 +# + +FROM ubuntu + +COPY rtmgr / +COPY run_rtmgr.sh / +RUN mkdir /db \ + && touch /db/rt.json diff --git a/build/container/run_rtmgr.sh b/build/container/run_rtmgr.sh new file mode 100755 index 0000000..d248edd --- /dev/null +++ b/build/container/run_rtmgr.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Mnemonic: run_rtmgr.sh +# Abstract: Runs the rtmgr executable with proper arguments +# Date: 19 March 2019 +# +exec ./rtmgr -nbi-httpget=$XMURL -sbi-nngsub=$SOCKET -sdl-file=$RTFILE -rpe=$RPE -loglevel=INFO diff --git a/cmd/rtmgr.go b/cmd/rtmgr.go new file mode 100644 index 0000000..e4f76d8 --- /dev/null +++ b/cmd/rtmgr.go @@ -0,0 +1,125 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: rtmgr.go + Abstract: Routing Manager Main file. Implemets the following functions: + - parseArgs: reading command line arguments + - init:Rtmgr initializing the service modules + - serve: running the loop + Date: 12 March 2019 +*/ +package main + +import ( + "flag" + "nbi" + "os" + "rpe" + "rtmgr" + "sbi" + "sdl" + "time" +) + +const SERVICENAME = "rtmgr" +const INTERVAL time.Duration = 2 + +var ( + args *map[string]string +) + +func parseArgs() { + a := make(map[string]string) + xmgeturl := flag.String("nbi-httpget", "http://localhost:3000/xapps", "xApp Manager URL") + nngpubsock := flag.String("sbi-nngsub", "tcp://0.0.0.0:4560", "NNG Subsciption Socket URI") + file := flag.String("sdl-file", "/db/rt.json", "Local file store location") + rpename := flag.String("rpe", "rmr", "Policy Engine Module name") + loglevel := flag.String("loglevel", "INFO", "INFO | WARN | ERROR | DEBUG") + flag.Parse() + if (*xmgeturl) != "" { + a["xmurl"] = (*xmgeturl) + a["nbiname"] = "httpGetter" + } + if (*nngpubsock) != "" { + a["socketuri"] = (*nngpubsock) + a["sbiname"] = "nngpub" + } + if (*file) != "" { + a["file"] = (*file) + a["sdlname"] = "file" + } + a["rpename"] = (*rpename) + a["loglevel"] = (*loglevel) + args = &a +} + +func initRtmgr() (*nbi.NbiEngineConfig, *sbi.SbiEngineConfig, *sdl.SdlEngineConfig, *rpe.RpeEngineConfig, error) { + var err error + if nbi, err := nbi.GetNbi((*args)["nbiname"]); err == nil && nbi != nil { + if sbi, err := sbi.GetSbi((*args)["sbiname"]); err == nil && sbi != nil { + if sdl, err := sdl.GetSdl((*args)["sdlname"]); err == nil && sdl != nil { + if rpe, err := rpe.GetRpe((*args)["rpename"]); err == nil && rpe != nil { + return nbi, sbi, sdl, rpe, nil + } + } + } + } + return nil, nil, nil, nil, err +} + +func serve(nbi *nbi.NbiEngineConfig, sbi *sbi.SbiEngineConfig, sdl *sdl.SdlEngineConfig, rpe *rpe.RpeEngineConfig) { + err := sbi.OpenSocket((*args)["socketuri"]) + if err != nil { + rtmgr.Logger.Info("fail to open pub socket due to: " + err.Error()) + return + } + defer sbi.CloseSocket() + for { + time.Sleep(INTERVAL * time.Second) + data, err := nbi.BatchFetch((*args)["xmurl"]) + if err != nil { + rtmgr.Logger.Error("cannot get data from " + nbi.Engine.Name + " interface dute to: " + err.Error()) + } else { + sdl.WriteAll((*args)["file"], data) + } + data, err = sdl.ReadAll((*args)["file"]) + if err != nil || data == nil { + rtmgr.Logger.Error("cannot get data from " + sdl.Engine.Name + " interface dute to: " + err.Error()) + continue + } + policies := rpe.GeneratePolicies(data) + err = sbi.DistributeAll(policies) + if err != nil { + rtmgr.Logger.Error("routing rable cannot be published due to: " + err.Error()) + } + } +} + +func main() { + parseArgs() + rtmgr.SetLogLevel((*args)["loglevel"]) + nbi, sbi, sdl, rpe, err := initRtmgr() + if err != nil { + rtmgr.Logger.Error(err.Error()) + os.Exit(1) + } + rtmgr.Logger.Info("Start " + SERVICENAME + " service") + serve(nbi, sbi, sdl, rpe) + os.Exit(0) +} diff --git a/manifests/namespace.yaml b/manifests/namespace.yaml new file mode 100644 index 0000000..9414a35 --- /dev/null +++ b/manifests/namespace.yaml @@ -0,0 +1,27 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Creates a dedicated namespace for Routing Manager deployment and related stuff +# Date: 29 March 2019 +# +apiVersion: v1 +kind: Namespace +metadata: + name: example + diff --git a/manifests/rtmgr/rtmgr-dep.yaml b/manifests/rtmgr/rtmgr-dep.yaml new file mode 100644 index 0000000..6916582 --- /dev/null +++ b/manifests/rtmgr/rtmgr-dep.yaml @@ -0,0 +1,52 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Routing Manager Kubernetes manifest +# Date: 29 March 2019 +# +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rtmgr + namespace: example +spec: + replicas: 1 + selector: + matchLabels: + app: rtmgr + template: + metadata: + labels: + app: rtmgr + spec: + containers: + - name: rtmgr + image: cmaster:5000/rtmgr:0.0.3 + command: ["/run_rtmgr.sh"] + env: + - name: XMURL + value: "http://xmgr:3000/xapps" + - name: SOCKET + value: "tcp://0.0.0.0:4560" + - name: RTFILE + value: "/db/rt.json" + - name: RPE + value: "rmr" + ports: + - containerPort: 4560 diff --git a/manifests/rtmgr/rtmgr-svc.yaml b/manifests/rtmgr/rtmgr-svc.yaml new file mode 100644 index 0000000..78674be --- /dev/null +++ b/manifests/rtmgr/rtmgr-svc.yaml @@ -0,0 +1,36 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Routing Manager service manifest +# Date: 29 March 2019 +# +kind: Service +apiVersion: v1 +metadata: + name: rtmgr + namespace: example +spec: + selector: + app: rtmgr + clusterIP: None + ports: + - name: nngpub + port: 4560 + protocol: TCP + diff --git a/pkg/glide.lock b/pkg/glide.lock new file mode 100644 index 0000000..1e8baeb --- /dev/null +++ b/pkg/glide.lock @@ -0,0 +1,52 @@ +hash: 8a251805c06cd6f4f20b276425eabe314968e2ad14fb32525fc93c53c2cfe845 +updated: 2019-03-26T04:13:15.650927387Z +imports: +- name: github.com/droundy/goopt + version: 0b8effe182da161d81b011aba271507324ecb7ab +- name: github.com/gorilla/websocket + version: 66b9c49e59c6c48f0ffce28c2d8b8a5678502c6d +- name: github.com/jcelliott/lumber + version: dd349441af25132d146d7095c6693a15431fc9b1 +- name: github.com/Microsoft/go-winio + version: 1a8911d1ed007260465c3bfbbc785ac6915a0bb8 +- name: golang.org/x/sys + version: f49334f85ddcf0f08d7fb6dd7363e9e6d6b777eb + subpackages: + - windows +- name: nanomsg.org/go/mangos/v2 + version: 63f66a65137b9a648ac9f7bf0160b4a4d17d7999 + subpackages: + - errors + - internal/core + - protocol + - protocol/bus + - protocol/pair + - protocol/pub + - protocol/pull + - protocol/push + - protocol/rep + - protocol/req + - protocol/respondent + - protocol/star + - protocol/sub + - protocol/surveyor + - protocol/xbus + - protocol/xpair + - protocol/xpub + - protocol/xpull + - protocol/xpush + - protocol/xrep + - protocol/xstar + - transport + - transport/all + - transport/inproc + - transport/ipc + - transport/tcp + - transport/tlstcp + - transport/ws + - transport/wss +testImports: +- name: github.com/smartystreets/goconvey + version: 200a235640ff2643e3126834b67f3e93df76640a + subpackages: + - convey diff --git a/pkg/glide.yaml b/pkg/glide.yaml new file mode 100644 index 0000000..c7dd74c --- /dev/null +++ b/pkg/glide.yaml @@ -0,0 +1,67 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Glide config for dependency management +# Date: 29 March 2019 +# +package: . +import: +- package: github.com/Microsoft/go-winio + version: v0.4.12 +- package: github.com/droundy/goopt +- package: github.com/gorilla/websocket + version: v1.4.0 +- package: nanomsg.org/go/mangos/v2 + version: v2.0.2 + subpackages: + - errors + - internal/core + - protocol + - protocol/bus + - protocol/pair + - protocol/pub + - protocol/pull + - protocol/push + - protocol/rep + - protocol/req + - protocol/respondent + - protocol/star + - protocol/sub + - protocol/surveyor + - protocol/xbus + - protocol/xpair + - protocol/xpub + - protocol/xpull + - protocol/xpush + - protocol/xrep + - protocol/xstar + - transport + - transport/all + - transport/inproc + - transport/ipc + - transport/tcp + - transport/tlstcp + - transport/ws + - transport/wss +ignore: +- rtmgr +testImport: +- package: github.com/smartystreets/goconvey + subpackages: + - convey diff --git a/pkg/nbi/httpgetter.go b/pkg/nbi/httpgetter.go new file mode 100644 index 0000000..6780403 --- /dev/null +++ b/pkg/nbi/httpgetter.go @@ -0,0 +1,50 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: httpgetter.go + Abstract: HTTPgetter NBI implementation + Simple HTTP getter solution. Only for testing purpose. + Date: 15 March 2019 +*/ + +package nbi + +import ( + "encoding/json" + "net/http" + "rtmgr" + "time" +) + +var myClient = &http.Client{Timeout: 1 * time.Second} + +func fetchXappList(url string) (*[]rtmgr.XApp, error) { + rtmgr.Logger.Debug("Invoked httpgetter.fetchXappList") + r, err := myClient.Get(url) + if err != nil { + return nil, err + } + defer r.Body.Close() + rtmgr.Logger.Debug("http client raw response: %v", r) + var xapps []rtmgr.XApp + json.NewDecoder(r.Body).Decode(&xapps) + rtmgr.Logger.Info("HTTP GET: OK") + rtmgr.Logger.Debug("httpgetter.fetchXappList returns: %v", xapps) + return &xapps, err +} diff --git a/pkg/nbi/nbi.go b/pkg/nbi/nbi.go new file mode 100644 index 0000000..cb19e71 --- /dev/null +++ b/pkg/nbi/nbi.go @@ -0,0 +1,81 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: nbi.go + Abstract: Contains NBI (NorthBound Interface) module definitions and generic NBI components + Date: 12 March 2019 +*/ + +package nbi + +import ( + "errors" + "fmt" + "rtmgr" +) + +var ( + SupportedNbis = []*NbiEngineConfig{ + &NbiEngineConfig{ + NbiEngine{ + Name: "httpGetter", + Version: "v1", + Protocol: "http", + }, + batchFetch(fetchXappList), + true, + }, + &NbiEngineConfig{ + NbiEngine{ + Name: "httpRESTful", + Version: "v1", + Protocol: "http", + }, + batchFetch(nil), + false, + }, + &NbiEngineConfig{ + NbiEngine{ + Name: "gRPC", + Version: "v1", + Protocol: "http2", + }, + batchFetch(nil), + false, + }, + } +) + +func ListNbis() { + fmt.Printf("NBI:\n") + for _, nbi := range SupportedNbis { + if nbi.IsAvailable { + rtmgr.Logger.Info(nbi.Engine.Name + "/" + nbi.Engine.Version) + } + } +} + +func GetNbi(nbiName string) (*NbiEngineConfig, error) { + for _, nbi := range SupportedNbis { + if nbi.Engine.Name == nbiName && nbi.IsAvailable { + return nbi, nil + } + } + return nil, errors.New("NBI:" + nbiName + "is not supported or still not a available") +} diff --git a/pkg/nbi/types.go b/pkg/nbi/types.go new file mode 100644 index 0000000..e02c30d --- /dev/null +++ b/pkg/nbi/types.go @@ -0,0 +1,41 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: nbi.go + Abstract: Containes NBI (NorthBound Interface) specific types + Date: 12 March 2019 +*/ + +package nbi + +import "rtmgr" + +type batchFetch func(url string) (*[]rtmgr.XApp, error) + +type NbiEngine struct { + Name string + Version string + Protocol string +} + +type NbiEngineConfig struct { + Engine NbiEngine + BatchFetch batchFetch + IsAvailable bool +} diff --git a/pkg/rpe/rmr.go b/pkg/rpe/rmr.go new file mode 100644 index 0000000..a4bf776 --- /dev/null +++ b/pkg/rpe/rmr.go @@ -0,0 +1,67 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: rmr.go + Abstract: RMR Route Policy implementation + Produces RMR (RIC Management Routing) formatted route messages + Date: 16 March 2019 +*/ + +package rpe + +import "rtmgr" + +/* +Produces the raw route message consumable by RMR +*/ +func generateRMRPolicies(xapps *[]rtmgr.XApp) *[]string { + rtmgr.Logger.Debug("Invoked rmr.generateRMRPolicies") + rtmgr.Logger.Debug("args: %v", (*xapps)) + key := "00000 " + rawrt := []string{key + "newrt|start\n"} + rt := getRouteTable(xapps) + for _, rte := range *rt { + rawrte := key + "rte|" + rte.MessageType + for _, tx := range rte.TxList { + rawrte += "," + tx.IpSocket + } + rawrte += "|" + group := "" + for _, rxg := range rte.RxGroups { + member := "" + for _, rx := range rxg { + if member == "" { + member += rx.IpSocket + } else { + member += "," + rx.IpSocket + } + } + if group == "" { + group += member + } else { + group += ";" + member + } + } + rawrte += group + rawrt = append(rawrt, rawrte+"\n") + } + rawrt = append(rawrt, key+"newrt|end\n") + rtmgr.Logger.Debug("rmr.generateRMRPolicies returns: %v", rawrt) + return &rawrt +} diff --git a/pkg/rpe/rpe.go b/pkg/rpe/rpe.go new file mode 100644 index 0000000..f915ddd --- /dev/null +++ b/pkg/rpe/rpe.go @@ -0,0 +1,123 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: rpe.go + Abstract: Contains RPE (Route Policy Engine) module definitions and generic RPE components + Date: 16 March 2019 +*/ + +package rpe + +import ( + "errors" + "fmt" + "rtmgr" + "strconv" +) + +var ( + SupportedRpes = []*RpeEngineConfig{ + &RpeEngineConfig{ + RpeEngine{ + Name: "rmr", + Version: "v1", + Protocol: "rmruta", + }, + generatePolicies(generateRMRPolicies), + true, + }, + } +) + +func ListRpes() { + fmt.Printf("RPE:\n") + for _, rpe := range SupportedRpes { + if rpe.IsAvailable { + rtmgr.Logger.Info(rpe.Engine.Name + "/" + rpe.Engine.Version) + } + } +} + +func GetRpe(rpeName string) (*RpeEngineConfig, error) { + for _, rpe := range SupportedRpes { + if rpe.Engine.Name == rpeName && rpe.IsAvailable { + return rpe, nil + } + } + return nil, errors.New("SBI:" + rpeName + "is not supported or still not a available") +} + +/* +Gets the raw xApp list and generates the list of sender endpoints and receiver endpoint groups +Returns the Tx EndpointList map where the key is the messge type and also returns the nested map of Rx EndpointList's map where keys are message type and xapp type +Endpoint object's message type already transcoded to integer id +*/ +func getEndpointLists(xapps *[]rtmgr.XApp) (*map[string]rtmgr.EndpointList, *map[string]map[string]rtmgr.EndpointList) { + txlist := make(map[string]rtmgr.EndpointList) + rxgroups := make(map[string]map[string]rtmgr.EndpointList) + for _, xapp := range *xapps { + for _, instance := range xapp.Instances { + ep := rtmgr.Endpoint{ + instance.Name, + xapp.Name, + instance.Ip + ":" + strconv.Itoa(instance.Port), + } + for _, message := range instance.RxMessages { + messageid := rtmgr.MESSAGETYPES[message] + if _, ok := rxgroups[messageid]; !ok { + rxgroups[messageid] = make(map[string]rtmgr.EndpointList) + } + rxgroups[messageid][xapp.Name] = append(rxgroups[messageid][xapp.Name], ep) + } + for _, message := range instance.TxMessages { + messageid := rtmgr.MESSAGETYPES[message] + txlist[messageid] = append(txlist[messageid], ep) + } + } + } + return &txlist, &rxgroups +} + +/* +Gets the raw xapp list and creates a route table for +Returns the array of route table entries +*/ +func getRouteTable(xapps *[]rtmgr.XApp) *rtmgr.RouteTable { + tx, rx := getEndpointLists(xapps) + var rt rtmgr.RouteTable + for _, messagetype := range rtmgr.MESSAGETYPES { + if _, ok := (*tx)[messagetype]; !ok { + continue + } + if _, ok := (*rx)[messagetype]; !ok { + continue + } + var rxgroups []rtmgr.EndpointList + for _, endpointlist := range (*rx)[messagetype] { + rxgroups = append(rxgroups, endpointlist) + } + rte := rtmgr.RouteTableEntry{ + messagetype, + (*tx)[messagetype], + rxgroups, + } + rt = append(rt, rte) + } + return &rt +} diff --git a/pkg/rpe/types.go b/pkg/rpe/types.go new file mode 100644 index 0000000..69f01c4 --- /dev/null +++ b/pkg/rpe/types.go @@ -0,0 +1,41 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: rpe/types.go + Abstract: Containes RPE (Route Policy Engine) specific types + Date: 12 March 2019 +*/ + +package rpe + +import "rtmgr" + +type generatePolicies func(*[]rtmgr.XApp) (*[]string) + +type RpeEngine struct { + Name string + Version string + Protocol string +} + +type RpeEngineConfig struct { + Engine RpeEngine + GeneratePolicies generatePolicies + IsAvailable bool +} diff --git a/pkg/rtmgr/rtmgr.go b/pkg/rtmgr/rtmgr.go new file mode 100644 index 0000000..d5d3fc5 --- /dev/null +++ b/pkg/rtmgr/rtmgr.go @@ -0,0 +1,70 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: rtmgr/rtmgr.go + Abstract: Containes RTMGR (Routing Manager) module's generic variables and functions + Date: 26 March 2019 +*/ + +package rtmgr + +import ( + "github.com/jcelliott/lumber" +) + +var ( + //TODO: temporary solution + // CamelCase Message Types are for being able to test with old fashioned admin controll xApps + MESSAGETYPES = map[string]string{ + "HandoverPreparation": "0", + "HandoverCancel": "1", + "LoadIndication": "2", + "ErrorIndication": "3", + "SNStatusTransfer": "4", + "UEContextRelease": "5", + "X2Setup": "6", + "Reset": "7", + "RIC_X2_SETUP": "10000", + "RIC_X2_RESPONSE": "10001", + "RIC_X2_RESOURCE_STATUS_REQUEST": "10002", + "RIC_X2_RESOURCE_STATUS_RESPONSE": "10003", + "RIC_X2_LOAD_INFORMATION": "10004", + "RIC_E2_TERMINATION_HC_REQUEST": "10005", + "RIC_E2_TERMINATION_HC_RESPONSE": "10006", + "RIC_E2_MANAGER_HC_REQUEST": "10007", + "RIC_E2_MANAGER_HC_RESPONSE": "10008", + "RIC_CONTROL_XAPP_CONFIG_REQUEST": "100000", + "RIC_CONTROL_XAPP_CONFIG_RESPONSE": "100001", + } + Logger = lumber.NewConsoleLogger(lumber.INFO) +) + +func SetLogLevel(loglevel string) { + switch loglevel { + case "INFO": + Logger.Level(lumber.INFO) + case "WARN": + Logger.Level(lumber.WARN) + case "ERROR": + Logger.Level(lumber.ERROR) + case "DEBUG": + Logger.Info("debugmode") + Logger.Level(lumber.DEBUG) + } +} diff --git a/pkg/rtmgr/types.go b/pkg/rtmgr/types.go new file mode 100644 index 0000000..0fa9dd1 --- /dev/null +++ b/pkg/rtmgr/types.go @@ -0,0 +1,61 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: rtmgr/types.go + Abstract: Containes RTMGR (Routing Manager) specific types + Date: 12 March 2019 +*/ + +package rtmgr + +type Endpoint struct { + Name string + Type string + IpSocket string +} + +type XApps struct { + XApplist []XApp +} + +type RouteTable []RouteTableEntry + +type EndpointList []Endpoint + +type RouteTableEntry struct { + MessageType string + TxList EndpointList + RxGroups []EndpointList +} + +type XApp struct { + Name string `json:"name"` + Status string `json:"status"` + Version string `json:"version"` + Instances []XAppInstance `json:"instances"` +} + +type XAppInstance struct { + Name string `json:"name"` + Status string `json:"status"` + Ip string `json:"ip"` + Port int `json:"port"` + TxMessages []string `json:"txMessages"` + RxMessages []string `json:"rxMessages"` +} diff --git a/pkg/sbi/nngpub.go b/pkg/sbi/nngpub.go new file mode 100644 index 0000000..02e4ebf --- /dev/null +++ b/pkg/sbi/nngpub.go @@ -0,0 +1,68 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: nngpub.go + Abstract: mangos (NNG) Pub/Sub SBI implementation + Date: 12 March 2019 +*/ + +package sbi + +import ( + "errors" + "nanomsg.org/go/mangos/v2" + "nanomsg.org/go/mangos/v2/protocol/pub" + _ "nanomsg.org/go/mangos/v2/transport/all" + "rtmgr" + "strconv" +) + +var sock mangos.Socket + +/* +Creates the NNG publication channel +*/ +func openNngPub(url string) error { + var err error + if sock, err = pub.NewSocket(); err != nil { + return errors.New("can't get new pub socket due to:" + err.Error()) + } + rtmgr.Logger.Info("publishing on: " + url) + if err = sock.Listen(url); err != nil { + return errors.New("can't publish on socket " + url + " due to:" + err.Error()) + } + return nil +} + +func closeNngPub() error { + if err := sock.Close(); err != nil { + return errors.New("can't close socket due to:" + err.Error()) + } + return nil +} + +func publishAll(policies *[]string) error { + for _, pe := range *policies { + if err := sock.Send([]byte(pe)); err != nil { + return errors.New("Unable to send policy entry due to: " + err.Error()) + } + } + rtmgr.Logger.Info("NNG PUB: OK (# of Entries:" + strconv.Itoa(len((*policies))) + ")") + return nil +} diff --git a/pkg/sbi/sbi.go b/pkg/sbi/sbi.go new file mode 100644 index 0000000..a2da825 --- /dev/null +++ b/pkg/sbi/sbi.go @@ -0,0 +1,76 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: sbi.go + Abstract: Contains SBI (SouthBound Interface) module definitions and generic SBI components + Date: 16 March 2019 +*/ + +package sbi + +import ( + "errors" + "fmt" + "rtmgr" +) + +var ( + SupportedSbis = []*SbiEngineConfig{ + &SbiEngineConfig{ + SbiEngine{ + Name: "nngpub", + Version: "v1", + Protocol: "nngpubsub", + }, + openSocket(openNngPub), + closeSocket(closeNngPub), + distributeAll(publishAll), + true, + }, + &SbiEngineConfig{ + SbiEngine{ + Name: "nngpush", + Version: "v1", + Protocol: "nngpipeline", + }, + openSocket(nil), + closeSocket(nil), + distributeAll(nil), + false, + }, + } +) + +func ListSbis() { + fmt.Printf("SBI:\n") + for _, sbi := range SupportedSbis { + if sbi.IsAvailable { + rtmgr.Logger.Info(sbi.Engine.Name + "/" + sbi.Engine.Version) + } + } +} + +func GetSbi(sbiName string) (*SbiEngineConfig, error) { + for _, sbi := range SupportedSbis { + if sbi.Engine.Name == sbiName && sbi.IsAvailable { + return sbi, nil + } + } + return nil, errors.New("SBI:" + sbiName + "is not supported or still not a available") +} diff --git a/pkg/sbi/types.go b/pkg/sbi/types.go new file mode 100644 index 0000000..1254e93 --- /dev/null +++ b/pkg/sbi/types.go @@ -0,0 +1,43 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: sbi/types.go + Abstract: Containes SBI (SouthBound Interface) specific types + Date: 16 March 2019 +*/ + +package sbi + +type distributeAll func(*[]string) error +type openSocket func(string) error +type closeSocket func() error + +type SbiEngine struct { + Name string + Version string + Protocol string +} + +type SbiEngineConfig struct { + Engine SbiEngine + OpenSocket openSocket + CloseSocket closeSocket + DistributeAll distributeAll + IsAvailable bool +} diff --git a/pkg/sdl/file.go b/pkg/sdl/file.go new file mode 100644 index 0000000..11c3350 --- /dev/null +++ b/pkg/sdl/file.go @@ -0,0 +1,74 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: file.go + Abstract: File SDL implementation. Only for testing purpose. + Date: 16 March 2019 +*/ + +package sdl + +import ( + "encoding/json" + "errors" + "io/ioutil" + "os" + "rtmgr" +) + +/* +Reads the content of the rt.json file +Parses the JSON content and loads each xApp entry into an xApp object +Returns an array os xApp object +*/ +func fileReadAll(file string) (*[]rtmgr.XApp, error) { + rtmgr.Logger.Debug("Invoked file.fileReadAll") + rtmgr.Logger.Debug("file.fileReadAll opens file: " + file) + var xapps *[]rtmgr.XApp + jsonFile, err := os.Open(file) + if err != nil { + return nil, errors.New("cannot open the file due to: " + err.Error()) + } + defer jsonFile.Close() + byteValue, err := ioutil.ReadAll(jsonFile) + if err != nil { + return nil, errors.New("cannot read the file due to: " + err.Error()) + } + err = json.Unmarshal(byteValue, &xapps) + if err != nil { + return nil, errors.New("cannot parse data due to: " + err.Error()) + } + rtmgr.Logger.Debug("file.fileReadAll returns: %v", xapps) + return xapps, nil +} + +func fileWriteAll(file string, xapps *[]rtmgr.XApp) error { + rtmgr.Logger.Debug("Invoked file.fileWriteAll") + rtmgr.Logger.Debug("file.fileWriteAll writes into file: " + file) + rtmgr.Logger.Debug("file.fileWriteAll writes data: %v", (*xapps)) + byteValue, err := json.Marshal(xapps) + if err != nil { + return errors.New("cannot convert data due to: " + err.Error()) + } + err = ioutil.WriteFile(file, byteValue, 0644) + if err != nil { + return errors.New("cannot write file due to: " + err.Error()) + } + return nil +} diff --git a/pkg/sdl/sdl.go b/pkg/sdl/sdl.go new file mode 100644 index 0000000..097b983 --- /dev/null +++ b/pkg/sdl/sdl.go @@ -0,0 +1,74 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: sdl.go + Abstract: Contains SDL (Shared Data Layer) module definitions and generic SDL components + Date: 16 March 2019 +*/ + +package sdl + +import ( + "errors" + "fmt" + "rtmgr" +) + +var ( + SupportedSdls = []*SdlEngineConfig{ + &SdlEngineConfig{ + SdlEngine{ + Name: "file", + Version: "v1", + Protocol: "rawfile", + }, + readAll(fileReadAll), + writeAll(fileWriteAll), + true, + }, + &SdlEngineConfig{ + SdlEngine{ + Name: "redis", + Version: "v1", + Protocol: "nsdl", + }, + readAll(nil), + writeAll(nil), + false, + }, + } +) + +func ListSdls() { + fmt.Printf("SDL:\n") + for _, sdl := range SupportedSdls { + if sdl.IsAvailable { + rtmgr.Logger.Info(sdl.Engine.Name + "/" + sdl.Engine.Version) + } + } +} + +func GetSdl(sdlName string) (*SdlEngineConfig, error) { + for _, sdl := range SupportedSdls { + if sdl.Engine.Name == sdlName && sdl.IsAvailable { + return sdl, nil + } + } + return nil, errors.New("SDL:" + sdlName + "is not supported or still not a available") +} diff --git a/pkg/sdl/types.go b/pkg/sdl/types.go new file mode 100644 index 0000000..961c88e --- /dev/null +++ b/pkg/sdl/types.go @@ -0,0 +1,42 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ +/* + Mnemonic: sdl/types.go + Abstract: Containes SDL (Shared Data Layer) specific types + Date: 16 March 2019 +*/ +package sdl + +import "rtmgr" + +type readAll func(string) (*[]rtmgr.XApp, error) +type writeAll func(string, *[]rtmgr.XApp) error + +type SdlEngine struct { + Name string + Version string + Protocol string +} + +type SdlEngineConfig struct { + Engine SdlEngine + ReadAll readAll + WriteAll writeAll + IsAvailable bool +} diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..3fa3c89 --- /dev/null +++ b/test/README.md @@ -0,0 +1 @@ +Examples or Testing Scripts/Manifests/Sample data \ No newline at end of file diff --git a/test/data/rt.json b/test/data/rt.json new file mode 100644 index 0000000..db80193 --- /dev/null +++ b/test/data/rt.json @@ -0,0 +1 @@ +[{"name":"xapp-01","status":"unknown","version":"1.2.3","instances":[{"name":"xapp-01-instance-01","status":"pending","ip":"172.16.1.103","port":4555,"txMessages":["ControlIndication"],"rxMessages":["LoadIndication","Reset"]},{"name":"xapp-01-instance-02","status":"pending","ip":"10.244.1.12","port":4561,"txMessages":["ControlIndication","SNStatusTransfer"],"rxMessages":["LoadIndication","HandoverPreparation"]}]},{"name":"xapp-02","status":"unknown","version":"1.2.3","instances":[{"name":"xapp-02-instance-01","status":"pending","ip":"192.168.2.1","port":32300,"txMessages":["ControlIndication"],"rxMessages":["LoadIndication"]},{"name":"xapp-02-instance-02","status":"pending","ip":"192.168.2.2","port":32300,"txMessages":["ControlIndication"],"rxMessages":["LoadIndication"]}]}] \ No newline at end of file diff --git a/test/docker/xapp-tx.build/Dockerfile b/test/docker/xapp-tx.build/Dockerfile new file mode 100644 index 0000000..de783dc --- /dev/null +++ b/test/docker/xapp-tx.build/Dockerfile @@ -0,0 +1,29 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Builds container image for Test Tx xApp +# Date: 29 March 2019 +# +FROM ubuntu + +COPY usr/local/lib/* /usr/local/lib/ +COPY usr/local/include/* /usr/local/include/ +COPY test-tx / +COPY run_test-tx.sh / +RUN ldconfig diff --git a/test/docker/xapp-tx.build/run_test-tx.sh b/test/docker/xapp-tx.build/run_test-tx.sh new file mode 100755 index 0000000..c50201a --- /dev/null +++ b/test/docker/xapp-tx.build/run_test-tx.sh @@ -0,0 +1,31 @@ +#! /bin/sh -e +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Mnemonic: run_test-tx.sh +# Abstract: Runs the TX transmitter xApp with proper arguments +# Date: 19 March 2019 +# +NAME=${NAME} +PORT=${PORT} +RATE=${RATE} +MESSAGE_TYPE=0 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib + +exec /test-tx -n $NAME -p $PORT -r $RATE -m $MESSAGE_TYPE diff --git a/test/docker/xapp.build/Dockerfile b/test/docker/xapp.build/Dockerfile new file mode 100644 index 0000000..2aff362 --- /dev/null +++ b/test/docker/xapp.build/Dockerfile @@ -0,0 +1,29 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Builds container image for Test xApp +# Date: 29 March 2019 +# +FROM ubuntu + +COPY usr/local/lib/* /usr/local/lib/ +COPY usr/local/include/* /usr/local/include/ +COPY adm-ctrl-xapp / +COPY run_xapp.sh / +RUN ldconfig diff --git a/test/docker/xapp.build/run_xapp.sh b/test/docker/xapp.build/run_xapp.sh new file mode 100755 index 0000000..c2e952a --- /dev/null +++ b/test/docker/xapp.build/run_xapp.sh @@ -0,0 +1,38 @@ +#!/bin/sh -e +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Mnemonic: run_xapp.sh +# Abstract: Runs the listener xApp with proper arguments +# Date: 19 March 2019 +# + +NAME=${NAME} +PORT=${PORT} +THREADS=${THREADS} +VERBOSE=${VERBOSE} +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib + +if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" -ge "1" ]; +then + exec /adm-ctrl-xapp -n $NAME -p $PORT -t $THREADS --verbose +else + exec /adm-ctrl-xapp -n $NAME -p $PORT -t $THREADS +fi; + diff --git a/test/docker/xmgr.build/Dockerfile b/test/docker/xmgr.build/Dockerfile new file mode 100644 index 0000000..ac8d2b9 --- /dev/null +++ b/test/docker/xmgr.build/Dockerfile @@ -0,0 +1,25 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Builds container image for Test xApp Manager +# Date: 29 March 2019 +# +FROM node + +RUN npm install -g json-server diff --git a/test/kubernetes/xapp-tx/xapp-tx.yaml b/test/kubernetes/xapp-tx/xapp-tx.yaml new file mode 100644 index 0000000..ea02211 --- /dev/null +++ b/test/kubernetes/xapp-tx/xapp-tx.yaml @@ -0,0 +1,53 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Test Tx xApp manifest +# Date: 29 March 2019 +# +apiVersion: apps/v1 +kind: Deployment +metadata: + name: xapptx + namespace: example +spec: + replicas: 1 + selector: + matchLabels: + app: xapptx + template: + metadata: + labels: + app: xapptx + spec: + containers: + - name: xapptx + image: cmaster:5000/xapp-tx:0.0.2 + args: + - /run_test-tx.sh + ports: + - containerPort: 4555 + env: + - name: NAME + value: "RM" + - name: PORT + value: "tcp:4555" + - name: RATE + value: "10" + - name: RMR_RTG_SVC + value: "rtmgr:4560" diff --git a/test/kubernetes/xapp/xapp.yaml b/test/kubernetes/xapp/xapp.yaml new file mode 100644 index 0000000..34dc5a3 --- /dev/null +++ b/test/kubernetes/xapp/xapp.yaml @@ -0,0 +1,55 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Test xApp Kubernetes manifest +# Date: 29 March 2019 +# +apiVersion: apps/v1 +kind: Deployment +metadata: + name: xapp + namespace: example +spec: + replicas: 1 + selector: + matchLabels: + app: xapp + template: + metadata: + labels: + app: xapp + spec: + containers: + - name: xapp + image: cmaster:5000/xapp:0.0.2 + args: + - /run_xapp.sh + ports: + - containerPort: 4561 + env: + - name: NAME + value: "XAPP" + - name: PORT + value: "tcp:4561" + - name: THREADS + value: "1" + - name: VERBOSE + value: "1" + - name: RMR_RTG_SVC + value: "rtmgr:4560" diff --git a/test/kubernetes/xmgr/xmgr-cfg.yaml b/test/kubernetes/xmgr/xmgr-cfg.yaml new file mode 100644 index 0000000..a12c824 --- /dev/null +++ b/test/kubernetes/xmgr/xmgr-cfg.yaml @@ -0,0 +1,101 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Static dataset distributed by the Test xApp Manager +# Date: 29 March 2019 +# +apiVersion: v1 +kind: ConfigMap +metadata: + name: xmgrcfg + namespace: example +data: + xmgrdata: | + { + "xapps": + [{ + "name": "admin", + "status": "unknown", + "version": "1.2.3", + "instances": [{ + "name": "admin-01", + "status": "pending", + "ip": "10.244.1.19", + "port": 4561, + "txMessages": ["HandoverPreparation","HandoverCancel"], + "rxMessages": [] + }, + { + "name": "admin-02", + "status": "pending", + "ip": "10.244.3.16", + "port": 4555, + "txMessages": ["HandoverPreparation","HandoverCancel"], + "rxMessages": [] + } + ] + }, + { + "name": "xapp", + "status": "unknown", + "version": "1.2.3", + "instances": [{ + "name": "xapp-01", + "status": "pending", + "ip": "192.168.2.1", + "port": 32300, + "txMessages": ["X2Setup","Reset"], + "rxMessages": ["HandoverPreparation","HandoverCancel"] + }, + { + "name": "xapp-02", + "status": "pending", + "ip": "192.168.2.2", + "port": 32300, + "txMessages": ["X2Setup","Reset"], + "rxMessages": ["HandoverPreparation","HandoverCancel"] + } + ] + }, + { + "name": "e2t", + "status": "unknown", + "version": "1.2.3", + "instances": [{ + "name": "e2t-01", + "status": "pending", + "ip": "192.168.3.1", + "port": 32300, + "txMessages": [], + "rxMessages": ["HandoverPreparation","HandoverCancel","X2Setup","Reset"] + }, + { + "name": "e2t-02", + "status": "pending", + "ip": "192.168.3.2", + "port": 32300, + "txMessages": [], + "rxMessages": ["HandoverPreparation","HandoverCancel","X2Setup","Reset"] + } + ] + } + + ] + } + diff --git a/test/kubernetes/xmgr/xmgr-dep.yaml b/test/kubernetes/xmgr/xmgr-dep.yaml new file mode 100644 index 0000000..768bae7 --- /dev/null +++ b/test/kubernetes/xmgr/xmgr-dep.yaml @@ -0,0 +1,59 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Test xApp Manager Kubernetes manifest +# Date: 29 March 2019 +# +apiVersion: apps/v1 +kind: Deployment +metadata: + name: xmgr + namespace: example +spec: + replicas: 1 + selector: + matchLabels: + app: xmgr + template: + metadata: + labels: + app: xmgr + spec: + containers: + - name: xmgr + image: cmaster:5000/xmgr:0.0.2 + args: + - json-server + - -w + - --host=0.0.0.0 + - /db/xapps.json + ports: + - containerPort: 3000 + volumeMounts: + - mountPath: /db + name: xmgrdata + readOnly: true + volumes: + - name: xmgrdata + configMap: + name: xmgrcfg + items: + - key: xmgrdata + path: xapps.json + mode: 0644 diff --git a/test/kubernetes/xmgr/xmgr-svc.yaml b/test/kubernetes/xmgr/xmgr-svc.yaml new file mode 100644 index 0000000..ad56bf8 --- /dev/null +++ b/test/kubernetes/xmgr/xmgr-svc.yaml @@ -0,0 +1,35 @@ +# +#================================================================================== +# Copyright (c) 2019 AT&T Intellectual Property. +# Copyright (c) 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#================================================================================== +# +# +# Abstract: Test xApp Manager service manifest +# Date: 29 March 2019 +# +kind: Service +apiVersion: v1 +metadata: + name: xmgr + namespace: example +spec: + selector: + app: xmgr + clusterIP: None + ports: + - name: http + port: 3000 + protocol: TCP