latest oclib for glory + comments

This commit is contained in:
mr
2024-08-30 10:44:47 +02:00
parent 61c92977fe
commit e89c70a9bd
4 changed files with 11 additions and 8 deletions

View File

@@ -2,7 +2,6 @@ package controllers
import (
"encoding/json"
"fmt"
"cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web"
@@ -34,19 +33,18 @@ type StatusController struct {
func (o *StatusController) Status() {
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 _, host := range []string{"oc-datacenter", "oc-workflow", "oc-workspace", "oc-shared"} {
for _, host := range []string{"oc-datacenter", "oc-workflow", "oc-workspace", "oc-shared", "oc-workspace"} {
address[host] = "http://" + host + ":8080/oc"
}
}
api := tools.API{}
state, services, err := api.CheckRemoteAPIs(address)
state, services, err := api.CheckRemoteAPIs(address) // check if the services are alive
errSTR := ""
if err != nil {
errSTR = err.Error()
}
o.Data["json"] = map[string]interface{}{
o.Data["json"] = map[string]interface{}{ // return the status
"data": map[string]interface{}{
"state": state.String(),
"code": state.EnumIndex(),