| @@ -24,7 +24,7 @@ require ( | |||||
| gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20250107025835-8fc888b1d170 | gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20250107025835-8fc888b1d170 | ||||
| gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4 | gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4 | ||||
| gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 | gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 | ||||
| gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 | |||||
| gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250617093406-3b91e2734fe4 | |||||
| gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee | gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee | ||||
| gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 | gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 | ||||
| gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 | gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 | ||||
| @@ -539,8 +539,8 @@ gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4 h1:WIs/189l | |||||
| gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4/go.mod h1:YbuoRgF9sEVvNJPQtGRjdocX7Du6NBOTLn+GVwqRVjo= | gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4/go.mod h1:YbuoRgF9sEVvNJPQtGRjdocX7Du6NBOTLn+GVwqRVjo= | ||||
| gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 h1:9o0ONbSiQHTzODptzgtVZjRYFBLncZ6dpHp9YF+v73I= | gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 h1:9o0ONbSiQHTzODptzgtVZjRYFBLncZ6dpHp9YF+v73I= | ||||
| gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0= | gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0= | ||||
| gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 h1:GaXwr5sgDh0raHjUf9IewTvnRvajYea7zbLsaerYyXo= | |||||
| gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ= | |||||
| gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250617093406-3b91e2734fe4 h1:KQamNpMUFxOhJovS4oXys7CJK4TLHVdWNLxUvlPKVRI= | |||||
| gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250617093406-3b91e2734fe4/go.mod h1:iQtyaoeMP4mNY0xutDBDD/305QwnPjj0zNtiQjXix50= | |||||
| gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee h1:+YYzcWPX0Up98nOb5ngkCaqiWHpSH7XJQRTUSvYclWU= | gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee h1:+YYzcWPX0Up98nOb5ngkCaqiWHpSH7XJQRTUSvYclWU= | ||||
| gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee/go.mod h1:0VMTWXsRx7Z5z+kxBid2zf7kq5YtFlxubXEwPHiicyM= | gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee/go.mod h1:0VMTWXsRx7Z5z+kxBid2zf7kq5YtFlxubXEwPHiicyM= | ||||
| gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI= | gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI= | ||||
| @@ -1,17 +1,25 @@ | |||||
| package octopusHttp | package octopusHttp | ||||
| import ( | import ( | ||||
| "bytes" | |||||
| "context" | "context" | ||||
| "encoding/json" | |||||
| "errors" | "errors" | ||||
| "fmt" | |||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" | "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" | ||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" | "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" | ||||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference" | "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference" | ||||
| omodel "gitlink.org.cn/JointCloud/pcm-octopus/http/model" | |||||
| "gitlink.org.cn/JointCloud/pcm-openi/common" | |||||
| "mime/multipart" | "mime/multipart" | ||||
| "net/http" | |||||
| ) | ) | ||||
| const ( | const ( | ||||
| RESOURCE_POOL = "common-pool" | RESOURCE_POOL = "common-pool" | ||||
| Param_Token = "token" | |||||
| Param_Addr = "addr" | |||||
| Octopus = "octopus" | |||||
| Forward_Slash = "/" | |||||
| ) | ) | ||||
| const ( | const ( | ||||
| @@ -24,18 +32,16 @@ const ( | |||||
| ) | ) | ||||
| type OctopusHttp struct { | type OctopusHttp struct { | ||||
| server string | |||||
| host string | host string | ||||
| platform string | platform string | ||||
| participantId int64 | participantId int64 | ||||
| token *Token | token *Token | ||||
| } | } | ||||
| func NewOctopusHttp(name string, id int64, host string, user string, pwd string) *OctopusHttp { | |||||
| token, err := NewToken(host, user, pwd) | |||||
| if err != nil { | |||||
| fmt.Println(err.Error()) | |||||
| } | |||||
| return &OctopusHttp{platform: name, participantId: id, host: host, token: token} | |||||
| func NewOctopusHttp(id int64, name, server, host string, user string, pwd string) *OctopusHttp { | |||||
| token, _ := NewToken(host, user, pwd) | |||||
| return &OctopusHttp{platform: name, participantId: id, server: server, host: host, token: token} | |||||
| } | } | ||||
| // executor | // executor | ||||
| @@ -51,6 +57,71 @@ func (o *OctopusHttp) Stop(ctx context.Context, id string) error { | |||||
| // collector | // collector | ||||
| func (o *OctopusHttp) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { | func (o *OctopusHttp) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { | ||||
| resourcespecsUrl := o.server + Forward_Slash + ResourcespecsUrl | |||||
| token, err := o.token.Get() | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| param := omodel.ResourceSpecParam{ | |||||
| ResourcePool: RESOURCE_POOL, | |||||
| } | |||||
| b, _ := json.Marshal(param) | |||||
| byt := bytes.NewBuffer(b) | |||||
| resp := struct { | |||||
| Code int `json:"code"` | |||||
| Msg string `json:"msg"` | |||||
| Data interface{} `json:"data"` | |||||
| }{} | |||||
| req := common.GetRestyRequest(common.TIMEOUT) | |||||
| r, _ := http.NewRequest("GET", resourcespecsUrl, byt) | |||||
| req.RawRequest = r | |||||
| req.URL = resourcespecsUrl | |||||
| _, err = req. | |||||
| SetHeader("Content-Type", "application/json"). | |||||
| SetQueryParam(Param_Token, token). | |||||
| SetQueryParam(Param_Addr, o.host). | |||||
| SetBody(byt). | |||||
| SetResult(&resp). | |||||
| Send() | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if resp.Code != http.StatusOK { | |||||
| if resp.Data != nil { | |||||
| marshal, err := json.Marshal(resp.Data) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| errormdl := &omodel.Error{} | |||||
| err = json.Unmarshal(marshal, errormdl) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| return nil, errors.New(errormdl.Message) | |||||
| } | |||||
| } else { | |||||
| if resp.Data != nil { | |||||
| spec := omodel.ResourceSpec{} | |||||
| marshal, err := json.Marshal(resp.Data) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| err = json.Unmarshal(marshal, &spec.Payload) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| } | |||||
| } | |||||
| return nil, nil | return nil, nil | ||||
| } | } | ||||
| @@ -8,8 +8,7 @@ import ( | |||||
| ) | ) | ||||
| const ( | const ( | ||||
| GetToken = "openaiserver/v1/authmanage/token" | |||||
| Forward_Slash = "/" | |||||
| GetToken = "openaiserver/v1/authmanage/token" | |||||
| ) | ) | ||||
| type TokenModel struct { | type TokenModel struct { | ||||