Add a new API to return the list of undeployed xApps 88/388/4
authorMohamed Abukar <abukar.mohamed@nokia.com>
Thu, 20 Jun 2019 03:37:13 +0000 (06:37 +0300)
committerMohamed Abukar <abukar.mohamed@nokia.com>
Fri, 21 Jun 2019 11:04:42 +0000 (14:04 +0300)
Change-Id: I0cd95d5f19399aa94837b91338e544f1d8a20364
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
Dockerfile
api/appmgr_rest_api.json
api/appmgr_rest_api.yaml
cmd/appmgr/api.go
cmd/appmgr/api_test.go
cmd/appmgr/desc_test.go
cmd/appmgr/helm.go
cmd/appmgr/types.go

index c20bde2..db660b9 100644 (file)
@@ -69,9 +69,8 @@ CMD ["/bin/bash"]
 #----------------------------------------------------------
 FROM appmgr-xapp-base as appmgr-build
 
-ARG PACKAGEURL
-ARG HELMVERSION
-
+ARG HELMVERSION=v2.13.0-rc.1
+ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
 
 #
 # helm
@@ -105,7 +104,7 @@ CMD ["/bin/bash"]
 #
 #----------------------------------------------------------
 FROM appmgr-build as appmgr-test_unit
-ARG PACKAGEURL
+ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
 WORKDIR "/go/src/${PACKAGEURL}"
 CMD ["make","go-test"]
 
@@ -114,7 +113,7 @@ CMD ["make","go-test"]
 #
 #----------------------------------------------------------
 FROM appmgr-build as appmgr-test_fmt
-ARG PACKAGEURL
+ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
 WORKDIR "/go/src/${PACKAGEURL}"
 CMD ["make","go-test-fmt"]
 
@@ -122,7 +121,7 @@ CMD ["make","go-test-fmt"]
 #
 #----------------------------------------------------------
 FROM appmgr-build as appmgr-test_sanity
-ARG PACKAGEURL
+ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
 WORKDIR "/go/src/${PACKAGEURL}"
 CMD ["jq","-s",".", "api/appmgr_rest_api.json"]
 
@@ -131,7 +130,7 @@ CMD ["jq","-s",".", "api/appmgr_rest_api.json"]
 #
 #----------------------------------------------------------
 FROM ubuntu:16.04 as appmgr
-ARG PACKAGEURL
+ARG PACKAGEURL=gerrit.o-ran-sc.org/r/c/ric-plt/appmgr/
 
 RUN apt-get update -y \
     && apt-get install -y sudo openssl ca-certificates ca-cacert \
index 07390b0..9e8f076 100644 (file)
@@ -2,7 +2,7 @@
   "swagger": "2.0",
   "info": {
     "description": "This is a draft API for RIC appmgr",
-    "version": "0.1.3",
+    "version": "0.1.5",
     "title": "RIC appmgr",
     "license": {
       "name": "Apache 2.0",
@@ -12,7 +12,6 @@
   "host": "hostname",
   "basePath": "/ric/v1",
   "schemes": [
-    "https",
     "http"
   ],
   "paths": {
           "200": {
             "description": "successful query of xApps",
             "schema": {
-              "$ref": "#/definitions/AllXapps"
+              "$ref": "#/definitions/AllDeployedXapps"
+            }
+          },
+          "500": {
+            "description": "Internal error"
+          }
+        }
+      }
+    },
+    "/xapps/list": {
+        "get": {
+        "summary": "Returns the list of all deployable xapps",
+        "tags": [
+          "xapp"
+        ],
+        "operationId": "listAllXapps",
+        "produces": [
+          "application/json"
+        ],
+        "responses": {
+          "200": {
+            "description": "successful list of deployable xApps",
+            "schema": {
+              "$ref": "#/definitions/AllDeployableXapps"
             }
           },
           "500": {
     }
   },
   "definitions": {
-    "AllXapps": {
+    "AllDeployableXapps": {
+      "type": "array",
+      "items": {
+        "type": "string",
+        "example": "xapp-dummy"
+      }
+    },
+    "AllDeployedXapps": {
       "type": "array",
       "items": {
         "$ref": "#/definitions/Xapp"
           ]
         },
         "xApps": {
-          "$ref": "#/definitions/AllXapps"
+          "$ref": "#/definitions/AllDeployedXapps"
         }
       }
     }
index afa90f7..a15448f 100644 (file)
@@ -1,7 +1,7 @@
 swagger: '2.0'
 info:
   description: This is a draft API for RIC appmgr
-  version: 0.1.3
+  version: 0.1.5
   title: RIC appmgr
   license:
     name: Apache 2.0
@@ -9,7 +9,6 @@ info:
 host: hostname
 basePath: /ric/v1
 schemes:
-  - https
   - http
 paths:
   /health/alive :
@@ -95,7 +94,22 @@ paths:
         '200':
           description: successful query of xApps
           schema:
-            $ref: '#/definitions/AllXapps'
+            $ref: '#/definitions/AllDeployedXapps'
+        '500':
+          description: Internal error
+  '/xapps/list':
+    get:
+      summary: Returns the list of all deployable xapps
+      tags:
+        - xapp
+      operationId: listAllXapps
+      produces:
+        - application/json
+      responses:
+        '200':
+          description: successful list of deployable xApps
+          schema:
+            $ref: '#/definitions/AllDeployableXapps'
         '500':
           description: Internal error
   '/xapps/{xAppName}':
@@ -366,7 +380,12 @@ paths:
         '400':
           description: Invalid subscription supplied
 definitions:
-  AllXapps:
+  AllDeployableXapps:
+    type: array
+    items:
+      type: string
+      example: "xapp-dummy"
+  AllDeployedXapps:
     type: array
     items:
       $ref: '#/definitions/Xapp'
@@ -557,4 +576,4 @@ definitions:
           - deleted
           - updated
       xApps:
-        $ref: '#/definitions/AllXapps'
+        $ref: '#/definitions/AllDeployedXapps'
index 2de8b05..db54eb2 100755 (executable)
@@ -42,6 +42,7 @@ func (m *XappManager) Initialize(h Helmer, cm ConfigMapper) {
                {"GET", "/ric/v1/health/ready", m.getHealthStatus},
 
                {"GET", "/ric/v1/xapps", m.getAllXapps},
+               {"GET", "/ric/v1/xapps/search", m.searchAllXapps},
                {"GET", "/ric/v1/xapps/{name}", m.getXappByName},
                {"GET", "/ric/v1/xapps/{name}/instances/{id}", m.getXappInstanceByName},
                {"POST", "/ric/v1/xapps", m.deployXapp},
@@ -155,6 +156,10 @@ func (m *XappManager) getAllXapps(w http.ResponseWriter, r *http.Request) {
        respondWithJSON(w, http.StatusOK, xapps)
 }
 
+func (m *XappManager) searchAllXapps(w http.ResponseWriter, r *http.Request) {
+       respondWithJSON(w, http.StatusOK, m.helm.SearchAll())
+}
+
 func (m *XappManager) deployXapp(w http.ResponseWriter, r *http.Request) {
        if r.Body == nil {
                Logger.Error("No xapp data found in request body - url=%s", r.URL.RequestURI())
index 109f6e9..248ffee 100755 (executable)
@@ -55,6 +55,10 @@ func (h *MockedHelmer) StatusAll() ([]Xapp, error) {
        return xapps, helmError
 }
 
+func (h *MockedHelmer) SearchAll() (s []string) {
+       return s
+}
+
 func (h *MockedHelmer) List() (names []string, err error) {
        return names, helmError
 }
index bd4a3f3..a49836b 100755 (executable)
@@ -118,6 +118,10 @@ func (cm *MockedConfigMapper) GetNamespace(ns string) (n string) {
        return
 }
 
+func (cm *MockedConfigMapper) GetNamesFromHelmRepo() (names []string) {
+       return
+}
+
 // Test cases
 func TestGetMessages(t *testing.T) {
        cm := ConfigMap{}
index a3785c8..9e2fde7 100755 (executable)
@@ -208,6 +208,10 @@ func (h *Helm) List() (names []string, err error) {
        return h.GetNames(string(out))
 }
 
+func (h *Helm) SearchAll() (names []string) {
+       return h.cm.GetNamesFromHelmRepo()
+}
+
 func (h *Helm) Delete(name string) (xapp Xapp, err error) {
        xapp, err = h.Status(name)
        if err != nil {
index d452498..685d118 100755 (executable)
@@ -84,6 +84,7 @@ type ConfigMapper interface {
        ApplyConfigMap(r XAppConfig, action string) (err error)
        GetMessages(name string) (msgs MessageTypes)
        GetNamespace(ns string) string
+       GetNamesFromHelmRepo() (names []string)
 }
 
 type Helmer interface {
@@ -92,6 +93,7 @@ type Helmer interface {
        Install(m XappDeploy) (xapp Xapp, err error)
        Status(name string) (xapp Xapp, err error)
        StatusAll() (xapps []Xapp, err error)
+       SearchAll() (xapps []string)
        List() (xapps []string, err error)
        Delete(name string) (xapp Xapp, err error)
 }