Merge remote-tracking branch 'origin/master' into upmaster
# Conflicts: # api/internal/types/types.go Former-commit-id: 844ae53a2ede50fd681dfc373b97ca50c07ec24d
This commit is contained in:
commit
1d1b024e09
|
@ -23,10 +23,11 @@ type (
|
|||
CentersIndex []CenterIndex `json:"centersIndex"`
|
||||
}
|
||||
CenterIndex {
|
||||
id int64 `json:"id"`
|
||||
name string `json:"name"`
|
||||
cpu float32 `json:"cpu"`
|
||||
memory float32 `json:"memory"`
|
||||
storage float32 `json:"storage"`
|
||||
cpu string `json:"cpu"`
|
||||
memory string `json:"memory"`
|
||||
storage string `json:"storage"`
|
||||
centerType string `json:"centerType"`
|
||||
}
|
||||
)
|
||||
|
@ -35,9 +36,16 @@ type (
|
|||
clusterLoadRecords []ClusterLoadRecord `json:"clusterLoadRecords"`
|
||||
}
|
||||
ClusterLoadRecord {
|
||||
AdapterId int64 `json:"adapterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
CpuAvail float64 `json:"cpuAvail"`
|
||||
CpuTotal float64 `json:"cpuTotal"`
|
||||
CpuUsage float64 `json:"cpuUsage"`
|
||||
MemoryAvail float64 `json:"memoryAvail"`
|
||||
MemoryUsage float64 `json:"memoryUsage"`
|
||||
MemoryTotal float64 `json:"memoryTotal"`
|
||||
DiskAvail float64 `json:"diskAvail"`
|
||||
DiskTotal float64 `json:"diskTotal"`
|
||||
DiskUsage float64 `json:"diskUsage"`
|
||||
}
|
||||
)
|
||||
|
@ -79,7 +87,6 @@ type commitTaskReq {
|
|||
MatchLabels map[string]string `json:"matchLabels,optional"`
|
||||
YamlList []string `json:"yamlList"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
|
||||
}
|
||||
|
||||
type (
|
||||
|
@ -544,6 +551,14 @@ type (
|
|||
Server string `form:"server,optional"`
|
||||
PageInfo
|
||||
}
|
||||
AdapterRelationQueryReq {
|
||||
Id string `form:"id,optional" db:"id"`
|
||||
Name string `form:"name,optional"`
|
||||
Type string `form:"type,optional"`
|
||||
Nickname string `form:"nickname,optional"`
|
||||
Version string `form:"version,optional"`
|
||||
Server string `form:"server,optional"`
|
||||
}
|
||||
AdapterReq {
|
||||
Id string `json:"id,optional" db:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
|
|
|
@ -852,7 +852,7 @@ service pcm {
|
|||
get /adapter/cluster/get (FId) returns (ClusterResp)
|
||||
|
||||
@handler GetAdapterRelationHandler
|
||||
get /adapter/relation (AdapterQueryReq) returns (PageResult)
|
||||
get /adapter/relation (AdapterRelationQueryReq) returns (PageResult)
|
||||
|
||||
@handler GetClusterSumHandler
|
||||
get /adapter/clusterSum (clusterSumReq) returns (clusterSumReqResp)
|
||||
|
|
|
@ -16,6 +16,8 @@ Cache:
|
|||
- Host: 10.206.0.12:6379
|
||||
Pass: redisPW123
|
||||
|
||||
PromUrl: http://47.92.39.128:30877
|
||||
|
||||
# k8s rpc
|
||||
K8sNativeConf:
|
||||
# target: nacos://10.206.0.12:8848/pcm.kubenative.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api
|
||||
|
|
|
@ -49,6 +49,7 @@ type Config struct {
|
|||
Password string
|
||||
}
|
||||
SnowflakeConf SnowflakeConf
|
||||
PromUrl string
|
||||
}
|
||||
|
||||
// SnowflakeConf 雪花算法机器id配置
|
||||
|
|
|
@ -33,7 +33,7 @@ func SyncParticipantRpc(svc *svc.ServiceContext) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
svc.PromClient[participant.Id] = promClient
|
||||
svc.MonitorClient[participant.Id] = promClient
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
func GetAdapterRelationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterQueryReq
|
||||
var req types.AdapterRelationQueryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
|
|
|
@ -24,7 +24,7 @@ func NewGetAdapterRelationLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
}
|
||||
}
|
||||
|
||||
func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterQueryReq) (resp *types.PageResult, err error) {
|
||||
func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterRelationQueryReq) (resp *types.PageResult, err error) {
|
||||
resp = &types.PageResult{}
|
||||
var list []types.AdapterInfo
|
||||
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter")
|
||||
|
|
|
@ -27,14 +27,14 @@ func NewControllerMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
|
||||
func (l *ControllerMetricsLogic) ControllerMetrics(req *types.ControllerMetricsReq) (resp *types.ControllerMetricsResp, err error) {
|
||||
resp = &types.ControllerMetricsResp{}
|
||||
if _, ok := l.svcCtx.PromClient[req.ParticipantId]; ok {
|
||||
if _, ok := l.svcCtx.MonitorClient[req.ParticipantId]; ok {
|
||||
if len(req.Pod) != 0 {
|
||||
resp.Data = l.svcCtx.PromClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.PodOption{
|
||||
resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.PodOption{
|
||||
PodName: req.Pod,
|
||||
})
|
||||
} else {
|
||||
|
||||
resp.Data = l.svcCtx.PromClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.ControllerOption{
|
||||
resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.ControllerOption{
|
||||
WorkloadName: req.WorkloadName,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package core
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/prometheus/common/model"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
|
||||
"strconv"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
|
@ -24,31 +27,45 @@ func NewCenterResourcesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
|
|||
}
|
||||
|
||||
func (l *CenterResourcesLogic) CenterResources() (resp *types.CenterResourcesResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
centerIndex1 := types.CenterIndex{
|
||||
Name: "阿里云",
|
||||
Cpu: float32(12.33),
|
||||
Memory: float32(64.55),
|
||||
Storage: float32(33.90),
|
||||
CenterType: "cloud",
|
||||
}
|
||||
centerIndex2 := types.CenterIndex{
|
||||
Name: "A超算中心",
|
||||
Cpu: float32(42.36),
|
||||
Memory: float32(66.55),
|
||||
Storage: float32(23.231),
|
||||
CenterType: "hpc",
|
||||
}
|
||||
centerIndex3 := types.CenterIndex{
|
||||
Name: "智算中心",
|
||||
Cpu: float32(78.33),
|
||||
Memory: float32(36.55),
|
||||
Storage: float32(88.93),
|
||||
CenterType: "ai",
|
||||
}
|
||||
resp = &types.CenterResourcesResp{}
|
||||
resp.CentersIndex = append(resp.CentersIndex, centerIndex1)
|
||||
resp.CentersIndex = append(resp.CentersIndex, centerIndex2)
|
||||
resp.CentersIndex = append(resp.CentersIndex, centerIndex3)
|
||||
rawData, err := l.svcCtx.PromClient.GetRawData("center_top3", tracker.AdapterOption{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var centersIndex []*types.CenterIndex
|
||||
data := rawData.(model.Vector)
|
||||
for _, d := range data {
|
||||
for _, v := range d.Metric {
|
||||
num, err := strconv.ParseInt(string(v), 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
centersIndex = append(centersIndex, &types.CenterIndex{Id: num})
|
||||
}
|
||||
}
|
||||
for _, centerIndex := range centersIndex {
|
||||
// Query the types of resource centers
|
||||
l.svcCtx.DbEngin.Raw("select name,type as CenterType from t_adapter where id = ?", centerIndex.Id).Scan(¢erIndex)
|
||||
cpuRawData, err := l.svcCtx.PromClient.GetRawData("center_cpu_usage", tracker.AdapterOption{AdapterId: centerIndex.Id})
|
||||
cpuData := cpuRawData.(model.Vector)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
centerIndex.Cpu = cpuData[0].Value.String()
|
||||
memoryRawData, err := l.svcCtx.PromClient.GetRawData("center_memory_usage", tracker.AdapterOption{AdapterId: centerIndex.Id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
memoryData := memoryRawData.(model.Vector)
|
||||
|
||||
centerIndex.Memory = memoryData[0].Value.String()
|
||||
diskRawData, err := l.svcCtx.PromClient.GetRawData("center_disk_usage", tracker.AdapterOption{AdapterId: centerIndex.Id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
diskData := diskRawData.(model.Vector)
|
||||
centerIndex.Storage = diskData[0].Value.String()
|
||||
resp.CentersIndex = append(resp.CentersIndex, *centerIndex)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
|
||||
"strconv"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -26,9 +27,17 @@ func NewSyncClusterLoadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *S
|
|||
func (l *SyncClusterLoadLogic) SyncClusterLoad(req *types.SyncClusterLoadReq) error {
|
||||
if len(req.ClusterLoadRecords) != 0 {
|
||||
for _, record := range req.ClusterLoadRecords {
|
||||
tracker.ClusterCpuGauge.WithLabelValues(record.ClusterName).Set(record.CpuUsage)
|
||||
tracker.ClusterMemoryGauge.WithLabelValues(record.ClusterName).Set(record.MemoryUsage)
|
||||
tracker.ClusterDiskGauge.WithLabelValues(record.ClusterName).Set(record.DiskUsage)
|
||||
tracker.ClusterCpuUsageGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.CpuUsage)
|
||||
tracker.ClusterCpuAvailGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.CpuAvail)
|
||||
tracker.ClusterCpuTotalGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.CpuTotal)
|
||||
|
||||
tracker.ClusterMemoryUsageGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.MemoryUsage)
|
||||
tracker.ClusterMemoryAvailGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.MemoryAvail)
|
||||
tracker.ClusterMemoryTotalGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.MemoryTotal)
|
||||
|
||||
tracker.ClusterDiskUsageGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.DiskUsage)
|
||||
tracker.ClusterDiskAvailGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.DiskAvail)
|
||||
tracker.ClusterDiskTotalGauge.WithLabelValues(record.ClusterName, strconv.FormatInt(record.AdapterId, 10)).Set(record.DiskTotal)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -15,18 +15,11 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response"
|
||||
"math"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SubSchedule interface {
|
||||
GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error)
|
||||
PickOptimalStrategy() (strategy.Strategy, error)
|
||||
AssignTask(clusters []*strategy.AssignedCluster) error
|
||||
}
|
||||
|
||||
// 求交集
|
||||
func Intersect(slice1, slice2 []int64) []int64 {
|
||||
m := make(map[int64]int)
|
||||
|
@ -90,3 +83,8 @@ func MicsSlice(origin []int64, count int) []int64 {
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func RoundFloat(val float64, precision uint) float64 {
|
||||
ratio := math.Pow(10, float64(precision))
|
||||
return math.Round(val*ratio) / ratio
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/executor"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/rpc/client/participantservice"
|
||||
"gorm.io/gorm"
|
||||
|
@ -33,7 +34,7 @@ import (
|
|||
type Scheduler struct {
|
||||
task *response.TaskInfo
|
||||
participantIds []int64
|
||||
subSchedule common.SubSchedule
|
||||
subSchedule SubSchedule
|
||||
dbEngin *gorm.DB
|
||||
result []string //pID:子任务yamlstring 键值对
|
||||
participantRpc participantservice.ParticipantService
|
||||
|
@ -43,7 +44,13 @@ type Scheduler struct {
|
|||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func NewScheduler(subSchedule common.SubSchedule, val string, dbEngin *gorm.DB, participantRpc participantservice.ParticipantService) (*Scheduler, error) {
|
||||
type SubSchedule interface {
|
||||
GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error)
|
||||
PickOptimalStrategy() (strategy.Strategy, error)
|
||||
AssignTask(clusters []*strategy.AssignedCluster) error
|
||||
}
|
||||
|
||||
func NewScheduler(subSchedule SubSchedule, val string, dbEngin *gorm.DB, participantRpc participantservice.ParticipantService) (*Scheduler, error) {
|
||||
var task *response.TaskInfo
|
||||
err := json.Unmarshal([]byte(val), &task)
|
||||
if err != nil {
|
||||
|
@ -123,7 +130,7 @@ func (s *Scheduler) TempAssign() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Scheduler) AssignAndSchedule(ss common.SubSchedule) error {
|
||||
func (s *Scheduler) AssignAndSchedule(ss SubSchedule) error {
|
||||
//// 已指定 ParticipantId
|
||||
//if s.task.ParticipantId != 0 {
|
||||
// return nil
|
||||
|
|
|
@ -74,6 +74,9 @@ func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) {
|
|||
case strategy.RESOURCES_PRICING:
|
||||
strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: 1})
|
||||
return strategy, nil
|
||||
case strategy.DYNAMIC_RESOURCES:
|
||||
strategy := strategy.NewDynamicResourcesStrategy(resources, as.option, 1)
|
||||
return strategy, nil
|
||||
}
|
||||
|
||||
return nil, errors.New("no strategy has been chosen")
|
||||
|
|
|
@ -4,6 +4,7 @@ type AiOption struct {
|
|||
AiClusterId string // shuguangAi /octopus ClusterId
|
||||
TaskName string
|
||||
ResourceType string // cpu/gpu/compute card
|
||||
CpuCoreNum int64
|
||||
TaskType string // pytorch/tensorflow/mindspore
|
||||
DatasetsName string // mnist/imageNet/iris
|
||||
StrategyName string
|
||||
|
@ -29,3 +30,7 @@ type AiOption struct {
|
|||
Image string
|
||||
Model interface{}
|
||||
}
|
||||
|
||||
func (a AiOption) GetOptionType() string {
|
||||
return AI
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package option
|
||||
|
||||
type Option struct {
|
||||
Name string
|
||||
const (
|
||||
AI = "ai"
|
||||
CLOUD = "cloud"
|
||||
HPC = "hpc"
|
||||
)
|
||||
|
||||
type Option interface {
|
||||
GetOptionType() string
|
||||
}
|
||||
|
|
|
@ -8,20 +8,22 @@ type AiCollector interface {
|
|||
type ResourceStats struct {
|
||||
ParticipantId int64
|
||||
Name string
|
||||
CpuAvail float64
|
||||
CpuCoreAvail int64
|
||||
MemAvail float64
|
||||
DiskAvail float64
|
||||
GpuAvail float64
|
||||
CardToHours map[Card]float64
|
||||
CpuToHours map[int]float64
|
||||
GpuAvail int64
|
||||
CardsAvail []*Card
|
||||
CpuCoreHours float64
|
||||
Balance float64
|
||||
}
|
||||
|
||||
type Card struct {
|
||||
Platform string
|
||||
Type string
|
||||
Name string
|
||||
TOpsAtFp16 float64
|
||||
Price int32
|
||||
CardHours float64
|
||||
Num int32
|
||||
}
|
||||
|
||||
type DatasetsSpecs struct {
|
||||
|
|
|
@ -1,8 +1,70 @@
|
|||
package strategy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
)
|
||||
|
||||
type DynamicResourcesStrategy struct {
|
||||
replicas int32
|
||||
resources []*collector.ResourceStats
|
||||
opt option.Option
|
||||
}
|
||||
|
||||
func NewDynamicResourcesStrategy(resources []*collector.ResourceStats, opt option.Option, replica int32) *DynamicResourcesStrategy {
|
||||
return &DynamicResourcesStrategy{resources: resources, opt: opt, replicas: replica}
|
||||
}
|
||||
|
||||
func (ps *DynamicResourcesStrategy) Schedule() ([]*AssignedCluster, error) {
|
||||
return nil, nil
|
||||
if ps.replicas < 1 {
|
||||
return nil, errors.New("replicas must be greater than 0")
|
||||
}
|
||||
|
||||
switch ps.opt.GetOptionType() {
|
||||
case option.AI:
|
||||
opt := (interface{})(ps.opt).(*option.AiOption)
|
||||
|
||||
var maxCardHoursAvailable float64
|
||||
var maxCpuCoreHoursAvailable float64
|
||||
var assignedCluster *AssignedCluster
|
||||
var results []*AssignedCluster
|
||||
for _, res := range ps.resources {
|
||||
if opt.ResourceType == "" {
|
||||
if res.CpuCoreHours <= 0 {
|
||||
cluster := &AssignedCluster{ParticipantId: res.ParticipantId, Name: res.Name, Replicas: ps.replicas}
|
||||
results = append(results, cluster)
|
||||
return results, nil
|
||||
}
|
||||
|
||||
if res.CpuCoreHours > maxCpuCoreHoursAvailable {
|
||||
maxCpuCoreHoursAvailable = res.CpuCoreHours
|
||||
assignedCluster.Name = res.Name
|
||||
assignedCluster.ParticipantId = res.ParticipantId
|
||||
assignedCluster.Replicas = ps.replicas
|
||||
}
|
||||
}
|
||||
|
||||
if opt.ResourceType == "" {
|
||||
var maxCurrentCardHours float64
|
||||
for _, card := range res.CardsAvail {
|
||||
cardHours := common.RoundFloat(card.TOpsAtFp16*card.CardHours, 3)
|
||||
if cardHours > maxCurrentCardHours {
|
||||
maxCurrentCardHours = cardHours
|
||||
}
|
||||
}
|
||||
if maxCurrentCardHours > maxCardHoursAvailable {
|
||||
maxCardHoursAvailable = maxCurrentCardHours
|
||||
assignedCluster.Name = res.Name
|
||||
assignedCluster.ParticipantId = res.ParticipantId
|
||||
assignedCluster.Replicas = ps.replicas
|
||||
}
|
||||
}
|
||||
}
|
||||
results = append(results, assignedCluster)
|
||||
return results, nil
|
||||
}
|
||||
|
||||
return nil, errors.New("failed to apply DynamicResourcesStrategy")
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func (r *ResourcePricingParams) GetProviders() []*providerPricing.Provider {
|
|||
for _, resource := range r.Resources {
|
||||
provider := providerPricing.NewProvider(
|
||||
resource.ParticipantId,
|
||||
resource.CpuAvail,
|
||||
float64(resource.CpuCoreAvail),
|
||||
resource.MemAvail,
|
||||
resource.DiskAvail, 0.0, 0.0, 0.0)
|
||||
providerList = append(providerList, provider)
|
||||
|
|
|
@ -60,6 +60,10 @@ var (
|
|||
MLU: CAMBRICON,
|
||||
GCU: ENFLAME,
|
||||
}
|
||||
cardTopsMap = map[string]float64{
|
||||
MLU: CAMBRICONMLU290,
|
||||
GCU: EnflameT20,
|
||||
}
|
||||
)
|
||||
|
||||
func NewOctopusLink(ctx context.Context, svcCtx *svc.ServiceContext, name string, id int64) *OctopusLink {
|
||||
|
@ -245,13 +249,49 @@ func (o *OctopusLink) GetResourceStats() (*collector.ResourceStats, error) {
|
|||
return nil, errors.New(balanceResp.Error.Message)
|
||||
}
|
||||
|
||||
//resourceStat := collector.ResourceStats{}
|
||||
//
|
||||
//for _, spec := range specResp.TrainResourceSpecs {
|
||||
//
|
||||
//}
|
||||
var cards []*collector.Card
|
||||
balance := float64(balanceResp.Payload.BillingUser.Amount)
|
||||
var cpuHours float64
|
||||
for _, spec := range specResp.TrainResourceSpecs {
|
||||
if spec.Price == 0 {
|
||||
ns := strings.Split(spec.Name, COMMA)
|
||||
if len(ns) == 2 {
|
||||
nss := strings.Split(ns[0], COLON)
|
||||
if nss[0] == CPU {
|
||||
cpuHours = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
if spec.Price == 1 {
|
||||
ns := strings.Split(spec.Name, COMMA)
|
||||
cardSpecs := strings.Split(ns[0], STAR)
|
||||
|
||||
cardTops, isMapContainsKey := cardTopsMap[cardSpecs[1]]
|
||||
if !isMapContainsKey {
|
||||
continue
|
||||
}
|
||||
|
||||
card := &collector.Card{
|
||||
Platform: OCTOPUS,
|
||||
Type: CARD,
|
||||
Name: cardSpecs[1],
|
||||
TOpsAtFp16: cardTops,
|
||||
CardHours: balance / spec.Price,
|
||||
}
|
||||
cards = append(cards, card)
|
||||
}
|
||||
}
|
||||
|
||||
resourceStats := &collector.ResourceStats{
|
||||
ParticipantId: o.participantId,
|
||||
Name: o.platform,
|
||||
Balance: balance,
|
||||
CardsAvail: cards,
|
||||
CpuCoreHours: cpuHours,
|
||||
}
|
||||
|
||||
return resourceStats, nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) GetDatasetsSpecs() ([]*collector.DatasetsSpecs, error) {
|
||||
|
@ -349,6 +389,7 @@ func (o *OctopusLink) generateResourceId(option *option.AiOption) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("failed to get ResourceId")
|
||||
|
@ -433,7 +474,14 @@ func (o *OctopusLink) generateImageId(option *option.AiOption) error {
|
|||
|
||||
func (o *OctopusLink) generateAlgorithmId(option *option.AiOption) error {
|
||||
// temporarily set algorithm to cnn
|
||||
if option.AlgorithmName == "" {
|
||||
switch option.DatasetsName {
|
||||
case "cifar10":
|
||||
option.AlgorithmName = "cnn"
|
||||
case "mnist":
|
||||
option.AlgorithmName = "fcn"
|
||||
}
|
||||
}
|
||||
|
||||
req := &octopus.GetMyAlgorithmListReq{
|
||||
Platform: o.platform,
|
||||
|
@ -457,14 +505,26 @@ func (o *OctopusLink) generateAlgorithmId(option *option.AiOption) error {
|
|||
if ns[1] != option.AlgorithmName {
|
||||
continue
|
||||
}
|
||||
if ns[2] != option.ResourceType {
|
||||
switch option.ResourceType {
|
||||
case CPU:
|
||||
if ns[2] != CPU {
|
||||
continue
|
||||
}
|
||||
case CARD:
|
||||
if ns[2] != strings.ToLower(option.ComputeCard) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
option.AlgorithmId = algorithm.AlgorithmId
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if option.AlgorithmId == "" {
|
||||
return errors.New("Algorithm does not exist")
|
||||
}
|
||||
|
||||
return errors.New("failed to get AlgorithmId")
|
||||
}
|
||||
|
||||
|
@ -487,7 +547,10 @@ func (o *OctopusLink) generateEnv(option *option.AiOption) error {
|
|||
}
|
||||
|
||||
func (o *OctopusLink) generateParams(option *option.AiOption) error {
|
||||
|
||||
if len(option.Params) == 0 {
|
||||
epoch := "epoch" + COMMA + "1"
|
||||
option.Params = append(option.Params, epoch)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package storeLink
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
|
@ -42,6 +43,8 @@ const (
|
|||
DATASETS_DIR = "/work/home/acgnnmfbwo/pcmv1/dataset"
|
||||
ALGORITHM_DIR = "/work/home/acgnnmfbwo/pcmv1/algorithm"
|
||||
TRAIN_FILE = "train.py"
|
||||
CPUCOREPRICEPERHOUR = 0.09
|
||||
DCUPRICEPERHOUR = 2.0
|
||||
)
|
||||
|
||||
var RESOURCESGAIMAP = map[string]ResourceSpecSGAI{
|
||||
|
@ -197,9 +200,9 @@ func (s *ShuguangAi) SubmitTensorflowTask(imageId string, cmd string, envs []str
|
|||
}
|
||||
|
||||
func (s *ShuguangAi) SubmitTask(imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) {
|
||||
// set algorithmId temporarily
|
||||
// set algorithmId temporarily for storelink submit
|
||||
if algorithmId == "" {
|
||||
algorithmId = "pytorch-mnist-fully_connected_network"
|
||||
algorithmId = "pytorch-mnist-fcn"
|
||||
}
|
||||
|
||||
// shuguangAi提交任务
|
||||
|
@ -268,24 +271,41 @@ func (s *ShuguangAi) GetResourceStats() (*collector.ResourceStats, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
limitReq := &hpcAC.QueueReq{}
|
||||
_, err = s.svcCtx.ACRpc.QueryUserQuotasLimit(s.ctx, limitReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
diskReq := &hpcAC.ParaStorQuotaReq{}
|
||||
_, err = s.svcCtx.ACRpc.ParaStorQuota(s.ctx, diskReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//limitReq := &hpcAC.QueueReq{}
|
||||
//limitResp, err := s.svcCtx.ACRpc.QueryUserQuotasLimit(s.ctx, limitReq)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
|
||||
//diskReq := &hpcAC.ParaStorQuotaReq{}
|
||||
//diskResp, err := s.svcCtx.ACRpc.ParaStorQuota(s.ctx, diskReq)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
|
||||
var cards []*collector.Card
|
||||
balance, _ := strconv.ParseFloat(userinfo.Data.AccountBalance, 64)
|
||||
_ = &collector.ResourceStats{
|
||||
cardHours := common.RoundFloat(balance/DCUPRICEPERHOUR, 3)
|
||||
cpuHours := common.RoundFloat(balance/CPUCOREPRICEPERHOUR, 3)
|
||||
|
||||
dcu := &collector.Card{
|
||||
Platform: SHUGUANGAI,
|
||||
Type: CARD,
|
||||
Name: DCU,
|
||||
TOpsAtFp16: DCU_TOPS,
|
||||
CardHours: cardHours,
|
||||
}
|
||||
cards = append(cards, dcu)
|
||||
resourceStats := &collector.ResourceStats{
|
||||
ParticipantId: s.participantId,
|
||||
Name: s.platform,
|
||||
Balance: balance,
|
||||
CardsAvail: cards,
|
||||
CpuCoreHours: cpuHours,
|
||||
}
|
||||
return nil, nil
|
||||
|
||||
return resourceStats, nil
|
||||
}
|
||||
|
||||
func (s *ShuguangAi) GetDatasetsSpecs() ([]*collector.DatasetsSpecs, error) {
|
||||
|
@ -413,6 +433,7 @@ func (s *ShuguangAi) generateAlgorithmId(option *option.AiOption) error {
|
|||
if option.DatasetsName == "" {
|
||||
return errors.New("DatasetsName not set")
|
||||
}
|
||||
|
||||
req := &hpcAC.GetFileListReq{Limit: 100, Path: ALGORITHM_DIR + FORWARD_SLASH + option.TaskType, Start: 0}
|
||||
list, err := s.svcCtx.ACRpc.GetFileList(s.ctx, req)
|
||||
if err != nil {
|
||||
|
@ -426,11 +447,32 @@ func (s *ShuguangAi) generateAlgorithmId(option *option.AiOption) error {
|
|||
for _, file := range list.Data.FileList {
|
||||
ns := strings.Split(file.Name, DASH)
|
||||
if ns[0] == option.DatasetsName {
|
||||
algorithmId = option.TaskType + DASH + file.Name
|
||||
algoName := ns[1]
|
||||
if option.AlgorithmName == "" {
|
||||
switch option.DatasetsName {
|
||||
case "cifar10":
|
||||
algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + "cnn"
|
||||
option.AlgorithmId = algorithmId
|
||||
option.AlgorithmName = ns[1]
|
||||
option.AlgorithmName = algoName
|
||||
return nil
|
||||
case "mnist":
|
||||
algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + "fcn"
|
||||
option.AlgorithmId = algorithmId
|
||||
option.AlgorithmName = algoName
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
if algoName == option.AlgorithmName {
|
||||
algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + algoName
|
||||
option.AlgorithmId = algorithmId
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if algorithmId == "" {
|
||||
return errors.New("Algorithm does not exist")
|
||||
}
|
||||
|
||||
return errors.New("failed to get AlgorithmId")
|
||||
|
@ -451,8 +493,10 @@ func (s *ShuguangAi) generateParams(option *option.AiOption) error {
|
|||
return errors.New("ResourceType not set")
|
||||
}
|
||||
|
||||
//epoch := "epoch" + COMMA + "1"
|
||||
//option.Params = append(option.Params, epoch)
|
||||
if len(option.Params) == 0 {
|
||||
epoch := "epoch" + COMMA + "1"
|
||||
option.Params = append(option.Params, epoch)
|
||||
}
|
||||
|
||||
switch option.ResourceType {
|
||||
case CPU:
|
||||
|
|
|
@ -59,8 +59,9 @@ type ServiceContext struct {
|
|||
Downloader *s3manager.Downloader
|
||||
Uploader *s3manager.Uploader
|
||||
K8sRpc kubernetesclient.Kubernetes
|
||||
PromClient map[int64]tracker.Prometheus
|
||||
MonitorClient map[int64]tracker.Prometheus
|
||||
ParticipantRpc participantservice.ParticipantService
|
||||
PromClient tracker.Prometheus
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
|
@ -72,8 +73,14 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||
DisableSSL: aws.Bool(false), //是否禁用https,这里表示不禁用,即使用HTTPS
|
||||
S3ForcePathStyle: aws.Bool(true), //使用路径样式而非虚拟主机样式,区别请参考:https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html
|
||||
})
|
||||
promClient, err := tracker.NewPrometheus(c.PromUrl)
|
||||
if err != nil {
|
||||
logx.Errorf("InitPrometheus err: %v", err)
|
||||
panic("InitSnowflake err")
|
||||
}
|
||||
|
||||
//添加snowflake支持
|
||||
err := utils.InitSnowflake(c.SnowflakeConf.MachineId)
|
||||
err = utils.InitSnowflake(c.SnowflakeConf.MachineId)
|
||||
if err != nil {
|
||||
logx.Errorf("InitSnowflake err: %v", err)
|
||||
panic("InitSnowflake err")
|
||||
|
@ -122,10 +129,11 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||
OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)),
|
||||
OpenstackRpc: openstackclient.NewOpenstack(zrpc.MustNewClient(c.OpenstackRpcConf)),
|
||||
K8sRpc: kubernetesclient.NewKubernetes(zrpc.MustNewClient(c.K8sNativeConf)),
|
||||
PromClient: make(map[int64]tracker.Prometheus),
|
||||
MonitorClient: make(map[int64]tracker.Prometheus),
|
||||
ParticipantRpc: participantservice.NewParticipantService(zrpc.MustNewClient(c.PcmCoreRpcConf)),
|
||||
DockerClient: dockerClient,
|
||||
Downloader: downloader,
|
||||
Uploader: uploader,
|
||||
PromClient: promClient,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,11 @@ type CenterResourcesResp struct {
|
|||
}
|
||||
|
||||
type CenterIndex struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Cpu float32 `json:"cpu"`
|
||||
Memory float32 `json:"memory"`
|
||||
Storage float32 `json:"storage"`
|
||||
Cpu string `json:"cpu"`
|
||||
Memory string `json:"memory"`
|
||||
Storage string `json:"storage"`
|
||||
CenterType string `json:"centerType"`
|
||||
}
|
||||
|
||||
|
@ -29,9 +30,16 @@ type SyncClusterLoadReq struct {
|
|||
}
|
||||
|
||||
type ClusterLoadRecord struct {
|
||||
AdapterId int64 `json:"adapterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
CpuAvail float64 `json:"cpuAvail"`
|
||||
CpuTotal float64 `json:"cpuTotal"`
|
||||
CpuUsage float64 `json:"cpuUsage"`
|
||||
MemoryAvail float64 `json:"memoryAvail"`
|
||||
MemoryUsage float64 `json:"memoryUsage"`
|
||||
MemoryTotal float64 `json:"memoryTotal"`
|
||||
DiskAvail float64 `json:"diskAvail"`
|
||||
DiskTotal float64 `json:"diskTotal"`
|
||||
DiskUsage float64 `json:"diskUsage"`
|
||||
}
|
||||
|
||||
|
@ -518,6 +526,15 @@ type AdapterQueryReq struct {
|
|||
PageInfo
|
||||
}
|
||||
|
||||
type AdapterRelationQueryReq struct {
|
||||
Id string `form:"id,optional" db:"id"`
|
||||
Name string `form:"name,optional"`
|
||||
Type string `form:"type,optional"`
|
||||
Nickname string `form:"nickname,optional"`
|
||||
Version string `form:"version,optional"`
|
||||
Server string `form:"server,optional"`
|
||||
}
|
||||
|
||||
type AdapterReq struct {
|
||||
Id string `json:"id,optional" db:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
|
@ -2569,7 +2586,7 @@ type Limits struct {
|
|||
}
|
||||
|
||||
type GetComputeLimitsReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type GetComputeLimitsResp struct {
|
||||
|
@ -2601,7 +2618,7 @@ type VolumeLimits struct {
|
|||
}
|
||||
|
||||
type GetVolumeLimitsReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type GetVolumeLimitsResp struct {
|
||||
|
@ -2614,7 +2631,7 @@ type GetVolumeLimitsResp struct {
|
|||
type ListServersReq struct {
|
||||
Limit int32 `form:"limit,optional"`
|
||||
OffSet int32 `form:"offSet,optional"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListServersResp struct {
|
||||
|
@ -2643,7 +2660,7 @@ type Servers_links struct {
|
|||
}
|
||||
|
||||
type ListServersDetailedReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListServersDetailedResp struct {
|
||||
|
@ -2667,7 +2684,7 @@ type ServersDetailed struct {
|
|||
|
||||
type GetServersDetailedByIdReq struct {
|
||||
ServerId string `form:"server_id" copier:"ServerId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type GetServersDetailedByIdResp struct {
|
||||
|
@ -2755,7 +2772,7 @@ type ExtraSpecs struct {
|
|||
type UpdateServerReq struct {
|
||||
ServerId string `form:"server_id" copier:"ServerId"`
|
||||
ServerUpdate ServerUpdate `json:"server_update" copier:"ServerUpdate"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ServerUpdate struct {
|
||||
|
@ -2773,7 +2790,7 @@ type StartServerReq struct {
|
|||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"action,optional" copier:"Action"`
|
||||
Start_action string `json:"start_action" copier:"start_action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type StartServerResp struct {
|
||||
|
@ -2786,7 +2803,7 @@ type StopServerReq struct {
|
|||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"action,optional" copier:"Action"`
|
||||
Stop_action string `json:"stop_action" copier:"stop_action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type StopServerResp struct {
|
||||
|
@ -2798,7 +2815,7 @@ type StopServerResp struct {
|
|||
type RebootServerReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Reboot Reboot `json:"reboot" copier:"Reboot"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type RebootServerResp struct {
|
||||
|
@ -2815,7 +2832,7 @@ type PauseServerReq struct {
|
|||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"Action,optional" copier:"Action"`
|
||||
Pause_action string `json:"pause_action" copier:"pause_action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type PauseServerResp struct {
|
||||
|
@ -2828,7 +2845,7 @@ type UnpauseServerReq struct {
|
|||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"Action,optional" copier:"Action"`
|
||||
Unpause_action string `json:"unpause_action" copier:"unpause_action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type UnpauseServerResp struct {
|
||||
|
@ -2839,7 +2856,7 @@ type UnpauseServerResp struct {
|
|||
|
||||
type DeleteServerReq struct {
|
||||
ServerId string `form:"server_id" copier:"ServerId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type DeleteServerResp struct {
|
||||
|
@ -2850,7 +2867,7 @@ type DeleteServerResp struct {
|
|||
|
||||
type CreateServerReq struct {
|
||||
Server Server `json:"server" copier:"Server"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type CreateServerResp struct {
|
||||
|
@ -2894,7 +2911,7 @@ type ServerResp struct {
|
|||
|
||||
type RebuildServerReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
Rebuild Rebuild `json:"rebuild" copier:"Rebuild"`
|
||||
}
|
||||
|
||||
|
@ -2969,7 +2986,7 @@ type ShelveServerReq struct {
|
|||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"Action,optional" copier:"Action"`
|
||||
Shelve_action string `json:"shelve_action" copier:"shelve_action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ShelveServerResp struct {
|
||||
|
@ -2980,7 +2997,7 @@ type ShelveServerResp struct {
|
|||
|
||||
type RescueServerReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
Rescue Rescue `json:"rescue" copier:"Rescue"`
|
||||
}
|
||||
|
||||
|
@ -2998,7 +3015,7 @@ type Rescue struct {
|
|||
type UnRescueServerReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"Action,optional" copier:"Action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
UnRescue_action string `json:"UnRescue_action" copier:"UnRescue_action"`
|
||||
Rescue Rescue `json:"rescue" copier:"Rescue"`
|
||||
}
|
||||
|
@ -3012,7 +3029,7 @@ type UnRescueServerResp struct {
|
|||
type ChangeAdministrativePasswordReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Changepassword string `json:"changePassword" copier:"Changepassword"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
ChangePassword ChangePassword `json:"changepassword" copier:"ChangePassword"`
|
||||
}
|
||||
|
||||
|
@ -3029,7 +3046,7 @@ type ChangePassword struct {
|
|||
type SuspendServerReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"Action,optional" copier:"Action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
UnRescue_action string `json:"UnRescue_action" copier:"UnRescue_action"`
|
||||
Rescue Rescue `json:"rescue" copier:"Rescue"`
|
||||
}
|
||||
|
@ -3043,7 +3060,7 @@ type SuspendServerResp struct {
|
|||
type AddSecurityGroupToServerReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Action []map[string]string `json:"Action,optional" copier:"Action"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
UnRescue_action string `json:"UnRescue_action" copier:"UnRescue_action"`
|
||||
AddSecurityGroup AddSecurityGroup `json:"addSecurityGroup" copier:"AddSecurityGroup"`
|
||||
}
|
||||
|
@ -3060,7 +3077,7 @@ type AddSecurityGroup struct {
|
|||
|
||||
type RemoveSecurityGroupReq struct {
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
RemoveSecurityGroup RemoveSecurityGroup `json:"removeSecurityGroup" copier:"RemoveSecurityGroup"`
|
||||
}
|
||||
|
||||
|
@ -3096,7 +3113,7 @@ type FlavorServer struct {
|
|||
}
|
||||
|
||||
type DeleteFlavorReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
ServerId string `json:"server_id" copier:"ServerId"`
|
||||
FlavorId string `json:"flavor_id" copier:"FlavorId"`
|
||||
}
|
||||
|
@ -3108,7 +3125,8 @@ type DeleteFlavorResp struct {
|
|||
}
|
||||
|
||||
type ListImagesReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Limit int32 `form:"limit,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListImagesResp struct {
|
||||
|
@ -3178,7 +3196,7 @@ type CreateImageResp struct {
|
|||
|
||||
type UploadOsImageReq struct {
|
||||
ImageId string `form:"image_id" copier:"ImageId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type UploadOsImageResp struct {
|
||||
|
@ -3189,7 +3207,7 @@ type UploadOsImageResp struct {
|
|||
|
||||
type DeleteImageReq struct {
|
||||
ImageId string `form:"image_id" copier:"ImageId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type DeleteImageResp struct {
|
||||
|
@ -3213,7 +3231,7 @@ type ImageNum struct {
|
|||
}
|
||||
|
||||
type ListNetworksReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListNetworksResp struct {
|
||||
|
@ -3253,7 +3271,7 @@ type Network struct {
|
|||
|
||||
type DeleteNetworkReq struct {
|
||||
NetworkId string `form:"network_id" copier:"NetworkId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type DeleteNetworkResp struct {
|
||||
|
@ -3264,7 +3282,7 @@ type DeleteNetworkResp struct {
|
|||
|
||||
type CreateNetworkReq struct {
|
||||
Network CreateNetwork `json:"network" copier:"Network"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type CreateNetworkResp struct {
|
||||
|
@ -3282,7 +3300,7 @@ type CreateNetwork struct {
|
|||
|
||||
type CreateSubnetReq struct {
|
||||
Subnet Subnet `json:"subnet" copier:"Subnet"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type CreateSubnetResp struct {
|
||||
|
@ -3337,7 +3355,7 @@ type Allocation_pools struct {
|
|||
|
||||
type ShowNetworkDetailsReq struct {
|
||||
NetworkId string `form:"network_id" copier:"NetworkId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ShowNetworkDetailsResp struct {
|
||||
|
@ -3376,7 +3394,7 @@ type Networkdetail struct {
|
|||
type UpdateNetworkReq struct {
|
||||
NetworkId string `form:"network_id" copier:"NetworkId"`
|
||||
Network Network `json:"network" copier:"Network"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type UpdateNetworkResp struct {
|
||||
|
@ -3401,7 +3419,7 @@ type BulkCreateNetworksResp struct {
|
|||
type ListSubnetsReq struct {
|
||||
Limit int32 `json:"limit,optional"`
|
||||
OffSet int32 `json:"offSet,optional"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListSubnetsResp struct {
|
||||
|
@ -3443,7 +3461,7 @@ type Allocation_pool struct {
|
|||
|
||||
type DeleteSubnetReq struct {
|
||||
SubnetId string `json:"subnet_id,optional" copier:"subnetId"`
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
}
|
||||
|
||||
type DeleteSubnetResp struct {
|
||||
|
@ -3454,7 +3472,7 @@ type DeleteSubnetResp struct {
|
|||
|
||||
type UpdateSubnetReq struct {
|
||||
SubnetId string `json:"subnet_id,optional" copier:"subnetId"`
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
}
|
||||
|
||||
type UpdateSubnetResp struct {
|
||||
|
@ -3499,7 +3517,7 @@ type Used struct {
|
|||
type ListNetworkSegmentRangesReq struct {
|
||||
Limit int32 `json:"limit,optional"`
|
||||
OffSet int32 `json:"offSet,optional"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListNetworkSegmentRangesResp struct {
|
||||
|
@ -3529,7 +3547,7 @@ type Network_segment_ranges struct {
|
|||
|
||||
type DeleteNetworkSegmentRangesReq struct {
|
||||
Network_segment_range_id string `json:"network_segment_range_id,optional" copier:"network_segment_range_id"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type DeleteNetworkSegmentRangesResp struct {
|
||||
|
@ -3541,7 +3559,7 @@ type DeleteNetworkSegmentRangesResp struct {
|
|||
type UpdateNetworkSegmentRangesReq struct {
|
||||
Network_segment_range_id string `json:"network_segment_range_id,optional" copier:"network_segment_range_id"`
|
||||
NetworkSegmentRange Network_segment_range `json:"network_segment_range,optional" copier:"NetworkSegmentRange"`
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
}
|
||||
|
||||
type UpdateNetworkSegmentRangesResp struct {
|
||||
|
@ -3613,7 +3631,7 @@ type CreatePortResp struct {
|
|||
type ListPortsReq struct {
|
||||
Limit int32 `json:"limit,optional"`
|
||||
OffSet int32 `json:"offSet,optional"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListPortsResp struct {
|
||||
|
@ -3672,7 +3690,7 @@ type Fixed_ips struct {
|
|||
|
||||
type DeletePortReq struct {
|
||||
Port_id string `json:"port_id,optional" copier:"port_id"`
|
||||
Platform string `form:"platform,optional" copier:"platform"`
|
||||
Platform string `json:"platform,optional" copier:"platform"`
|
||||
}
|
||||
|
||||
type DeletePortResp struct {
|
||||
|
@ -3684,7 +3702,7 @@ type DeletePortResp struct {
|
|||
type UpdatePortReq struct {
|
||||
Port_id string `json:"port_id,optional" copier:"port_id"`
|
||||
Port Port `json:"port,optional" copier:"port"`
|
||||
Platform string `form:"platform,optional" copier:"platform"`
|
||||
Platform string `json:"platform,optional" copier:"platform"`
|
||||
}
|
||||
|
||||
type UpdatePortResp struct {
|
||||
|
@ -3697,7 +3715,7 @@ type UpdatePortResp struct {
|
|||
type ShowPortDetailsReq struct {
|
||||
Port_id string `json:"port_id,optional" copier:"port_id"`
|
||||
Fields string `json:"fields,optional" copier:"fields"`
|
||||
Platform string `form:"platform,optional" copier:"platform"`
|
||||
Platform string `json:"platform,optional" copier:"platform"`
|
||||
}
|
||||
|
||||
type ShowPortDetailsResp struct {
|
||||
|
@ -3710,7 +3728,7 @@ type ShowPortDetailsResp struct {
|
|||
type ListRoutersReq struct {
|
||||
Limit int32 `json:"limit,optional"`
|
||||
OffSet int32 `json:"offSet,optional"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListRoutersResp struct {
|
||||
|
@ -3804,7 +3822,7 @@ type Router struct {
|
|||
|
||||
type UpdateRouterReq struct {
|
||||
Router Router `json:"router,optional" copier:"router"`
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
}
|
||||
|
||||
type UpdateRouterResp struct {
|
||||
|
@ -3816,7 +3834,7 @@ type UpdateRouterResp struct {
|
|||
|
||||
type ShowRouterDetailsReq struct {
|
||||
Router Router `json:"router,optional" copier:"router"`
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
}
|
||||
|
||||
type ShowRouterDetailsResp struct {
|
||||
|
@ -3827,7 +3845,7 @@ type ShowRouterDetailsResp struct {
|
|||
}
|
||||
|
||||
type DeleteRouterReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Router_id string `json:"router_id,optional" copier:"router_id"`
|
||||
}
|
||||
|
||||
|
@ -3838,7 +3856,7 @@ type DeleteRouterResp struct {
|
|||
}
|
||||
|
||||
type ListFloatingIPsReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Limit int32 `json:"limit,optional" copier:"Limit"`
|
||||
OffSet int32 `json:"offSet,optional" copier:"OffSet"`
|
||||
}
|
||||
|
@ -3925,7 +3943,7 @@ type Floatingip struct {
|
|||
}
|
||||
|
||||
type UpdateFloatingIPReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Floatingip_id string `json:"floatingip_id,optional" copier:"floatingip_id"`
|
||||
Floatingip Floatingip `json:"floatingip,optional" copier:"floatingip"`
|
||||
}
|
||||
|
@ -3938,7 +3956,7 @@ type UpdateFloatingIPResp struct {
|
|||
}
|
||||
|
||||
type DeleteFloatingIPReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Floatingip_id string `json:"floatingip_id,optional" copier:"floatingip_id"`
|
||||
}
|
||||
|
||||
|
@ -3961,7 +3979,7 @@ type ShowFloatingIPDetailsResp struct {
|
|||
}
|
||||
|
||||
type ListFirewallGroupsReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Fields string `json:"fields,optional" copier:"fields"`
|
||||
}
|
||||
|
||||
|
@ -3988,7 +4006,7 @@ type Firewall_groups struct {
|
|||
|
||||
type DeleteFirewallGroupReq struct {
|
||||
Firewall_group_id string `json:"firewall_group_id,optional" copier:"firewall_group_id"`
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
}
|
||||
|
||||
type DeleteFirewallGroupResp struct {
|
||||
|
@ -4025,7 +4043,7 @@ type Firewall_group struct {
|
|||
|
||||
type UpdateFirewallGroupReq struct {
|
||||
Firewall_group Firewall_group `json:"firewall_group,optional" copier:"firewall_group"`
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Firewall_group_id string `json:"firewall_group_id,optional" copier:"firewall_group_id"`
|
||||
}
|
||||
|
||||
|
@ -4037,7 +4055,7 @@ type UpdateFirewallGroupResp struct {
|
|||
}
|
||||
|
||||
type ShowFirewallGroupDetailsReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Firewall_group_id string `json:"firewall_group_id,optional" copier:"firewall_group_id"`
|
||||
}
|
||||
|
||||
|
@ -4072,7 +4090,7 @@ type Firewall_policy struct {
|
|||
}
|
||||
|
||||
type DeleteFirewallPolicyReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Firewall_policy_id string `json:"firewall_policy_id,optional" copier:"firewall_policy_id"`
|
||||
}
|
||||
|
||||
|
@ -4083,7 +4101,7 @@ type DeleteFirewallPolicyResp struct {
|
|||
}
|
||||
|
||||
type ListFirewallPoliciesReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Fields string `json:"fields,optional" copier:"fields"`
|
||||
}
|
||||
|
||||
|
@ -4149,7 +4167,7 @@ type Firewall_rule struct {
|
|||
}
|
||||
|
||||
type DeleteFirewallRuleReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Firewall_rule_id string `json:"firewall_rule_id,optional" copier:"firewall_rule_id"`
|
||||
}
|
||||
|
||||
|
@ -4160,7 +4178,7 @@ type DeleteFirewallRuleResp struct {
|
|||
}
|
||||
|
||||
type ListFirewallRulesReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Fields string `json:"fields,optional" copier:"fields"`
|
||||
}
|
||||
|
||||
|
@ -4191,7 +4209,7 @@ type Firewall_rules struct {
|
|||
}
|
||||
|
||||
type ShowFirewallRuleDetailsReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Firewall_rule_id string `json:"firewall_rule_id,optional" copier:"firewall_rule_id"`
|
||||
}
|
||||
|
||||
|
@ -4203,7 +4221,7 @@ type ShowFirewallRuleDetailsResp struct {
|
|||
}
|
||||
|
||||
type ListSecurityGroupsReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Fields string `json:"firewall_rule_id,optional" copier:"firewall_rule_id"`
|
||||
}
|
||||
|
||||
|
@ -4229,7 +4247,7 @@ type Security_groups struct {
|
|||
}
|
||||
|
||||
type CreateSecurityGroupReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Firewall_rule_id string `json:"firewall_rule_id,optional" copier:"firewall_rule_id"`
|
||||
}
|
||||
|
||||
|
@ -4276,7 +4294,7 @@ type Security_group_rules struct {
|
|||
}
|
||||
|
||||
type DeleteSecurityGroupReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Security_group_id string `json:"security_group_id,optional" copier:"security_group_id"`
|
||||
}
|
||||
|
||||
|
@ -4287,7 +4305,7 @@ type DeleteSecurityGroupResp struct {
|
|||
}
|
||||
|
||||
type UpdateSecurityGroupReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Security_group_id string `json:"security_group_id,optional" copier:"security_group_id"`
|
||||
}
|
||||
|
||||
|
@ -4299,7 +4317,7 @@ type UpdateSecurityGroupResp struct {
|
|||
}
|
||||
|
||||
type ShowSecurityGroupReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Security_group_id string `json:"security_group_id,optional" copier:"security_group_id"`
|
||||
Fields string `json:"fields,optional" copier:"fields"`
|
||||
Verbose string `json:"verbose,optional" copier:"verbose"`
|
||||
|
@ -4313,7 +4331,7 @@ type ShowSecurityGroupResp struct {
|
|||
}
|
||||
|
||||
type ListSecurityGroupRulesReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
}
|
||||
|
||||
type ListSecurityGroupRulesResp struct {
|
||||
|
@ -4355,7 +4373,7 @@ type Security_group_rule struct {
|
|||
}
|
||||
|
||||
type ShowSecurityGroupRuleReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Security_group_rule_id string `json:"security_group_rule_id,optional" copier:"security_group_rule_id"`
|
||||
}
|
||||
|
||||
|
@ -4367,7 +4385,7 @@ type ShowSecurityGroupRuleResp struct {
|
|||
}
|
||||
|
||||
type DeleteSecurityGroupRuleReq struct {
|
||||
Platform string `form:"platform,optional" copier:"Platform"`
|
||||
Platform string `json:"platform,optional" copier:"Platform"`
|
||||
Security_group_rule_id string `json:"security_group_rule_id,optional" copier:"security_group_rule_id"`
|
||||
}
|
||||
|
||||
|
@ -4379,7 +4397,7 @@ type DeleteSecurityGroupRuleResp struct {
|
|||
}
|
||||
|
||||
type ListVolumesDetailReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListVolumesDetailResp struct {
|
||||
|
@ -4413,7 +4431,7 @@ type DeleteVolumeReq struct {
|
|||
VolumeId string `form:"volume_id" copier:"VolumeId"`
|
||||
Cascade bool `json:"cascade" copier:"Cascade"`
|
||||
Force bool `json:"force" copier:"force"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type DeleteVolumeResp struct {
|
||||
|
@ -4463,7 +4481,7 @@ type VolumeResp struct {
|
|||
}
|
||||
|
||||
type ListVolumeTypesReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListVolumeTypesResp struct {
|
||||
|
@ -4490,7 +4508,7 @@ type Extra_specs struct {
|
|||
type UpdateVolumeReq struct {
|
||||
Volume Volume `json:"volume" copier:"Volume"`
|
||||
VolumeId string `json:"volume_id" copier:"VolumeId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type UpdateVolumeResp struct {
|
||||
|
@ -4502,7 +4520,7 @@ type UpdateVolumeResp struct {
|
|||
|
||||
type GetVolumeDetailedByIdReq struct {
|
||||
VolumeId string `form:"volume_id" copier:"VolumeId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type GetVolumeDetailedByIdResp struct {
|
||||
|
@ -4554,7 +4572,7 @@ type VolumeType struct {
|
|||
|
||||
type DeleteVolumeTypeReq struct {
|
||||
VolumeTypeId string `json:"volume_type_id" copier:"VolumeTypeId"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type DeleteVolumeTypeResp struct {
|
||||
|
@ -4574,7 +4592,7 @@ type ListVolumesReq struct {
|
|||
CreatedAt string `json:"created_at" copier:"CreatedAt"`
|
||||
ConsumesQuota bool `json:"consumes_quota" copier:"ConsumesQuota"`
|
||||
UpdatedAt string `json:"updated_at" copier:"UpdatedAt"`
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListVolumesResp struct {
|
||||
|
@ -4591,7 +4609,7 @@ type VolumesList struct {
|
|||
}
|
||||
|
||||
type ListFlavorsDetailReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
}
|
||||
|
||||
type ListFlavorsDetailResp struct {
|
||||
|
@ -4616,7 +4634,7 @@ type Flavors struct {
|
|||
}
|
||||
|
||||
type ListNodesReq struct {
|
||||
Platform string `form:"platform,optional"`
|
||||
Platform string `json:"platform,optional"`
|
||||
Limit int64 `json:"limit" copier:"Limit"`
|
||||
Marker string `json:"marker" copier:"Marker"`
|
||||
SortDir string `json:"sort_dir" copier:"SortDir"`
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
|
||||
package tracker
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"github.com/prometheus/common/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
//GetMetric(expr string, time time.Time) Metric
|
||||
|
@ -27,4 +30,5 @@ type Interface interface {
|
|||
//// meter
|
||||
//GetNamedMeters(meters []string, time time.Time, opts []QueryOption) []Metric
|
||||
//GetNamedMetersOverTime(metrics []string, start, end time.Time, step time.Duration, opts []QueryOption) []Metric
|
||||
GetRawData(expr string, o QueryOption) (model.Value, error)
|
||||
}
|
||||
|
|
|
@ -27,35 +27,16 @@ const (
|
|||
|
||||
var promQLTemplates = map[string]string{
|
||||
|
||||
//namespace
|
||||
"cluster_cpu_usage": "sum by (cluster_name)(cluster_cpu_usage{$1})",
|
||||
"cluster_memory_usage": "sum by (cluster_name)(cluster_memory_usage{$1})",
|
||||
"cluster_disk_usage": "sum by (cluster_name)(cluster_disk_usage{$1})",
|
||||
"center_cpu_usage": "(sum by (adapter_id)(cluster_cpu_total{$1})-sum by (adapter_id)(cluster_cpu_avail{$1}))/sum by (adapter_id)(cluster_cpu_total{$1})",
|
||||
"center_memory_usage": "(sum by (adapter_id)(cluster_memory_total{$1})-sum by (adapter_id)(cluster_memory_avail{$1}))/sum by (adapter_id)(cluster_memory_total{$1})",
|
||||
"center_disk_usage": "(sum by (adapter_id)(cluster_disk_total{$1})-sum by (adapter_id)(cluster_disk_avail{$1}))/sum by (adapter_id)(cluster_disk_total{$1})",
|
||||
"center_top3": "topk(3,((sum by (adapter_id)(cluster_cpu_total)-sum by (adapter_id)(cluster_cpu_avail))/sum by (adapter_id)(cluster_cpu_total) + (sum by (adapter_id)(cluster_memory_total) - sum by (adapter_id)(cluster_memory_avail))/sum by (adapter_id)(cluster_memory_total) + (sum by (adapter_id)(cluster_disk_total)-sum by (adapter_id)(cluster_disk_avail))/sum by (adapter_id)(cluster_disk_total))/3)",
|
||||
"namespace_cpu_usage": `round(namespace:container_cpu_usage_seconds_total:sum_rate{namespace!="", $1}, 0.001)`,
|
||||
"namespace_memory_usage": `namespace:container_memory_usage_bytes:sum{namespace!="", $1}`,
|
||||
"namespace_memory_usage_wo_cache": `namespace:container_memory_usage_bytes_wo_cache:sum{namespace!="", $1}`,
|
||||
"namespace_net_bytes_transmitted": `sum by (namespace) (irate(container_network_transmit_bytes_total{namespace!="", pod!="", interface!~"^(cali.+|tunl.+|dummy.+|kube.+|flannel.+|cni.+|docker.+|veth.+|lo.*)", job="kubelet"}[5m]) * on (namespace) group_left(workspace) kube_namespace_labels{$1}) or on(namespace) max by(namespace) (kube_namespace_labels{$1} * 0)`,
|
||||
"namespace_net_bytes_received": `sum by (namespace) (irate(container_network_receive_bytes_total{namespace!="", pod!="", interface!~"^(cali.+|tunl.+|dummy.+|kube.+|flannel.+|cni.+|docker.+|veth.+|lo.*)", job="kubelet"}[5m]) * on (namespace) group_left(workspace) kube_namespace_labels{$1}) or on(namespace) max by(namespace) (kube_namespace_labels{$1} * 0)`,
|
||||
"namespace_pod_count": `sum by (namespace) (kube_pod_status_phase{phase!~"Failed|Succeeded", namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1}) or on(namespace) max by(namespace) (kube_namespace_labels{$1} * 0)`,
|
||||
"namespace_pod_running_count": `sum by (namespace) (kube_pod_status_phase{phase="Running", namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1}) or on(namespace) max by(namespace) (kube_namespace_labels{$1} * 0)`,
|
||||
"namespace_pod_succeeded_count": `sum by (namespace) (kube_pod_status_phase{phase="Succeeded", namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1}) or on(namespace) max by(namespace) (kube_namespace_labels{$1} * 0)`,
|
||||
"namespace_pod_abnormal_count": `namespace:pod_abnormal:count{namespace!="", $1}`,
|
||||
"namespace_pod_abnormal_ratio": `namespace:pod_abnormal:ratio{namespace!="", $1}`,
|
||||
"namespace_memory_limit_hard": `min by (namespace) (kube_resourcequota{resourcequota!="quota", type="hard", namespace!="", resource="limits.memory"} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_cpu_limit_hard": `min by (namespace) (kube_resourcequota{resourcequota!="quota", type="hard", namespace!="", resource="limits.cpu"} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_pod_count_hard": `min by (namespace) (kube_resourcequota{resourcequota!="quota", type="hard", namespace!="", resource="count/pods"} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_cronjob_count": `sum by (namespace) (kube_cronjob_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_pvc_count": `sum by (namespace) (kube_persistentvolumeclaim_info{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_daemonset_count": `sum by (namespace) (kube_daemonset_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_deployment_count": `sum by (namespace) (kube_deployment_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_endpoint_count": `sum by (namespace) (kube_endpoint_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_hpa_count": `sum by (namespace) (kube_horizontalpodautoscaler_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_job_count": `sum by (namespace) (kube_job_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_statefulset_count": `sum by (namespace) (kube_statefulset_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_replicaset_count": `count by (namespace) (kube_replicaset_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_service_count": `sum by (namespace) (kube_service_info{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_secret_count": `sum by (namespace) (kube_secret_info{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_configmap_count": `sum by (namespace) (kube_configmap_info{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_ingresses_extensions_count": `sum by (namespace) (kube_ingress_labels{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
"namespace_s2ibuilder_count": `sum by (namespace) (s2i_s2ibuilder_created{namespace!=""} * on (namespace) group_left(workspace) kube_namespace_labels{$1})`,
|
||||
|
||||
"controller_cpu_usage_rate": `sum( node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{$1}) by (workload)/sum( kube_pod_container_resource_limits{job="kube-state-metrics", resource="cpu"}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{ }) by (workload)`,
|
||||
"controller_memory_usage_rate": `sum( container_memory_working_set_bytes{job="kubelet", metrics_path="/metrics/cadvisor", container!="", image!=""} * on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{$1}) by (workload)/sum( kube_pod_container_resource_limits{job="kube-state-metrics", resource="memory"}* on(namespace,pod) group_left(workload) namespace_workload_pod:kube_pod_owner:relabel{ }) by (workload)`,
|
||||
// pod
|
||||
|
@ -80,8 +61,10 @@ var promQLTemplates = map[string]string{
|
|||
func makeExpr(metric string, opts QueryOptions) string {
|
||||
tmpl := promQLTemplates[metric]
|
||||
switch opts.Level {
|
||||
case LevelAdapter:
|
||||
return makeAdapterMetricExpr(tmpl, opts)
|
||||
case LevelCluster:
|
||||
return tmpl
|
||||
return makeClusterMetricExpr(tmpl, opts)
|
||||
case LevelNode:
|
||||
return makeNodeMetricExpr(tmpl, opts)
|
||||
case LevelWorkspace:
|
||||
|
@ -105,6 +88,24 @@ func makeExpr(metric string, opts QueryOptions) string {
|
|||
}
|
||||
}
|
||||
|
||||
func makeClusterMetricExpr(tmpl string, o QueryOptions) string {
|
||||
var clusterSelector string
|
||||
if o.ClusterName != "" {
|
||||
clusterSelector = fmt.Sprintf(`cluster_name="%s"`, o.ClusterName)
|
||||
}
|
||||
return strings.Replace(tmpl, "$1", clusterSelector, -1)
|
||||
|
||||
}
|
||||
|
||||
func makeAdapterMetricExpr(tmpl string, o QueryOptions) string {
|
||||
var adapterSelector string
|
||||
if o.AdapterId != 0 {
|
||||
adapterSelector = fmt.Sprintf(`adapter_id="%d"`, o.AdapterId)
|
||||
}
|
||||
return strings.Replace(tmpl, "$1", adapterSelector, -1)
|
||||
|
||||
}
|
||||
|
||||
func makeNodeMetricExpr(tmpl string, o QueryOptions) string {
|
||||
var nodeSelector string
|
||||
if o.NodeName != "" {
|
||||
|
@ -177,19 +178,12 @@ func makePVCMetricExpr(tmpl string, o QueryOptions) string {
|
|||
// GET /namespaces/{namespace}/persistentvolumeclaims/{persistentvolumeclaim} or
|
||||
// GET /namespaces/{namespace}/persistentvolumeclaims
|
||||
if o.Namespace != "" {
|
||||
if o.PersistentVolumeClaimName != "" {
|
||||
pvcSelector = fmt.Sprintf(`namespace="%s", persistentvolumeclaim="%s"`, o.Namespace, o.PersistentVolumeClaimName)
|
||||
} else {
|
||||
|
||||
pvcSelector = fmt.Sprintf(`namespace="%s", persistentvolumeclaim=~"%s"`, o.Namespace, o.ResourceFilter)
|
||||
}
|
||||
|
||||
return strings.Replace(tmpl, "$1", pvcSelector, -1)
|
||||
}
|
||||
|
||||
// For monitoring persistentvolumeclaims of the specific storageclass
|
||||
// GET /storageclasses/{storageclass}/persistentvolumeclaims
|
||||
if o.StorageClassName != "" {
|
||||
pvcSelector = fmt.Sprintf(`storageclass="%s", persistentvolumeclaim=~"%s"`, o.StorageClassName, o.ResourceFilter)
|
||||
}
|
||||
return strings.Replace(tmpl, "$1", pvcSelector, -1)
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ const (
|
|||
LevelWorkspace
|
||||
LevelNamespace
|
||||
LevelApplication
|
||||
LevelOpenpitrix
|
||||
LevelController
|
||||
LevelService
|
||||
LevelPod
|
||||
|
@ -36,9 +35,11 @@ const (
|
|||
LevelPVC
|
||||
LevelComponent
|
||||
LevelIngress
|
||||
LevelAdapter
|
||||
)
|
||||
|
||||
var MeteringLevelMap = map[string]int{
|
||||
"LevelAdapter": LevelAdapter,
|
||||
"LevelCluster": LevelCluster,
|
||||
"LevelNode": LevelNode,
|
||||
"LevelWorkspace": LevelWorkspace,
|
||||
|
@ -68,6 +69,7 @@ type QueryOptions struct {
|
|||
NamespacedResourcesFilter string
|
||||
QueryType string
|
||||
ResourceFilter string
|
||||
ClusterName string
|
||||
NodeName string
|
||||
WorkspaceName string
|
||||
Namespace string
|
||||
|
@ -77,10 +79,7 @@ type QueryOptions struct {
|
|||
PodName string
|
||||
PodsName string
|
||||
ContainerName string
|
||||
StorageClassName string
|
||||
PersistentVolumeClaimName string
|
||||
PVCFilter string
|
||||
ApplicationName string
|
||||
AdapterId int64
|
||||
ServiceName string
|
||||
Ingress string
|
||||
Job string
|
||||
|
@ -92,10 +91,22 @@ func NewQueryOptions() *QueryOptions {
|
|||
return &QueryOptions{}
|
||||
}
|
||||
|
||||
type ClusterOption struct{}
|
||||
type AdapterOption struct {
|
||||
AdapterId int64
|
||||
}
|
||||
|
||||
func (_ ClusterOption) Apply(o *QueryOptions) {
|
||||
func (a AdapterOption) Apply(o *QueryOptions) {
|
||||
o.Level = LevelAdapter
|
||||
o.AdapterId = a.AdapterId
|
||||
}
|
||||
|
||||
type ClusterOption struct {
|
||||
ClusterName string
|
||||
}
|
||||
|
||||
func (c ClusterOption) Apply(o *QueryOptions) {
|
||||
o.Level = LevelCluster
|
||||
o.ClusterName = c.ClusterName
|
||||
}
|
||||
|
||||
type NodeOption struct {
|
||||
|
@ -110,8 +121,6 @@ func (no NodeOption) Apply(o *QueryOptions) {
|
|||
o.Level = LevelNode
|
||||
o.ResourceFilter = no.ResourceFilter
|
||||
o.NodeName = no.NodeName
|
||||
o.PVCFilter = no.PVCFilter
|
||||
o.StorageClassName = no.StorageClassName
|
||||
o.QueryType = no.QueryType
|
||||
}
|
||||
|
||||
|
@ -126,8 +135,6 @@ func (wo WorkspaceOption) Apply(o *QueryOptions) {
|
|||
o.Level = LevelWorkspace
|
||||
o.ResourceFilter = wo.ResourceFilter
|
||||
o.WorkspaceName = wo.WorkspaceName
|
||||
o.PVCFilter = wo.PVCFilter
|
||||
o.StorageClassName = wo.StorageClassName
|
||||
}
|
||||
|
||||
type NamespaceOption struct {
|
||||
|
@ -143,8 +150,6 @@ func (no NamespaceOption) Apply(o *QueryOptions) {
|
|||
o.ResourceFilter = no.ResourceFilter
|
||||
o.WorkspaceName = no.WorkspaceName
|
||||
o.Namespace = no.NamespaceName
|
||||
o.PVCFilter = no.PVCFilter
|
||||
o.StorageClassName = no.StorageClassName
|
||||
}
|
||||
|
||||
type ApplicationsOption struct {
|
||||
|
@ -183,8 +188,6 @@ type ApplicationOption struct {
|
|||
func (ao ApplicationOption) Apply(o *QueryOptions) {
|
||||
o.Level = LevelApplication
|
||||
o.Namespace = ao.NamespaceName
|
||||
o.ApplicationName = ao.Application
|
||||
o.StorageClassName = ao.StorageClassName
|
||||
|
||||
app_components := strings.Join(ao.ApplicationComponents[:], "|")
|
||||
|
||||
|
@ -303,11 +306,6 @@ func (po PVCOption) Apply(o *QueryOptions) {
|
|||
o.Level = LevelPVC
|
||||
o.ResourceFilter = po.ResourceFilter
|
||||
o.Namespace = po.NamespaceName
|
||||
o.StorageClassName = po.StorageClassName
|
||||
o.PersistentVolumeClaimName = po.PersistentVolumeClaimName
|
||||
|
||||
// for meter
|
||||
o.PVCFilter = po.PersistentVolumeClaimName
|
||||
}
|
||||
|
||||
type IngressOption struct {
|
||||
|
|
|
@ -27,22 +27,53 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
ClusterCpuGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
ClusterCpuUsageGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_cpu_usage",
|
||||
Help: "Cluster CPU Utilization Rate.",
|
||||
}, []string{"cluster_name"})
|
||||
ClusterMemoryGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterCpuAvailGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_cpu_avail",
|
||||
Help: "Cluster CPU Available.",
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterCpuTotalGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_cpu_total",
|
||||
Help: "Cluster CPU Total.",
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterMemoryUsageGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_memory_usage",
|
||||
Help: "Cluster Memory Utilization Rate.",
|
||||
}, []string{"cluster_name"})
|
||||
ClusterDiskGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterMemoryAvailGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_memory_avail",
|
||||
Help: "Cluster Memory Available.",
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterMemoryTotalGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_memory_total",
|
||||
Help: "Cluster Memory Total.",
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterDiskUsageGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_disk_usage",
|
||||
Help: "Cluster Disk Utilization Rate.",
|
||||
}, []string{"cluster_name"})
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterDiskAvailGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_disk_avail",
|
||||
Help: "Cluster Disk Available.",
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
ClusterDiskTotalGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "cluster_disk_total",
|
||||
Help: "Cluster Disk Total.",
|
||||
}, []string{"cluster_name", "adapter_id"})
|
||||
|
||||
metrics = []prometheus.Collector{
|
||||
ClusterCpuGauge,
|
||||
ClusterMemoryGauge,
|
||||
ClusterDiskGauge,
|
||||
ClusterCpuUsageGauge,
|
||||
ClusterCpuAvailGauge,
|
||||
ClusterCpuTotalGauge,
|
||||
ClusterMemoryUsageGauge,
|
||||
ClusterMemoryAvailGauge,
|
||||
ClusterMemoryTotalGauge,
|
||||
ClusterDiskUsageGauge,
|
||||
ClusterDiskAvailGauge,
|
||||
ClusterDiskTotalGauge,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -225,3 +256,13 @@ func genMetricFilter(o QueryOption) func(metric model.Metric) bool {
|
|||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (p Prometheus) GetRawData(expr string, o QueryOption) (model.Value, error) {
|
||||
opts := NewQueryOptions()
|
||||
o.Apply(opts)
|
||||
value, _, err := p.client.Query(context.Background(), makeExpr(expr, *opts), time.Now())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue