amend:multiple clusters

This commit is contained in:
zhouqunjie 2024-04-18 23:11:10 +08:00
parent af4480e322
commit bccb69f4de
4 changed files with 27 additions and 8 deletions

View File

@ -58,6 +58,8 @@ func newClient(options ClientOptions) (Client, error) {
}
c := &client{
adapterId: options.AdapterId,
clusterId: options.ClusterId,
clusterUrl: options.ClusterUrl,
tokenUrl: options.TokenUrl,
stateUrl: options.StateUrl,

29
main.go
View File

@ -2,9 +2,12 @@ package main
import (
"encoding/json"
"flag"
"github.com/go-resty/resty/v2"
"github.com/robfig/cron"
"github.com/zeromicro/go-zero/core/conf"
"gitlink.org.cn/JointCloud/pcm-hpc/ac"
"gitlink.org.cn/JointCloud/pcm-hpc/ac/config"
confHpc "gitlink.org.cn/JointCloud/pcm-hpc/config"
cronPCM "gitlink.org.cn/JointCloud/pcm-hpc/cron"
"gitlink.org.cn/JointCloud/pcm-hpc/paratera"
@ -46,10 +49,16 @@ func init() {
var resp types.ClusterResp
json.Unmarshal(result.Body(), &resp)
cfg := config.Config{}
configFile := flag.String("main", "ac/etc/ac.yaml", "the config file")
conf.MustLoad(*configFile, &cfg)
for _, cluster := range resp.Data.List {
switch cluster.Label {
case "slurm":
slurmClient, _ := slurm.NewClient(slurm.ClientOptions{
AdapterId: cluster.AdapterId,
ClusterId: cluster.Id,
RestUserName: cluster.Username,
CmdUserName: cluster.Username,
Password: cluster.Password,
@ -60,21 +69,25 @@ func init() {
})
cronPCM.SlurmClients = append(cronPCM.SlurmClients, slurmClient)
case "ac":
acClient, _ := ac.NewClient(ac.ClientOptions{
ClusterUrl: "https://wuzh02.hpccube.com:65051/hpc/openapi/v2/cluster",
TokenUrl: "https://ac.sugon.com/ac/openapi/v2/tokens",
StateUrl: "https://ac.sugon.com/ac/openapi/v2/tokens/state",
AdapterId: cluster.AdapterId,
ClusterId: cluster.Id,
ClusterUrl: cfg.ClusterUrl,
TokenUrl: cfg.TokenUrl,
StateUrl: cfg.StateUrl,
User: cluster.Username,
Password: cluster.Password,
OrgId: "c8befbc1301665ba2dc5b2826f8dca1e",
EndPoint: "https://api01.hpccube.com:65106",
Token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6ImFjZ25ubWZid28iLCJhY2NvdW50U3RhdHVzIjoiVHJpYWwiLCJjcmVhdG9yIjoiYWMiLCJyb2xlIjoiMSIsImV4cGlyZVRpbWUiOiIxNzEwOTkwNjUyNzYwIiwiY2x1c3RlcklkIjoiMTEyNzYiLCJpbnZva2VyIjoiYzhiZWZiYzEzMDE2NjViYTJkYzViMjgyNmY4ZGNhMWUiLCJ1c2VyIjoiYWNnbm5tZmJ3byIsInVzZXJJZCI6IjExNzkxMTQ4MjAwIn0.OKASpJvVetAqhEQPhxcpDEeUbir5bJjCYDrPBbPyXbs",
ClusterIdAC: cluster.OwnerId,
BaseEndpoint: "https://wuzh02.hpccube.com:65051"})
OrgId: cluster.OwnerId,
EndPoint: cfg.AcBaseUrl,
ClusterIdAC: cluster.ProjectId,
BaseEndpoint: cfg.AcBaseUrl})
cronPCM.AcClients = append(cronPCM.AcClients, acClient)
case "paratera":
parateraClient, _ := paratera.NewClient(paratera.ClientOptions{
AdapterId: cluster.AdapterId,
ClusterId: cluster.Id,
Url: cluster.Server,
TokenType: "TOKEN",
ThirdParty: cluster.ProjectId,

View File

@ -57,6 +57,8 @@ func newClient(options ClientOptions) (Client, error) {
SetQueryParams(params).Post("https://user.paratera.com/user/api/login")
c := &client{
adapterId: options.AdapterId,
clusterId: options.ClusterId,
url: options.Url,
tokenType: options.TokenType,
thirdParty: options.ThirdParty,

View File

@ -39,6 +39,8 @@ func (c *client) GetClientInfo() (ClientOptions, error) {
func newClient(options ClientOptions) (Client, error) {
c := &client{
adapterId: options.AdapterId,
clusterId: options.ClusterId,
restUsername: options.RestUserName,
cmdUsername: options.CmdUserName,
password: options.Password,