Route generation fix 20/1020/1
authorzkoczka <zoltan.koczka@nokia.com>
Thu, 26 Sep 2019 14:59:54 +0000 (16:59 +0200)
committerzkoczka <zoltan.koczka@nokia.com>
Thu, 26 Sep 2019 14:59:54 +0000 (16:59 +0200)
Change-Id: I986d83ac5caecaf37b1d408ca0aa42698346f683
Signed-off-by: zkoczka <zoltan.koczka@nokia.com>
45 files changed:
Dockerfile
cmd/rtmgr.go
manifests/rtmgr/rtmgr-cfg.yaml
manifests/rtmgr/rtmgr-dep.yaml
manifests/rtmgr/rtmgr-svc.yaml
pkg/nbi/httpgetter.go
pkg/nbi/httpgetter_test.go
pkg/nbi/httprestful.go
pkg/nbi/httprestful_test.go
pkg/nbi/nbi.go
pkg/nbi/nbi_test.go
pkg/nbi/types.go
pkg/rpe/rmr.go
pkg/rpe/rmr_test.go
pkg/rpe/rpe.go
pkg/rpe/types.go
pkg/rtmgr/rtmgr.go
pkg/rtmgr/rtmgr_test.go
pkg/rtmgr/types.go
pkg/sbi/nngpub.go [deleted file]
pkg/sbi/nngpub_test.go [deleted file]
pkg/sbi/nngpush.go
pkg/sbi/sbi.go
pkg/sbi/sbi_test.go
pkg/sbi/types.go
pkg/sdl/file.go
pkg/sdl/sdl.go
pkg/sdl/types.go
pkg/stub/mangos.go
pkg/stub/stub.go
test/README.md [deleted file]
test/data/platform_routes.json [deleted file]
test/data/rt.json [deleted file]
test/data/xapps.json [deleted file]
test/docker/xapp-tx.build/Dockerfile [deleted file]
test/docker/xapp-tx.build/run_test-tx.sh [deleted file]
test/docker/xapp.build/Dockerfile [deleted file]
test/docker/xapp.build/run_xapp.sh [deleted file]
test/docker/xmgr.build/Dockerfile [deleted file]
test/docker/xmgr.build/middleware.js [deleted file]
test/kubernetes/xapp-tx/xapp-tx.yaml [deleted file]
test/kubernetes/xapp/xapp.yaml [deleted file]
test/kubernetes/xmgr/xmgr-cfg.yaml [deleted file]
test/kubernetes/xmgr/xmgr-dep.yaml [deleted file]
test/kubernetes/xmgr/xmgr-svc.yaml [deleted file]

index 1c68cc1..b876e94 100644 (file)
@@ -29,9 +29,10 @@ RUN cd /go/bin \
     && mv swagger_linux_amd64 swagger \
     && chmod +x swagger
 
-COPY . /go/src/routing-manager
-
 WORKDIR /go/src/routing-manager
+COPY api/ /go/src/routing-manager/api
+COPY LICENSE LICENSE
+RUN mkdir pkg
 
 RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/appmgr" \
     && cp appmgr/api/appmgr_rest_api.yaml api/ \
@@ -40,11 +41,17 @@ RUN git clone "https://gerrit.o-ran-sc.org/r/ric-plt/appmgr" \
 RUN swagger generate server -f api/routing_manager.yaml -t pkg/ --exclude-main -r LICENSE
 RUN swagger generate client -f api/appmgr_rest_api.yaml -t pkg/ -m appmgr_model -c appmgr_client -r LICENSE
 
+COPY glide.lock glide.lock
+COPY glide.yaml glide.yaml
+
 RUN glide install --strip-vendor
 
-RUN go build cmd/rtmgr.go \
-    && cp rtmgr /go/bin/rtmgr \
-    && cp run_rtmgr.sh /run_rtmgr.sh
+COPY pkg pkg
+COPY cmd cmd
+COPY run_rtmgr.sh /run_rtmgr.sh
+
+ENV GOBIN /go/bin
+RUN go install ./cmd/rtmgr.go
 
 # UT intermediate container
 FROM rtmgrbuild as rtmgrut
@@ -57,4 +64,3 @@ COPY --from=rtmgrbuild /run_rtmgr.sh /
 RUN mkdir /db && touch /db/rt.json && chmod 777 /db/rt.json
 RUN chmod 755 /run_rtmgr.sh
 CMD /run_rtmgr.sh
-
index e6a9665..248226b 100644 (file)
@@ -26,6 +26,7 @@
 */
 package main
 
+//TODO: change flag to pflag (won't need any argument parse)
 import (
        "flag"
        "os"
@@ -51,8 +52,8 @@ func parseArgs() {
        args = make(map[string]*string)
        args["configfile"] = flag.String("configfile", "/etc/rtmgrcfg.json", "Routing manager's configuration file path")
        args["nbi"] = flag.String("nbi", "httpRESTful", "Northbound interface module to be used. Valid values are: 'httpGetter | httpRESTful'")
-       args["sbi"] = flag.String("sbi", "nngpush", "Southbound interface module to be used. Valid values are: 'nngpush | nngpub'")
-       args["rpe"] = flag.String("rpe", "rmrpush", "Route Policy Engine to be used. Valid values are: 'rmrpush | rmrpub'")
+       args["sbi"] = flag.String("sbi", "nngpush", "Southbound interface module to be used. Valid values are: 'nngpush")
+       args["rpe"] = flag.String("rpe", "rmrpush", "Route Policy Engine to be used. Valid values are: 'rmrpush'")
        args["sdl"] = flag.String("sdl", "file", "Datastore enginge to be used. Valid values are: 'file'")
        args["xm-url"] = flag.String("xm-url", "http://localhost:3000/xapps", "HTTP URL where xApp Manager exposes the entire xApp List")
        args["nbi-if"] = flag.String("nbi-if", "http://localhost:8888", "Base HTTP URL where routing manager will be listening on")
@@ -85,14 +86,14 @@ func serveSBI(triggerSBI <-chan bool, sbiEngine sbi.SbiEngine, sdlEngine sdl.Sdl
                if <-triggerSBI {
                        data, err := sdlEngine.ReadAll(*args["filename"])
                        if err != nil || data == nil {
-                               rtmgr.Logger.Error("cannot get data from sdl interface due to: " + err.Error())
+                               rtmgr.Logger.Error("Cannot get data from sdl interface due to: " + err.Error())
                                continue
                        }
                        sbiEngine.UpdateEndpoints(data)
                        policies := rpeEngine.GeneratePolicies(rtmgr.Eps)
                        err = sbiEngine.DistributeAll(policies)
                        if err != nil {
-                               rtmgr.Logger.Error("routing rable cannot be published due to: " + err.Error())
+                               rtmgr.Logger.Error("Routing table cannot be published due to: " + err.Error())
                        }
                }
        }
@@ -103,15 +104,15 @@ func serve(nbiEngine nbi.NbiEngine, sbiEngine sbi.SbiEngine, sdlEngine sdl.SdlEn
        triggerSBI := make(chan bool)
 
        nbiErr := nbiEngine.Initialize(*args["xm-url"], *args["nbi-if"], *args["filename"], *args["configfile"],
-                                       sdlEngine, rpeEngine, triggerSBI)
+               sdlEngine, rpeEngine, triggerSBI)
        if nbiErr != nil {
-               rtmgr.Logger.Error("fail to initialize nbi due to: " + nbiErr.Error())
+               rtmgr.Logger.Error("Failed to initialize nbi due to: " + nbiErr.Error())
                return
        }
 
        err := sbiEngine.Initialize(*args["sbi-if"])
        if err != nil {
-               rtmgr.Logger.Info("fail to open pub socket due to: " + err.Error())
+               rtmgr.Logger.Info("Failed to open push socket due to: " + err.Error())
                return
        }
        defer nbiEngine.Terminate()
@@ -125,7 +126,7 @@ func serve(nbiEngine nbi.NbiEngine, sbiEngine sbi.SbiEngine, sdlEngine sdl.SdlEn
                if *args["nbi"] == "httpGetter" {
                        data, err := nbiEngine.(*nbi.HttpGetter).FetchAllXapps(*args["xm-url"])
                        if err != nil {
-                               rtmgr.Logger.Error("cannot fetch xapp data dute to: " + err.Error())
+                               rtmgr.Logger.Error("Cannot fetch xapp data due to: " + err.Error())
                        } else if data != nil {
                                sdlEngine.WriteXapps(*args["filename"], data)
                        }
index 65c6a6e..7d1d18f 100644 (file)
@@ -26,29 +26,29 @@ metadata:
   name: rtmgrcfg
 data:
   # FQDN and port info of the platform components for routing manager to form and distribute corresponding routes to them
-        rtmgrcfg: |
-                {
-                        "PlatformComponents":
-                        [
-                                {
-                                        "name": "E2TERM",
-                                        "fqdn": "e2term",
-                                        "port": 4561
-                                },
-                                {
-                                        "name": "SUBMAN",
-                                        "fqdn": "subman",
-                                        "port": 4561
-                                },
-                                {
-                                        "name": "E2MAN",
-                                        "fqdn": "e2man",
-                                        "port": 4561
-                                },
-                                {
-                                        "name": "UEMAN",
-                                        "fqdn": "ueman",
-                                        "port": 4561
-                                }
-                        ]
-                }
+  rtmgrcfg: |
+    {
+      "PlatformComponents":
+      [
+        {
+          "name": "E2TERM",
+          "fqdn": "e2term",
+          "port": 4561
+        },
+        {
+          "name": "SUBMAN",
+          "fqdn": "subman",
+          "port": 4561
+        },
+        {
+          "name": "E2MAN",
+          "fqdn": "e2man",
+          "port": 4561
+        },
+        {
+          "name": "UEMAN",
+          "fqdn": "ueman",
+          "port": 4561
+        }
+      ]
+    }
index fc1ae3a..55b7176 100644 (file)
@@ -35,35 +35,35 @@ spec:
         app: rtmgr
     spec:
       containers:
-      - name: rtmgr
-        image: cmaster:5000/rtmgr:latest
-        command: ["/run_rtmgr.sh"]
-        env:
-        - name: XMURL
-          value: "http://appmgr-service:8080/ric/v1/xapps"
-        - name: RTFILE
-          value: "/db/rt.json"
-        - name: RPE
-          value: "rmrpush"
-        - name: SBI
-          value: "nngpush"
-        - name: SBIURL
-          value: "0.0.0.0"
-        - name: NBI
-          value: "httpRESTful"
-        - name: NBIURL
-          value: "http://rtmgr:8888"
-        - name: CFGFILE
-          value: "/cfg/rtmgr-config.json"
-        - name: LOGLEVEL
-          value: "DEBUG"
-        ports:
-        - containerPort: 8888
-        - containerPort: 4560
-        volumeMounts:
-          - mountPath: /cfg
-            name: rtmgrcfg
-            readOnly: true
+        - name: rtmgr
+          image: cmaster:5000/rtmgr:latest
+          command: ["/run_rtmgr.sh"]
+          env:
+            - name: XMURL
+              value: "http://appmgr-service:8080/ric/v1/xapps"
+            - name: RTFILE
+              value: "/db/rt.json"
+            - name: RPE
+              value: "rmrpush"
+            - name: SBI
+              value: "nngpush"
+            - name: SBIURL
+              value: "0.0.0.0"
+            - name: NBI
+              value: "httpRESTful"
+            - name: NBIURL
+              value: "http://rtmgr:8888"
+            - name: CFGFILE
+              value: "/cfg/rtmgr-config.json"
+            - name: LOGLEVEL
+              value: "DEBUG"
+          ports:
+            - containerPort: 8888
+            - containerPort: 4560
+          volumeMounts:
+            - mountPath: /cfg
+              name: rtmgrcfg
+              readOnly: true
       volumes:
         - name: rtmgrcfg
           configMap:
index bbb12a4..6ebb2a2 100644 (file)
@@ -29,7 +29,7 @@ spec:
     app: rtmgr
   clusterIP: None
   ports:
-  - name: nngpub
-    port: 4560
-    protocol: TCP
+    - name: nngpub
+      port: 4560
+      protocol: TCP
 
index 33db0f8..93ef532 100644 (file)
@@ -19,7 +19,7 @@
 /*
   Mnemonic:    httpgetter.go
   Abstract:    HTTPgetter NBI implementation
-               Simple HTTP getter solution. Only for testing purpose.
+               Simple HTTP getter solution.
   Date:                15 March 2019
 */
 
@@ -28,8 +28,8 @@ package nbi
 import (
        "encoding/json"
        "net/http"
-       "routing-manager/pkg/rtmgr"
        "routing-manager/pkg/rpe"
+       "routing-manager/pkg/rtmgr"
        "routing-manager/pkg/sdl"
        "time"
 )
@@ -71,7 +71,7 @@ func fetchAllXapps(xmurl string) (*[]rtmgr.XApp, error) {
 }
 
 func (g *HttpGetter) Initialize(xmurl string, nbiif string, fileName string, configfile string,
-                               sdlEngine sdl.SdlEngine, rpeEngine rpe.RpeEngine, triggerSBI chan<- bool) error {
+       sdlEngine sdl.SdlEngine, rpeEngine rpe.RpeEngine, triggerSBI chan<- bool) error {
        return nil
 }
 
index a6cbbf7..c1c597a 100644 (file)
@@ -36,16 +36,14 @@ var (
        XMURL string = "http://127.0.0.1:3000/ric/v1/xapps"
 )
 
-
 func TestFetchXappListInvalidData(t *testing.T) {
        var httpGetter = NewHttpGetter()
-        _, err := httpGetter.FetchAllXapps(XMURL)
+       _, err := httpGetter.FetchAllXapps(XMURL)
        if err == nil {
-               t.Error("No XApp data received: "+err.Error())
+               t.Error("No XApp data received: " + err.Error())
        }
 }
 
-
 func TestFetchXappListWithInvalidData(t *testing.T) {
        var expected int = 0
        rtmgr.SetLogLevel("debug")
@@ -70,7 +68,7 @@ func TestFetchXappListWithInvalidData(t *testing.T) {
        ts.Start()
        defer ts.Close()
        var httpGetter = NewHttpGetter()
-        xapplist, err := httpGetter.FetchAllXapps(XMURL)
+       xapplist, err := httpGetter.FetchAllXapps(XMURL)
        if err == nil {
                t.Error("Error occured: " + err.Error())
        } else {
@@ -127,4 +125,3 @@ func TestFetchAllXappsWithValidData(t *testing.T) {
                }
        }
 }
-
index 336e615..4124c02 100644 (file)
 package nbi
 
 import (
+       "encoding/json"
+       "errors"
        "fmt"
-       "os"
-       "time"
+       "github.com/go-openapi/loads"
+       "github.com/go-openapi/runtime/middleware"
        "net/url"
-       "strconv"
-       "errors"
-       "encoding/json"
-       "routing-manager/pkg/rtmgr"
-       "routing-manager/pkg/rpe"
-       "routing-manager/pkg/sdl"
+       "os"
        "routing-manager/pkg/models"
        "routing-manager/pkg/restapi"
        "routing-manager/pkg/restapi/operations"
-       "github.com/go-openapi/runtime/middleware"
        "routing-manager/pkg/restapi/operations/handle"
-       loads "github.com/go-openapi/loads"
+       "routing-manager/pkg/rpe"
+       "routing-manager/pkg/rtmgr"
+       "routing-manager/pkg/sdl"
+       "strconv"
+       "time"
 )
 
 //var myClient = &http.Client{Timeout: 1 * time.Second}
@@ -76,8 +76,8 @@ func recvXappCallbackData(dataChannel <-chan *models.XappCallbackData) (*[]rtmgr
                xappData = <-dataChannel
        }
        if nil != xappData {
-                var xapps []rtmgr.XApp
-                err := json.Unmarshal([]byte(xappData.XApps), &xapps)
+               var xapps []rtmgr.XApp
+               err := json.Unmarshal([]byte(xappData.XApps), &xapps)
                return &xapps, err
        } else {
                rtmgr.Logger.Info("No data")
@@ -85,7 +85,6 @@ func recvXappCallbackData(dataChannel <-chan *models.XappCallbackData) (*[]rtmgr
 
        rtmgr.Logger.Debug("Nothing received on the Http interface")
        return nil, nil
-
 }
 
 func validateXappCallbackData(callbackData *models.XappCallbackData) error {
@@ -93,8 +92,8 @@ func validateXappCallbackData(callbackData *models.XappCallbackData) error {
                return fmt.Errorf("Invalid Data field: \"%s\"", callbackData.XApps)
        }
        var xapps []rtmgr.XApp
-        err := json.Unmarshal([]byte(callbackData.XApps), &xapps)
-        if err != nil {
+       err := json.Unmarshal([]byte(callbackData.XApps), &xapps)
+       if err != nil {
                return fmt.Errorf("Unmarshal failed: \"%s\"", err.Error())
        }
        return nil
@@ -106,10 +105,10 @@ func provideXappHandleHandlerImpl(datach chan<- *models.XappCallbackData, data *
        }
        err := validateXappCallbackData(data)
        if err != nil {
-               rtmgr.Logger.Warn("XApp callback data validation failed: "+err.Error())
+               rtmgr.Logger.Warn("XApp callback data validation failed: " + err.Error())
                return err
        } else {
-               datach<-data
+               datach <- data
                return nil
        }
 }
@@ -126,7 +125,7 @@ func validateXappSubscriptionData(data *models.XappSubscriptionData) error {
 }
 
 func provideXappSubscriptionHandleImpl(subchan chan<- *models.XappSubscriptionData,
-                                       data *models.XappSubscriptionData) error {
+       data *models.XappSubscriptionData) error {
        rtmgr.Logger.Debug("Invoked provideXappSubscriptionHandleImpl")
        err := validateXappSubscriptionData(data)
        if err != nil {
@@ -141,7 +140,7 @@ func provideXappSubscriptionHandleImpl(subchan chan<- *models.XappSubscriptionDa
 
 func subscriptionExists(data *models.XappSubscriptionData) bool {
        present := false
-       sub := rtmgr.Subscription{SubID:*data.SubscriptionID, Fqdn:*data.Address, Port:*data.Port,}
+       sub := rtmgr.Subscription{SubID: *data.SubscriptionID, Fqdn: *data.Address, Port: *data.Port}
        for _, elem := range rtmgr.Subs {
                if elem == sub {
                        present = true
@@ -152,7 +151,7 @@ func subscriptionExists(data *models.XappSubscriptionData) bool {
 }
 
 func deleteXappSubscriptionHandleImpl(subdelchan chan<- *models.XappSubscriptionData,
-                                        data *models.XappSubscriptionData) error {
+       data *models.XappSubscriptionData) error {
        rtmgr.Logger.Debug("Invoked deleteXappSubscriptionHandleImpl")
        err := validateXappSubscriptionData(data)
        if err != nil {
@@ -171,40 +170,40 @@ func deleteXappSubscriptionHandleImpl(subdelchan chan<- *models.XappSubscription
 }
 
 func launchRest(nbiif *string, datach chan<- *models.XappCallbackData, subchan chan<- *models.XappSubscriptionData,
-                                                               subdelchan chan<- *models.XappSubscriptionData) {
-        swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
-        if err != nil {
-                //log.Fatalln(err)
-                rtmgr.Logger.Error(err.Error())
-                os.Exit(1)
-        }
+       subdelchan chan<- *models.XappSubscriptionData) {
+       swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
+       if err != nil {
+               //log.Fatalln(err)
+               rtmgr.Logger.Error(err.Error())
+               os.Exit(1)
+       }
        nbiUrl, err := url.Parse(*nbiif)
        if err != nil {
                rtmgr.Logger.Error(err.Error())
                os.Exit(1)
        }
-        api := operations.NewRoutingManagerAPI(swaggerSpec)
-        server := restapi.NewServer(api)
-        defer server.Shutdown()
-
-        server.Port, err = strconv.Atoi(nbiUrl.Port())
-        if err != nil {
-               rtmgr.Logger.Error("Invalid NBI RestAPI port")
-               os.Exit(1)
-        }
-        server.Host = "0.0.0.0"
-        // set handlers
-        api.HandleProvideXappHandleHandler = handle.ProvideXappHandleHandlerFunc(
-                func(params handle.ProvideXappHandleParams) middleware.Responder {
-                rtmgr.Logger.Info("Data received on Http interface")
-               err := provideXappHandleHandlerImpl(datach, params.XappCallbackData)
-               if err != nil {
-                       rtmgr.Logger.Error("Invalid XApp callback data: "+err.Error())
-                       return handle.NewProvideXappHandleBadRequest()
-               } else {
-                       return handle.NewGetHandlesOK()
-               }
-        })
+       api := operations.NewRoutingManagerAPI(swaggerSpec)
+       server := restapi.NewServer(api)
+       defer server.Shutdown()
+
+       server.Port, err = strconv.Atoi(nbiUrl.Port())
+       if err != nil {
+               rtmgr.Logger.Error("Invalid NBI RestAPI port")
+               os.Exit(1)
+       }
+       server.Host = "0.0.0.0"
+       // set handlers
+       api.HandleProvideXappHandleHandler = handle.ProvideXappHandleHandlerFunc(
+               func(params handle.ProvideXappHandleParams) middleware.Responder {
+                       rtmgr.Logger.Info("Data received on Http interface")
+                       err := provideXappHandleHandlerImpl(datach, params.XappCallbackData)
+                       if err != nil {
+                               rtmgr.Logger.Error("Invalid XApp callback data: " + err.Error())
+                               return handle.NewProvideXappHandleBadRequest()
+                       } else {
+                               return handle.NewGetHandlesOK()
+                       }
+               })
        api.HandleProvideXappSubscriptionHandleHandler = handle.ProvideXappSubscriptionHandleHandlerFunc(
                func(params handle.ProvideXappSubscriptionHandleParams) middleware.Responder {
                        err := provideXappSubscriptionHandleImpl(subchan, params.XappSubscriptionData)
@@ -223,77 +222,72 @@ func launchRest(nbiif *string, datach chan<- *models.XappCallbackData, subchan c
                                return handle.NewGetHandlesOK()
                        }
                })
-        // start to serve API
-        rtmgr.Logger.Info("Starting the HTTP Rest service")
-        if err := server.Serve(); err != nil {
-                rtmgr.Logger.Error(err.Error())
-        }
+       // start to serve API
+       rtmgr.Logger.Info("Starting the HTTP Rest service")
+       if err := server.Serve(); err != nil {
+               rtmgr.Logger.Error(err.Error())
+       }
 }
 
 func httpGetXapps(xmurl string) (*[]rtmgr.XApp, error) {
-        rtmgr.Logger.Info("Invoked httpgetter.fetchXappList: " + xmurl)
-        r, err := myClient.Get(xmurl)
-        if err != nil {
-                return nil, err
-        }
-        defer r.Body.Close()
-
-        if r.StatusCode == 200 {
-                rtmgr.Logger.Debug("http client raw response: %v", r)
-                var xapps []rtmgr.XApp
-                err = json.NewDecoder(r.Body).Decode(&xapps)
-                if err != nil {
-                        rtmgr.Logger.Warn("Json decode failed: " + err.Error())
-                }
-                rtmgr.Logger.Info("HTTP GET: OK")
-                rtmgr.Logger.Debug("httpgetter.fetchXappList returns: %v", xapps)
-                return &xapps, err
-        }
-        rtmgr.Logger.Warn("httpgetter got an unexpected http status code: %v", r.StatusCode)
-        return nil, nil
+       rtmgr.Logger.Info("Invoked httpgetter.fetchXappList: " + xmurl)
+       r, err := myClient.Get(xmurl)
+       if err != nil {
+               return nil, err
+       }
+       defer r.Body.Close()
+
+       if r.StatusCode == 200 {
+               rtmgr.Logger.Debug("http client raw response: %v", r)
+               var xapps []rtmgr.XApp
+               err = json.NewDecoder(r.Body).Decode(&xapps)
+               if err != nil {
+                       rtmgr.Logger.Warn("Json decode failed: " + err.Error())
+               }
+               rtmgr.Logger.Info("HTTP GET: OK")
+               rtmgr.Logger.Debug("httpgetter.fetchXappList returns: %v", xapps)
+               return &xapps, err
+       }
+       rtmgr.Logger.Warn("httpgetter got an unexpected http status code: %v", r.StatusCode)
+       return nil, nil
 }
 
 func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile string, sdlEngine sdl.SdlEngine) error {
-        var readErr error
-        var maxRetries = 10
-
-                for i := 1; i <= maxRetries; i++ {
-                        time.Sleep(2 * time.Second)
-
-                        xappData, err := httpGetXapps(xmurl)
-
-                        if xappData != nil && err == nil {
-                               pcData, confErr := rtmgr.GetPlatformComponents(configfile)
-                               if confErr != nil {
-                                       rtmgr.Logger.Error(confErr.Error())
-                                       return confErr
-                               }
-
-                                rtmgr.Logger.Info("Recieved intial xapp data and platform data, writing into SDL.")
-                               // Combine the xapps data and platform data before writing to the SDL
-                               ricData := &rtmgr.RicComponents{Xapps: *xappData, Pcs: *pcData}
-
-                                writeErr := sdlEngine.WriteAll(fileName, ricData)
-                                if writeErr != nil {
-                                        rtmgr.Logger.Error(writeErr.Error())
-                                }
-                                // post subscription req to appmgr
-                                readErr = PostSubReq(xmurl, nbiif)
-                                if readErr == nil {
-                                        return nil
-                                }
-                        } else if err == nil {
-                                readErr = errors.New("Unexpected HTTP status code")
-                        } else {
-                                rtmgr.Logger.Warn("cannot get xapp data due to: " + err.Error())
-                                readErr = err
-                        }
-                }
-        return readErr
+       var readErr error
+       var maxRetries = 10
+       for i := 1; i <= maxRetries; i++ {
+               time.Sleep(2 * time.Second)
+               xappData, err := httpGetXapps(xmurl)
+               if xappData != nil && err == nil {
+                       pcData, confErr := rtmgr.GetPlatformComponents(configfile)
+                       if confErr != nil {
+                               rtmgr.Logger.Error(confErr.Error())
+                               return confErr
+                       }
+                       rtmgr.Logger.Info("Recieved intial xapp data and platform data, writing into SDL.")
+                       // Combine the xapps data and platform data before writing to the SDL
+                       ricData := &rtmgr.RicComponents{Xapps: *xappData, Pcs: *pcData}
+                       writeErr := sdlEngine.WriteAll(fileName, ricData)
+                       if writeErr != nil {
+                               rtmgr.Logger.Error(writeErr.Error())
+                       }
+                       // post subscription req to appmgr
+                       readErr = PostSubReq(xmurl, nbiif)
+                       if readErr == nil {
+                               return nil
+                       }
+               } else if err == nil {
+                       readErr = errors.New("Unexpected HTTP status code")
+               } else {
+                       rtmgr.Logger.Warn("cannot get xapp data due to: " + err.Error())
+                       readErr = err
+               }
+       }
+       return readErr
 }
 
 func (r *HttpRestful) Initialize(xmurl string, nbiif string, fileName string, configfile string,
-                                sdlEngine sdl.SdlEngine, rpeEngine rpe.RpeEngine, triggerSBI chan<- bool) error {
+       sdlEngine sdl.SdlEngine, rpeEngine rpe.RpeEngine, triggerSBI chan<- bool) error {
        err := r.RetrieveStartupData(xmurl, nbiif, fileName, configfile, sdlEngine)
        if err != nil {
                rtmgr.Logger.Error("Exiting as nbi failed to get the intial startup data from the xapp manager: " + err.Error())
@@ -347,7 +341,7 @@ func (r *HttpRestful) Terminate() error {
 
 func addSubscription(subs *rtmgr.SubscriptionList, xappSubData *models.XappSubscriptionData) bool {
        var b bool = false
-       sub := rtmgr.Subscription{SubID:*xappSubData.SubscriptionID, Fqdn:*xappSubData.Address, Port:*xappSubData.Port,}
+       sub := rtmgr.Subscription{SubID: *xappSubData.SubscriptionID, Fqdn: *xappSubData.Address, Port: *xappSubData.Port}
        for _, elem := range *subs {
                if elem == sub {
                        rtmgr.Logger.Warn("rtmgr.addSubscription: Subscription already present: %v", elem)
@@ -363,7 +357,7 @@ func addSubscription(subs *rtmgr.SubscriptionList, xappSubData *models.XappSubsc
 func delSubscription(subs *rtmgr.SubscriptionList, xappSubData *models.XappSubscriptionData) bool {
        rtmgr.Logger.Debug("Deleteing the subscription from the subscriptions list")
        var present bool = false
-       sub := rtmgr.Subscription{SubID:*xappSubData.SubscriptionID, Fqdn:*xappSubData.Address, Port:*xappSubData.Port,}
+       sub := rtmgr.Subscription{SubID: *xappSubData.SubscriptionID, Fqdn: *xappSubData.Address, Port: *xappSubData.Port}
        for i, elem := range *subs {
                if elem == sub {
                        present = true
index c52643b..a844425 100644 (file)
 package nbi
 
 import (
-       "routing-manager/pkg/stub"
-        "routing-manager/pkg/models"
-        "routing-manager/pkg/sdl"
-       "github.com/go-openapi/swag"
-        "testing"
-       "time"
-        "net"
-        "net/http"
-        "net/http/httptest"
+       "encoding/json"
        "fmt"
-       "os"
+       "github.com/go-openapi/swag"
        "io/ioutil"
-       "encoding/json"
+       "net"
+       "net/http"
+       "net/http/httptest"
+       "os"
+       "routing-manager/pkg/models"
+       "routing-manager/pkg/sdl"
+       "routing-manager/pkg/stub"
+       "testing"
+       "time"
 )
 
 var BASIC_XAPPLIST = []byte(`[
@@ -58,10 +58,8 @@ var BASIC_XAPPLIST = []byte(`[
 
 var SUBSCRIPTION_RESP = []byte(`{"ID":"deadbeef1234567890", "Version":0, "EventType":"all"}`)
 
-
 var INVALID_SUB_RESP = []byte(`{"Version":0, "EventType":all}`)
 
-
 func createMockAppmgrWithData(url string, g []byte, p []byte) *httptest.Server {
        l, err := net.Listen("tcp", url)
        if err != nil {
@@ -74,10 +72,10 @@ func createMockAppmgrWithData(url string, g []byte, p []byte) *httptest.Server {
                        w.Write(g)
                }
                if r.Method == "POST" && r.URL.String() == "/ric/v1/subscriptions" {
-                        w.Header().Add("Content-Type", "application/json")
-                        w.WriteHeader(http.StatusCreated)
-                        w.Write(p)
-                }
+                       w.Header().Add("Content-Type", "application/json")
+                       w.WriteHeader(http.StatusCreated)
+                       w.Write(p)
+               }
 
        }))
        ts.Listener.Close()
@@ -89,28 +87,28 @@ func createMockPlatformComponents() {
        var filename = string("config.json")
        file, _ := json.MarshalIndent(stub.ValidPlatformComponents, "", "")
        filestr := string(file)
-       filestr = "{\"PlatformComponents\":"+filestr+"}"
+       filestr = "{\"PlatformComponents\":" + filestr + "}"
        file = []byte(filestr)
        _ = ioutil.WriteFile(filename, file, 644)
 }
 
 func TestRecvXappCallbackData(t *testing.T) {
-       data := models.XappCallbackData {
-                XApps: *swag.String("[]"),
-                Version: *swag.Int64(1),
-                Event: *swag.String("any"),
-                ID: *swag.String("123456"),
+       data := models.XappCallbackData{
+               XApps:   *swag.String("[]"),
+               Version: *swag.Int64(1),
+               Event:   *swag.String("any"),
+               ID:      *swag.String("123456"),
        }
 
        ch := make(chan *models.XappCallbackData)
        defer close(ch)
        httpRestful := NewHttpRestful()
-       go func() {ch<- &data}()
+       go func() { ch <- &data }()
        time.Sleep(1 * time.Second)
        t.Log(string(len(ch)))
        xappList, err := httpRestful.RecvXappCallbackData(ch)
        if err != nil {
-               t.Error("Receive failed: "+err.Error())
+               t.Error("Receive failed: " + err.Error())
        } else {
                if xappList == nil {
                        t.Error("Expected an XApp notification list")
@@ -124,18 +122,18 @@ func TestProvideXappHandleHandlerImpl(t *testing.T) {
        datach := make(chan *models.XappCallbackData, 10)
        defer close(datach)
        data := models.XappCallbackData{
-               XApps: *swag.String("[]"),
+               XApps:   *swag.String("[]"),
                Version: *swag.Int64(1),
-               Event: *swag.String("someevent"),
-               ID: *swag.String("123456")}
+               Event:   *swag.String("someevent"),
+               ID:      *swag.String("123456")}
        var httpRestful, _ = GetNbi("httpRESTful")
        err := httpRestful.(*HttpRestful).ProvideXappHandleHandlerImpl(datach, &data)
        if err != nil {
-               t.Error("Error occured: "+err.Error())
+               t.Error("Error occured: " + err.Error())
        } else {
                recv := <-datach
                if recv == nil {
-                       t.Error("Something gone wrong: "+err.Error())
+                       t.Error("Something gone wrong: " + err.Error())
                } else {
                        if recv != &data {
                                t.Error("Malformed data on channel")
@@ -145,37 +143,36 @@ func TestProvideXappHandleHandlerImpl(t *testing.T) {
 }
 
 func TestValidateXappCallbackData(t *testing.T) {
-        data := models.XappCallbackData{
-                XApps: *swag.String("[]"),
-                Version: *swag.Int64(1),
-                Event: *swag.String("someevent"),
-                ID: *swag.String("123456")}
+       data := models.XappCallbackData{
+               XApps:   *swag.String("[]"),
+               Version: *swag.Int64(1),
+               Event:   *swag.String("someevent"),
+               ID:      *swag.String("123456")}
 
        err := validateXappCallbackData(&data)
        if err != nil {
-               t.Error("Invalid XApp callback data: "+err.Error())
+               t.Error("Invalid XApp callback data: " + err.Error())
        }
 }
 
 func TestValidateXappCallbackDataWithInvalidData(t *testing.T) {
-        data := models.XappCallbackData{
-                XApps: *swag.String("{}"),
-                Version: *swag.Int64(1),
-                Event: *swag.String("someevent"),
-                ID: *swag.String("123456")}
-
-        err := validateXappCallbackData(&data)
-        if err == nil {
-                t.Error("Invalid XApp callback data: "+err.Error())
-        }
-}
+       data := models.XappCallbackData{
+               XApps:   *swag.String("{}"),
+               Version: *swag.Int64(1),
+               Event:   *swag.String("someevent"),
+               ID:      *swag.String("123456")}
 
+       err := validateXappCallbackData(&data)
+       if err == nil {
+               t.Error("Invalid XApp callback data: " + err.Error())
+       }
+}
 
 func TestHttpGetXappsInvalidData(t *testing.T) {
-        _, err := httpGetXapps(XMURL)
-        if err == nil {
-                t.Error("No XApp data received: "+err.Error())
-        }
+       _, err := httpGetXapps(XMURL)
+       if err == nil {
+               t.Error("No XApp data received: " + err.Error())
+       }
 }
 
 func TestHttpGetXappsWithValidData(t *testing.T) {
@@ -197,9 +194,9 @@ func TestHttpGetXappsWithValidData(t *testing.T) {
 func TestRetrieveStartupDataTimeout(t *testing.T) {
        sdlEngine, _ := sdl.GetSdl("file")
        createMockPlatformComponents()
-       err := retrieveStartupData(XMURL, "httpgetter","rt.json", "config.json", sdlEngine)
+       err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
        if err == nil {
-               t.Error("Cannot retrieve startup data: "+err.Error())
+               t.Error("Cannot retrieve startup data: " + err.Error())
        }
        os.Remove("rt.json")
        os.Remove("config.json")
@@ -209,14 +206,14 @@ func TestRetrieveStartupData(t *testing.T) {
        ts := createMockAppmgrWithData("127.0.0.1:3000", BASIC_XAPPLIST, SUBSCRIPTION_RESP)
        ts.Start()
        defer ts.Close()
-        sdlEngine, _ := sdl.GetSdl("file")
+       sdlEngine, _ := sdl.GetSdl("file")
        var httpRestful, _ = GetNbi("httpRESTful")
        createMockPlatformComponents()
-       err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json","config.json", sdlEngine)
-        //err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
-        if err != nil {
-                t.Error("Cannot retrieve startup data: "+err.Error())
-        }
+       err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
+       //err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
+       if err != nil {
+               t.Error("Cannot retrieve startup data: " + err.Error())
+       }
        os.Remove("rt.json")
        os.Remove("config.json")
 }
@@ -225,13 +222,13 @@ func TestRetrieveStartupDataWithInvalidSubResp(t *testing.T) {
        ts := createMockAppmgrWithData("127.0.0.1:3000", BASIC_XAPPLIST, INVALID_SUB_RESP)
        ts.Start()
        defer ts.Close()
-        sdlEngine, _ := sdl.GetSdl("file")
+       sdlEngine, _ := sdl.GetSdl("file")
        var httpRestful, _ = GetNbi("httpRESTful")
        createMockPlatformComponents()
-        err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
-        if err == nil {
-                t.Error("Cannot retrieve startup data: "+err.Error())
-        }
+       err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
+       if err == nil {
+               t.Error("Cannot retrieve startup data: " + err.Error())
+       }
        os.Remove("rt.json")
        os.Remove("config.json")
 }
index 1e2a8d3..cee3374 100644 (file)
@@ -26,39 +26,37 @@ package nbi
 
 import (
        "errors"
+       httptransport "github.com/go-openapi/runtime/client"
+       "github.com/go-openapi/strfmt"
+       "github.com/go-openapi/swag"
+       "net/url"
+       apiclient "routing-manager/pkg/appmgr_client"
+       "routing-manager/pkg/appmgr_client/operations"
+       "routing-manager/pkg/appmgr_model"
        "routing-manager/pkg/rtmgr"
-        "net/url"
-        apiclient "routing-manager/pkg/appmgr_client"
-        "routing-manager/pkg/appmgr_client/operations"
-        "routing-manager/pkg/appmgr_model"
-        httptransport "github.com/go-openapi/runtime/client"
-        "github.com/go-openapi/strfmt"
-        "github.com/go-openapi/swag"
-        "time"
-
+       "time"
 )
 
 var (
        SupportedNbis = []*NbiEngineConfig{
                &NbiEngineConfig{
-                       Name:     "httpGetter",
-                       Version:  "v1",
-                       Protocol: "http",
-                       Instance: NewHttpGetter(),
+                       Name:        "httpGetter",
+                       Version:     "v1",
+                       Protocol:    "http",
+                       Instance:    NewHttpGetter(),
                        IsAvailable: true,
                },
                &NbiEngineConfig{
-                       Name:     "httpRESTful",
-                       Version:  "v1",
-                       Protocol: "http",
-                       Instance: NewHttpRestful(),
+                       Name:        "httpRESTful",
+                       Version:     "v1",
+                       Protocol:    "http",
+                       Instance:    NewHttpRestful(),
                        IsAvailable: true,
                },
        }
 )
 
 type Nbi struct {
-
 }
 
 func GetNbi(nbiName string) (NbiEngine, error) {
@@ -72,41 +70,40 @@ func GetNbi(nbiName string) (NbiEngine, error) {
 
 func CreateSubReq(restUrl string, restPort string) *appmgr_model.SubscriptionRequest {
        // TODO: parametize function
-        subReq := appmgr_model.SubscriptionRequest{
-                TargetURL:  swag.String(restUrl + ":" + restPort + "/ric/v1/handles/xapp-handle/"),
-                EventType:  swag.String("all"),
-                MaxRetries: swag.Int64(5),
-                RetryTimer: swag.Int64(10),
-        }
+       subReq := appmgr_model.SubscriptionRequest{
+               TargetURL:  swag.String(restUrl + ":" + restPort + "/ric/v1/handles/xapp-handle/"),
+               EventType:  swag.String("all"),
+               MaxRetries: swag.Int64(5),
+               RetryTimer: swag.Int64(10),
+       }
 
-        return &subReq
+       return &subReq
 }
 
 func PostSubReq(xmUrl string, nbiif string) error {
-        // setting up POST request to Xapp Manager
-        appmgrUrl, err := url.Parse(xmUrl)
-        if err != nil {
-                rtmgr.Logger.Error("Invalid XApp manager url/hostname: " + err.Error())
-                return err
-        }
+       // setting up POST request to Xapp Manager
+       appmgrUrl, err := url.Parse(xmUrl)
+       if err != nil {
+               rtmgr.Logger.Error("Invalid XApp manager url/hostname: " + err.Error())
+               return err
+       }
        nbiifUrl, err := url.Parse(nbiif)
        if err != nil {
                rtmgr.Logger.Error("Invalid NBI address/port: " + err.Error())
                return err
        }
-        transport := httptransport.New(appmgrUrl.Hostname()+":"+appmgrUrl.Port(), "/ric/v1", []string{"http"})
-        client := apiclient.New(transport, strfmt.Default)
-        addSubParams := operations.NewAddSubscriptionParamsWithTimeout(10 * time.Second)
-        // create sub req with rest url and port
-        subReq := CreateSubReq(string(nbiifUrl.Scheme+"://"+nbiifUrl.Hostname()), nbiifUrl.Port())
-        resp, postErr := client.Operations.AddSubscription(addSubParams.WithSubscriptionRequest(subReq))
-        if postErr != nil {
-                rtmgr.Logger.Error("POST unsuccessful:"+postErr.Error())
-                return postErr
-        } else {
-                // TODO: use the received ID
-                rtmgr.Logger.Info("POST received: "+string(resp.Payload.ID))
-                return nil
-        }
+       transport := httptransport.New(appmgrUrl.Hostname()+":"+appmgrUrl.Port(), "/ric/v1", []string{"http"})
+       client := apiclient.New(transport, strfmt.Default)
+       addSubParams := operations.NewAddSubscriptionParamsWithTimeout(10 * time.Second)
+       // create sub req with rest url and port
+       subReq := CreateSubReq(string(nbiifUrl.Scheme+"://"+nbiifUrl.Hostname()), nbiifUrl.Port())
+       resp, postErr := client.Operations.AddSubscription(addSubParams.WithSubscriptionRequest(subReq))
+       if postErr != nil {
+               rtmgr.Logger.Error("POST unsuccessful:" + postErr.Error())
+               return postErr
+       } else {
+               // TODO: use the received ID
+               rtmgr.Logger.Info("POST received: " + string(resp.Payload.ID))
+               return nil
+       }
 }
-
index a3aa836..e309355 100644 (file)
 package nbi
 
 import (
-       "testing"
-       "reflect"
        "errors"
-       "routing-manager/pkg/appmgr_model"
        "github.com/go-openapi/swag"
        "net"
        "net/http"
        "net/http/httptest"
+       "reflect"
+       "routing-manager/pkg/appmgr_model"
+       "testing"
 )
 
 func TestGetNbi(t *testing.T) {
@@ -58,66 +58,65 @@ func TestGetNbi(t *testing.T) {
 
 func TestCreateSubReq(t *testing.T) {
        var subReq = appmgr_model.SubscriptionRequest{
-                TargetURL:  swag.String("localhost:8000/ric/v1/handles/xapp-handle/"),
-                EventType:  swag.String("all"),
-                MaxRetries: swag.Int64(5),
-                RetryTimer: swag.Int64(10),
-        }
-       subReq2 := CreateSubReq("localhost","8000")
+               TargetURL:  swag.String("localhost:8000/ric/v1/handles/xapp-handle/"),
+               EventType:  swag.String("all"),
+               MaxRetries: swag.Int64(5),
+               RetryTimer: swag.Int64(10),
+       }
+       subReq2 := CreateSubReq("localhost", "8000")
        if reflect.TypeOf(subReq) != reflect.TypeOf(*subReq2) {
                t.Errorf("Invalid type, got: %v, want: %v.", reflect.TypeOf(subReq), reflect.TypeOf(*subReq2))
        }
        if *(subReq.TargetURL) != *(subReq2.TargetURL) {
                t.Errorf("Invalid TargetURL generated, got %v, want %v", *subReq.TargetURL, *subReq2.TargetURL)
        }
-        if *(subReq.EventType) != *(subReq2.EventType) {
-                t.Errorf("Invalid EventType generated, got %v, want %v", *subReq.EventType, *subReq2.EventType)
-        }
-        if *(subReq.MaxRetries) != *(subReq2.MaxRetries) {
-                t.Errorf("Invalid MaxRetries generated, got %v, want %v", *subReq.MaxRetries, *subReq2.MaxRetries)
-        }
-        if *(subReq.RetryTimer) != *(subReq2.RetryTimer) {
-                t.Errorf("Invalid RetryTimer generated, got %v, want %v", *subReq.RetryTimer, *subReq2.RetryTimer)
-        }
+       if *(subReq.EventType) != *(subReq2.EventType) {
+               t.Errorf("Invalid EventType generated, got %v, want %v", *subReq.EventType, *subReq2.EventType)
+       }
+       if *(subReq.MaxRetries) != *(subReq2.MaxRetries) {
+               t.Errorf("Invalid MaxRetries generated, got %v, want %v", *subReq.MaxRetries, *subReq2.MaxRetries)
+       }
+       if *(subReq.RetryTimer) != *(subReq2.RetryTimer) {
+               t.Errorf("Invalid RetryTimer generated, got %v, want %v", *subReq.RetryTimer, *subReq2.RetryTimer)
+       }
 }
 
 func TestPostSubReq(t *testing.T) {
        b := []byte(`{"ID":"deadbeef1234567890", "Version":0, "EventType":"all"}`)
        l, err := net.Listen("tcp", "127.0.0.1:3000")
-        if err != nil {
-                t.Error("Failed to create listener: " + err.Error())
-        }
-        ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-                t.Log(r.Method)
-                t.Log(r.URL)
-                if r.Method == "POST" && r.URL.String() == "/ric/v1/subscriptions" {
-                        t.Log("Sending reply")
-                        w.Header().Add("Content-Type", "application/json")
-                        w.WriteHeader(http.StatusCreated)
-                        w.Write(b)
-                }
-        }))
-        ts.Listener.Close()
-        ts.Listener = l
+       if err != nil {
+               t.Error("Failed to create listener: " + err.Error())
+       }
+       ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+               t.Log(r.Method)
+               t.Log(r.URL)
+               if r.Method == "POST" && r.URL.String() == "/ric/v1/subscriptions" {
+                       t.Log("Sending reply")
+                       w.Header().Add("Content-Type", "application/json")
+                       w.WriteHeader(http.StatusCreated)
+                       w.Write(b)
+               }
+       }))
+       ts.Listener.Close()
+       ts.Listener = l
 
-        ts.Start()
+       ts.Start()
        defer ts.Close()
-       err = PostSubReq("http://127.0.0.1:3000/ric/v1/subscription","localhost:8888")
+       err = PostSubReq("http://127.0.0.1:3000/ric/v1/subscription", "localhost:8888")
        if err != nil {
-               t.Error("Error occured: "+err.Error())
+               t.Error("Error occured: " + err.Error())
        }
 }
 
 func TestPostSubReqWithInvalidUrls(t *testing.T) {
        // invalid Xapp Manager URL
-        err := PostSubReq("http://127.0","http://localhost:8888")
-        if err == nil {
-                t.Error("Error occured: "+err.Error())
-        }
+       err := PostSubReq("http://127.0", "http://localhost:8888")
+       if err == nil {
+               t.Error("Error occured: " + err.Error())
+       }
        // invalid rest api url
-       err = PostSubReq("http://127.0.0.1:3000/","localhost:8888")
+       err = PostSubReq("http://127.0.0.1:3000/", "localhost:8888")
        if err == nil {
-               t.Error("Error occured: "+err.Error())
+               t.Error("Error occured: " + err.Error())
        }
 }
-
index 813363e..0f7fee6 100644 (file)
 package nbi
 
 import (
-       "routing-manager/pkg/rtmgr"
        "routing-manager/pkg/models"
        "routing-manager/pkg/rpe"
+       "routing-manager/pkg/rtmgr"
        "routing-manager/pkg/sdl"
 )
 
 type FetchAllXappsHandler func(string) (*[]rtmgr.XApp, error)
 type RecvXappCallbackDataHandler func(<-chan *models.XappCallbackData) (*[]rtmgr.XApp, error)
 type LaunchRestHandler func(*string, chan<- *models.XappCallbackData, chan<- *models.XappSubscriptionData, chan<- *models.XappSubscriptionData)
-type ProvideXappHandleHandlerImpl func(chan<- *models.XappCallbackData, *models.XappCallbackData) (error)
+type ProvideXappHandleHandlerImpl func(chan<- *models.XappCallbackData, *models.XappCallbackData) error
 type RetrieveStartupDataHandler func(string, string, string, string, sdl.SdlEngine) error
 
 type NbiEngineConfig struct {
@@ -49,4 +49,3 @@ type NbiEngine interface {
        Initialize(string, string, string, string, sdl.SdlEngine, rpe.RpeEngine, chan<- bool) error
        Terminate() error
 }
-
index 9cda9d9..dba8db6 100644 (file)
@@ -34,19 +34,10 @@ type Rmr struct {
        Rpe
 }
 
-type RmrPub struct {
-       Rmr
-}
-
 type RmrPush struct {
        Rmr
 }
 
-func NewRmrPub() *RmrPub {
-       instance := new(RmrPub)
-       return instance
-}
-
 func NewRmrPush() *RmrPush {
        instance := new(RmrPush)
        return instance
@@ -57,7 +48,7 @@ Produces the raw route message consumable by RMR
 */
 func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, key string) *[]string {
        rawrt := []string{key + "newrt|start\n"}
-       rt := r.getRouteTable(eps)
+       rt := r.generateRouteTable(eps)
        for _, rte := range *rt {
                rawrte := key + "mse|" + rte.MessageType
                for _, tx := range rte.TxList {
@@ -88,21 +79,11 @@ func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, key string) *[]string {
        return &rawrt
 }
 
-func (r *RmrPub) GeneratePolicies(eps rtmgr.Endpoints) *[]string {
-       rtmgr.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
-       return r.generateRMRPolicies(eps, "00000           ")
-}
-
 func (r *RmrPush) GeneratePolicies(eps rtmgr.Endpoints) *[]string {
        rtmgr.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
        return r.generateRMRPolicies(eps, "")
 }
 
-func (r *RmrPub) GetRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
-       return r.getRouteTable(eps)
+func (r *RmrPush) GenerateRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
+       return r.generateRouteTable(eps)
 }
-
-func (r *RmrPush) GetRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
-       return r.getRouteTable(eps)
-}
-
index bdbeff4..016aef2 100644 (file)
@@ -37,17 +37,6 @@ func resetTestDataset(testdata []rtmgr.Endpoint) {
        }
 }
 
-/*
-RmrPub.GeneratePolicies() method is tested for happy path case
-*/
-func TestRmrPubGeneratePolicies(t *testing.T) {
-       var rmrpub = RmrPub{}
-       resetTestDataset(stub.ValidEndpoints)
-
-       rawrt := rmrpub.GeneratePolicies(rtmgr.Eps)
-       t.Log(rawrt)
-}
-
 /*
 RmrPush.GeneratePolicies() method is tested for happy path case
 */
index 5dd8f4d..e8daf61 100644 (file)
@@ -27,18 +27,12 @@ package rpe
 import (
        "errors"
        "routing-manager/pkg/rtmgr"
+       "routing-manager/pkg/sbi"
        "strconv"
 )
 
 var (
        SupportedRpes = []*RpeEngineConfig{
-               &RpeEngineConfig{
-                       Name:        "rmrpub",
-                       Version:     "pubsub",
-                       Protocol:    "rmruta",
-                       Instance:    NewRmrPub(),
-                       IsAvailable: true,
-               },
                &RpeEngineConfig{
                        Name:        "rmrpush",
                        Version:     "pubsush",
@@ -61,105 +55,6 @@ func GetRpe(rpeName string) (RpeEngine, error) {
 type Rpe struct {
 }
 
-/*
-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 (r *Rpe) getRouteRxTxLists(eps rtmgr.Endpoints) (*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 _, ep := range eps {
-               for _, message := range ep.RxMessages {
-                       messageid := rtmgr.MESSAGETYPES[message]
-                       if _, ok := rxgroups[messageid]; !ok {
-                               rxgroups[messageid] = make(map[string]rtmgr.EndpointList)
-                       }
-                       rxgroups[messageid][ep.XAppType] = append(rxgroups[messageid][ep.XAppType], (*ep))
-               }
-               for _, message := range ep.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 (r *Rpe) getRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
-       tx, rx := r.getRouteRxTxLists(eps)
-       var rt rtmgr.RouteTable
-       for _, messagetype := range rtmgr.MESSAGETYPES {
-               /*if _, ok := (*tx)[messagetype]; !ok {
-                       continue
-               }
-               if _, ok := (*rx)[messagetype]; !ok {
-                       continue
-               }*/
-               txList, ok := (*tx)[messagetype]
-               if !ok {
-                       txList = rtmgr.EndpointList{}
-               }
-               var rxgroups []rtmgr.EndpointList
-               for _, endpointlist := range (*rx)[messagetype] {
-                       rxgroups = append(rxgroups, endpointlist)
-               }
-               if len(txList) > 0 || len(rxgroups) > 0 {
-                       rte := rtmgr.RouteTableEntry{
-                               messagetype,
-                               txList,
-                               rxgroups,
-                               -1,
-                       }
-                       rt = append(rt, rte)
-               }
-       }
-       r.addStaticRoutes(eps, &rt)
-       r.addSubscriptionRoutes(eps, &rt, &rtmgr.Subs)
-       return &rt
-}
-
-/*
-Adds specific static routes to the route table
-which cannot be calculated with endpoint tx/rx message types.
-*/
-func (r *Rpe) addStaticRoutes(eps rtmgr.Endpoints, rt *rtmgr.RouteTable) {
-       var uemanep, submanep *rtmgr.Endpoint
-       for _, ep := range eps {
-               if ep.Name == "UEMAN" {
-                       uemanep = ep
-               }
-               if ep.Name == "SUBMAN" {
-                       submanep = ep
-               }
-       }
-
-       if uemanep != nil && submanep != nil {
-               txlist := rtmgr.EndpointList{*uemanep}
-               rxlist := []rtmgr.EndpointList{[]rtmgr.Endpoint{*submanep}}
-               rte1 := rtmgr.RouteTableEntry{
-                       rtmgr.MESSAGETYPES["RIC_SUB_REQ"],
-                       txlist,
-                       rxlist,
-                       -1,
-               }
-               rte2 := rtmgr.RouteTableEntry{
-                       rtmgr.MESSAGETYPES["RIC_SUB_DEL_REQ"],
-                       txlist,
-                       rxlist,
-                       -1,
-               }
-               *rt = append(*rt, rte1)
-               *rt = append(*rt, rte2)
-       } else {
-               rtmgr.Logger.Warn("Cannot get the static route details of the platform components UEMAN/SUBMAN")
-       }
-}
-
 func getEndpointByName(eps *rtmgr.Endpoints, name string) *rtmgr.Endpoint {
        for _, ep := range *eps {
                if ep.Name == name {
@@ -171,8 +66,9 @@ func getEndpointByName(eps *rtmgr.Endpoints, name string) *rtmgr.Endpoint {
        return nil
 }
 
-func getEndpointByUuid(eps *rtmgr.Endpoints, uuid string) *rtmgr.Endpoint {
-       for _, ep := range *eps {
+func getEndpointByUuid(uuid string) *rtmgr.Endpoint {
+       endPoints := rtmgr.Eps
+       for _, ep := range endPoints {
                if ep.Uuid == uuid {
                        rtmgr.Logger.Debug("name: %s", ep.Uuid)
                        rtmgr.Logger.Debug("ep: %v", ep)
@@ -181,53 +77,139 @@ func getEndpointByUuid(eps *rtmgr.Endpoints, uuid string) *rtmgr.Endpoint {
        }
        return nil
 }
-func (r *Rpe) addSubscriptionRoutes(eps rtmgr.Endpoints, rt *rtmgr.RouteTable, subs *rtmgr.SubscriptionList) {
-       rtmgr.Logger.Debug("rpe.addSubscriptionRoutes invoked")
-       rtmgr.Logger.Debug("params: %v", eps)
-       var e2termep, submanep, xappEp *rtmgr.Endpoint
-       var xappName string
-       e2termep = getEndpointByName(&eps, "E2TERM")
-       submanep = getEndpointByName(&eps, "SUBMAN")
-       if e2termep != nil && submanep != nil {
-               // looping through the subscription list, add routes one by one
-               for _, sub := range *subs {
-                       // SubMan -> XApp
-                       xappName = sub.Fqdn + ":" + strconv.Itoa(int(sub.Port))
-                       xappEp = getEndpointByUuid(&eps, xappName)
-                       if xappEp == nil {
-                               rtmgr.Logger.Error("XApp not found: %s", xappName)
-                               rtmgr.Logger.Debug("Endpoints: %v", eps)
-                       } else {
-                               txlist := rtmgr.EndpointList{*submanep}
-                               rxlist := []rtmgr.EndpointList{[]rtmgr.Endpoint{*xappEp}}
-                               subManMsgs := []string{"RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}
-                               for _, entry := range subManMsgs {
-                                       rte := rtmgr.RouteTableEntry{
-                                               rtmgr.MESSAGETYPES[entry],
-                                               txlist,
-                                               rxlist,
-                                               sub.SubID,
-                                       }
-                                       *rt = append(*rt, rte)
-                               }
-                               // E2Term -> XApp
-                               txlist = rtmgr.EndpointList{*e2termep}
-                               rxlist = []rtmgr.EndpointList{[]rtmgr.Endpoint{*xappEp}}
-                               e2apMsgs := []string{"RIC_CONTROL_ACK", "RIC_CONTROL_FAILURE", "RIC_INDICATION"}
-                               for _, entry := range e2apMsgs {
-                                       rte := rtmgr.RouteTableEntry{
-                                               rtmgr.MESSAGETYPES[entry],
-                                               txlist,
-                                               rxlist,
-                                               sub.SubID,
-                                       }
-                                       *rt = append(*rt, rte)
-                               }
-                       }
+
+func (r *Rpe) addRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
+       txList := rtmgr.EndpointList{*tx}
+       rxList := []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
+       messageId := rtmgr.MESSAGETYPES[messageType]
+       route := rtmgr.RouteTableEntry{
+               messageId,
+               txList,
+               rxList,
+               -1}
+       *routeTable = append(*routeTable, route)
+       rtmgr.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: -1", messageId, txList, rxList)
+}
+
+func (r *Rpe) addSubscriptionRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoint, routeTable *rtmgr.RouteTable, subId int32) {
+       txList := rtmgr.EndpointList{*tx}
+       rxList := []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
+       messageId := rtmgr.MESSAGETYPES[messageType]
+       route := rtmgr.RouteTableEntry{
+               messageId,
+               txList,
+               rxList,
+               subId,
+       }
+       *routeTable = append(*routeTable, route)
+       rtmgr.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, txList, rxList, subId)
+}
+
+func (r *Rpe) generateXappRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
+       rtmgr.Logger.Debug("rpe.generateXappRoutes invoked")
+       endPointList := rtmgr.Eps
+       for _, endPoint := range endPointList {
+               rtmgr.Logger.Debug("Endpoint: %v, xAppType: %v", endPoint.Name, endPoint.XAppType)
+               if endPoint.XAppType != sbi.PLATFORMTYPE && len(endPoint.TxMessages) > 0 && len(endPoint.RxMessages) > 0 {
+                       //xApp -> Subscription Manager
+                       r.addRoute("RIC_SUB_REQ", endPoint, subManEp, routeTable)
+                       r.addRoute("RIC_SUB_DEL_REQ", endPoint, subManEp, routeTable)
+                       //xApp -> E2 Termination
+                       r.addRoute("RIC_CONTROL_REQ", endPoint, e2TermEp, routeTable)
                }
-               rtmgr.Logger.Debug("addSubscriptionRoutes eps: %v", eps)
-       } else {
-               rtmgr.Logger.Warn("Subscription route update failure: Cannot get the static route details of the platform components E2TERM/SUBMAN")
        }
+}
 
+func (r *Rpe) generateSubscriptionRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
+       rtmgr.Logger.Debug("rpe.addSubscriptionRoutes invoked")
+       subscriptionList := rtmgr.Subs
+       for _, subscription := range subscriptionList {
+               rtmgr.Logger.Debug("Subscription: %v", subscription)
+               xAppUuid := subscription.Fqdn + ":" + strconv.Itoa(int(subscription.Port))
+               rtmgr.Logger.Debug("xApp UUID: %v", xAppUuid)
+               xAppEp := getEndpointByUuid(xAppUuid)
+               //Subscription Manager -> xApp
+               r.addSubscriptionRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID)
+               r.addSubscriptionRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID)
+               r.addSubscriptionRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, subscription.SubID)
+               r.addSubscriptionRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID)
+               //E2 Termination -> xApp
+               r.addSubscriptionRoute("RIC_INDICATION", e2TermEp, xAppEp, routeTable, subscription.SubID)
+               r.addSubscriptionRoute("RIC_CONTROL_ACK", e2TermEp, xAppEp, routeTable, subscription.SubID)
+               r.addSubscriptionRoute("RIC_CONTROL_FAILURE", e2TermEp, xAppEp, routeTable, subscription.SubID)
+       }
+}
+
+func (r *Rpe) generatePlatformRoutes(e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, e2ManEp *rtmgr.Endpoint, ueManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
+       rtmgr.Logger.Debug("rpe.generatePlatformRoutes invoked")
+       //Platform Routes --- Subscription Routes
+       //Subscription Manager -> E2 Termination
+       r.addRoute("RIC_SUB_REQ", subManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_SUB_DEL_REQ", subManEp, e2TermEp, routeTable)
+       //E2 Termination -> Subscription Manager
+       r.addRoute("RIC_SUB_RESP", e2TermEp, subManEp, routeTable)
+       r.addRoute("RIC_SUB_DEL_RESP", e2TermEp, subManEp, routeTable)
+       r.addRoute("RIC_SUB_FAILURE", e2TermEp, subManEp, routeTable)
+       r.addRoute("RIC_SUB_DEL_FAILURE", e2TermEp, subManEp, routeTable)
+       //TODO: UE Man Routes removed (since it is not existing)
+       //UE Manager -> Subscription Manager
+       //r.addRoute("RIC_SUB_REQ", ueManEp, subManEp, routeTable)
+       //r.addRoute("RIC_SUB_DEL_REQ", ueManEp, subManEp, routeTable)
+       ////UE Manager -> E2 Termination
+       //r.addRoute("RIC_CONTROL_REQ", ueManEp, e2TermEp, routeTable)
+
+       //Platform Routes --- X2 Routes
+       //E2 Manager -> E2 Termination
+       r.addRoute("RIC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_X2_RESET_RESP", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_ENDC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_ENDC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_ENDC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable)
+       //E2 Termination -> E2 Manager
+       r.addRoute("RIC_X2_SETUP_REQ", e2TermEp, e2ManEp, routeTable)
+       r.addRoute("RIC_X2_SETUP_RESP", e2TermEp, e2ManEp, routeTable)
+       r.addRoute("RIC_X2_RESET", e2TermEp, e2ManEp, routeTable)
+       r.addRoute("RIC_X2_RESOURCE_STATUS_RESPONSE", e2TermEp, e2ManEp, routeTable)
+       r.addRoute("RIC_X2_RESET_RESP", e2TermEp, e2ManEp, routeTable)
+       r.addRoute("RIC_ENDC_X2_SETUP_REQ", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_ENDC_X2_SETUP_RESP", e2ManEp, e2TermEp, routeTable)
+       r.addRoute("RIC_ENDC_X2_SETUP_FAILURE", e2ManEp, e2TermEp, routeTable)
+}
+
+func (r *Rpe) generateRouteTable(endPointList rtmgr.Endpoints) *rtmgr.RouteTable {
+       rtmgr.Logger.Debug("rpe.generateRouteTable invoked")
+       rtmgr.Logger.Debug("Endpoint List:  %v", endPointList)
+       routeTable := &rtmgr.RouteTable{}
+       e2TermEp := getEndpointByName(&endPointList, "E2TERM")
+       if e2TermEp == nil {
+               rtmgr.Logger.Error("Platform component not found: %v", "E2 Termination")
+               rtmgr.Logger.Debug("Endpoints: %v", endPointList)
+       }
+       subManEp := getEndpointByName(&endPointList, "SUBMAN")
+       if subManEp == nil {
+               rtmgr.Logger.Error("Platform component not found: %v", "Subscription Manager")
+               rtmgr.Logger.Debug("Endpoints: %v", endPointList)
+       }
+       e2ManEp := getEndpointByName(&endPointList, "E2MAN")
+       if e2ManEp == nil {
+               rtmgr.Logger.Error("Platform component not found: %v", "E2 Manager")
+               rtmgr.Logger.Debug("Endpoints: %v", endPointList)
+       }
+       ueManEp := getEndpointByName(&endPointList, "UEMAN")
+       if ueManEp == nil {
+               rtmgr.Logger.Error("Platform component not found: %v", "UE Manger")
+               rtmgr.Logger.Debug("Endpoints: %v", endPointList)
+       }
+       r.generatePlatformRoutes(e2TermEp, subManEp, e2ManEp, ueManEp, routeTable)
+
+       for _, endPoint := range endPointList {
+               rtmgr.Logger.Debug("Endpoint: %v, xAppType: %v", endPoint.Name, endPoint.XAppType)
+               if endPoint.XAppType != sbi.PLATFORMTYPE && len(endPoint.TxMessages) > 0 && len(endPoint.RxMessages) > 0 {
+                       r.generateXappRoutes(e2TermEp, subManEp, routeTable)
+                       r.generateSubscriptionRoutes(e2TermEp, subManEp, routeTable)
+               }
+       }
+       return routeTable
 }
index 426cc7c..f55b08e 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
   Mnemonic:    rpe/types.go
-  Abstract:    Containes RPE (Route Policy Engine) specific types
+  Abstract:    Contains RPE (Route Policy Engine) specific types
   Date:                12 March 2019
 */
 
@@ -27,7 +27,7 @@ package rpe
 import "routing-manager/pkg/rtmgr"
 
 type generatePolicies func(rtmgr.Endpoints) *[]string
-type getRouteTable func(rtmgr.Endpoints) *rtmgr.RouteTable
+type generateRouteTable func(rtmgr.Endpoints) *rtmgr.RouteTable
 
 type RpeEngineConfig struct {
        Name        string
@@ -39,5 +39,5 @@ type RpeEngineConfig struct {
 
 type RpeEngine interface {
        GeneratePolicies(rtmgr.Endpoints) *[]string
-       GetRouteTable(rtmgr.Endpoints) *rtmgr.RouteTable
+       GenerateRouteTable(rtmgr.Endpoints) *rtmgr.RouteTable
 }
index 5b27d76..9118685 100644 (file)
 package rtmgr
 
 import (
-       "github.com/jcelliott/lumber"
+       "encoding/json"
        "errors"
-       "strings"
-       "os"
+       "github.com/jcelliott/lumber"
        "io/ioutil"
-       "encoding/json"
+       "os"
+       "strings"
 )
 
 var (
@@ -58,51 +58,51 @@ var (
                "RIC_CONTROL_XAPP_CONFIG_REQUEST":  "100000",
                "RIC_CONTROL_XAPP_CONFIG_RESPONSE": "100001",
 
-               "RIC_X2_SETUP_REQ":                 "10060",
-               "RIC_X2_SETUP_RESP":                "10061",
-               "RIC_X2_SETUP_FAILURE":             "10062",
-               "RIC_X2_RESET":                     "10070",
-               "RIC_X2_RESET_RESP":                "10071",
+               "RIC_X2_SETUP_REQ":     "10060",
+               "RIC_X2_SETUP_RESP":    "10061",
+               "RIC_X2_SETUP_FAILURE": "10062",
+               "RIC_X2_RESET":         "10070",
+               "RIC_X2_RESET_RESP":    "10071",
 
-               "RIC_SUB_REQ":                      "12010",
-               "RIC_SUB_RESP":                     "12011",
-               "RIC_SUB_FAILURE":                  "12012",
-               "RIC_SUB_DEL_REQ":                  "12020",
-               "RIC_SUB_DEL_RESP":                 "12021",
-               "RIC_SUB_DEL_FAILURE":              "12022",
+               "RIC_SUB_REQ":         "12010",
+               "RIC_SUB_RESP":        "12011",
+               "RIC_SUB_FAILURE":     "12012",
+               "RIC_SUB_DEL_REQ":     "12020",
+               "RIC_SUB_DEL_RESP":    "12021",
+               "RIC_SUB_DEL_FAILURE": "12022",
 
-               "RIC_CONTROL_REQ":                  "12040",
-               "RIC_CONTROL_ACK":                  "12041",
-               "RIC_CONTROL_FAILURE":              "12042",
-               "RIC_INDICATION":                   "12050",
-               "RIC_ENDC_X2_SETUP_REQ":            "10360",
-               "RIC_ENDC_X2_SETUP_RESP":           "10361",
-               "RIC_ENDC_X2_SETUP_FAILURE":        "10362",
-               "RIC_ENDC_CONF_UPDATE":             "10370",
-               "RIC_ENDC_CONF_UPDATE_ACK":         "10371",
-               "RIC_ENDC_CONF_UPDATE_FAILURE":     "10372",
-               "RIC_RES_STATUS_REQ":               "10090",
-               "RIC_RES_STATUS_RESP":              "10091",
-               "RIC_RES_STATUS_FAILURE":           "10092",
-               "RIC_ENB_CONF_UPDATE":              "10080",
-               "RIC_ENB_CONF_UPDATE_ACK":          "10081",
-               "RIC_ENB_CONF_UPDATE_FAILURE":      "10082",
-               "RIC_ENB_LOAD_INFORMATION":         "10020",
-               "RIC_GNB_STATUS_INDICATION":        "10450",
-               "RIC_RESOURCE_STATUS_UPDATE":       "10100",
-               "RIC_ERROR_INDICATION":             "10030",
-               "DC_ADM_INT_CONTROL":               "20000",
-               "DC_ADM_INT_CONTROL_ACK":           "20001",
+               "RIC_CONTROL_REQ":              "12040",
+               "RIC_CONTROL_ACK":              "12041",
+               "RIC_CONTROL_FAILURE":          "12042",
+               "RIC_INDICATION":               "12050",
+               "RIC_ENDC_X2_SETUP_REQ":        "10360",
+               "RIC_ENDC_X2_SETUP_RESP":       "10361",
+               "RIC_ENDC_X2_SETUP_FAILURE":    "10362",
+               "RIC_ENDC_CONF_UPDATE":         "10370",
+               "RIC_ENDC_CONF_UPDATE_ACK":     "10371",
+               "RIC_ENDC_CONF_UPDATE_FAILURE": "10372",
+               "RIC_RES_STATUS_REQ":           "10090",
+               "RIC_RES_STATUS_RESP":          "10091",
+               "RIC_RES_STATUS_FAILURE":       "10092",
+               "RIC_ENB_CONF_UPDATE":          "10080",
+               "RIC_ENB_CONF_UPDATE_ACK":      "10081",
+               "RIC_ENB_CONF_UPDATE_FAILURE":  "10082",
+               "RIC_ENB_LOAD_INFORMATION":     "10020",
+               "RIC_GNB_STATUS_INDICATION":    "10450",
+               "RIC_RESOURCE_STATUS_UPDATE":   "10100",
+               "RIC_ERROR_INDICATION":         "10030",
+               "DC_ADM_INT_CONTROL":           "20000",
+               "DC_ADM_INT_CONTROL_ACK":       "20001",
        }
 
-       // Messagetype mappings for the platform components. 
+       // Messagetype mappings for the platform components.
        // This implements static default routes needed by the RIC. Needs to be changed in case new components/message types needes to be added/updated.
        // Representation : {"componentName1": {"tx": <tx message type list>, "rx": <rx message type list>}}
        PLATFORMMESSAGETYPES = map[string]map[string][]string{
-               "E2TERM":   {"tx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE", "RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}, "rx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE", "RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ"}},
-               "E2MAN":    {"tx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE"}, "rx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE"}},
-               "SUBMAN":   {"tx": []string{"RIC_SUB_REQ", "RIC_SUB_DEL_REQ"}, "rx": []string{"RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}},
-               "UEMAN":    {"tx": []string{"RIC_CONTROL_REQ"}, "rx": []string{}},
+               "E2TERM": {"tx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE", "RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}, "rx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE", "RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ"}},
+               "E2MAN":  {"tx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE"}, "rx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE"}},
+               "SUBMAN": {"tx": []string{"RIC_SUB_REQ", "RIC_SUB_DEL_REQ"}, "rx": []string{"RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}},
+               "UEMAN":  {"tx": []string{"RIC_CONTROL_REQ"}, "rx": []string{}},
        }
 
        Logger = lumber.NewConsoleLogger(lumber.INFO)
@@ -110,7 +110,7 @@ var (
        Subs   SubscriptionList
 )
 
-func SetLogLevel(loglevel string) error{
+func SetLogLevel(loglevel string) error {
        switch strings.ToUpper(loglevel) {
        case "INFO":
                Logger.Level(lumber.INFO)
@@ -133,7 +133,7 @@ func SetLogLevel(loglevel string) error{
 }
 
 func GetPlatformComponents(configfile string) (*PlatformComponents, error) {
-       Logger.Debug("Invoked rtmgr.GetPlatformComponents("+ configfile +")")
+       Logger.Debug("Invoked rtmgr.GetPlatformComponents(" + configfile + ")")
        var rcfg RtmgrConfig
        jsonFile, err := os.Open(configfile)
        if err != nil {
@@ -151,4 +151,3 @@ func GetPlatformComponents(configfile string) (*PlatformComponents, error) {
        Logger.Debug("Platform components read from the configfile:  %v", rcfg.Pcs)
        return &(rcfg.Pcs), nil
 }
-
index ad6c504..3c089fc 100644 (file)
@@ -29,18 +29,17 @@ import (
 )
 
 func TestSetLogLevel(t *testing.T) {
-       modes_ok := []string{"info","warn","debug","error"}
-       modes_nok := []string{"inValId","LogLEVEL","PRoviDeD"}
-       for _, value := range(modes_ok) {
+       modes_ok := []string{"info", "warn", "debug", "error"}
+       modes_nok := []string{"inValId", "LogLEVEL", "PRoviDeD"}
+       for _, value := range modes_ok {
                if SetLogLevel(value) != nil {
                        t.Error("Invalid log level: " + value)
                }
        }
 
-        for _, value := range(modes_nok) {
-                if SetLogLevel(value) == nil {
-                        t.Error("Invalid log level: " + value)
-                }
-        }
+       for _, value := range modes_nok {
+               if SetLogLevel(value) == nil {
+                       t.Error("Invalid log level: " + value)
+               }
+       }
 }
-
index 80d2dc0..dc46e24 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
   Mnemonic:    rtmgr/types.go
-  Abstract:    Containes RTMGR (Routing Manager) specific types
+  Abstract:    Contains RTMGR (Routing Manager) specific types
   Date:                12 March 2019
 */
 
@@ -35,7 +35,6 @@ type Endpoints map[string]*Endpoint
 
 type SubscriptionList []Subscription
 
-
 //TODO: uuid is not a real UUID but a string of "ip:port"
 // this should be changed to real UUID later on which should come from xApp Manager // petszila
 type Endpoint struct {
@@ -90,8 +89,7 @@ type RicComponents struct {
 }
 
 type Subscription struct {
-       SubID    int32
-       Fqdn     string
-       Port     uint16
+       SubID int32
+       Fqdn  string
+       Port  uint16
 }
-
diff --git a/pkg/sbi/nngpub.go b/pkg/sbi/nngpub.go
deleted file mode 100644 (file)
index ae96aa4..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-==================================================================================
-  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/protocol/pub"
-       _ "nanomsg.org/go/mangos/v2/transport/all"
-       "routing-manager/pkg/rtmgr"
-       "strconv"
-)
-
-type NngPub struct {
-       Sbi
-       socket NngSocket
-       NewSocket CreateNewNngSocketHandler
-}
-
-func NewNngPub() *NngPub {
-       instance := new(NngPub)
-       instance.NewSocket = createNewPubSocket
-       return instance
-}
-
-func createNewPubSocket() (NngSocket, error) {
-       rtmgr.Logger.Debug("Invoked createNewPubSocket()")
-       s, err := pub.NewSocket()
-       if err != nil {
-               return nil, errors.New("can't create new pub socket due to: " + err.Error())
-       }
-       return s, nil
-}
-
-func (c *NngPub) Initialize(ip string) error {
-       rtmgr.Logger.Debug("Invoked sbi.Initialize("+ ip +")")
-       var err error
-       c.socket, err = c.NewSocket()
-       if err != nil {
-               return errors.New("create socket error due to: " + err.Error())
-       }
-       if err = c.listen(ip); err != nil {
-               return errors.New("can't listen on socket due to: " + err.Error())
-       }
-       return nil
-}
-
-func (c *NngPub) Terminate() error {
-       rtmgr.Logger.Debug("Invoked sbi.Terminate()")
-       return c.closeSocket()
-}
-
-func (c *NngPub) AddEndpoint(ep *rtmgr.Endpoint) error {
-       return nil
-}
-
-func (c *NngPub) DeleteEndpoint(ep *rtmgr.Endpoint) error {
-       return nil
-}
-
-func (c *NngPub) UpdateEndpoints(rcs *rtmgr.RicComponents) {
-       c.updateEndpoints(rcs, c)
-}
-
-func (c *NngPub) listen(ip string) error {
-       rtmgr.Logger.Debug("Start listening on: " + ip)
-       uri := DEFAULT_NNG_PUBSUB_SOCKET_PREFIX + ip + ":" + strconv.Itoa(DEFAULT_NNG_PUBSUB_SOCKET_NUMBER)
-       rtmgr.Logger.Info("publishing on: " + uri)
-       if err := c.socket.(NngSocket).Listen(uri); err != nil {
-               return errors.New("can't publish on socket " + uri + " due to: " + err.Error())
-       }
-       return nil
-}
-
-func (c *NngPub) closeSocket() error {
-       rtmgr.Logger.Debug("Close NngPub Socket")
-       if err := c.socket.(NngSocket).Close(); err != nil {
-               return errors.New("can't close socket due to: " + err.Error())
-       }
-       return nil
-}
-
-func (c *NngPub) DistributeAll(policies *[]string) error {
-       rtmgr.Logger.Debug("Invoked: sbi.DistributeAll(), args: %v",(*policies))
-       for _, pe := range *policies {
-               if err := c.socket.(NngSocket).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/nngpub_test.go b/pkg/sbi/nngpub_test.go
deleted file mode 100644 (file)
index 85a300c..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
-==================================================================================
-   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_test.go
-       Abstract:
-       Date:           25 April 2019
-*/
-package sbi
-
-import (
-       "errors"
-       "routing-manager/pkg/rtmgr"
-       "routing-manager/pkg/stub"
-       "testing"
-)
-
-/*
-Returns an error free Socket instance
-*/
-func createNewStubPubSocket() (NngSocket, error) {
-       socket := stub.MangosSocket{}
-       return socket, nil
-}
-
-/*
-Returns a SocketError
-*/
-func createNewStubPubSocketError() (NngSocket, error) {
-       return nil, errors.New("stub generated Create Socket error")
-}
-
-/*
-Returns a Socket which always generates error on Close()
-*/
-func createNewStubPubSocketCloseError() (NngSocket, error) {
-       socket := stub.MangosSocket{}
-       socket.GenerateSocketCloseError = true
-       return socket, nil
-}
-
-/*
-Returns a Socket which always generates error on Listen()
-*/
-func createNewStubPubSocketListenError() (NngSocket, error) {
-       socket := stub.MangosSocket{}
-       socket.GenerateSocketListenError = true
-       return socket, nil
-}
-
-/*
-Returns a Socket which always generates error on Send()
-*/
-func createNewStubPubSocketSendError() (NngSocket, error) {
-       socket := stub.MangosSocket{}
-       socket.GenerateSocketSendError = true
-       return socket, nil
-}
-
-/*
-Resets the EndpointList according to argumnets
-*/
-func resetTestPubDataset(instance NngPub, testdata []rtmgr.Endpoint) {
-       rtmgr.Eps = make(map[string]*rtmgr.Endpoint)
-       for _, endpoint := range testdata {
-               ep := endpoint
-               ep.Socket, _ = instance.NewSocket()
-               rtmgr.Eps[ep.Uuid] = &ep
-       }
-}
-
-/*
-nngPub.Initialize() method is tested for happy path case
-*/
-func TestNngPubInitialize(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocket
-
-       err := nngpub.Initialize("")
-       if err != nil {
-               t.Errorf("nngPub.Initialize() was incorrect, got: %v, want: %v.", err, nil)
-       }
-}
-
-/*
-nngPub.Initialize() is tested for Socket creating error case
-*/
-func TestNngPubInitializeWithSocketError(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocketError
-
-       err := nngpub.Initialize("")
-       if err == nil {
-               t.Errorf("nngPub.Initialize() was incorrect, got: %v, want: %v.", nil, "error")
-       }
-}
-
-/*
-nngPub.Initialize() is tested for Socket listening error case
-*/
-func TestNngPubInitializeWithSocketListenError(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocketListenError
-
-       err := nngpub.Initialize("")
-       if err == nil {
-               t.Errorf("nngPub.Initialize() was incorrect, got: %v, want: %v.", nil, "error")
-       }
-}
-
-/*
-nngPub.Terminate() method is empty, nothing to be tested
-*/
-func TestNngPubTerminate(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocket
-       nngpub.Initialize("")
-
-       err := nngpub.Terminate()
-       if err != nil {
-               t.Errorf("nngPub.Terminate() was incorrect, got: %v, want: %v.", err, nil)
-       }
-}
-
-/*
-nngPub.Terminate() is tested for Socket closing error case
-*/
-func TestNngPubTerminateWithSocketCloseError(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocketCloseError
-       nngpub.Initialize("")
-
-       err := nngpub.Terminate()
-       if err == nil {
-               t.Errorf("nngPub.Terminate() was incorrect, got: %v, want: %v.", nil, "error")
-       }
-}
-
-/*
-nngPub.UpdateEndpoints() is testd against stub.ValidXapps dataset
-*/
-func TestNngPubUpdateEndpoints(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocket
-       nngpub.Initialize("")
-       rtmgr.Eps = make(rtmgr.Endpoints)
-       nngpub.UpdateEndpoints(&stub.ValidRicComponents)
-       if rtmgr.Eps == nil {
-               t.Errorf("nngPub.UpdateEndpoints() result was incorrect, got: %v, want: %v.", nil, "rtmgr.Endpoints")
-       }
-}
-
-/*
-nngPub.AddEndpoint() method is empty, nothing to be tested
-*/
-func TestNngPubAddEndpoint(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocket
-
-       _ = nngpub.AddEndpoint(new(rtmgr.Endpoint))
-}
-
-/*
-nngPub.DeleteEndpoint() method is empty, nothing to be tested
-*/
-func TestNngPubDeleteEndpoint(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocket
-
-       _ = nngpub.DeleteEndpoint(new(rtmgr.Endpoint))
-}
-
-/*
-nngPub.DistributeAll() is tested for happy path case
-*/
-func TestNngPubDistributeAll(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocket
-       nngpub.Initialize("")
-       resetTestPubDataset(nngpub, stub.ValidEndpoints)
-
-       err := nngpub.DistributeAll(stub.ValidPolicies)
-       if err != nil {
-               t.Errorf("nngPub.DistributeAll(policies) was incorrect, got: %v, want: %v.", err, nil)
-       }
-}
-
-/*
-nngPub.DistributeAll() is tested for Sending error case
-*/
-func TestNngPubDistributeAllSocketSendError(t *testing.T) {
-       var nngpub = NngPub{}
-       nngpub.NewSocket = createNewStubPubSocketSendError
-       nngpub.Initialize("")
-       resetTestPubDataset(nngpub, stub.ValidEndpoints)
-
-       err := nngpub.DistributeAll(stub.ValidPolicies)
-       if err == nil {
-               t.Errorf("nngPub.DistributeAll(policies) was incorrect, got: %v, want: %v.", nil, "error")
-       }
-}
index 6f2535c..bb39be4 100644 (file)
@@ -99,9 +99,9 @@ func (c *NngPush) AddEndpoint(ep *rtmgr.Endpoint) error {
 func (c *NngPush) DeleteEndpoint(ep *rtmgr.Endpoint) error {
        rtmgr.Logger.Debug("Invoked sbi. DeleteEndpoint")
        rtmgr.Logger.Debug("args: %v", (*ep))
-       if err:= ep.Socket.(NngSocket).Close(); err != nil {
-                       return errors.New("can't close push socket of endpoint:" + ep.Uuid + " due to: " + err.Error())
-               }
+       if err := ep.Socket.(NngSocket).Close(); err != nil {
+               return errors.New("can't close push socket of endpoint:" + ep.Uuid + " due to: " + err.Error())
+       }
        return nil
 }
 
@@ -137,11 +137,11 @@ func (c *NngPush) DistributeAll(policies *[]string) error {
 }
 
 func (c *NngPush) send(ep *rtmgr.Endpoint, policies *[]string) {
-       rtmgr.Logger.Debug("Push policy to endpoint: "+ ep.Uuid)
+       rtmgr.Logger.Debug("Push policy to endpoint: " + ep.Uuid)
        for _, pe := range *policies {
                if err := ep.Socket.(NngSocket).Send([]byte(pe)); err != nil {
                        rtmgr.Logger.Error("Unable to send policy entry due to: " + err.Error())
                }
        }
-       rtmgr.Logger.Info("NNG PUSH to ednpoint " + ep.Uuid + ": OK (# of Entries:" + strconv.Itoa(len((*policies))) + ")")
+       rtmgr.Logger.Info("NNG PUSH to endpoint " + ep.Uuid + ": OK (# of Entries:" + strconv.Itoa(len((*policies))) + ")")
 }
index 09d9381..5b94cbd 100644 (file)
@@ -27,32 +27,23 @@ package sbi
 
 import (
        "errors"
-        "strconv"
        "routing-manager/pkg/rtmgr"
+       "strconv"
 )
 
-const DEFAULT_NNG_PUBSUB_SOCKET_PREFIX = "tcp://"
-const DEFAULT_NNG_PUBSUB_SOCKET_NUMBER = 4560
 const DEFAULT_NNG_PIPELINE_SOCKET_PREFIX = "tcp://"
 const DEFAULT_NNG_PIPELINE_SOCKET_NUMBER = 4561
-const PLATFORMTYPE = "platformcomponenttype"
+const PLATFORMTYPE = "platform"
 
 var (
        SupportedSbis = []*SbiEngineConfig{
                &SbiEngineConfig{
-                        Name:     "nngpush",
-                        Version:  "v1",
-                        Protocol: "nngpipeline",
-                        Instance: NewNngPush(),
-                        IsAvailable: true,
-                },
-               &SbiEngineConfig{
-                        Name:     "nngpub",
-                        Version:  "v1",
-                        Protocol: "nngpubsub",
-                        Instance: NewNngPub(),
-                        IsAvailable: true,
-                },
+                       Name:        "nngpush",
+                       Version:     "v1",
+                       Protocol:    "nngpipeline",
+                       Instance:    NewNngPush(),
+                       IsAvailable: true,
+               },
        }
 )
 
@@ -66,78 +57,76 @@ func GetSbi(sbiName string) (SbiEngine, error) {
 }
 
 type Sbi struct {
-
 }
 
-func (s *Sbi) pruneEndpointList(sbii SbiEngine) {
-        for _, ep := range rtmgr.Eps {
-                if !ep.Keepalive {
-                       rtmgr.Logger.Debug("deleting %v",ep)
-                       sbii.DeleteEndpoint(ep)
-                        delete(rtmgr.Eps, ep.Uuid)
-                } else {
-                        rtmgr.Eps[ep.Uuid].Keepalive = false
-                }
-        }
+func (s *Sbi) pruneEndpointList(sbi SbiEngine) {
+       for _, ep := range rtmgr.Eps {
+               if !ep.Keepalive {
+                       rtmgr.Logger.Debug("deleting %v", ep)
+                       sbi.DeleteEndpoint(ep)
+                       delete(rtmgr.Eps, ep.Uuid)
+               } else {
+                       rtmgr.Eps[ep.Uuid].Keepalive = false
+               }
+       }
 }
 
 func (s *Sbi) updateEndpoints(rcs *rtmgr.RicComponents, sbii SbiEngine) {
        for _, xapp := range (*rcs).Xapps {
-                for _, instance := range xapp.Instances {
-                        uuid := instance.Ip + ":" + strconv.Itoa(int(instance.Port))
-                        if _, ok := rtmgr.Eps[uuid]; ok {
-                                rtmgr.Eps[uuid].Keepalive = true
-                        } else {
-                                ep := &rtmgr.Endpoint{
-                                        uuid,
-                                        instance.Name,
-                                        xapp.Name,
-                                        instance.Ip,
-                                        instance.Port,
-                                        instance.TxMessages,
-                                        instance.RxMessages,
-                                        nil,
-                                        false,
-                                        true,
-                                }
-                                if err := sbii.AddEndpoint(ep); err != nil {
-                                        rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
-                                        continue
-                                }
-                                rtmgr.Eps[uuid] = ep
-                        }
-                }
-        }
+               for _, instance := range xapp.Instances {
+                       uuid := instance.Ip + ":" + strconv.Itoa(int(instance.Port))
+                       if _, ok := rtmgr.Eps[uuid]; ok {
+                               rtmgr.Eps[uuid].Keepalive = true
+                       } else {
+                               ep := &rtmgr.Endpoint{
+                                       uuid,
+                                       instance.Name,
+                                       xapp.Name,
+                                       instance.Ip,
+                                       instance.Port,
+                                       instance.TxMessages,
+                                       instance.RxMessages,
+                                       nil,
+                                       false,
+                                       true,
+                               }
+                               if err := sbii.AddEndpoint(ep); err != nil {
+                                       rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
+                                       continue
+                               }
+                               rtmgr.Eps[uuid] = ep
+                       }
+               }
+       }
        s.updatePlatformEndpoints(&((*rcs).Pcs), sbii)
-        s.pruneEndpointList(sbii)
+       s.pruneEndpointList(sbii)
 }
 
-func (s *Sbi ) updatePlatformEndpoints(pcs *rtmgr.PlatformComponents, sbii SbiEngine) {
+func (s *Sbi) updatePlatformEndpoints(pcs *rtmgr.PlatformComponents, sbii SbiEngine) {
        rtmgr.Logger.Debug("updatePlatformEndpoints invoked. PCS: %v", *pcs)
-        for _, pc := range *pcs {
-                uuid := pc.Fqdn + ":" + strconv.Itoa(int(pc.Port))
-                if _, ok := rtmgr.Eps[uuid]; ok {
-                        rtmgr.Eps[uuid].Keepalive = true
-                } else {
-                        ep := &rtmgr.Endpoint{
-                                uuid,
-                                pc.Name,
-                                PLATFORMTYPE,
-                                pc.Fqdn,
-                                pc.Port,
-                                rtmgr.PLATFORMMESSAGETYPES[pc.Name]["tx"],
-                                rtmgr.PLATFORMMESSAGETYPES[pc.Name]["rx"],
-                                nil,
-                                false,
-                                true,
-                        }
-                       rtmgr.Logger.Debug("ep created: %v",ep)
-                        if err := sbii.AddEndpoint(ep); err != nil {
-                                rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
-                                continue
-                        }
-                        rtmgr.Eps[uuid] = ep
-                }
-        }
+       for _, pc := range *pcs {
+               uuid := pc.Fqdn + ":" + strconv.Itoa(int(pc.Port))
+               if _, ok := rtmgr.Eps[uuid]; ok {
+                       rtmgr.Eps[uuid].Keepalive = true
+               } else {
+                       ep := &rtmgr.Endpoint{
+                               uuid,
+                               pc.Name,
+                               PLATFORMTYPE,
+                               pc.Fqdn,
+                               pc.Port,
+                               rtmgr.PLATFORMMESSAGETYPES[pc.Name]["tx"],
+                               rtmgr.PLATFORMMESSAGETYPES[pc.Name]["rx"],
+                               nil,
+                               false,
+                               true,
+                       }
+                       rtmgr.Logger.Debug("ep created: %v", ep)
+                       if err := sbii.AddEndpoint(ep); err != nil {
+                               rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
+                               continue
+                       }
+                       rtmgr.Eps[uuid] = ep
+               }
+       }
 }
-
index 5c7e848..feba821 100644 (file)
 package sbi
 
 import (
-       "testing"
-       "reflect"
        "errors"
+       "reflect"
+       "testing"
 )
 
 func TestGetSbi(t *testing.T) {
        var errtype = errors.New("")
-       var sbitype = new(NngPub)
+       var sbitype = new(NngPush)
        var invalids = []string{"nngpus", ""}
 
-       sbii, err := GetSbi("nngpub")
+       sbii, err := GetSbi("nngpush")
        if err != nil {
                t.Errorf("GetSbi(nngpub) was incorrect, got: %v, want: %v.", reflect.TypeOf(err), nil)
        }
index 357d87c..b6dfcd5 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
   Mnemonic:    sbi/types.go
-  Abstract:    Containes SBI (SouthBound Interface) specific types
+  Abstract:    Contains SBI (SouthBound Interface) specific types
   Date:                16 March 2019
 */
 
@@ -27,27 +27,27 @@ package sbi
 import "routing-manager/pkg/rtmgr"
 
 type SbiEngineConfig struct {
-       Name     string
-       Version  string
-  Protocol string
-  Instance SbiEngine
-  IsAvailable bool
+       Name        string
+       Version     string
+       Protocol    string
+       Instance    SbiEngine
+       IsAvailable bool
 }
 
 type SbiEngine interface {
-  Initialize(string) error
-  Terminate() error
-  DistributeAll(*[]string) error
-  AddEndpoint(*rtmgr.Endpoint) error
-  DeleteEndpoint(*rtmgr.Endpoint) error
-  UpdateEndpoints(*rtmgr.RicComponents)
+       Initialize(string) error
+       Terminate() error
+       DistributeAll(*[]string) error
+       AddEndpoint(*rtmgr.Endpoint) error
+       DeleteEndpoint(*rtmgr.Endpoint) error
+       UpdateEndpoints(*rtmgr.RicComponents)
 }
 
 type NngSocket interface {
        Listen(string) error
        Send([]byte) error
-  Close() error
-  DialOptions(string, map[string]interface{}) error
+       Close() error
+       DialOptions(string, map[string]interface{}) error
 }
 
-type CreateNewNngSocketHandler func() (NngSocket,error)
+type CreateNewNngSocketHandler func() (NngSocket, error)
index 638f1af..b85b2d5 100644 (file)
@@ -48,7 +48,7 @@ func NewFile() *File {
 }
 
 func (f *File) ReadAll(file string) (*rtmgr.RicComponents, error) {
-       rtmgr.Logger.Debug("Invoked sdl.ReadAll("+ file +")")
+       rtmgr.Logger.Debug("Invoked sdl.ReadAll(" + file + ")")
        var rcs *rtmgr.RicComponents
        jsonFile, err := os.Open(file)
        if err != nil {
index b6e0bde..4d3d8d1 100644 (file)
@@ -31,17 +31,17 @@ import (
 var (
        SupportedSdls = []*SdlEngineConfig{
                &SdlEngineConfig{
-                       Name:     "file",
-                       Version:  "v1",
-                       Protocol: "rawfile",
-                       Instance: NewFile(),
+                       Name:        "file",
+                       Version:     "v1",
+                       Protocol:    "rawfile",
+                       Instance:    NewFile(),
                        IsAvailable: true,
                },
                &SdlEngineConfig{
-                       Name:     "redis",
-                       Version:  "v1",
-                       Protocol: "ndsl",
-                       Instance: nil,
+                       Name:        "redis",
+                       Version:     "v1",
+                       Protocol:    "ndsl",
+                       Instance:    nil,
                        IsAvailable: false,
                },
        }
@@ -57,5 +57,4 @@ func GetSdl(sdlName string) (SdlEngine, error) {
 }
 
 type Sdl struct {
-
 }
index dd86890..89fc89f 100644 (file)
@@ -29,15 +29,15 @@ type readAll func(string) (*rtmgr.RicComponents, error)
 type writeAll func(string, *rtmgr.RicComponents) error
 
 type SdlEngineConfig struct {
-       Name     string
-       Version  string
-  Protocol string
-  Instance SdlEngine
+       Name        string
+       Version     string
+       Protocol    string
+       Instance    SdlEngine
        IsAvailable bool
 }
 
 type SdlEngine interface {
-  ReadAll(string) (*rtmgr.RicComponents, error)
-  WriteAll(string, *rtmgr.RicComponents) error
-  WriteXapps(string, *[]rtmgr.XApp) error
+       ReadAll(string) (*rtmgr.RicComponents, error)
+       WriteAll(string, *rtmgr.RicComponents) error
+       WriteXapps(string, *[]rtmgr.XApp) error
 }
index 0620648..bdc82c4 100644 (file)
@@ -18,7 +18,7 @@
 */
 /*
   Mnemonic:    mangos.go
-  Abstract:    
+  Abstract:
   Date:                3 May 2019
 */
 
@@ -28,12 +28,12 @@ import "errors"
 
 type MangosMessage struct {
        Header []byte
-       Body []byte
-       Pipe MangosPipe
-       bbuf  []byte
-       hbuf  []byte
-       bsize int
-       pool  interface {}
+       Body   []byte
+       Pipe   MangosPipe
+       bbuf   []byte
+       hbuf   []byte
+       bsize  int
+       pool   interface{}
 }
 
 type MangosProtocolInfo struct {
@@ -46,7 +46,6 @@ type MangosProtocolInfo struct {
 // Mangos Listener Stub
 
 type MangosListener struct {
-
 }
 
 func (l MangosListener) Listen() error {
@@ -65,14 +64,14 @@ func (l MangosListener) SetOption(s string, i interface{}) error {
        return nil
 }
 
-func (l MangosListener) GetOption(s string) (interface{},error) {
+func (l MangosListener) GetOption(s string) (interface{}, error) {
        return nil, nil
 }
 
 // Mangos Dialer Stub
 
 type MangosDialer struct {
-       }
+}
 
 func (d MangosDialer) Open() error {
        return nil
@@ -90,14 +89,13 @@ func (d MangosDialer) SetOption(s string, i interface{}) error {
        return nil
 }
 
-func (d MangosDialer) GetOption(s string) (interface{},error) {
+func (d MangosDialer) GetOption(s string) (interface{}, error) {
        return nil, nil
 }
 
 // Mangos Context Stub
 
 type MangosContext struct {
-
 }
 
 func (c MangosContext) Close() error {
@@ -108,7 +106,7 @@ func (c MangosContext) SetOption(s string, i interface{}) error {
        return nil
 }
 
-func (c MangosContext) GetOption(s string) (interface{},error) {
+func (c MangosContext) GetOption(s string) (interface{}, error) {
        return nil, nil
 }
 
@@ -117,7 +115,7 @@ func (c MangosContext) Send(b []byte) error {
 }
 
 func (c MangosContext) Recv() ([]byte, error) {
-       return make([]byte,0), nil
+       return make([]byte, 0), nil
 }
 
 func (c MangosContext) SendMsg(*MangosMessage) error {
@@ -131,7 +129,6 @@ func (c MangosContext) RecvMsg() (*MangosMessage, error) {
 // Mangos Pipe Stub
 
 type MangosPipe struct {
-
 }
 
 func (p MangosPipe) ID() uint32 {
@@ -154,7 +151,7 @@ func (p MangosPipe) Address() string {
        return ""
 }
 
-func (p MangosPipe) GetOption(s string) (interface{},error) {
+func (p MangosPipe) GetOption(s string) (interface{}, error) {
        return nil, nil
 }
 
@@ -165,9 +162,9 @@ type PipeEventHook func(int, MangosPipe)
 // Mangos Socket Stub
 
 type MangosSocket struct {
-       GenerateSocketCloseError bool
-       GenerateSocketSendError bool
-       GenerateSocketDialError bool
+       GenerateSocketCloseError  bool
+       GenerateSocketSendError   bool
+       GenerateSocketDialError   bool
        GenerateSocketListenError bool
 }
 
@@ -190,7 +187,7 @@ func (s MangosSocket) Send(b []byte) error {
 }
 
 func (s MangosSocket) Recv() ([]byte, error) {
-       return make([]byte,0), nil
+       return make([]byte, 0), nil
 }
 
 func (s MangosSocket) SendMsg(*MangosMessage) error {
@@ -238,7 +235,7 @@ func (s MangosSocket) SetOption(t string, i interface{}) error {
        return nil
 }
 
-func (s MangosSocket) GetOption(t string) (interface{},error) {
+func (s MangosSocket) GetOption(t string) (interface{}, error) {
        return nil, nil
 }
 
@@ -253,7 +250,6 @@ func (s MangosSocket) SetPipeEventHook(p PipeEventHook) PipeEventHook {
 // Mangos ProtocolPipe Stub
 
 type MangosProtocolPipe struct {
-
 }
 
 func (p MangosProtocolPipe) ID() uint32 {
@@ -275,7 +271,6 @@ func (p MangosProtocolPipe) RecvMsg() *MangosMessage {
 // Mangos ProtocolContext Stub
 
 type MangosProtocolContext struct {
-
 }
 
 func (p MangosProtocolContext) Close() error {
index 9ab7d1d..06f2e30 100644 (file)
@@ -27,27 +27,27 @@ package stub
 import "routing-manager/pkg/rtmgr"
 
 var ValidXapps = &[]rtmgr.XApp{
-       rtmgr.XApp{Name: "app1", Status: "", Version: "", Instances: []rtmgr.XAppInstance{rtmgr.XAppInstance{Name: "instance1", Status: "unknown", Ip: "10.0.0.1", Port: 0, TxMessages: []string{"HandoverPreparation", "HandoverCancel"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
-       rtmgr.XApp{Name: "app2", Status: "", Version: "", Instances: []rtmgr.XAppInstance{rtmgr.XAppInstance{Name: "instance2", Status: "unknown", Ip: "192.168.0.1", Port: 0, TxMessages: []string{"HandoverCancel", "HandoverPreparation"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
-       rtmgr.XApp{Name: "app3", Status: "", Version: "", Instances: []rtmgr.XAppInstance{rtmgr.XAppInstance{Name: "instance2", Status: "unknown", Ip: "10.1.1.1", Port: 0, TxMessages: []string{"X2Setup"}, RxMessages: []string{"Reset", "UEContextRelease"}}}},
-       rtmgr.XApp{Name: "app4", Status: "", Version: "", Instances: []rtmgr.XAppInstance{rtmgr.XAppInstance{Name: "instance2", Status: "unknown", Ip: "10.2.2.1", Port: 0, TxMessages: []string{"Reset", "UEContextRelease"}, RxMessages: []string{"", ""}}}},
+       {Name: "app1", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "E2TERM", Status: "unknown", Ip: "10.0.0.1", Port: 0, TxMessages: []string{"HandoverPreparation", "HandoverCancel"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
+       {Name: "app2", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "SUBMAN", Status: "unknown", Ip: "192.168.0.1", Port: 0, TxMessages: []string{"HandoverCancel", "HandoverPreparation"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
+       {Name: "app3", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "E2MAN", Status: "unknown", Ip: "10.1.1.1", Port: 0, TxMessages: []string{"X2Setup"}, RxMessages: []string{"Reset", "UEContextRelease"}}}},
+       {Name: "app4", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "UEMAN", Status: "unknown", Ip: "10.2.2.1", Port: 0, TxMessages: []string{"Reset", "UEContextRelease"}, RxMessages: []string{"", ""}}}},
 }
 
-var ValidPlatformComponents = &rtmgr.PlatformComponents {
-       {Name:"E2TERM", Fqdn:"e2term", Port:4561},
-       {Name:"SUBMAN", Fqdn:"subman", Port:4561},
-       {Name:"E2MAN",  Fqdn:"e2man",  Port:4561},
-       {Name:"UEMAN",  Fqdn:"ueman",  Port:4561},
+var ValidPlatformComponents = &rtmgr.PlatformComponents{
+       {Name: "E2TERM", Fqdn: "e2term", Port: 4561},
+       {Name: "SUBMAN", Fqdn: "subman", Port: 4561},
+       {Name: "E2MAN", Fqdn: "e2man", Port: 4561},
+       {Name: "UEMAN", Fqdn: "ueman", Port: 4561},
 }
 
 var ValidEndpoints = []rtmgr.Endpoint{
-       rtmgr.Endpoint{Uuid: "10.0.0.1:0", Name: "i1", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
-       rtmgr.Endpoint{Uuid: "192.168.0.1:0", Name: "i2", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
-       rtmgr.Endpoint{Uuid: "10.1.1.1:0", Name: "i3", XAppType: "app3", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false},
-       rtmgr.Endpoint{Uuid: "10.2.2.1:0", Name: "i4", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: true},
+       {Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
+       {Uuid: "192.168.0.1:0", Name: "SUBMAN", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
+       {Uuid: "10.1.1.1:0", Name: "E2MAN", XAppType: "app3", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false},
+       {Uuid: "10.2.2.1:0", Name: "UEMAN", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: true},
 }
 
-var ValidRicComponents = rtmgr.RicComponents {
+var ValidRicComponents = rtmgr.RicComponents{
        *ValidXapps, *ValidPlatformComponents,
 }
 
diff --git a/test/README.md b/test/README.md
deleted file mode 100644 (file)
index 3fa3c89..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Examples or Testing Scripts/Manifests/Sample data
\ No newline at end of file
diff --git a/test/data/platform_routes.json b/test/data/platform_routes.json
deleted file mode 100644 (file)
index d53fe85..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-{
-    "PlatformComponents":
-    [
-        {
-            "name": "E2TERM",
-            "fqdn": "e2term",
-            "port": 4561
-        },
-        {
-            "name": "SUBMAN",
-            "fqdn": "subman",
-            "port": 4562
-        },
-        {
-            "name": "E2MAN",
-            "fqdn": "e2man",
-            "port": 4563
-        },
-        {
-            "name": "UEMAN",
-            "fqdn": "ueman",
-            "port": 4564
-        }
-    ]
-}
-
diff --git a/test/data/rt.json b/test/data/rt.json
deleted file mode 100644 (file)
index db80193..0000000
+++ /dev/null
@@ -1 +0,0 @@
-[{"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/data/xapps.json b/test/data/xapps.json
deleted file mode 100644 (file)
index 49db5c5..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-{
-  "id": 1,
-  "event": "whatever",
-  "data-version": 0,
-  "data":
-  "[{
-    \"name\": \"xapp-01\",
-    \"status\": \"unknown\",
-    \"version\": \"1.2.3\",
-    \"instances\": [{
-      \"name\": \"xapp-01-instance-01\",
-      \"status\": \"pending\",
-      \"ip\": \"10.244.0.51\",
-      \"port\": 4560,
-      \"txMessages\": [\"ControlIndication\", \"HandoverPreparation\"],
-      \"rxMessages\": [\"LoadIndication\", \"Reset\"]
-    },{
-      \"name\": \"xapp-01-instance-02\",
-      \"status\": \"pending\",
-      \"ip\": \"10.244.0.52\",
-      \"port\": 4560,
-      \"txMessages\": [\"ControlIndication\", \"HandoverPreparation\"],
-      \"rxMessages\": [\"LoadIndication\", \"Reset\"]
-    }]
-  },{
-    \"name\": \"xapp-02\",
-    \"status\": \"unknown\",
-    \"version\": \"1.2.3\",
-    \"instances\": [{
-      \"name\": \"xapp-02-instance-01\",
-      \"status\": \"pending\",
-      \"ip\": \"10.244.0.53\",
-      \"port\": 4560,
-      \"txMessages\": [\"ControlIndication\", \"HandoverPreparation\"],
-      \"rxMessages\": [\"LoadIndication\", \"Reset\"]
-    },{
-      \"name\": \"xapp-02-instance-01\",
-      \"status\": \"pending\",
-      \"ip\": \"10.244.0.54\",
-      \"port\": 4560,
-      \"txMessages\": [\"ControlIndication\", \"HandoverPreparation\"],
-      \"rxMessages\": [\"LoadIndication\", \"Reset\"]
-    }]
-  }]"
-}
\ No newline at end of file
diff --git a/test/docker/xapp-tx.build/Dockerfile b/test/docker/xapp-tx.build/Dockerfile
deleted file mode 100644 (file)
index de783dc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-#==================================================================================
-#   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
deleted file mode 100755 (executable)
index c50201a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#! /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
deleted file mode 100644 (file)
index 2aff362..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-#==================================================================================
-#   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
deleted file mode 100755 (executable)
index c2e952a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/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
deleted file mode 100644 (file)
index 8856f84..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-#==================================================================================
-#   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
-
-COPY middleware.js middleware.js
-
-RUN npm install -g json-server
diff --git a/test/docker/xmgr.build/middleware.js b/test/docker/xmgr.build/middleware.js
deleted file mode 100644 (file)
index 217fb4d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-module.exports = function (req, res, next) {
-  if (req.method === 'POST') {
-    // Converts POST to GET and move payload to query params
-    // This way it will make JSON Server that it's GET request
-    req.method = 'GET'
-    req.query = req.body
-  }
-  // Continue to JSON Server router
-  next()
-}
diff --git a/test/kubernetes/xapp-tx/xapp-tx.yaml b/test/kubernetes/xapp-tx/xapp-tx.yaml
deleted file mode 100644 (file)
index ae104b3..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-#==================================================================================
-#   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: 4561
-        env:
-        - name: NAME
-          value: "RM"
-        - name: PORT
-          value: "tcp:4561"
-        - 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
deleted file mode 100644 (file)
index 34dc5a3..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-#==================================================================================
-#   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
deleted file mode 100644 (file)
index caac0e8..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#
-#==================================================================================
-#   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"]
-                    }
-                ]
-            }
-    ],
-    "subscriptions":
-        {
-            "id": "1ILBltYYzEGzWRrVPZKmuUmhwcc",
-            "version": 0,
-            "eventType": "all"
-        }
-    }
-
diff --git a/test/kubernetes/xmgr/xmgr-dep.yaml b/test/kubernetes/xmgr/xmgr-dep.yaml
deleted file mode 100644 (file)
index b7aeeee..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-#==================================================================================
-#   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: xmgr:mock
-        args:
-        - json-server
-        - -w
-        - --host=0.0.0.0
-        - /db/xapps.json
-        - --middlewares=middleware.js
-        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
deleted file mode 100644 (file)
index ad56bf8..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-#==================================================================================
-#   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