Merge pull request 'fix updateClusterInfo' (#26) from feature_zqj into master

This commit is contained in:
zhouqunjie 2025-07-14 16:55:07 +08:00
commit 19d2dcddf7
5 changed files with 100 additions and 5 deletions

View File

@ -30,6 +30,7 @@ func NewService(platforms ...platform.IPlatform) (*Service, error) {
rmap := make(map[platform.Id]*Resource)
amap := make(map[platform.Id]*Algorithm)
imap := make(map[platform.Id]*Image)
mmap := make(map[platform.Id]*Model)
for _, pf := range platforms {
switch pf.Type() {
case platform.OpenI:
@ -52,6 +53,10 @@ func NewService(platforms ...platform.IPlatform) (*Service, error) {
img := NewImage(openI.Img)
imap[pf.Id()] = img
mdl := NewModel(openI.Mdl)
mmap[pf.Id()] = mdl
case platform.Octopus:
oct, ok := pf.(*octopus.Octopus)
if !ok {
@ -61,7 +66,7 @@ func NewService(platforms ...platform.IPlatform) (*Service, error) {
amap[pf.Id()] = alg
}
}
return &Service{rmap: rmap, amap: amap, imap: imap}, nil
return &Service{rmap: rmap, amap: amap, imap: imap, mmap: mmap}, nil
}
// resource

38
client/Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM --platform=$BUILDPLATFORM docker-0.unsee.tech/golang:alpine AS builder
WORKDIR /app
ENV GOPROXY=https://goproxy.cn \
GO111MODULE=on \
CGO_ENABLED=0 \
GOCACHE=/root/.cache/go-build \
GOMODCACHE=/go/pkg/mod
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG TARGETOS
ARG TARGETARCH
# 使用 GOOS 和 GOARCH 环境变量来构建不同架构的二进制文件
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-w -s" -o pcm-participant-client
FROM --platform=$TARGETPLATFORM docker-0.unsee.tech/alpine:latest
WORKDIR /app
RUN apk add --no-cache ca-certificates && update-ca-certificates && \
apk add --update tzdata && \
rm -rf /var/cache/apk/*
COPY --from=builder /app/pcm-participant-client .
COPY --from=builder /app/config/config.yaml ./config/config.yaml
ENV TZ=Asia/Shanghai
EXPOSE 8080
ENTRYPOINT exec ./pcm-participant-client

View File

@ -5,6 +5,34 @@ import (
"time"
)
type ClusterCreateReq struct {
Id string `json:"id,optional"`
AdapterId string `json:"adapterId,optional"`
Name string `json:"name,optional"`
Nickname string `json:"nickname,optional"`
Description string `json:"description,optional"`
Server string `json:"server,optional"`
MonitorServer string `json:"monitorServer,optional"`
Username string `json:"username,optional"`
Password string `json:"password,optional"`
Token string `json:"token,optional"`
Ak string `json:"ak,optional"`
Sk string `json:"sk,optional"`
Region []string `json:"region,optional"`
ProjectId string `json:"projectId,optional"`
Version string `json:"version,optional"`
Label string `json:"label,optional"`
OwnerId string `json:"ownerId,omitempty,optional"`
AuthType int32 `json:"authType,optional"`
ProducerDict string `json:"producerDict,optional"`
RegionDict string `json:"regionDict,optional"`
RegionName string `json:"regionName,optional"`
Environment map[string]string `json:"environment,optional"`
CostType string `json:"costType,optional"`
Price int `json:"price,optional"`
Status string `json:"status,optional"`
}
type ClusterInfo struct {
Id string `json:"id,omitempty" db:"id"`
AdapterId int64 `json:"adapterId,omitempty,string" db:"adapter_id"`
@ -25,7 +53,7 @@ type ClusterInfo struct {
Version string `json:"version,omitempty" db:"version"`
Label string `json:"label,omitempty" db:"label"`
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
AuthType string `json:"authType,omitempty" db:"auth_type"`
AuthType int32 `json:"authType,omitempty" db:"auth_type"`
ProducerDict string `json:"producerDict,omitempty" db:"producer_dict"`
RegionDict string `json:"regionDict,omitempty" db:"region_dict"`
Location string `json:"location,omitempty" db:"location"`
@ -51,7 +79,7 @@ type ServerConfig struct {
ProxyEnabled string
PrivateKey []byte
Passphrase string
AuthType string
AuthType int32
}
type SSHClient struct {

View File

@ -6,6 +6,6 @@ system:
pcm-core:
coordinator-host: http://127.0.0.1:8999
participant-host: http://localhost:9090
participant-host: http://localhost:8080
hpc-cluster-list: /pcm/v1/adapter/cluster/list?type=2&pageNum=1&pageSize=10&storageSchedule=1
ai-cluster-list: /pcm/v1/adapter/cluster/list?name=openI-new-p&type=1&pageNum=1&pageSize=10&storageSchedule=1

View File

@ -66,9 +66,33 @@ func initAISvcs(client *utils.RestyClient, core config.PcmCore) (*service.Servic
cluster.Server = core.ParticipantHost
cluster.Status = "online"
updateClusterReq := types.ClusterCreateReq{
Id: cluster.Id,
AdapterId: strconv.FormatInt(cluster.AdapterId, 10),
Name: cluster.Name,
Nickname: cluster.Nickname,
Description: cluster.Description,
Server: cluster.Server,
MonitorServer: cluster.MonitorServer,
Username: cluster.Username,
Password: cluster.Password,
Token: cluster.Token,
Ak: cluster.Ak,
Sk: cluster.Sk,
RegionName: cluster.Region,
ProjectId: cluster.ProjectId,
Version: cluster.Version,
Label: cluster.Label,
OwnerId: cluster.OwnerId,
AuthType: cluster.AuthType,
ProducerDict: cluster.ProducerDict,
RegionDict: cluster.RegionDict,
Status: cluster.Status,
}
updateResp := types.ResultResp{}
_, err := client.Request(core.CoordinatorHost+"/pcm/v1/adapter/cluster/update", "PUT", func(req *resty.Request) {
req.SetBody(cluster).SetResult(&updateResp) // 添加请求体
req.SetBody(updateClusterReq).SetResult(&updateResp) // 添加请求体
})
if err != nil {