mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
update get enterprise running service
This commit is contained in:
parent
c96ccad819
commit
e5862a274b
@ -1,15 +1,22 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/goodrain/rainbond/api/handler"
|
||||
httputil "github.com/goodrain/rainbond/util/http"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
|
||||
"github.com/goodrain/rainbond/api/handler"
|
||||
|
||||
httputil "github.com/goodrain/rainbond/util/http"
|
||||
)
|
||||
|
||||
//GetRunningServices list all running service ids
|
||||
func GetRunningServices(w http.ResponseWriter, r *http.Request) {
|
||||
enterpriseID := chi.URLParam(r, "enterprise_id")
|
||||
runningList := handler.GetServiceManager().GetEnterpriseRunningServices(enterpriseID)
|
||||
runningList, err := handler.GetServiceManager().GetEnterpriseRunningServices(enterpriseID)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnNoFomart(r, w, 200, map[string]interface{}{"service_ids": runningList})
|
||||
}
|
||||
|
@ -1683,23 +1683,23 @@ func (s *ServiceAction) GetServicesStatus(tenantID string, serviceIDs []string)
|
||||
}
|
||||
|
||||
// GetEnterpriseRunningServices get running services
|
||||
func (s *ServiceAction) GetEnterpriseRunningServices(enterpriseID string) []string {
|
||||
func (s *ServiceAction) GetEnterpriseRunningServices(enterpriseID string) ([]string, *util.APIHandleError) {
|
||||
var tenantIDs []string
|
||||
tenants, err := db.GetManager().EnterpriseDao().GetEnterpriseTenants(enterpriseID)
|
||||
if err != nil {
|
||||
logrus.Errorf("list tenant failed: %s", err.Error())
|
||||
return []string{}
|
||||
return nil, util.CreateAPIHandleErrorFromDBError(fmt.Sprintf("enterprise[%s] get tenant failed", enterpriseID), err)
|
||||
}
|
||||
if len(tenants) == 0 {
|
||||
return nil, util.CreateAPIHandleErrorf(400, "enterprise[%s] has not tenants", enterpriseID)
|
||||
}
|
||||
for _, tenant := range tenants {
|
||||
tenantIDs = append(tenantIDs, tenant.UUID)
|
||||
}
|
||||
if len(tenantIDs) == 0 {
|
||||
return []string{}
|
||||
}
|
||||
services, err := db.GetManager().TenantServiceDao().GetServicesByTenantIDs(tenantIDs)
|
||||
if err != nil {
|
||||
logrus.Errorf("list tenants servicee failed: %s", err.Error())
|
||||
return []string{}
|
||||
return nil, util.CreateAPIHandleErrorf(400, "enterprise[%s] has not tenants", enterpriseID)
|
||||
}
|
||||
var serviceIDs []string
|
||||
for _, svc := range services {
|
||||
@ -1712,7 +1712,7 @@ func (s *ServiceAction) GetEnterpriseRunningServices(enterpriseID string) []stri
|
||||
retServices = append(retServices, service)
|
||||
}
|
||||
}
|
||||
return retServices
|
||||
return retServices, nil
|
||||
}
|
||||
|
||||
//CreateTenant create tenant
|
||||
|
@ -58,7 +58,7 @@ type ServiceHandler interface {
|
||||
RollBack(rs *api_model.RollbackStruct) error
|
||||
GetStatus(serviceID string) (*api_model.StatusList, error)
|
||||
GetServicesStatus(tenantID string, services []string) []map[string]interface{}
|
||||
GetEnterpriseRunningServices(enterpriseID string) []string
|
||||
GetEnterpriseRunningServices(enterpriseID string) ([]string, *util.APIHandleError)
|
||||
CreateTenant(*dbmodel.Tenants) error
|
||||
CreateTenandIDAndName(eid string) (string, string, error)
|
||||
GetPods(serviceID string) (*K8sPodInfos, error)
|
||||
|
Loading…
Reference in New Issue
Block a user