| @@ -902,6 +902,8 @@ type ( | |||
| 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"` | |||
| } | |||
| ClusterInfo { | |||
| Id string `json:"id,omitempty" db:"id"` | |||
| @@ -1366,7 +1368,7 @@ type ( | |||
| } | |||
| ) | |||
| type ResourcePrice struct { | |||
| type ResourcePrice { | |||
| ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` | |||
| ResourceID int64 `json:"resourceId" gorm:"column:resource_id"` | |||
| Price int `json:"price" gorm:"column:price"` | |||
| @@ -1374,7 +1376,7 @@ type ResourcePrice struct { | |||
| ResourceType string `json:"resourceType" gorm:"column:resource_type"` | |||
| } | |||
| type ResourceCostRecord struct { | |||
| type ResourceCostRecord { | |||
| ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` | |||
| ResourcePriceID int64 `json:"resourcePriceId" gorm:"column:resource_price_id"` | |||
| UserId int64 `json:"userId" gorm:"column:user_id"` | |||
| @@ -30,8 +30,9 @@ type ( | |||
| StdInput string `json:"stdInput,optional"` | |||
| ClusterType string `json:"clusterType,optional"` | |||
| Partition string `json:"partition"` | |||
| UserId int64 `json:"userId,optional"` | |||
| Token string `json:"token,optional"` | |||
| UserId int64 `json:"userId,optional"` | |||
| Token string `json:"token,optional"` | |||
| UserIp string `json:"userIp,optional"` | |||
| } | |||
| commitHpcTaskResp { | |||
| @@ -155,24 +156,24 @@ type QueueAsset { | |||
| type ( | |||
| /******************instance center*************************/ | |||
| HpcInstanceCenterReq{ | |||
| InstanceType int32 `form:"instanceType,optional"` | |||
| InstanceClass string `form:"instanceClass,optional"` | |||
| InstanceName string `form:"instanceName,optional"` | |||
| HpcInstanceCenterReq { | |||
| InstanceType int32 `form:"instanceType,optional"` | |||
| InstanceClass string `form:"instanceClass,optional"` | |||
| InstanceName string `form:"instanceName,optional"` | |||
| PageInfo | |||
| } | |||
| HpcInstanceCenterResp { | |||
| InstanceCenterList []HpcInstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"` | |||
| TotalCount int `json:"totalCount"` | |||
| TotalCount int `json:"totalCount"` | |||
| } | |||
| HpcInstanceCenterList { | |||
| LogoPath string `json:"logo_path"` | |||
| InstanceName string `json:"instance_name"` | |||
| InstanceType int32 `json:"instance_type"` | |||
| InstanceClass string `json:"instance_class"` | |||
| InstanceClassChinese string `json:"instance_class_chinese"` | |||
| Description string `json:"description"` | |||
| Version string `json:"version"` | |||
| LogoPath string `json:"logo_path"` | |||
| InstanceName string `json:"instance_name"` | |||
| InstanceType int32 `json:"instance_type"` | |||
| InstanceClass string `json:"instance_class"` | |||
| InstanceClassChinese string `json:"instance_class_chinese"` | |||
| Description string `json:"description"` | |||
| Version string `json:"version"` | |||
| } | |||
| /******************instance center*************************/ | |||
| @@ -7,6 +7,7 @@ import ( | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" | |||
| "k8s.io/apimachinery/pkg/util/json" | |||
| "net/http" | |||
| ) | |||
| @@ -18,6 +19,9 @@ func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | |||
| result.ParamErrorResult(r, w, err) | |||
| return | |||
| } | |||
| // 获取ip信息 | |||
| ip := utils.GetClientIP(r) | |||
| req.UserIp = ip | |||
| // 获取token信息 | |||
| token := r.Header.Get("Authorization") | |||
| req.Token = token | |||
| @@ -6,6 +6,7 @@ import ( | |||
| "fmt" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" | |||
| "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" | |||
| tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" | |||
| "gorm.io/gorm" | |||
| "io/ioutil" | |||
| @@ -63,7 +64,13 @@ func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *t | |||
| logx.Errorf(tx.Error.Error()) | |||
| return nil, errors.New("cluster create failed") | |||
| } | |||
| // 创建资源价格信息 | |||
| resourcePrice := &types.ResourcePrice{ | |||
| Price: req.Price, | |||
| ResourceType: constants.CLUSTER, | |||
| CostType: req.CostType, | |||
| } | |||
| tx = l.svcCtx.DbEngin.Table("resource_cost").Create(resourcePrice) | |||
| // push cluster info to adapter | |||
| go func() { | |||
| var adapterServer string | |||
| @@ -134,8 +134,13 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er | |||
| db := tx.Table("task").Create(&taskModel) | |||
| db = tx.Table("task_cloud").Create(&taskClouds) | |||
| db = tx.Table("t_notice").Create(¬iceInfo) | |||
| if db.Error != nil { | |||
| logx.Errorf("Task creation failure, err: %v", db.Error) | |||
| return errors.New("task creation failure") | |||
| } | |||
| // 数据上链 | |||
| bytes, err := json.Marshal(taskModel) | |||
| bytes, _ := json.Marshal(taskModel) | |||
| if err != nil { | |||
| return err | |||
| } | |||
| @@ -148,10 +153,6 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er | |||
| Token: req.Token, | |||
| Args: []string{strconv.FormatInt(taskModel.Id, 10), string(bytes)}, | |||
| }) | |||
| if db.Error != nil { | |||
| logx.Errorf("Task creation failure, err: %v", db.Error) | |||
| return errors.New("task creation failure") | |||
| } | |||
| return nil | |||
| } | |||
| @@ -97,10 +97,6 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t | |||
| logx.Info("提交job到指定集群") | |||
| jobId, err := submitJob(&hpcInfo, &clusterInfo, server) | |||
| //if err != nil { | |||
| // return nil, err | |||
| //} | |||
| //logx.Info("提交job到指定集群完成") | |||
| // 保存操作记录 | |||
| noticeInfo := clientCore.NoticeInfo{ | |||
| AdapterId: clusterInfo.AdapterId, | |||
| @@ -122,6 +118,7 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t | |||
| // 数据上链 | |||
| bytes, _ := json.Marshal(taskModel) | |||
| remoteUtil.Evidence(remoteUtil.EvidenceParam{ | |||
| UserIp: req.UserIp, | |||
| Url: l.svcCtx.Config.BlockChain.Url, | |||
| ContractAddress: l.svcCtx.Config.BlockChain.ContractAddress, | |||
| FunctionName: l.svcCtx.Config.BlockChain.FunctionName, | |||
| @@ -835,6 +835,8 @@ type ClusterCreateReq struct { | |||
| 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"` | |||
| } | |||
| type ClusterInfo struct { | |||
| @@ -1323,6 +1325,7 @@ type CommitHpcTaskReq struct { | |||
| Partition string `json:"partition"` | |||
| UserId int64 `json:"userId,optional"` | |||
| Token string `json:"token,optional"` | |||
| UserIp string `json:"userIp,optional"` | |||
| } | |||
| type CommitHpcTaskResp struct { | |||
| @@ -0,0 +1,5 @@ | |||
| package constants | |||
| const ( | |||
| CLUSTER = "0" | |||
| ) | |||