X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=cmd%2Fappmgr%2Fapi.go;h=7acb7c790d8bbf7ed93209141ad405e16059857f;hb=4703b1a7457cf072640adbc0f5487a0675f5b6d3;hp=2de8b0578fa5ff2b61101648ef7ab78aec61559f;hpb=d732b871ab1dccaf9ef5311dede522879193b45e;p=ric-plt%2Fappmgr.git diff --git a/cmd/appmgr/api.go b/cmd/appmgr/api.go index 2de8b05..7acb7c7 100755 --- a/cmd/appmgr/api.go +++ b/cmd/appmgr/api.go @@ -26,6 +26,7 @@ import ( "github.com/spf13/viper" "log" "net/http" + "time" ) // API functions @@ -42,6 +43,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 +157,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()) @@ -176,6 +182,13 @@ func (m *XappManager) deployXapp(w http.ResponseWriter, r *http.Request) { return } + for i := 0; i < 3; i++ { + if xapp, err = m.helm.Status(xapp.Name); xapp.Instances != nil { + break + } + time.Sleep(time.Duration(5) * time.Second) + } + respondWithJSON(w, http.StatusCreated, xapp) m.sd.Publish(xapp, EventType("created"))