From d794903f392b800bfb73eac094aa03e9d1324677 Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Mon, 4 Sep 2023 16:03:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0openstack=E5=88=B0C?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: f0224fba84f8dc92d70155423f902a67afa80f0c --- api/desc/core/pcm-core.api | 14 ++ api/desc/pcm.api | 109 ++++----- api/desc/vm/pcm-vm.api | 227 ++++++++---------- .../core/getcomputilitystatisticshandler.go | 21 ++ api/internal/handler/routes.go | 61 ++--- api/internal/handler/vm/createimagehandler.go | 28 +++ .../handler/vm/listvolumetypeshandler.go | 28 +++ api/internal/handler/vm/uploadimagehandler.go | 28 +++ .../core/getcomputilitystatisticslogic.go | 103 ++++++++ api/internal/logic/vm/createimagelogic.go | 48 ++++ api/internal/logic/vm/listvolumetypeslogic.go | 48 ++++ api/internal/logic/vm/uploadimagelogic.go | 48 ++++ api/internal/types/types.go | 212 ++++++---------- go.mod | 2 +- go.sum | 8 +- 15 files changed, 612 insertions(+), 373 deletions(-) create mode 100644 api/internal/handler/core/getcomputilitystatisticshandler.go create mode 100644 api/internal/handler/vm/createimagehandler.go create mode 100644 api/internal/handler/vm/listvolumetypeshandler.go create mode 100644 api/internal/handler/vm/uploadimagehandler.go create mode 100644 api/internal/logic/core/getcomputilitystatisticslogic.go create mode 100644 api/internal/logic/vm/createimagelogic.go create mode 100644 api/internal/logic/vm/listvolumetypeslogic.go create mode 100644 api/internal/logic/vm/uploadimagelogic.go diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index 58c06512..1c54fba0 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -402,6 +402,20 @@ type ( } ) +type( + ComputilityStatisticsResp{ + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"ErrorMsg,omitempty"` + ComputilityStatistics ComputilityStatistics `json:"data"` //容器节点已使用 + } + ComputilityStatistics { + DomainSum int64 `json:"domainSum"` //域总数 + TotalComputility float64 `json:"totalComputility"` //算力总和 + ClusterNum int64 `json:"clusterNum"` //集群总数 + } +) + //jccSchedule容器集群资源监控 > start type ClusterMetrics struct { diff --git a/api/desc/pcm.api b/api/desc/pcm.api index a7d9586a..c6404fc8 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -6,7 +6,6 @@ import ( "ai/pcm-ai.api" "storage/pcm-storage.api" "vm/pcm-vm.api" - "cloud/pcm-cloud.api" ) info( @@ -25,54 +24,48 @@ info( service pcm { @handler scheduleTaskByYamlHandler post /core/scheduleTaskByYaml (scheduleTaskByYamlReq) returns () - + @handler scheduleTaskHandler post /core/scheduleTask (scheduleTaskReq) returns () - + @handler TaskListHandler get /core/taskList () returns (taskListResp) - + @handler JobTotalHandler get /core/jobTotal () returns (jobTotalResp) - + @handler listCenterHandler get /core/listCenter () returns (listCenterResp) - + @handler listClusterHandler get /core/listCluster/:centerId (listClusterReq) returns (listClusterResp) - + @handler submitJobHandler post /core/submitJob (submitJobReq) returns (submitJobResp) - + @handler getRegionHandler get /core/getRegion () returns (getRegionResp) - + @handler listRegionHandler get /core/listRegion () returns (listRegionResp) - + @handler getComputingPowerHandler get /core/getComputingPower returns (cpResp) - + @handler getGeneralInfoHandler get /core/getGeneralInfo () returns (GiResp) - + @handler listDomainResourceHandler get /core/listDomainResource returns (DomainResourceResp) - + @handler getResourcePanelConfigHandler get /core/getResourcePanelConfigHandler () returns (ResourcePanelConfigResp) - + @handler putResourcePanelConfigHandler put /core/resourcePanelConfigHandler (ResourcePanelConfigReq) returns () - - @handler nodeAssetsHandler - get /core/assets () returns (NodeAssetsResp) - - @handler saveHashcatHandler - post /core/saveHashcat (SaveHashcatReq) returns () - - @handler getHashcatHandler - get /core/getHashcat/:crackTaskId (getHashcatHandlerReq) returns (getHashcatHandlerResp) + + @handler getComputilityStatisticsHandler + get /core/getComputilityStatistics () returns (ComputilityStatisticsResp) } //hpc二级接口 @@ -83,25 +76,9 @@ service pcm { service pcm { @handler listJobHandler get /hpc/listJob (listJobReq) returns (listJobResp) - + @handler listHistoryJobHandler get /hpc/listHistoryJob (listHistoryJobReq) returns (listHistoryJobResp) - - @handler queueAssetsHandler - get /queue/assets () returns (QueueAssetsResp) -} - -//cloud二级接口 -@server( - prefix: pcm/v1 - group : cloud -) -service pcm { - @handler cloudListHandler - get /task/list () returns (cloudListResp) - - @handler deleteYamlHandler - get /cloud/DeleteYaml (ApplyReq) returns (DeleteResp) } //智算二级接口 @@ -112,10 +89,10 @@ service pcm { service pcm { @handler listDataSetHandler get /ai/listDataSet/:projectId (DataSetReq) returns (DataSetResp) - + @handler CreateDataSetHandler post /ai/createDataSet/:projectId (CreateDataSetReq) returns (CreateDataSetResp) - + @handler DeleteDataSetHandler delete /ai/deleteDataSet/:projectId/:datasetId (DeleteDataSetReq) returns (DeleteDataSetResp) // creat task 创建导入任务 @@ -136,17 +113,17 @@ service pcm { // ListAlgorithms 查询创建算法列表 @handler ListAlgorithms //get /ai/ListAlgorithms (ListAlgorithmsReq) returns (ListAlgorithmsResp) - get /ai/ListAlgorithms/:projectId (ListAlgorithmsReq) returns (ListAlgorithmsResp) + get /ai/ListAlgorithms/:projectId (ListAlgorithmsReq) returns (ListAlgorithmsResp) // DeleteAlgorithm 删除算法 @handler DeleteAlgorithm - delete /ai/DeleteAlgorithm/:projectId/:algorithmId (DeleteAlgorithmReq) returns (DeleteAlgorithmResp) + delete /ai/DeleteAlgorithm/:projectId/:algorithmId (DeleteAlgorithmReq) returns (DeleteAlgorithmResp) // CreateTrainingJob 创建训练作业 @handler CreateTrainingJobHandler post /ai/CreateTrainingJob/:projectId (CreateTrainingJobReq) returns (CreateTrainingJobResp) // ShowAlgorithmByUuid 展示算法详情 @handler ShowAlgorithmByUuid - get /ai/ShowAlgorithmByUuid/:projectId/:algorithmId (ShowAlgorithmByUuidReq) returns (ShowAlgorithmByUuidResp) - + get /ai/ShowAlgorithmByUuid/:projectId/:algorithmId (ShowAlgorithmByUuidReq) returns (ShowAlgorithmByUuidResp) + // creat export task 创建导出任务 @handler CreateExportTaskHandler post /ai/CreateExportTask/:projectId/:datasetId (CreateExportTaskReq) returns (ExportTaskDataResp) @@ -154,11 +131,11 @@ service pcm { get /ai/GetExportTasksOfDataset/:projectId/:datasetId (GetExportTasksOfDatasetReq) returns (GetExportTasksOfDatasetResp) @handler GetExportTaskStatusOfDatasetHandler get /ai/GetExportTaskStatusOfDataset/:projectId/:resourceId/:taskId (GetExportTaskStatusOfDatasetReq) returns (GetExportTaskStatusOfDatasetResp) - + // create processor task 创建处理任务 @handler CreateProcessorTaskHandler post /ai/CreateProcessorTask (CreateProcessorTaskReq) returns (CreateProcessorTaskResp) - + // create service 创建服务 @handler CreateServiceHandler post /ai/CreateService/:projectId (CreateServiceReq) returns (CreateServiceResp) @@ -170,11 +147,11 @@ service pcm { get /ai/ShowService/:projectId/:serviceId (ShowServiceReq) returns (ShowServiceResp) // Delete service 删除服务 @handler DeleteServiceHandler - delete /ai/DeleteService/:projectId/:serviceId (DeleteServiceReq) returns (DeleteServiceResp) + delete /ai/DeleteService/:projectId/:serviceId (DeleteServiceReq) returns (DeleteServiceResp) // ListClusters查询专属资源池列表 @handler ListClustersHandler get /ai/ListClusters (ListClustersReq) returns (ListClustersResp) - + /******************Notebook Method start*************************/ @handler listNotebookHandler get /ai/listNotebook (ListNotebookReq) returns (ListNotebookResp) @@ -189,7 +166,7 @@ service pcm { @handler mountNotebookStorageHandler post /ai/mountNotebookStorage (MountNotebookStorageReq) returns (MountNotebookStorageResp) /******************Notebook Method end*************************/ - + /******************Visualization Job Method start*************************/ @handler getVisualizationJobHandler get /ai/getVisualizationJob (GetVisualizationJobReq) returns (GetVisualizationJobResp) @@ -220,16 +197,16 @@ service pcm { service pcm { @handler uploadHandler post /upload () returns () - + @handler chunkHandler post /chunk () returns () - + @handler imageListHandler get /image/list () returns (imageListResp) - + @handler dataSetCheckHandler get /dataSet/check/:fileMd5 (checkReq) returns (checkResp) - + @handler uploadDataSetHandler post /dataSet/upload () returns () } @@ -240,10 +217,6 @@ service pcm { group : vm ) service pcm { - @handler GetComputeLimitsHandler - get /vm/getComputeLimits (GetComputeLimitsReq) returns (GetComputeLimitsResp) - @handler GetVolumeLimitsHandler - get /vm/getVolumeLimits (GetVolumeLimitsReq) returns (GetVolumeLimitsResp) @handler ListServerHandler get /vm/listServer (ListServersReq) returns (ListServersResp) @handler ListServersDetailedHandler @@ -259,17 +232,23 @@ service pcm { @handler DeleteNetworkHandler delete /vm/deleteNetwork (DeleteNetworkReq) returns (DeleteNetworkResp) @handler CreateNetworkHandler - post /vm/createNetwork (CreateNetworkReq) returns (CreateNetworkResp) + post /vm/createNetwork (CreateNetworkReq) returns (CreateNetworkResp) @handler CreateSubnetHandler - post /vm/createSubnet (CreateSubnetReq) returns (CreateSubnetResp) + post /vm/createSubnet (CreateSubnetReq) returns (CreateSubnetResp) @handler ListVolumesDetailHandler - get /vm/listVolumesDetail (ListVolumesDetailReq) returns (ListVolumesDetailResp) + get /vm/listVolumesDetail (ListVolumesDetailReq) returns (ListVolumesDetailResp) @handler DeleteVolumeHandler delete /vm/deleteVolume (DeleteVolumeReq) returns (DeleteVolumeResp) @handler CreateVolumeHandler - post /vm/createVolume (CreateVolumeReq) returns (CreateVolumeResp) + post /vm/createVolume (CreateVolumeReq) returns (CreateVolumeResp) @handler ListFlavorsDetailHandler - get /vm/listFlavorsDetail (ListFlavorsDetailReq) returns (ListFlavorsDetailResp) + get /vm/listFlavorsDetail (ListFlavorsDetailReq) returns (ListFlavorsDetailResp) @handler CreateServerHandler - post /vm/createServer (CreateServerReq) returns (CreateServerResp) + post /vm/createServer (CreateServerReq) returns (CreateServerResp) + @handler ListVolumeTypesHandler + get /vm/listVolumeTypes (ListVolumeTypesReq) returns (ListVolumeTypesResp) + @handler CreateImageHandler + post /vm/createImage (CreateImageReq) returns (CreateImageResp) + @handler UploadImageHandler + put /vm/uploadImage (UploadOsImageReq) returns (UploadOsImageResp) } \ No newline at end of file diff --git a/api/desc/vm/pcm-vm.api b/api/desc/vm/pcm-vm.api index 7a71b3aa..fe308a20 100644 --- a/api/desc/vm/pcm-vm.api +++ b/api/desc/vm/pcm-vm.api @@ -7,82 +7,6 @@ info( email: "1364512070@qq.com" ) - -type ( - Rate{ - } - Absolute{ - MaxServerMeta int64 `json:"max_server_meta,optional"` - MaxPersonality int64 `json:"max_personality,optional"` - TotalServerGroupsUsed int64 `json:"total_server_groups_used,optional"` - MaxImageMeta int64 `json:"max_image_meta,optional"` - MaxPersonalitySize int64 `json:"max_personality_size,optional"` - MaxTotalKeypairs int64 `json:"max_total_keypairs,optional"` - MaxSecurityGroupRules int64 `json:"max_security_group_rules,optional"` - MaxServerGroups int64 `json:"max_server_groups,optional"` - TotalCoresUsed int64 `json:"total_cores_used,optional"` - TotalRAMUsed int64 `json:"total_ram_used,optional"` - TotalInstancesUsed int64 `json:"total_instances_used,optional"` - MaxSecurityGroups int64 `json:"max_security_groups,optional"` - TotalFloatingIpsUsed int64 `json:"total_floating_ips_used,optional"` - MaxTotalCores int64 `json:"max_total_cores,optional"` - MaxServerGroupMembers int64 `json:"max_server_group_members,optional"` - MaxTotalFloatingIps int64 `json:"max_total_floating_ips,optional"` - TotalSecurityGroupsUsed int64 `json:"total_security_groups_used,optional"` - MaxTotalInstances int64 `json:"max_total_instances,optional"` - MaxTotalRAMSize int64 `json:"max_total_ram_size,optional"` - } - Limits{ - rate Rate `json:"rate,optional"` - absolute Absolute`json:"absolute,optional"` - } - GetComputeLimitsReq{ - Limit int32 `json:"limit,optional"` - OffSet int32 `json:"offSet,optional"` - } - - GetComputeLimitsResp{ - limits Limits `json:"limits,optional"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"errorMsg,omitempty"` - } -) - - -type ( - VolumeRate{ - } - VolumeAbsolute{ - TotalSnapshotsUsed int32 `json:"total_snapshots_used,optional"` - MaxTotalBackups int32 `json:"max_total_backups,optional"` - MaxTotalVolumeGigabytes int32 `json:"max_total_volume_gigabytes,optional"` - MaxTotalSnapshots int32 `json:"max_total_snapshots,optional"` - MaxTotalBackupGigabytes int32 `json:"max_total_backup_gigabytes,optional"` - TotalBackupGigabytesUsed int32 `json:"total_backup_gigabytes_used,optional"` - MaxTotalVolumes int32 `json:"max_total_volumes,optional"` - TotalVolumesUsed int32 `json:"total_volumes_used,optional"` - TotalBackupsUsed int32 `json:"total_backups_used,optional"` - TotalGigabytesUsed int32 `json:"total_gigabytes_used,optional"` - } - VolumeLimits{ - rate VolumeRate `json:"rate,optional"` - absolute VolumeAbsolute`json:"absolute,optional"` - } - GetVolumeLimitsReq{ - Limit int32 `json:"limit,optional"` - OffSet int32 `json:"offSet,optional"` - } - - GetVolumeLimitsResp{ - limits VolumeLimits `json:"limits,optional"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"errorMsg,omitempty"` - } -) - - /****************** servers start*************************/ type ( ListServersReq { @@ -116,34 +40,34 @@ type ( ) type( - ListServersDetailedReq{ + ListServersDetailedReq{ - } - ListServersDetailedResp{ - ServersDetailed []ServersDetailed `json:"servers" copier:"ServersDetailed"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"errorMsg,omitempty"` - } + } + ListServersDetailedResp{ + ServersDetailed []ServersDetailed `json:"servers" copier:"ServersDetailed"` + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"errorMsg,omitempty"` + } - ServersDetailed{ - created string `json:"created" copier:"created"` - id string `json:"id" copier:"id"` - key_name string `json:"key_name" copier:"key_name"` - locked bool `json:"locked" copier:"locked"` - name string `json:"name" copier:"name"` - progress uint32 `json:"progress" copier:"progress"` - status string `json:"status" copier:"status"` - tenant_id string `json:"tenant_id" copier:"tenant_id"` - updated string `json:"updated" copier:"updated"` - user_id string `json:"user_id" copier:"user_id"` - } + ServersDetailed{ + created string `json:"created" copier:"created"` + id string `json:"id" copier:"id"` + key_name string `json:"key_name" copier:"key_name"` + locked bool `json:"locked" copier:"locked"` + name string `json:"name" copier:"name"` + progress uint32 `json:"progress" copier:"progress"` + status string `json:"status" copier:"status"` + tenant_id string `json:"tenant_id" copier:"tenant_id"` + updated string `json:"updated" copier:"updated"` + user_id string `json:"user_id" copier:"user_id"` + } ) type ( DeleteServerReq{ ServerId string `form:"server_id" copier:"ServerId"` - } + } DeleteServerResp{ Code int32 `json:"code,omitempty"` @@ -168,6 +92,7 @@ type ( ImageRef string `json:"imageRef" copier:"ImageRef"` Networks []CreNetwork `json:"networks" copier:"Networks"` //AdminPass string `json:"adminPass" copier:"AdminPass"` + BlockDeviceMappingV2 []Block_device_mapping_v2 `json:"block_device_mapping_v2" copier:"BlockDeviceMappingV2"` } CreNetwork { Uuid string `json:"uuid" copier:"Uuid"` @@ -183,6 +108,13 @@ type ( Security_groups { Name string `json:"name" copier:"Name"` } + Block_device_mapping_v2 { + SourceType string `json:"source_type" copier:"SourceType"` + Uuid string `json:"uuid" copier:"Uuid"` + BootIndex string `json:"boot_index" copier:"BootIndex"` + DestinationType string `json:"destination_type" copier:"DestinationType"` + DeleteOnTermination bool `json:"delete_on_termination" copier:"DeleteOnTermination"` + } ) /****************** servers end*************************/ @@ -193,20 +125,20 @@ type ( Limit int32 `form:"limit,optional"` // Marker string `json:"marker" copier:"Marker"` - // Name string `json:"name" copier:"Name"` - // Owner string `json:"owner" copier:"Owner"` - // Protected bool `json:"protected" copier:"Protected"` - // Status int32 `json:"status" copier:"Status"` - // Visibility int32 `json:"visibility" copier:"Visibility"` - // Os_hidden bool `json:"os_hidden" copier:"Os_hidden"` - // Member_status string `json:"member_status" copier:"Member_status"` - // Size_max string `json:"size_max" copier:"Size_max"` - // Size_min string `json:"size_min" copier:"Size_min"` - // Created_at string `json:"created_at" copier:"Created_at"` - // Updated_at string `json:"updated_at" copier:"Updated_at"` - // Sort_dir string `json:"sort_dir" copier:"Sort_dir"` - // Sort_key string `json:"sort_key" copier:"Sort_key"` - // Sort string `json:"sort" copier:"Sort"` + // Name string `json:"name" copier:"Name"` + // Owner string `json:"owner" copier:"Owner"` + // Protected bool `json:"protected" copier:"Protected"` + // Status int32 `json:"status" copier:"Status"` + // Visibility int32 `json:"visibility" copier:"Visibility"` + // Os_hidden bool `json:"os_hidden" copier:"Os_hidden"` + // Member_status string `json:"member_status" copier:"Member_status"` + // Size_max string `json:"size_max" copier:"Size_max"` + // Size_min string `json:"size_min" copier:"Size_min"` + // Created_at string `json:"created_at" copier:"Created_at"` + // Updated_at string `json:"updated_at" copier:"Updated_at"` + // Sort_dir string `json:"sort_dir" copier:"Sort_dir"` + // Sort_key string `json:"sort_key" copier:"Sort_key"` + // Sort string `json:"sort" copier:"Sort"` } ListImagesResp { First string `json:"first" copier:"First"` @@ -246,22 +178,43 @@ type ( ) type( - CreateImageReq{ - Container_format string `json:"container_format" copier:"Container_format"` - Disk_format string `json:"disk_format" copier:"Disk_format"` - Id string `json:"id" copier:"Id"` - Min_disk string `json:"min_disk" copier:"Min_disk"` - Min_ram string `json:"min_ram" copier:"Min_ram"` - Name string `json:"name" copier:"Name"` - Protected string `json:"protected" copier:"Protected"` - Tags []Tags `json:"tags" copier:"Tags"` - visibility string `json:"visibility" copier:"visibility"` -} - CreateImageResq { - Location string `json:"location" copier:"Location"` - } + CreateImageReq{ + Container_format string `json:"container_format" copier:"Container_format"` + Disk_format string `json:"disk_format" copier:"Disk_format"` + Min_disk int32 `json:"min_disk" copier:"Min_disk"` + Min_ram int32 `json:"min_ram" copier:"Min_ram"` + Name string `json:"name" copier:"Name"` + Protected bool `json:"protected" copier:"Protected"` + //Tags []Tags `json:"tags" copier:"Tags"` + Visibility string `json:"visibility" copier:"Visibility"` + } + CreateImageResp { + Location string `json:"location" copier:"Location"` + Created_at string `json:"created_at" copier:"Created_at"` + Container_format string `json:"Container_format" copier:"Container_format"` + Disk_format string `json:"disk_format" copier:"Disk_format"` + File string `json:"file" copier:"File"` + Id string `json:"id" copier:"Id"` + Min_disk int32 `json:"min_disk" copier:"Min_disk"` + Min_ram int32 `json:"min_ram" copier:"Min_ram"` + Status string `json:"status" copier:"Status"` + Visibility string `json:"visibility" copier:"Visibility"` + Code int32 `json:"code,omitempty" copier:"Code"` + Msg string `json:"msg,omitempty" copier:"Msg"` + ErrorMsg string `json:"errorMsg,omitempty" copier:"ErrorMsg"` + } ) +type( + UploadOsImageReq{ + ImageId string `form:"image_id" copier:"ImageId"` + } + UploadOsImageResp { + Code int32 `json:"code,omitempty" copier:"Code"` + Msg string `json:"msg,omitempty" copier:"Msg"` + ErrorMsg string `json:"errorMsg,omitempty" copier:"ErrorMsg"` + } +) type( DeleteImageReq{ @@ -481,6 +434,30 @@ type( ConsumesQuota bool `json:"consumes_quota" copier:"ConsumesQuota"` } ) +type( + ListVolumeTypesReq{ + + } + ListVolumeTypesResp{ + VolumeTypes []Volume_types `json:"volume_types" copier:"VolumeTypes"` + Code int32 `json:"code,omitempty" copier:"Code"` + Msg string `json:"msg,omitempty" copier:"Msg"` + ErrorMsg string `json:"errorMsg,omitempty" copier:"ErrorMsg"` + } + Volume_types{ + Description string `json:"description" copier:"Description"` + Id string `json:"id" copier:"Id"` + IsPublic bool `json:"is_public" copier:"IsPublic"` + Name string `json:"name" copier:"Name"` + OsVolumeTypeAccessIsPublic bool `json:"os_volume_type_access_is_public" copier:"OsVolumeTypeAccessIsPublic"` + QosSpecsId string `json:"qos_specs_id" copier:"QosSpecsId"` + ExtraSpecs Extra_specs `json:"extra_specs" copier:"ExtraSpecs"` + } + Extra_specs { + Capabilities string `json:"capabilities" copier:"Capabilities"` + } + +) /******************find ListVolumesDetail end*************************/ diff --git a/api/internal/handler/core/getcomputilitystatisticshandler.go b/api/internal/handler/core/getcomputilitystatisticshandler.go new file mode 100644 index 00000000..bc047154 --- /dev/null +++ b/api/internal/handler/core/getcomputilitystatisticshandler.go @@ -0,0 +1,21 @@ +package core + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/core" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" +) + +func GetComputilityStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetComputilityStatisticsLogic(r.Context(), svcCtx) + resp, err := l.GetComputilityStatistics() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 1718d620..07003774 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -5,7 +5,6 @@ import ( "net/http" ai "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler/ai" - cloud "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler/cloud" core "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler/core" hpc "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler/hpc" image "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/handler/image" @@ -91,18 +90,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { }, { Method: http.MethodGet, - Path: "/core/assets", - Handler: core.NodeAssetsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/saveHashcat", - Handler: core.SaveHashcatHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getHashcat/:crackTaskId", - Handler: core.GetHashcatHandler(serverCtx), + Path: "/core/getComputilityStatistics", + Handler: core.GetComputilityStatisticsHandler(serverCtx), }, }, rest.WithPrefix("/pcm/v1"), @@ -120,27 +109,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/hpc/listHistoryJob", Handler: hpc.ListHistoryJobHandler(serverCtx), }, - { - Method: http.MethodGet, - Path: "/queue/assets", - Handler: hpc.QueueAssetsHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodGet, - Path: "/task/list", - Handler: cloud.CloudListHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/cloud/DeleteYaml", - Handler: cloud.DeleteYamlHandler(serverCtx), - }, }, rest.WithPrefix("/pcm/v1"), ) @@ -350,16 +318,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { server.AddRoutes( []rest.Route{ - { - Method: http.MethodGet, - Path: "/vm/getComputeLimits", - Handler: vm.GetComputeLimitsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/getVolumeLimits", - Handler: vm.GetVolumeLimitsHandler(serverCtx), - }, { Method: http.MethodGet, Path: "/vm/listServer", @@ -430,6 +388,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/vm/createServer", Handler: vm.CreateServerHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/vm/listVolumeTypes", + Handler: vm.ListVolumeTypesHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createImage", + Handler: vm.CreateImageHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/uploadImage", + Handler: vm.UploadImageHandler(serverCtx), + }, }, rest.WithPrefix("/pcm/v1"), ) diff --git a/api/internal/handler/vm/createimagehandler.go b/api/internal/handler/vm/createimagehandler.go new file mode 100644 index 00000000..7a4ebf0b --- /dev/null +++ b/api/internal/handler/vm/createimagehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/vm" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" +) + +func CreateImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateImageReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateImageLogic(r.Context(), svcCtx) + resp, err := l.CreateImage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/vm/listvolumetypeshandler.go b/api/internal/handler/vm/listvolumetypeshandler.go new file mode 100644 index 00000000..82d1bbed --- /dev/null +++ b/api/internal/handler/vm/listvolumetypeshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/vm" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" +) + +func ListVolumeTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListVolumeTypesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListVolumeTypesLogic(r.Context(), svcCtx) + resp, err := l.ListVolumeTypes(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/vm/uploadimagehandler.go b/api/internal/handler/vm/uploadimagehandler.go new file mode 100644 index 00000000..cd847620 --- /dev/null +++ b/api/internal/handler/vm/uploadimagehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/vm" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" +) + +func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UploadOsImageReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUploadImageLogic(r.Context(), svcCtx) + resp, err := l.UploadImage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/logic/core/getcomputilitystatisticslogic.go b/api/internal/logic/core/getcomputilitystatisticslogic.go new file mode 100644 index 00000000..a54c5408 --- /dev/null +++ b/api/internal/logic/core/getcomputilitystatisticslogic.go @@ -0,0 +1,103 @@ +package core + +import ( + "context" + "fmt" + "strconv" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetComputilityStatisticsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetComputilityStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputilityStatisticsLogic { + return &GetComputilityStatisticsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetComputilityStatisticsLogic) GetComputilityStatistics() (resp *types.ComputilityStatisticsResp, err error) { + // todo: add your logic here and delete this line + + resp = &types.ComputilityStatisticsResp{} + var computilityStatistics types.ComputilityStatistics + var domainSum int64 //所有域的总和 + var AiFlopsNum float64 //所有域的总和 + var K8sFlopsNum float64 //所有域的总和 + var aiClusterSum int64 //所有域的总和 + var hpcClusterSum int64 //所有域的总和 + var PCClusterSum int64 //所有域的总和 + var ClusterSum int64 //所有域的总和 + + //算力中心总数(计算域):包括所有云算域,智算域,超算域以及鹏城返回的所有域的总和 + sqlStr := "select count(*) as domainSum from `pcm`.domain_resource t where t.connection_state = 3 OR t.domain_source=0" + tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&domainSum) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + + computilityStatistics.DomainSum = domainSum + + //统计集群 + clusterStr := "select count(*) from `joint_domain`.domain_cluster" + tc := l.svcCtx.DbEngin.Raw(clusterStr).Scan(&ClusterSum) + if tc.Error != nil { + logx.Error(err) + return nil, tc.Error + } + //智算算力总和 + aiFlopsStr := "select sum(t.flops) as flopsNum from `pcm`.domain_resource t" + tf := l.svcCtx.DbEngin.Raw(aiFlopsStr).Scan(&AiFlopsNum) + if tf.Error != nil { + logx.Error(err) + return nil, tf.Error + } + + //云算算力总和 SELECT sum(t.flops) FROM `resources` t + k8sFlopsStr := "SELECT sum(t.flops) as k8sFlopsNum FROM `joint_domain`.`resources` t" + tk := l.svcCtx.DbEngin.Raw(k8sFlopsStr).Scan(&K8sFlopsNum) + if tk.Error != nil { + logx.Error(err) + return nil, tk.Error + } + value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", K8sFlopsNum/1000000+AiFlopsNum), 64) + + computilityStatistics.TotalComputility = value + + //智算集群数 + aiClusterStr := "select count(*) as aiClusterSum from `pcm`.ai_cluster" + ts := l.svcCtx.DbEngin.Raw(aiClusterStr).Scan(&aiClusterSum) + if ts.Error != nil { + logx.Error(err) + return nil, ts.Error + } + //云算集群数 + hpcClusterStr := "select count(*) as hpcClusterSum from `pcm`.hpc_cluster" + th := l.svcCtx.DbEngin.Raw(hpcClusterStr).Scan(&hpcClusterSum) + if th.Error != nil { + logx.Error(err) + return nil, th.Error + } + //鹏城集群数 + PCClusterStr := "select count(*) as PCClusterSum from `pcm`.domain_resource t where t.connection_state = 3 " + tp := l.svcCtx.DbEngin.Raw(PCClusterStr).Scan(&PCClusterSum) + if tp.Error != nil { + logx.Error(err) + return nil, tp.Error + } + computilityStatistics.ClusterNum = ClusterSum + PCClusterSum + hpcClusterSum + aiClusterSum + resp.ComputilityStatistics = computilityStatistics + resp.Code = 200 + resp.Msg = "Success" + return resp, nil +} diff --git a/api/internal/logic/vm/createimagelogic.go b/api/internal/logic/vm/createimagelogic.go new file mode 100644 index 00000000..91bd8313 --- /dev/null +++ b/api/internal/logic/vm/createimagelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack" + "gitlink.org.cn/jcce-pcm/utils/result" + "gitlink.org.cn/jcce-pcm/utils/tool" + "gitlink.org.cn/jcce-pcm/utils/xerr" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateImageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateImageLogic { + return &CreateImageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateImageLogic) CreateImage(req *types.CreateImageReq) (resp *types.CreateImageResp, err error) { + // todo: add your logic here and delete this line + CreateImageReq := &openstack.CreateImageReq{} + err = copier.CopyWithOption(CreateImageReq, req, copier.Option{Converters: tool.Converters}) + CreateImageResp, err := l.svcCtx.OpenstackRpc.CreateImage(l.ctx, CreateImageReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateImageResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateImageResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/api/internal/logic/vm/listvolumetypeslogic.go b/api/internal/logic/vm/listvolumetypeslogic.go new file mode 100644 index 00000000..e38b4da8 --- /dev/null +++ b/api/internal/logic/vm/listvolumetypeslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack" + "gitlink.org.cn/jcce-pcm/utils/result" + "gitlink.org.cn/jcce-pcm/utils/tool" + "gitlink.org.cn/jcce-pcm/utils/xerr" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListVolumeTypesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListVolumeTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVolumeTypesLogic { + return &ListVolumeTypesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListVolumeTypesLogic) ListVolumeTypes(req *types.ListVolumeTypesReq) (resp *types.ListVolumeTypesResp, err error) { + // todo: add your logic here and delete this line + ListVolumeTypesReq := &openstack.ListVolumeTypesReq{} + err = copier.CopyWithOption(ListVolumeTypesReq, req, copier.Option{Converters: tool.Converters}) + ListVolumeTypesResp, err := l.svcCtx.OpenstackRpc.ListVolumeTypes(l.ctx, ListVolumeTypesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Volumes list"), "Failed to get db Volumes list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListVolumeTypesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListVolumeTypesResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/api/internal/logic/vm/uploadimagelogic.go b/api/internal/logic/vm/uploadimagelogic.go new file mode 100644 index 00000000..f3114739 --- /dev/null +++ b/api/internal/logic/vm/uploadimagelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/jcce-pcm/pcm-participant-openstack/openstack" + "gitlink.org.cn/jcce-pcm/utils/result" + "gitlink.org.cn/jcce-pcm/utils/tool" + "gitlink.org.cn/jcce-pcm/utils/xerr" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UploadImageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUploadImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadImageLogic { + return &UploadImageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UploadImageLogic) UploadImage(req *types.UploadOsImageReq) (resp *types.UploadOsImageResp, err error) { + // todo: add your logic here and delete this line + UploadOsImageReq := &openstack.UploadOsImageReq{} + err = copier.CopyWithOption(UploadOsImageReq, req, copier.Option{Converters: tool.Converters}) + CreateImageResp, err := l.svcCtx.OpenstackRpc.UploadImage(l.ctx, UploadOsImageReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateImageResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateImageResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 6adda916..b71d1fcd 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -374,6 +374,19 @@ type ResourcePanelConfigResp struct { UpdateTime string `json:"updateTime"` //更新时间 } +type ComputilityStatisticsResp struct { + Code int32 `json:"code,omitempty"` + Msg string `json:"msg,omitempty"` + ErrorMsg string `json:"ErrorMsg,omitempty"` + ComputilityStatistics ComputilityStatistics `json:"data"` //容器节点已使用 +} + +type ComputilityStatistics struct { + DomainSum int64 `json:"domainSum"` //域总数 + TotalComputility float64 `json:"totalComputility"` //算力总和 + ClusterNum int64 `json:"clusterNum"` //集群总数 +} + type ClusterMetrics struct { Code int `json:"code,omitempty"` Msg string `json:"msg,omitempty"` @@ -2130,81 +2143,6 @@ type CheckResp struct { Exist bool `json:"exist"` } -type Rate struct { -} - -type Absolute struct { - MaxServerMeta int64 `json:"max_server_meta,optional"` - MaxPersonality int64 `json:"max_personality,optional"` - TotalServerGroupsUsed int64 `json:"total_server_groups_used,optional"` - MaxImageMeta int64 `json:"max_image_meta,optional"` - MaxPersonalitySize int64 `json:"max_personality_size,optional"` - MaxTotalKeypairs int64 `json:"max_total_keypairs,optional"` - MaxSecurityGroupRules int64 `json:"max_security_group_rules,optional"` - MaxServerGroups int64 `json:"max_server_groups,optional"` - TotalCoresUsed int64 `json:"total_cores_used,optional"` - TotalRAMUsed int64 `json:"total_ram_used,optional"` - TotalInstancesUsed int64 `json:"total_instances_used,optional"` - MaxSecurityGroups int64 `json:"max_security_groups,optional"` - TotalFloatingIpsUsed int64 `json:"total_floating_ips_used,optional"` - MaxTotalCores int64 `json:"max_total_cores,optional"` - MaxServerGroupMembers int64 `json:"max_server_group_members,optional"` - MaxTotalFloatingIps int64 `json:"max_total_floating_ips,optional"` - TotalSecurityGroupsUsed int64 `json:"total_security_groups_used,optional"` - MaxTotalInstances int64 `json:"max_total_instances,optional"` - MaxTotalRAMSize int64 `json:"max_total_ram_size,optional"` -} - -type Limits struct { - Rate Rate `json:"rate,optional"` - Absolute Absolute `json:"absolute,optional"` -} - -type GetComputeLimitsReq struct { - Limit int32 `json:"limit,optional"` - OffSet int32 `json:"offSet,optional"` -} - -type GetComputeLimitsResp struct { - Limits Limits `json:"limits,optional"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"errorMsg,omitempty"` -} - -type VolumeRate struct { -} - -type VolumeAbsolute struct { - TotalSnapshotsUsed int32 `json:"total_snapshots_used,optional"` - MaxTotalBackups int32 `json:"max_total_backups,optional"` - MaxTotalVolumeGigabytes int32 `json:"max_total_volume_gigabytes,optional"` - MaxTotalSnapshots int32 `json:"max_total_snapshots,optional"` - MaxTotalBackupGigabytes int32 `json:"max_total_backup_gigabytes,optional"` - TotalBackupGigabytesUsed int32 `json:"total_backup_gigabytes_used,optional"` - MaxTotalVolumes int32 `json:"max_total_volumes,optional"` - TotalVolumesUsed int32 `json:"total_volumes_used,optional"` - TotalBackupsUsed int32 `json:"total_backups_used,optional"` - TotalGigabytesUsed int32 `json:"total_gigabytes_used,optional"` -} - -type VolumeLimits struct { - Rate VolumeRate `json:"rate,optional"` - Absolute VolumeAbsolute `json:"absolute,optional"` -} - -type GetVolumeLimitsReq struct { - Limit int32 `json:"limit,optional"` - OffSet int32 `json:"offSet,optional"` -} - -type GetVolumeLimitsResp struct { - Limits VolumeLimits `json:"limits,optional"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"errorMsg,omitempty"` -} - type ListServersReq struct { Limit int32 `form:"limit,optional"` OffSet int32 `form:"offSet,optional"` @@ -2280,10 +2218,11 @@ type CreateServerResp struct { } type Server struct { - Name string `json:"name" copier:"Name"` - FlavorRef string `json:"flavorRef" copier:"FlavorRef"` - ImageRef string `json:"imageRef" copier:"ImageRef"` - Networks []CreNetwork `json:"networks" copier:"Networks"` + Name string `json:"name" copier:"Name"` + FlavorRef string `json:"flavorRef" copier:"FlavorRef"` + ImageRef string `json:"imageRef" copier:"ImageRef"` + Networks []CreNetwork `json:"networks" copier:"Networks"` + BlockDeviceMappingV2 []Block_device_mapping_v2 `json:"block_device_mapping_v2" copier:"BlockDeviceMappingV2"` } type CreNetwork struct { @@ -2302,6 +2241,14 @@ type Security_groups struct { Name string `json:"name" copier:"Name"` } +type Block_device_mapping_v2 struct { + SourceType string `json:"source_type" copier:"SourceType"` + Uuid string `json:"uuid" copier:"Uuid"` + BootIndex string `json:"boot_index" copier:"BootIndex"` + DestinationType string `json:"destination_type" copier:"DestinationType"` + DeleteOnTermination bool `json:"delete_on_termination" copier:"DeleteOnTermination"` +} + type ListImagesReq struct { Limit int32 `form:"limit,optional"` } @@ -2347,17 +2294,37 @@ type Tags struct { type CreateImageReq struct { Container_format string `json:"container_format" copier:"Container_format"` Disk_format string `json:"disk_format" copier:"Disk_format"` - Id string `json:"id" copier:"Id"` - Min_disk string `json:"min_disk" copier:"Min_disk"` - Min_ram string `json:"min_ram" copier:"Min_ram"` + Min_disk int32 `json:"min_disk" copier:"Min_disk"` + Min_ram int32 `json:"min_ram" copier:"Min_ram"` Name string `json:"name" copier:"Name"` - Protected string `json:"protected" copier:"Protected"` - Tags []Tags `json:"tags" copier:"Tags"` - Visibility string `json:"visibility" copier:"visibility"` + Protected bool `json:"protected" copier:"Protected"` + Visibility string `json:"visibility" copier:"Visibility"` } -type CreateImageResq struct { - Location string `json:"location" copier:"Location"` +type CreateImageResp struct { + Location string `json:"location" copier:"Location"` + Created_at string `json:"created_at" copier:"Created_at"` + Container_format string `json:"Container_format" copier:"Container_format"` + Disk_format string `json:"disk_format" copier:"Disk_format"` + File string `json:"file" copier:"File"` + Id string `json:"id" copier:"Id"` + Min_disk int32 `json:"min_disk" copier:"Min_disk"` + Min_ram int32 `json:"min_ram" copier:"Min_ram"` + Status string `json:"status" copier:"Status"` + Visibility string `json:"visibility" copier:"Visibility"` + Code int32 `json:"code,omitempty" copier:"Code"` + Msg string `json:"msg,omitempty" copier:"Msg"` + ErrorMsg string `json:"errorMsg,omitempty" copier:"ErrorMsg"` +} + +type UploadOsImageReq struct { + ImageId string `form:"image_id" copier:"ImageId"` +} + +type UploadOsImageResp struct { + Code int32 `json:"code,omitempty" copier:"Code"` + Msg string `json:"msg,omitempty" copier:"Msg"` + ErrorMsg string `json:"errorMsg,omitempty" copier:"ErrorMsg"` } type DeleteImageReq struct { @@ -2570,6 +2537,30 @@ type VolumeResp struct { ConsumesQuota bool `json:"consumes_quota" copier:"ConsumesQuota"` } +type ListVolumeTypesReq struct { +} + +type ListVolumeTypesResp struct { + VolumeTypes []Volume_types `json:"volume_types" copier:"VolumeTypes"` + Code int32 `json:"code,omitempty" copier:"Code"` + Msg string `json:"msg,omitempty" copier:"Msg"` + ErrorMsg string `json:"errorMsg,omitempty" copier:"ErrorMsg"` +} + +type Volume_types struct { + Description string `json:"description" copier:"Description"` + Id string `json:"id" copier:"Id"` + IsPublic bool `json:"is_public" copier:"IsPublic"` + Name string `json:"name" copier:"Name"` + OsVolumeTypeAccessIsPublic bool `json:"os_volume_type_access_is_public" copier:"OsVolumeTypeAccessIsPublic"` + QosSpecsId string `json:"qos_specs_id" copier:"QosSpecsId"` + ExtraSpecs Extra_specs `json:"extra_specs" copier:"ExtraSpecs"` +} + +type Extra_specs struct { + Capabilities string `json:"capabilities" copier:"Capabilities"` +} + type ListFlavorsDetailReq struct { } @@ -2593,50 +2584,3 @@ type Flavors struct { Rxtx_factor float32 `json:"rxtx_factor" copier:"rxtx_factor"` Os_flavor_access_is_public bool `json:"os_flavor_access_is_public" copier:"os_flavor_access_is_public"` } - -type ApplyReq struct { - YamlString string `json:"yamlString" copier:"yamlString"` -} - -type DeleteReq struct { - YamlString string `json:"yamlString" copier:"yamlString"` -} - -type ApplyResp struct { - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - DataSet []DataSet `json:"dataSet,omitempty"` -} - -type DeleteResp struct { - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - Data string `json:"data,omitempty"` -} - -type DataSet struct { - ApiVersion int32 `json:"apiVersion,omitempty"` - Kind string `json:"kind,omitempty"` - Name string `json:"name,omitempty"` - NameSpace string `json:"nameSpace,omitempty"` -} - -type CloudListResp struct { - Clouds []Cloud `json:"clouds"` -} - -type Cloud struct { - Id int64 `json:"id"` // id - TaskId int64 `json:"taskId"` // 任务id - ParticipantId int64 `json:"participantId"` // 集群静态信息id - ApiVersion string `json:"apiVersion"` - Name string `json:"name"` // 名称 - Namespace string `json:"namespace"` // 命名空间 - Kind string `json:"kind"` // 种类 - Status string `json:"status"` // 状态 - StartTime string `json:"startTime"` // 开始时间 - RunningTime int64 `json:"runningTime"` // 运行时长 - CreatedBy int64 `json:"createdBy"` // 创建人 - CreatedTime string `json:"createdTime"` // 创建时间 - Result string `json:"result"` -} diff --git a/go.mod b/go.mod index 59fd9ffe..40a54a06 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230817103341-2459e5bfc835 gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230719015658-08a29549d86a gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714030856-601935bc30e2 - gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20230831020641-98c737b3e61e + gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20230904012700-2e8e98c5fd2f gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4 gitlink.org.cn/jcce-pcm/utils v0.0.2 gonum.org/v1/gonum v0.11.0 diff --git a/go.sum b/go.sum index 4a65f667..df6fdc5e 100644 --- a/go.sum +++ b/go.sum @@ -650,8 +650,8 @@ github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/ github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fullstorydev/grpcurl v1.8.7/go.mod h1:pVtM4qe3CMoLaIzYS8uvTuDj2jVYmXqMUkZeijnXp/E= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= @@ -802,8 +802,8 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -1150,8 +1150,8 @@ gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230719015658-08a29549 gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230719015658-08a29549d86a/go.mod h1:BhOgwM1LC+BD46DjTaQyYQVZs1CikwI5Pl/6qzKUexc= gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714030856-601935bc30e2 h1:RcGSqhsod6VXLksSLqNjV0q/SCeoUv6CbThKmV9NTZE= gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714030856-601935bc30e2/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo= -gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20230831020641-98c737b3e61e h1:wkmtmvFzXjV04j6Gcz+WyOMaYj9LYxo1Nr8EJIFCD2I= -gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20230831020641-98c737b3e61e/go.mod h1:6lFti0ujjUP9RtJHGAHcoLa9CpPymvG2S2TNob0WdQo= +gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20230904012700-2e8e98c5fd2f h1:SSmRAO+lCf7/r2sJ35akkCP61+lYTCNhPZXf59LJPa0= +gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20230904012700-2e8e98c5fd2f/go.mod h1:JRFx7CjtUDyjJGyLWuInhr4rKfqcNY66Fxi+jq+Y+sc= gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4 h1:r2hBP5G/bbkPpDTPk3ENnQxD82vkoYMSeNHYhNAVRX4= gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4/go.mod h1:zRdVJiv4r4jgBli2xpYGmV0n6Gmz8fkZ5pJaNK2MbTU= gitlink.org.cn/jcce-pcm/utils v0.0.2 h1:Stif8W9C9TOCS2hw4g+OlOywDrsVYNrkiyKfBrWkT0w=