mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[ADD] Add region support protocol list
This commit is contained in:
parent
0cb1baef60
commit
28c5c9bff0
@ -2086,6 +2086,38 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/tenants/{tenant_name}/protocols": {
|
||||
"get": {
|
||||
"description": "get region protocols",
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"tags": [
|
||||
"v2"
|
||||
],
|
||||
"summary": "获取当前数据中心支持的protocols",
|
||||
"operationId": "getSupportProtocols",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "TenantName",
|
||||
"description": "tenant name",
|
||||
"name": "tenant_name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "统一返回格式",
|
||||
"schema": {
|
||||
"$ref": "#/responses/commandResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/tenants/{tenant_name}/res": {
|
||||
"get": {
|
||||
"description": "get tenant resources",
|
||||
|
@ -34,6 +34,7 @@ type TenantInterface interface {
|
||||
TenantsGetByName(w http.ResponseWriter, r *http.Request)
|
||||
SumTenants(w http.ResponseWriter, r *http.Request)
|
||||
SingleTenantResources(w http.ResponseWriter, r *http.Request)
|
||||
GetSupportProtocols(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
//ServiceInterface ServiceInterface
|
||||
|
@ -60,6 +60,7 @@ func (v2 *V2) tenantNameRouter() chi.Router {
|
||||
r.Delete("/", controller.GetManager().Tenant)
|
||||
//租户中的日志
|
||||
r.Post("/event-log", controller.GetManager().TenantLogByAction)
|
||||
r.Get("/protocols", controller.GetManager().GetSupportProtocols)
|
||||
//代码检测
|
||||
r.Post("/code-check", controller.GetManager().CheckCode)
|
||||
r.Post("/cloud-share", controller.GetManager().ShareCloud)
|
||||
|
@ -1475,29 +1475,27 @@ func (t *TenantStruct) Probe(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
//AddProbe add probe
|
||||
// swagger:operation POST /v2/tenants/{tenant_name}/services/{service_alias}/probe v2 addProbe
|
||||
//
|
||||
// 增加应用探针
|
||||
//
|
||||
// add probe
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
func (t *TenantStruct) AddProbe(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation POST /v2/tenants/{tenant_name}/services/{service_alias}/probe v2 addProbe
|
||||
//
|
||||
// 增加应用探针
|
||||
//
|
||||
// add probe
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
|
||||
logrus.Debugf("trans add probe dependency service ")
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
var tsp api_model.ServiceProbe
|
||||
if ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &tsp, nil); !ok {
|
||||
@ -1526,29 +1524,27 @@ func (t *TenantStruct) AddProbe(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
//UpdateProbe update probe
|
||||
// swagger:operation PUT /v2/tenants/{tenant_name}/services/{service_alias}/probe v2 updateProbe
|
||||
//
|
||||
// 更新应用探针信息, *注意此处为全量更新
|
||||
//
|
||||
// update probe
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
func (t *TenantStruct) UpdateProbe(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation PUT /v2/tenants/{tenant_name}/services/{service_alias}/probe v2 updateProbe
|
||||
//
|
||||
// 更新应用探针信息, *注意此处为全量更新
|
||||
//
|
||||
// update probe
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
|
||||
logrus.Debugf("trans update probe dependency service ")
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
var tsp api_model.ServiceProbe
|
||||
if ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &tsp, nil); !ok {
|
||||
@ -1582,29 +1578,27 @@ func (t *TenantStruct) UpdateProbe(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
//DeleteProbe delete probe
|
||||
// swagger:operation DELETE /v2/tenants/{tenant_name}/services/{service_alias}/probe v2 deleteProbe
|
||||
//
|
||||
// 删除应用探针
|
||||
//
|
||||
// delete probe
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
func (t *TenantStruct) DeleteProbe(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation DELETE /v2/tenants/{tenant_name}/services/{service_alias}/probe v2 deleteProbe
|
||||
//
|
||||
// 删除应用探针
|
||||
//
|
||||
// delete probe
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
|
||||
logrus.Debugf("trans delete probe dependency service ")
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
var tsp api_model.ServiceProbe
|
||||
if ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &tsp, nil); !ok {
|
||||
@ -1649,30 +1643,29 @@ func (t *TenantStruct) UpdatePort(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
//SingleTenantResources SingleTenantResources
|
||||
// swagger:operation GET /v2/tenants/{tenant_name}/resources v2 singletenantResources
|
||||
//
|
||||
// 指定租户资源使用情况
|
||||
//
|
||||
// get tenant resources
|
||||
//
|
||||
// ---
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
// parameters:
|
||||
// - name: tenant_name
|
||||
// in: path
|
||||
// description: tenant name
|
||||
// required: true
|
||||
// type: string
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
func (t *TenantStruct) SingleTenantResources(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation GET /v2/tenants/{tenant_name}/resources v2 singletenantResources
|
||||
//
|
||||
// 指定租户资源使用情况
|
||||
//
|
||||
// get tenant resources
|
||||
//
|
||||
// ---
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
// parameters:
|
||||
// - name: tenant_name
|
||||
// in: path
|
||||
// description: tenant name
|
||||
// required: true
|
||||
// type: string
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
|
||||
tenantID := r.Context().Value(middleware.ContextKey("tenant_id")).(string)
|
||||
//11ms
|
||||
services, err := handler.GetServiceManager().GetService(tenantID)
|
||||
@ -1690,3 +1683,36 @@ func (t *TenantStruct) SingleTenantResources(w http.ResponseWriter, r *http.Requ
|
||||
httputil.ReturnSuccess(r, w, statsInfo)
|
||||
return
|
||||
}
|
||||
|
||||
//GetSupportProtocols GetSupportProtocols
|
||||
// swagger:operation GET /v2/tenants/{tenant_name}/protocols v2 getSupportProtocols
|
||||
//
|
||||
// 获取当前数据中心支持的protocols
|
||||
//
|
||||
// get region protocols
|
||||
//
|
||||
// ---
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
// parameters:
|
||||
// - name: tenant_name
|
||||
// in: path
|
||||
// description: tenant name
|
||||
// required: true
|
||||
// type: string
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
func (t *TenantStruct) GetSupportProtocols(w http.ResponseWriter, r *http.Request) {
|
||||
rps, err := handler.GetTenantManager().GetProtocols()
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, rps)
|
||||
return
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
// RAINBOND, Application Management Platform
|
||||
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
|
||||
|
||||
@ -22,13 +21,14 @@ package handler
|
||||
import (
|
||||
"github.com/goodrain/rainbond/cmd/api/option"
|
||||
api_model "github.com/goodrain/rainbond/pkg/api/model"
|
||||
"github.com/goodrain/rainbond/pkg/api/util"
|
||||
dbmodel "github.com/goodrain/rainbond/pkg/db/model"
|
||||
)
|
||||
|
||||
//TenantHandler tenant handler
|
||||
type TenantHandler interface {
|
||||
GetTenants() ([]*dbmodel.Tenants, error)
|
||||
GetTenantsPaged(offset,len int) ([]*dbmodel.Tenants, error)
|
||||
GetTenantsPaged(offset, len int) ([]*dbmodel.Tenants, error)
|
||||
GetTenantsByName(name string) (*dbmodel.Tenants, error)
|
||||
GetTenantsByUUID(uuid string) (*dbmodel.Tenants, error)
|
||||
GetTenantsName() ([]string, error)
|
||||
@ -38,6 +38,7 @@ type TenantHandler interface {
|
||||
HTTPTsdb(md *api_model.MontiorData) ([]byte, error)
|
||||
GetTenantsResources(tr *api_model.TenantResources) ([]*map[string]interface{}, error)
|
||||
TenantsSum() (int, error)
|
||||
GetProtocols() ([]*dbmodel.RegionProcotols, *util.APIHandleError)
|
||||
}
|
||||
|
||||
var defaultTenantHandler TenantHandler
|
||||
|
@ -26,15 +26,17 @@ import (
|
||||
|
||||
"github.com/goodrain/rainbond/cmd/api/option"
|
||||
api_db "github.com/goodrain/rainbond/pkg/api/db"
|
||||
"github.com/goodrain/rainbond/pkg/api/util"
|
||||
"github.com/goodrain/rainbond/pkg/mq/api/grpc/pb"
|
||||
|
||||
api_model "github.com/goodrain/rainbond/pkg/api/model"
|
||||
"github.com/goodrain/rainbond/pkg/db"
|
||||
dbmodel "github.com/goodrain/rainbond/pkg/db/model"
|
||||
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//TenantAction tenant act
|
||||
@ -91,7 +93,7 @@ func (t *TenantAction) GetTenants() ([]*dbmodel.Tenants, error) {
|
||||
}
|
||||
return tenants, err
|
||||
}
|
||||
func (t *TenantAction) GetTenantsPaged(offset,len int) ([]*dbmodel.Tenants, error) {
|
||||
func (t *TenantAction) GetTenantsPaged(offset, len int) ([]*dbmodel.Tenants, error) {
|
||||
tenants, err := db.GetManager().TenantDao().GetALLTenants()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -99,10 +101,8 @@ func (t *TenantAction) GetTenantsPaged(offset,len int) ([]*dbmodel.Tenants, erro
|
||||
return tenants, err
|
||||
}
|
||||
|
||||
|
||||
|
||||
//StatsMemCPU StatsMemCPU
|
||||
func (t *TenantAction) TotalMemCPU(services []*dbmodel.TenantServices) (*api_model.StatsInfo, error){
|
||||
func (t *TenantAction) TotalMemCPU(services []*dbmodel.TenantServices) (*api_model.StatsInfo, error) {
|
||||
cpus := 0
|
||||
mem := 0
|
||||
for _, service := range services {
|
||||
@ -140,6 +140,7 @@ func (t *TenantAction) GetTenantsByName(name string) (*dbmodel.Tenants, error) {
|
||||
|
||||
return tenant, err
|
||||
}
|
||||
|
||||
//GetTenants get tenants
|
||||
func (t *TenantAction) GetTenantsByUUID(uuid string) (*dbmodel.Tenants, error) {
|
||||
tenant, err := db.GetManager().TenantDao().GetTenantByUUID(uuid)
|
||||
@ -150,7 +151,6 @@ func (t *TenantAction) GetTenantsByUUID(uuid string) (*dbmodel.Tenants, error) {
|
||||
return tenant, err
|
||||
}
|
||||
|
||||
|
||||
//StatsMemCPU StatsMemCPU
|
||||
func (t *TenantAction) StatsMemCPU(services []*dbmodel.TenantServices) (*api_model.StatsInfo, error) {
|
||||
cpus := 0
|
||||
@ -236,3 +236,12 @@ func (t *TenantAction) TenantsSum() (int, error) {
|
||||
}
|
||||
return len(s), nil
|
||||
}
|
||||
|
||||
//GetProtocols GetProtocols
|
||||
func (t *TenantAction) GetProtocols() ([]*dbmodel.RegionProcotols, *util.APIHandleError) {
|
||||
rps, err := db.GetManager().RegionProcotolsDao().GetAllSupportProtocol("v2")
|
||||
if err != nil {
|
||||
return nil, util.CreateAPIHandleErrorFromDBError("get all support protocols", err)
|
||||
}
|
||||
return rps, nil
|
||||
}
|
||||
|
@ -1227,3 +1227,11 @@ type TenantServiceVolume struct {
|
||||
VolumePath string `gorm:"column:volume_path" json:"volume_path" validate:"volume_path|required"`
|
||||
IsReadOnly bool `gorm:"column:is_read_only;default:false" json:"is_read_only" validate:"is_read_only|bool"`
|
||||
}
|
||||
|
||||
// GetSupportProtocols GetSupportProtocols
|
||||
// swagger:parameters getSupportProtocols
|
||||
type GetSupportProtocols struct {
|
||||
// in: path
|
||||
// required: true
|
||||
TenantName string `json:"tenant_name"`
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ type TenantDao interface {
|
||||
GetTenantByUUID(uuid string) (*model.Tenants, error)
|
||||
GetTenantIDByName(tenantName string) (*model.Tenants, error)
|
||||
GetALLTenants() ([]*model.Tenants, error)
|
||||
GetPagedTenants(offset,len int) ([]*model.Tenants, error)
|
||||
GetPagedTenants(offset, len int) ([]*model.Tenants, error)
|
||||
}
|
||||
|
||||
//LicenseDao LicenseDao
|
||||
@ -65,7 +65,7 @@ type TenantServiceDao interface {
|
||||
GetServicesAllInfoByTenantID(tenantID string) ([]*model.TenantServices, error)
|
||||
DeleteServiceByServiceID(serviceID string) error
|
||||
GetCPUAndMEM(tenantName []string) ([]*map[string]interface{}, error)
|
||||
GetPagedTenantService(offset,len int) ([]map[string]interface{}, error)
|
||||
GetPagedTenantService(offset, len int) ([]map[string]interface{}, error)
|
||||
GetTenantServiceRes(uuid string) (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
@ -323,3 +323,10 @@ type RegionAPIClassDao interface {
|
||||
GetPrefixesByClass(apiClass string) ([]*model.RegionAPIClass, error)
|
||||
DeletePrefixInClass(apiClass, prefix string) error
|
||||
}
|
||||
|
||||
//RegionProcotolsDao RegionProcotolsDao
|
||||
type RegionProcotolsDao interface {
|
||||
Dao
|
||||
GetAllSupportProtocol(version string) ([]*model.RegionProcotols, error)
|
||||
GetProtocolGroupByProtocolChild(version, protocolChild string) (*model.RegionProcotols, error)
|
||||
}
|
||||
|
@ -95,6 +95,8 @@ type Manager interface {
|
||||
|
||||
RegionAPIClassDao() dao.RegionAPIClassDao
|
||||
RegionAPIClassDaoTransactions(db *gorm.DB) dao.RegionAPIClassDao
|
||||
|
||||
RegionProcotolsDao() dao.RegionProcotolsDao
|
||||
}
|
||||
|
||||
var defaultManager Manager
|
||||
|
@ -439,3 +439,10 @@ func (m *Manager) RegionAPIClassDaoTransactions(db *gorm.DB) dao.RegionAPIClassD
|
||||
DB: db,
|
||||
}
|
||||
}
|
||||
|
||||
//RegionProcotolsDao RegionProcotolsDao
|
||||
func (m *Manager) RegionProcotolsDao() dao.RegionProcotolsDao {
|
||||
return &mysqldao.RegionProcotolsDaoImpl{
|
||||
DB: m.db,
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +129,7 @@ func (m *Manager) RegisterTableModel() {
|
||||
m.models = append(m.models, &model.RegionUserInfo{})
|
||||
m.models = append(m.models, &model.TenantServicesStreamPluginPort{})
|
||||
m.models = append(m.models, &model.RegionAPIClass{})
|
||||
m.models = append(m.models, &model.RegionProcotols{})
|
||||
}
|
||||
|
||||
//CheckTable 检测表结构
|
||||
@ -161,6 +162,8 @@ func (m *Manager) patchTable() {
|
||||
// m.db.Exec("alter table tenant_services add replica_id varchar(32)")
|
||||
// m.db.Exec("alter table tenant_services add status int(11) default 0")
|
||||
// m.db.Exec("alter table tenant_services add node_label varchar(40)")
|
||||
|
||||
//权限组
|
||||
m.db.Exec("insert into region_api_class VALUES ('','','server_source','/v2/tenants','','','')")
|
||||
m.db.Exec("insert into region_api_class VALUES ('','','server_source','/v2/show','','','')")
|
||||
m.db.Exec("insert into region_api_class VALUES ('','','server_source','/v2/resources','','','')")
|
||||
@ -171,4 +174,11 @@ func (m *Manager) patchTable() {
|
||||
m.db.Exec("insert into region_api_class VALUES ('','','node_manager','/v2/taskgroups','','','')")
|
||||
m.db.Exec("insert into region_api_class VALUES ('','','node_manager','/v2/tasktemps','','','')")
|
||||
m.db.Exec("insert into region_api_class VALUES ('','','node_manager','/v2/configs','','','')")
|
||||
|
||||
//协议族支持
|
||||
m.db.Exec("insert into region_protocols VALUES ('','','http','http','v2',1)")
|
||||
m.db.Exec("insert into region_protocols VALUES ('','','stream','mysql','v2',1)")
|
||||
m.db.Exec("insert into region_protocols VALUES ('','','stream','udp','v2',1)")
|
||||
m.db.Exec("insert into region_protocols VALUES ('','','stream','tcp','v2',1)")
|
||||
m.db.Exec("insert into region_protocols VALUES ('','','http','grpc','v2',0)")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user