neo oc-peers
This commit is contained in:
@@ -2,8 +2,8 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
@@ -32,21 +32,28 @@ type StatusController struct {
|
||||
// @Success 200 {status} models.status
|
||||
// @router / [post]
|
||||
func (o *StatusController) Status() {
|
||||
var address []string
|
||||
var address map[string]string
|
||||
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &address)
|
||||
fmt.Println(len(address))
|
||||
if len(address) == 0 { // default if nothing is send in body
|
||||
for k, v := range oclib.GetPaths() {
|
||||
address = append(address, "http://"+k.API()+v+"/oc")
|
||||
for _, host := range []string{"oc-datacenter", "oc-workflow", "oc-workspace", "oc-shared"} {
|
||||
address[host] = "http://" + host + ":8080/oc"
|
||||
}
|
||||
}
|
||||
api := tools.API{}
|
||||
state, code, err := api.CheckRemoteAPIs(address)
|
||||
state, services, err := api.CheckRemoteAPIs(address)
|
||||
errSTR := ""
|
||||
if err != nil {
|
||||
errSTR = err.Error()
|
||||
}
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": map[string]string{
|
||||
"state": state.String(),
|
||||
"data": map[string]interface{}{
|
||||
"state": state.String(),
|
||||
"code": state.EnumIndex(),
|
||||
"services": services,
|
||||
},
|
||||
"code": code,
|
||||
"error": err.Error(),
|
||||
"code": 200,
|
||||
"error": errSTR,
|
||||
}
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user