JCC-CSScheduler/common/models/models.go

170 lines
5.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package schmod
import (
"fmt"
sch "gitlink.org.cn/cloudream/common/sdks/pcmscheduler"
"time"
pcmsdk "gitlink.org.cn/cloudream/common/sdks/pcm"
schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler"
cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
uopsdk "gitlink.org.cn/cloudream/common/sdks/unifyops"
"gitlink.org.cn/cloudream/common/utils/reflect2"
"gitlink.org.cn/cloudream/common/utils/serder"
)
type ExecutorID string
type AdvisorID string
type ComputingCenter struct {
// 计算中心名称
CCID schsdk.CCID `json:"CCID" gorm:"column:CCID"`
// 计算中心在运控系统的ID
UOPSlwNodeID uopsdk.SlwNodeID `json:"uopSlwNodeID" gorm:"column:UOPSlwNodeID"`
// 计算中心在PCM系统的ID
PCMParticipantID pcmsdk.ParticipantID `json:"pcmParticipantID" gorm:"column:PCMParticipantID"`
// 此算力中心的存储服务对应在存储系统中的ID
CDSStorageID cdssdk.StorageID `json:"cdsStorageID" gorm:"column:CDSStorageID"`
// 计算中心名称
Name string `json:"name" gorm:"column:Name"`
// 任务启动方式
//Bootstrap schsdk.Bootstrap `json:"bootstrap" gorm:"column:Bootstrap"`
Bootstrap schsdk.Bootstrap `json:"bootstrap" gorm:"-"`
// 执行器ID
ExecutorID string `json:"executorID" gorm:"column:executorID"`
// 执行器URL
ExecutorURL string `json:"executorURL" gorm:"column:executorURL"`
//ClusterID schsdk.ClusterID `json:"clusterID" gorm:"column:ClusterID"`
}
type Image struct {
// 调度系统内的镜像ID
ImageID schsdk.ImageID `json:"imageID" gorm:"column:ImageID"`
// 镜像文件对应的存储系统PackageID可以为空为空则代表此镜像不可被自动导入到算力中心比如是预制镜像
CDSPackageID *cdssdk.PackageID `json:"cdsPackageID" gorm:"column:CDSPackageID"`
// 镜像名称,在调度系统上设置的
Name string `json:"name" gorm:"column:Name"`
// 镜像创建时间
CreateTime time.Time `json:"createTime" gorm:"column:CreateTime"`
}
type PCMImage struct {
// 调度系统内的镜像ID
ImageID schsdk.ImageID `json:"imageID" gorm:"column:ImageID"`
// 导入到的计算中心的ID
CCID schsdk.CCID `json:"ccID" gorm:"column:CCID"`
// 通过PCM系统导入到各计算中心后得到的ID
PCMImageID pcmsdk.ImageID `json:"pcmImageID" gorm:"column:PCMImageID"`
// 镜像名称通过PCM导入后获得
Name string `json:"name" gorm:"column:Name"`
// 镜像导入时间
UploadTime time.Time `json:"uploadTime" gorm:"column:UploadTime"`
}
type CCResource struct {
// 计算中心ID
CCID schsdk.CCID `json:"ccID" gorm:"column:CCID"`
// PCM系统返回的资源规格ID
PCMResourceID pcmsdk.ResourceID `json:"pcmResourceID" gorm:"column:PCMResourceID"`
// PCM系统返回的资源规格名称
PCMResourceName string `json:"pcmResourceName" gorm:"column:PCMResourceName"`
// 此种规格具体包含的资源信息
Resource CCResourceInfo `json:"resource" gorm:"column:Resource"`
}
type CCResourceInfo struct {
CPU float64 `json:"cpu"`
GPU float64 `json:"gpu"`
NPU float64 `json:"npu"`
MLU float64 `json:"mlu"`
Storage int64 `json:"storage"`
Memory int64 `json:"memory"`
}
type Models struct {
// 模型ID
ModelID schsdk.ModelID `json:"modelID" gorm:"column:modelID"`
// 模型名称
ModelName schsdk.ModelName `json:"modelName" gorm:"column:modelName"`
}
type ModelResource struct {
// 模型ID
ModelID int64 `json:"modelID" gorm:"column:modelID"`
// 存储ID
OjbStgID int64 `json:"OjbStgID" gorm:"column:OjbStgID"`
// 模型路径
ModelPath string `json:"modelPath" gorm:"column:modelPath"`
// 启动脚本路径
StartShellPath string `json:"startShellPath" gorm:"column:startShellPath"`
// 服务器端口
ServerPort int64 `json:"serverPort" gorm:"column:serverPort"`
// 服务器URL路径
ServerUrlPath string `json:"serverUrlPath" gorm:"column:serverUrlPath"`
// 停止脚本路径
StopShellPath string `json:"stopShellPath" gorm:"column:stopShellPath"`
// 微调脚本路径
FinetuningShellPath string `json:"finetuningShellPath" gorm:"column:finetuningShellPath"`
}
type ObjectStorage struct {
// 存储ID
ID int64 `json:"ID" gorm:"column:ID"`
// 存储名称
Name string `json:"name" gorm:"column:name"`
// 厂商
Manufacturer string `json:"manufacturer" gorm:"column:manufacturer"`
// 区域
Region string `json:"region" gorm:"column:region"`
// 访问密钥ID
AK string `json:"access_key_id" gorm:"column:access_key_id"`
// 秘密访问密钥
SK string `json:"secret_access_key" gorm:"column:secret_access_key"`
// 存储端点
Endpoint string `json:"endpoint" gorm:"column:endpoint"`
// 存储桶
Bucket string `json:"bucket" gorm:"column:bucket"`
// CDS存储ID
CDSStorageID cdssdk.StorageID `json:"CDSStorageID" gorm:"column:CDSStorageID"`
// 挂载类型
MountType string `json:"mountType" gorm:"column:mountType"`
}
func (i *CCResourceInfo) Scan(src interface{}) error {
data, ok := src.([]uint8)
if !ok {
return fmt.Errorf("unknow src type: %v", reflect2.TypeOfValue(data).String())
}
return serder.JSONToObject(data, i)
}
const (
HuaweiCloud = "HuaweiCloud"
AliCloud = "AliCloud"
SugonCloud = "SugonCloud"
Write = "write"
Schedule = "schedule"
Update = "update"
BlockChain_Upload = "5"
BlockChain_Schedule = "6"
BlockChain_Access = "7"
)
//type FileUploadedInfo struct {
// FileName string `json:"fileName"`
// FileHash string `json:"fileHash"`
// FileSize int64 `json:"fileSize"`
//}
type UploadStatus struct {
ID int64 `json:"id"`
Status string `json:"status"`
Message string `json:"message"`
UploadInfo sch.UploadInfo `json:"uploadInfo"`
}