From 78b32614926ce6f223cdb8701d69b276b374fd33 Mon Sep 17 00:00:00 2001 From: Jake <450705171@qq.com> Date: Wed, 3 Jul 2024 09:46:33 +0800 Subject: [PATCH] restructure Former-commit-id: 85ed149ca19d46f6b1379c77315ae66c14a26f5e --- api/Dockerfile => Dockerfile | 0 Makefile | 13 +- api/Makefile | 8 - api/etc/pcm.yaml | 85 - api/internal/cron/aiCronTask.go | 250 -- api/internal/cron/cron.go | 42 - .../handler/adapters/adapterslisthandler.go | 24 - .../handler/adapters/clusterlisthandler.go | 24 - .../handler/adapters/createadapterhandler.go | 24 - .../handler/adapters/createclusterhandler.go | 24 - .../handler/adapters/deleteadapterhandler.go | 24 - .../handler/adapters/deleteclusterhandler.go | 24 - .../handler/adapters/getadapterhandler.go | 24 - .../adapters/getadapterrelationhandler.go | 24 - .../handler/adapters/getclusterhandler.go | 24 - .../handler/adapters/getclustersumhandler.go | 24 - .../handler/adapters/updateadapterhandler.go | 24 - .../handler/adapters/updateclusterhandler.go | 24 - .../handler/ai/createalgorithmhandler.go | 24 - .../handler/ai/createdatasethandler.go | 24 - .../handler/ai/createexporttaskhandler.go | 24 - .../handler/ai/createnotebookhandler.go | 24 - .../handler/ai/createprocessortaskhandler.go | 24 - .../handler/ai/createservicehandler.go | 24 - api/internal/handler/ai/createtaskhandler.go | 24 - .../handler/ai/createtrainingjobhandler.go | 24 - .../ai/createvisualizationjobhandler.go | 24 - .../handler/ai/deletealgorithmhandler.go | 24 - .../handler/ai/deletedatasethandler.go | 24 - .../handler/ai/deleteservicehandler.go | 24 - .../handler/ai/deletetrainingjobhandler.go | 24 - .../handler/ai/getcenterlisthandler.go | 21 - .../handler/ai/getcenteroverviewhandler.go | 21 - .../handler/ai/getcenterqueueinghandler.go | 21 - .../handler/ai/getcentertasklisthandler.go | 21 - .../ai/getexporttasksofdatasethandler.go | 24 - .../ai/getexporttaskstatusofdatasethandler.go | 24 - .../handler/ai/getlisttrainingjobshandler.go | 24 - .../handler/ai/getnotebookstoragehandler.go | 24 - .../handler/ai/getvisualizationjobhandler.go | 24 - .../handler/ai/listalgorithmshandler.go | 24 - .../handler/ai/listclustershandler.go | 24 - api/internal/handler/ai/listdatasethandler.go | 24 - api/internal/handler/ai/listimporthandler.go | 24 - .../handler/ai/listnotebookhandler.go | 24 - .../handler/ai/listserviceshandler.go | 24 - .../handler/ai/mountnotebookstoragehandler.go | 24 - api/internal/handler/ai/proxyapihandler.go | 24 - .../handler/ai/showalgorithmbyuuidhandler.go | 24 - api/internal/handler/ai/showservicehandler.go | 24 - .../handler/ai/startnotebookhandler.go | 24 - .../handler/ai/stopnotebookhandler.go | 24 - .../handler/cloud/cloudlisthandler.go | 16 - .../handler/cloud/clusterinfohandler.go | 25 - .../handler/cloud/commitgeneraltaskhandler.go | 24 - .../handler/cloud/controllermetricshandler.go | 24 - .../handler/cloud/deleteclusterhandler.go | 24 - .../handler/cloud/deleteyamlhandler.go | 24 - .../handler/cloud/getclusterlisthandler.go | 24 - api/internal/handler/cloud/podlogshandler.go | 24 - .../handler/cloud/registerclusterhandler.go | 24 - .../handler/core/centerresourceshandler.go | 16 - .../handler/core/committaskhandler.go | 24 - .../handler/core/commitvmtaskhandler.go | 24 - .../handler/core/counttaskstatushandler.go | 16 - .../handler/core/deletetaskhandler.go | 24 - .../core/getcomputilitystatisticshandler.go | 16 - .../handler/core/getcomputingpowerhandler.go | 16 - .../handler/core/getdomainresourcehandler.go | 17 - .../handler/core/getgeneralinfohandler.go | 16 - .../handler/core/getpublicflavorhandler.go | 28 - .../handler/core/getpublicimagehandler.go | 28 - .../handler/core/getpublicnetworkhandler.go | 28 - api/internal/handler/core/getregionhandler.go | 16 - .../core/getresourcepanelconfighandler.go | 16 - .../handler/core/getscreencharthandler.go | 17 - .../handler/core/getscreeninfohandler.go | 17 - .../handler/core/homeoverviewhandler.go | 28 - api/internal/handler/core/jobtotalhandler.go | 16 - .../handler/core/listcenterhandler.go | 16 - .../handler/core/listclusterhandler.go | 24 - .../handler/core/listnoticehandler.go | 28 - .../handler/core/listregionhandler.go | 16 - api/internal/handler/core/metricshandler.go | 11 - .../handler/core/nodeassetshandler.go | 16 - .../handler/core/pagelisttaskhandler.go | 24 - .../handler/core/participantlisthandler.go | 16 - .../handler/core/pulltaskinfohandler.go | 28 - .../handler/core/pushnoticehandler.go | 28 - .../handler/core/pushresourceinfohandler.go | 28 - .../handler/core/pushtaskinfohandler.go | 28 - .../core/putresourcepanelconfighandler.go | 24 - .../handler/core/scheduletaskbyyamlhandler.go | 36 - .../handler/core/syncclusterloadhandler.go | 24 - .../handler/core/taskdetailshandler.go | 24 - api/internal/handler/core/tasklisthandler.go | 24 - .../handler/dictionary/adddicthandler.go | 24 - .../handler/dictionary/adddictitemhandler.go | 24 - .../handler/dictionary/deletedicthandler.go | 24 - .../dictionary/deletedictitemhandler.go | 24 - .../handler/dictionary/editdicthandler.go | 24 - .../handler/dictionary/editdictitemhandler.go | 24 - .../handler/dictionary/getdicthandler.go | 24 - .../handler/dictionary/getdictitemhandler.go | 24 - .../handler/dictionary/listdicthandler.go | 24 - .../dictionary/listdictitembycodehandler.go | 24 - .../handler/dictionary/listdictitemhandler.go | 24 - .../handler/hpc/adaptersummaryhandler.go | 28 - .../handler/hpc/commithpctaskhandler.go | 24 - api/internal/handler/hpc/jobhandler.go | 28 - api/internal/handler/hpc/overviewhandler.go | 28 - .../handler/hpc/queueassetshandler.go | 16 - api/internal/handler/hpc/resourcehandler.go | 28 - .../inference/imageinferencehandler.go | 24 - .../inference/inferencetaskdetailhandler.go | 28 - .../inference/modelnamesbytypehandler.go | 25 - .../handler/inference/modeltypeshandler.go | 16 - .../inference/texttotextinferencehandler.go | 25 - .../handler/monitoring/adapterinfohandler.go | 25 - .../handler/monitoring/alertlisthandler.go | 25 - .../handler/monitoring/alertruleshandler.go | 25 - .../handler/monitoring/clustersloadhandler.go | 25 - .../monitoring/createalertrulehandler.go | 25 - .../monitoring/deletealertrulehandler.go | 25 - .../handler/monitoring/nodesloadtophandler.go | 25 - .../monitoring/schedulesituationhandler.go | 17 - .../monitoring/syncclusteralerthandler.go | 28 - .../handler/monitoring/tasknumhandler.go | 25 - api/internal/handler/routes.go | 1306 ------ .../schedule/downloadalgothmcodehandler.go | 25 - .../schedule/getclusterbalancebyidhandler.go | 26 - .../getcomputecardsbyclusterhandler.go | 28 - .../schedule/schedulegetaijoblogloghandler.go | 28 - .../schedulegetairesourcetypeshandler.go | 16 - .../schedule/schedulegetaitasktypeshandler.go | 16 - .../schedule/schedulegetalgorithmshandler.go | 24 - .../schedule/schedulegetdatasetshandler.go | 24 - .../schedule/schedulegetoverviewhandler.go | 21 - .../schedule/schedulegetstrategyhandler.go | 16 - .../handler/schedule/schedulesubmithandler.go | 24 - .../schedule/uploadalgothmcodehandler.go | 25 - .../storage/dailypowerscreenhandler.go | 17 - .../storage/percentercomputerpowershandler.go | 17 - .../handler/storage/screenstoragehandler.go | 24 - .../storelink/deletelinkimagehandler.go | 28 - .../storelink/deletelinktaskhandler.go | 28 - .../handler/storelink/getaispecshandler.go | 28 - .../storelink/getlinkimagelisthandler.go | 28 - .../handler/storelink/getlinktaskhandler.go | 28 - .../storelink/getparticipantshandler.go | 28 - .../storelink/submitlinktaskhandler.go | 28 - .../storelink/uploadlinkimagehandler.go | 28 - .../vm/addsecuritygrouptoserverhandler.go | 28 - .../handler/vm/bulkcreatenetworkshandler.go | 28 - .../vm/changeadministrativepasswordhandler.go | 28 - .../handler/vm/createfirewallgrouphandler.go | 28 - .../handler/vm/createfirewallpolicyhandler.go | 28 - .../handler/vm/createfirewallrulehandler.go | 28 - .../handler/vm/createflavorhandler.go | 28 - .../handler/vm/createfloatingiphandler.go | 28 - api/internal/handler/vm/createimagehandler.go | 28 - .../handler/vm/createmulserverhandler.go | 28 - .../handler/vm/createnetworkhandler.go | 28 - .../vm/createnetworksegmentrangehandler.go | 28 - api/internal/handler/vm/createnodehandler.go | 28 - api/internal/handler/vm/createporthandler.go | 28 - .../handler/vm/createrouterhandler.go | 28 - .../handler/vm/createsecuritygrouphandler.go | 28 - .../vm/createsecuritygrouprulehandler.go | 28 - .../handler/vm/createserverhandler.go | 28 - .../handler/vm/createsubnethandler.go | 28 - .../handler/vm/createvolumehandler.go | 28 - .../handler/vm/createvolumetypeshandler.go | 28 - .../handler/vm/deletefirewallgrouphandler.go | 28 - .../handler/vm/deletefirewallpolicyhandler.go | 28 - .../handler/vm/deletefirewallrulehandler.go | 28 - .../handler/vm/deleteflavorhandler.go | 28 - .../handler/vm/deletefloatingiphandler.go | 28 - api/internal/handler/vm/deleteimagehandler.go | 28 - .../handler/vm/deletenetworkhandler.go | 28 - .../vm/deletenetworksegmentrangeshandler.go | 28 - api/internal/handler/vm/deletenodehandler.go | 28 - api/internal/handler/vm/deleteporthandler.go | 28 - .../handler/vm/deleterouterhandler.go | 28 - .../handler/vm/deletesecuritygrouphandler.go | 28 - .../vm/deletesecuritygrouprulehandler.go | 28 - .../handler/vm/deleteserverhandler.go | 28 - .../handler/vm/deletesubnethandler.go | 28 - .../handler/vm/deletevolumehandler.go | 28 - .../handler/vm/deletevolumetypehandler.go | 28 - .../handler/vm/getcomputelimitshandler.go | 28 - api/internal/handler/vm/getimagenumhandler.go | 28 - .../handler/vm/getnetworknumhandler.go | 28 - .../handler/vm/getopenstackoverviewhandler.go | 28 - .../vm/getserversdetailedbyidhandler.go | 28 - .../vm/getvolumedetailedbyidhandler.go | 28 - .../handler/vm/getvolumelimitshandler.go | 28 - .../handler/vm/listfirewallgroupshandler.go | 28 - .../handler/vm/listfirewallpolicieshandler.go | 28 - .../handler/vm/listfirewallruleshandler.go | 28 - .../handler/vm/listflavorsdetailhandler.go | 28 - .../handler/vm/listfloatingipshandler.go | 28 - api/internal/handler/vm/listimageshandler.go | 28 - .../listnetworksegmentrangesrangehandler.go | 28 - .../handler/vm/listnetworkshandler.go | 28 - api/internal/handler/vm/listnodeshandler.go | 28 - api/internal/handler/vm/listportshandler.go | 28 - api/internal/handler/vm/listroutershandler.go | 28 - .../vm/listsecuritygroupruleshandler.go | 28 - .../handler/vm/listsecuritygroupshandler.go | 28 - api/internal/handler/vm/listserverhandler.go | 28 - .../handler/vm/listserversdetailedhandler.go | 28 - api/internal/handler/vm/listsubnetshandler.go | 28 - .../handler/vm/listvolumesdetailhandler.go | 28 - api/internal/handler/vm/listvolumeshandler.go | 28 - .../handler/vm/listvolumetypeshandler.go | 28 - .../handler/vm/migrateserverhandler.go | 28 - api/internal/handler/vm/pauseserverhandler.go | 28 - .../handler/vm/rebootserverhandler.go | 28 - .../handler/vm/removesecuritygrouphandler.go | 28 - .../handler/vm/rescueserverhandler.go | 28 - .../handler/vm/resizeserverhandler.go | 28 - .../handler/vm/shelveserverhandler.go | 28 - .../vm/showfirewallgroupdetailshandler.go | 28 - .../vm/showfirewallpolicydetailshandler.go | 28 - .../vm/showfirewallruledetailshandler.go | 28 - .../vm/showfloatingipdetailshandler.go | 28 - .../handler/vm/shownetworkdetailshandler.go | 28 - .../shownetworksegmentrangedetailshandler.go | 28 - .../handler/vm/shownodedetailshandler.go | 28 - .../handler/vm/showportdetailshandler.go | 28 - .../handler/vm/showrouterdetailshandler.go | 28 - .../handler/vm/showsecuritygrouphandler.go | 28 - .../vm/showsecuritygrouprulehandler.go | 28 - api/internal/handler/vm/startserverhandler.go | 28 - api/internal/handler/vm/stopserverhandler.go | 28 - .../handler/vm/suspendserverhandler.go | 28 - .../handler/vm/unpauseserverhandler.go | 28 - api/internal/handler/vm/unrescuehandler.go | 28 - .../handler/vm/updatefirewallgrouphandler.go | 28 - .../handler/vm/updatefloatingiphandler.go | 28 - .../handler/vm/updatenetworkhandler.go | 28 - .../vm/updatenetworksegmentrangeshandler.go | 28 - api/internal/handler/vm/updateporthandler.go | 28 - .../handler/vm/updaterouterhandler.go | 28 - .../handler/vm/updatesecuritygrouphandler.go | 28 - .../handler/vm/updateserverhandler.go | 28 - .../handler/vm/updatesubnethandler.go | 28 - .../handler/vm/updatevolumehandler.go | 28 - api/internal/handler/vm/uploadimagehandler.go | 28 - .../logic/adapters/adapterslistlogic.go | 59 - .../logic/adapters/clusterlistlogic.go | 80 - .../logic/adapters/createadapterlogic.go | 67 - .../logic/adapters/createclusterlogic.go | 66 - .../logic/adapters/deleteadapterlogic.go | 44 - .../logic/adapters/deleteclusterlogic.go | 39 - .../logic/adapters/getadapterlogic.go | 35 - .../logic/adapters/getadapterrelationlogic.go | 89 - .../logic/adapters/getclusterlogic.go | 36 - .../logic/adapters/getclustersumlogic.go | 67 - .../logic/adapters/updateadapterlogic.go | 38 - .../logic/adapters/updateclusterlogic.go | 38 - api/internal/logic/ai/createalgorithmlogic.go | 57 - api/internal/logic/ai/createdatasetlogic.go | 58 - .../logic/ai/createexporttasklogic.go | 61 - api/internal/logic/ai/createnotebooklogic.go | 56 - .../logic/ai/createprocessortasklogic.go | 56 - api/internal/logic/ai/createservicelogic.go | 58 - api/internal/logic/ai/createtasklogic.go | 60 - .../logic/ai/createtrainingjoblogic.go | 60 - .../logic/ai/createvisualizationjoblogic.go | 44 - api/internal/logic/ai/deletealgorithmlogic.go | 67 - api/internal/logic/ai/deletedatasetlogic.go | 61 - api/internal/logic/ai/deleteservicelogic.go | 59 - .../logic/ai/deletetrainingjoblogic.go | 58 - api/internal/logic/ai/getcenterlistlogic.go | 43 - .../logic/ai/getcenteroverviewlogic.go | 164 - .../logic/ai/getcenterqueueinglogic.go | 73 - .../logic/ai/getcentertasklistlogic.go | 136 - .../logic/ai/getexporttasksofdatasetlogic.go | 60 - .../ai/getexporttaskstatusofdatasetlogic.go | 59 - .../logic/ai/getlisttrainingjobslogic.go | 104 - .../logic/ai/getnotebookstoragelogic.go | 44 - .../logic/ai/getvisualizationjoblogic.go | 44 - api/internal/logic/ai/listalgorithmslogic.go | 59 - api/internal/logic/ai/listclusterslogic.go | 56 - api/internal/logic/ai/listdatasetlogic.go | 63 - api/internal/logic/ai/listimportlogic.go | 55 - api/internal/logic/ai/listnotebooklogic.go | 57 - api/internal/logic/ai/listserviceslogic.go | 58 - .../logic/ai/mountnotebookstoragelogic.go | 44 - api/internal/logic/ai/proxyapilogic.go | 91 - .../logic/ai/showalgorithmbyuuidlogic.go | 62 - api/internal/logic/ai/showservicelogic.go | 59 - api/internal/logic/ai/startnotebooklogic.go | 44 - api/internal/logic/ai/stopnotebooklogic.go | 44 - api/internal/logic/cloud/cloudlistlogic.go | 50 - api/internal/logic/cloud/clusterinfologic.go | 30 - .../logic/cloud/commitgeneraltasklogic.go | 168 - .../logic/cloud/controllermetricslogic.go | 46 - .../logic/cloud/deleteclusterlogic.go | 37 - api/internal/logic/cloud/deleteyamllogic.go | 44 - .../logic/cloud/getclusterlistlogic.go | 30 - .../logic/cloud/listcloudclusterlogic.go | 30 - api/internal/logic/cloud/podlogslogic.go | 30 - .../logic/cloud/registerclusterlogic.go | 68 - .../logic/core/centerresourceslogic.go | 73 - api/internal/logic/core/committasklogic.go | 66 - api/internal/logic/core/commitvmtasklogic.go | 170 - .../logic/core/counttaskstatuslogic.go | 41 - api/internal/logic/core/deletetasklogic.go | 56 - .../core/getcomputilitystatisticslogic.go | 117 - .../logic/core/getcomputingpowerlogic.go | 107 - .../logic/core/getdomainresourcelogic.go | 31 - .../logic/core/getgeneralinfologic.go | 67 - .../logic/core/getpublicflavorlogic.go | 40 - .../logic/core/getpublicimagelogic.go | 40 - .../logic/core/getpublicnetworklogic.go | 39 - api/internal/logic/core/getregionlogic.go | 55 - .../logic/core/getresourcepanelconfiglogic.go | 45 - .../logic/core/getscreenchartlogic.go | 33 - api/internal/logic/core/getscreeninfologic.go | 30 - api/internal/logic/core/homeoverviewlogic.go | 73 - api/internal/logic/core/jobtotallogic.go | 114 - api/internal/logic/core/listcenterlogic.go | 100 - api/internal/logic/core/listclusterlogic.go | 76 - api/internal/logic/core/listnoticelogic.go | 36 - api/internal/logic/core/listregionlogic.go | 68 - api/internal/logic/core/metricslogic.go | 28 - api/internal/logic/core/nodeassetslogic.go | 49 - api/internal/logic/core/pagelisttasklogic.go | 75 - .../logic/core/participantlistlogic.go | 49 - api/internal/logic/core/pulltaskinfologic.go | 95 - api/internal/logic/core/pushnoticelogic.go | 31 - .../logic/core/pushresourceinfologic.go | 28 - api/internal/logic/core/pushtaskinfologic.go | 214 - .../logic/core/putresourcepanelconfiglogic.go | 53 - .../logic/core/scheduletaskbyyamllogic.go | 83 - .../logic/core/syncclusterloadlogic.go | 35 - api/internal/logic/core/taskdetailslogic.go | 60 - api/internal/logic/core/tasklistlogic.go | 175 - .../logic/dictionary/adddictitemlogic.go | 55 - api/internal/logic/dictionary/adddictlogic.go | 43 - .../logic/dictionary/deletedictitemlogic.go | 39 - .../logic/dictionary/deletedictlogic.go | 43 - .../logic/dictionary/editdictitemlogic.go | 39 - .../logic/dictionary/editdictlogic.go | 41 - .../logic/dictionary/getdictitemlogic.go | 38 - api/internal/logic/dictionary/getdictlogic.go | 38 - .../dictionary/listdictitembycodelogic.go | 60 - .../logic/dictionary/listdictitemlogic.go | 88 - .../logic/dictionary/listdictlogic.go | 59 - api/internal/logic/hpc/adaptersummarylogic.go | 37 - api/internal/logic/hpc/commithpctasklogic.go | 135 - api/internal/logic/hpc/joblogic.go | 36 - api/internal/logic/hpc/overviewlogic.go | 37 - api/internal/logic/hpc/queueassetslogic.go | 48 - api/internal/logic/hpc/resourcelogic.go | 58 - .../logic/inference/imageinferencelogic.go | 139 - .../inference/inferencetaskdetaillogic.go | 58 - .../logic/inference/modelnamesbytypelogic.go | 36 - .../logic/inference/modeltypeslogic.go | 32 - .../inference/texttotextinferencelogic.go | 150 - .../logic/monitoring/adapterinfologic.go | 31 - .../logic/monitoring/alertlistlogic.go | 62 - .../logic/monitoring/alertruleslogic.go | 40 - .../logic/monitoring/clustersloadlogic.go | 34 - .../logic/monitoring/createalertrulelogic.go | 120 - .../logic/monitoring/deletealertrulelogic.go | 66 - .../logic/monitoring/nodesloadtoplogic.go | 44 - .../monitoring/schedulesituationlogic.go | 82 - .../logic/monitoring/syncclusteralertlogic.go | 44 - api/internal/logic/monitoring/tasknumlogic.go | 33 - .../schedule/downloadalgothmcodelogic.go | 37 - .../schedule/getclusterbalancebyidlogic.go | 35 - .../schedule/getcomputecardsbyclusterlogic.go | 35 - .../schedule/schedulegetaijoblogloglogic.go | 40 - .../schedulegetairesourcetypeslogic.go | 33 - .../schedule/schedulegetaitasktypeslogic.go | 33 - .../schedule/schedulegetalgorithmslogic.go | 35 - .../schedule/schedulegetdatasetslogic.go | 37 - .../schedule/schedulegetoverviewlogic.go | 30 - .../schedule/schedulegetstrategylogic.go | 32 - .../logic/schedule/schedulesubmitlogic.go | 106 - .../logic/schedule/uploadalgothmcodelogic.go | 35 - .../logic/storage/dailypowerscreenlogic.go | 40 - .../storage/percentercomputerpowerslogic.go | 39 - .../logic/storage/screenstoragelogic.go | 61 - .../logic/storelink/deletelinkimagelogic.go | 74 - .../logic/storelink/deletelinktasklogic.go | 74 - .../logic/storelink/getaispecslogic.go | 74 - .../logic/storelink/getlinkimagelistlogic.go | 74 - .../logic/storelink/getlinktasklogic.go | 75 - .../logic/storelink/getparticipantslogic.go | 60 - .../logic/storelink/submitlinktasklogic.go | 86 - .../logic/storelink/uploadlinkimagelogic.go | 75 - .../logic/vm/addsecuritygrouptoserverlogic.go | 48 - .../logic/vm/bulkcreatenetworkslogic.go | 61 - .../vm/changeadministrativepasswordlogic.go | 48 - .../logic/vm/createfirewallgrouplogic.go | 48 - .../logic/vm/createfirewallpolicylogic.go | 48 - .../logic/vm/createfirewallrulelogic.go | 48 - api/internal/logic/vm/createflavorlogic.go | 48 - .../logic/vm/createfloatingiplogic.go | 48 - api/internal/logic/vm/createimagelogic.go | 61 - api/internal/logic/vm/createmulserverlogic.go | 82 - api/internal/logic/vm/createnetworklogic.go | 61 - .../vm/createnetworksegmentrangelogic.go | 48 - api/internal/logic/vm/createnodelogic.go | 62 - api/internal/logic/vm/createportlogic.go | 48 - api/internal/logic/vm/createrouterlogic.go | 48 - .../logic/vm/createsecuritygrouplogic.go | 48 - .../logic/vm/createsecuritygrouprulelogic.go | 48 - api/internal/logic/vm/createserverlogic.go | 61 - api/internal/logic/vm/createsubnetlogic.go | 61 - api/internal/logic/vm/createvolumelogic.go | 61 - .../logic/vm/createvolumetypeslogic.go | 62 - .../logic/vm/deletefirewallgrouplogic.go | 48 - .../logic/vm/deletefirewallpolicylogic.go | 48 - .../logic/vm/deletefirewallrulelogic.go | 48 - api/internal/logic/vm/deleteflavorlogic.go | 48 - .../logic/vm/deletefloatingiplogic.go | 48 - api/internal/logic/vm/deleteimagelogic.go | 61 - api/internal/logic/vm/deletenetworklogic.go | 61 - .../vm/deletenetworksegmentrangeslogic.go | 48 - api/internal/logic/vm/deletenodelogic.go | 62 - api/internal/logic/vm/deleteportlogic.go | 48 - api/internal/logic/vm/deleterouterlogic.go | 48 - .../logic/vm/deletesecuritygrouplogic.go | 48 - .../logic/vm/deletesecuritygrouprulelogic.go | 48 - api/internal/logic/vm/deleteserverlogic.go | 61 - api/internal/logic/vm/deletesubnetlogic.go | 48 - api/internal/logic/vm/deletevolumelogic.go | 61 - .../logic/vm/deletevolumetypelogic.go | 62 - .../logic/vm/getcomputelimitslogic.go | 60 - api/internal/logic/vm/getimagenumlogic.go | 48 - api/internal/logic/vm/getnetworknumlogic.go | 47 - .../logic/vm/getopenstackoverviewlogic.go | 35 - .../logic/vm/getserversdetailedbyidlogic.go | 62 - .../logic/vm/getvolumedetailedbyidlogic.go | 62 - api/internal/logic/vm/getvolumelimitslogic.go | 60 - .../logic/vm/listfirewallgroupslogic.go | 48 - .../logic/vm/listfirewallpolicieslogic.go | 48 - .../logic/vm/listfirewallruleslogic.go | 48 - .../logic/vm/listflavorsdetaillogic.go | 61 - api/internal/logic/vm/listfloatingipslogic.go | 48 - api/internal/logic/vm/listimageslogic.go | 61 - .../vm/listnetworksegmentrangesrangelogic.go | 48 - api/internal/logic/vm/listnetworkslogic.go | 61 - api/internal/logic/vm/listnodeslogic.go | 62 - api/internal/logic/vm/listportslogic.go | 48 - api/internal/logic/vm/listrouterslogic.go | 48 - .../logic/vm/listsecuritygroupruleslogic.go | 48 - .../logic/vm/listsecuritygroupslogic.go | 48 - api/internal/logic/vm/listserverlogic.go | 60 - .../logic/vm/listserversdetailedlogic.go | 55 - api/internal/logic/vm/listsubnetslogic.go | 48 - .../logic/vm/listvolumesdetaillogic.go | 62 - api/internal/logic/vm/listvolumeslogic.go | 62 - api/internal/logic/vm/listvolumetypeslogic.go | 61 - api/internal/logic/vm/migrateserverlogic.go | 48 - api/internal/logic/vm/pauseserverlogic.go | 62 - api/internal/logic/vm/rebootserverlogic.go | 62 - .../logic/vm/removesecuritygrouplogic.go | 48 - api/internal/logic/vm/rescueserverlogic.go | 48 - api/internal/logic/vm/resizeserverlogic.go | 48 - api/internal/logic/vm/shelveserverlogic.go | 48 - .../logic/vm/showfirewallgroupdetailslogic.go | 48 - .../vm/showfirewallpolicydetailslogic.go | 48 - .../logic/vm/showfirewallruledetailslogic.go | 48 - .../logic/vm/showfloatingipdetailslogic.go | 48 - .../logic/vm/shownetworkdetailslogic.go | 62 - .../vm/shownetworksegmentrangedetailslogic.go | 48 - api/internal/logic/vm/shownodedetailslogic.go | 62 - api/internal/logic/vm/showportdetailslogic.go | 48 - .../logic/vm/showrouterdetailslogic.go | 48 - .../logic/vm/showsecuritygrouplogic.go | 48 - .../logic/vm/showsecuritygrouprulelogic.go | 48 - api/internal/logic/vm/startserverlogic.go | 62 - api/internal/logic/vm/stopserverlogic.go | 62 - api/internal/logic/vm/suspendserverlogic.go | 48 - api/internal/logic/vm/unpauseserverlogic.go | 48 - api/internal/logic/vm/unrescuelogic.go | 48 - .../logic/vm/updatefirewallgrouplogic.go | 48 - .../logic/vm/updatefloatingiplogic.go | 48 - api/internal/logic/vm/updatenetworklogic.go | 63 - .../vm/updatenetworksegmentrangeslogic.go | 48 - api/internal/logic/vm/updateportlogic.go | 48 - api/internal/logic/vm/updaterouterlogic.go | 48 - .../logic/vm/updatesecuritygrouplogic.go | 48 - api/internal/logic/vm/updateserverlogic.go | 62 - api/internal/logic/vm/updatesubnetlogic.go | 48 - api/internal/logic/vm/updatevolumelogic.go | 62 - api/internal/logic/vm/uploadimagelogic.go | 61 - api/internal/mqs/ScheduleAi.go | 49 - api/internal/mqs/ScheduleCloud.go | 63 - api/internal/mqs/ScheduleHpc.go | 40 - api/internal/mqs/ScheduleVm.go | 49 - api/internal/scheduler/database/aiStorage.go | 368 -- .../scheduler/database/cloudStorage.go | 34 - api/internal/scheduler/database/storage.go | 13 - api/internal/scheduler/scheduler.go | 172 - .../scheduler/schedulers/aiScheduler.go | 388 -- .../scheduler/schedulers/cloudScheduler.go | 190 - .../scheduler/schedulers/hpcScheduler.go | 55 - .../scheduler/schedulers/vmScheduler.go | 151 - api/internal/scheduler/service/aiService.go | 110 - .../scheduler/service/collector/collector.go | 67 - .../scheduler/service/executor/aiExecutor.go | 10 - .../scheduler/service/inference/imageInfer.go | 396 -- .../service/status/taskStatusSync.go | 337 -- .../scheduler/strategy/dynamicResources.go | 75 - .../scheduler/strategy/param/params.go | 9 - .../strategy/param/resourcePricing.go | 34 - .../scheduler/strategy/resourcePricing.go | 167 - .../scheduler/strategy/staticWeight.go | 50 - .../scheduler/strategy/test/strategy_test.go | 251 -- api/internal/storeLink/modelarts.go | 399 -- api/internal/storeLink/octopus.go | 904 ---- api/internal/storeLink/shuguangHpc.go | 268 -- api/internal/storeLink/shuguangai.go | 753 ---- api/internal/storeLink/storeLink.go | 1035 ----- api/internal/svc/servicecontext.go | 144 - api/pcm.go | 63 - {api/client => client}/client.go | 0 {api/client => client}/client_impl.go | 0 {api/client => client}/notice.go | 0 {api/client => client}/notice_impl.go | 0 {api/client => client}/task.go | 0 {api/client => client}/task_impl.go | 0 {api/client => client}/types.go | 0 {api => deploy}/pcm-coordinator-api.yaml | 0 {api/desc => desc}/ai/pcm-ai.api | 0 {api/desc => desc}/cloud/pcm-cloud.api | 0 {api/desc => desc}/core/pcm-core.api | 0 {api/desc => desc}/hpc/pcm-hpc.api | 0 {api/desc => desc}/inference/inference.api | 0 .../monitoring/pcm-monitoring.api | 0 {api/desc => desc}/pcm.api | 0 {api/desc => desc}/pcm.json | 0 {api/desc => desc}/schedule/pcm-schedule.api | 0 {api/desc => desc}/storage/pcm-storage.api | 0 .../desc => desc}/storelink/pcm-storelink.api | 0 {api/desc => desc}/vm/pcm-vm.api | 0 etc/pcm.yaml | 85 + examples/ai/modelArts.yaml | 10 - examples/cloud/nginx.yaml | 72 - examples/hpc/ac.yaml | 19 - examples/hpc/th.yaml | 8 - go.mod | 4 +- {api/internal => internal}/config/config.go | 0 internal/cron/aiCronTask.go | 250 ++ internal/cron/cron.go | 42 + .../handler/adapters/adapterslisthandler.go | 24 + .../handler/adapters/clusterlisthandler.go | 24 + .../handler/adapters/createadapterhandler.go | 24 + .../handler/adapters/createclusterhandler.go | 24 + .../handler/adapters/deleteadapterhandler.go | 24 + .../handler/adapters/deleteclusterhandler.go | 24 + .../handler/adapters/getadapterhandler.go | 24 + .../adapters/getadapterrelationhandler.go | 24 + .../handler/adapters/getclusterhandler.go | 24 + .../handler/adapters/getclustersumhandler.go | 24 + .../handler/adapters/updateadapterhandler.go | 24 + .../handler/adapters/updateclusterhandler.go | 24 + internal/handler/ai/createalgorithmhandler.go | 24 + internal/handler/ai/createdatasethandler.go | 24 + .../handler/ai/createexporttaskhandler.go | 24 + internal/handler/ai/createnotebookhandler.go | 24 + .../handler/ai/createprocessortaskhandler.go | 24 + internal/handler/ai/createservicehandler.go | 24 + internal/handler/ai/createtaskhandler.go | 24 + .../handler/ai/createtrainingjobhandler.go | 24 + .../ai/createvisualizationjobhandler.go | 24 + internal/handler/ai/deletealgorithmhandler.go | 24 + internal/handler/ai/deletedatasethandler.go | 24 + internal/handler/ai/deleteservicehandler.go | 24 + .../handler/ai/deletetrainingjobhandler.go | 24 + internal/handler/ai/getcenterlisthandler.go | 21 + .../handler/ai/getcenteroverviewhandler.go | 21 + .../handler/ai/getcenterqueueinghandler.go | 21 + .../handler/ai/getcentertasklisthandler.go | 21 + .../ai/getexporttasksofdatasethandler.go | 24 + .../ai/getexporttaskstatusofdatasethandler.go | 24 + .../handler/ai/getlisttrainingjobshandler.go | 24 + .../handler/ai/getnotebookstoragehandler.go | 24 + .../handler/ai/getvisualizationjobhandler.go | 24 + internal/handler/ai/listalgorithmshandler.go | 24 + internal/handler/ai/listclustershandler.go | 24 + internal/handler/ai/listdatasethandler.go | 24 + internal/handler/ai/listimporthandler.go | 24 + internal/handler/ai/listnotebookhandler.go | 24 + internal/handler/ai/listserviceshandler.go | 24 + .../handler/ai/mountnotebookstoragehandler.go | 24 + internal/handler/ai/proxyapihandler.go | 24 + .../handler/ai/showalgorithmbyuuidhandler.go | 24 + internal/handler/ai/showservicehandler.go | 24 + internal/handler/ai/startnotebookhandler.go | 24 + internal/handler/ai/stopnotebookhandler.go | 24 + internal/handler/cloud/cloudlisthandler.go | 16 + internal/handler/cloud/clusterinfohandler.go | 25 + .../handler/cloud/commitgeneraltaskhandler.go | 24 + .../handler/cloud/controllermetricshandler.go | 24 + .../handler/cloud/deleteclusterhandler.go | 24 + internal/handler/cloud/deleteyamlhandler.go | 24 + .../handler/cloud/getclusterlisthandler.go | 24 + internal/handler/cloud/podlogshandler.go | 24 + .../handler/cloud/registerclusterhandler.go | 24 + .../handler/core/centerresourceshandler.go | 16 + internal/handler/core/committaskhandler.go | 24 + internal/handler/core/commitvmtaskhandler.go | 24 + .../handler/core/counttaskstatushandler.go | 16 + internal/handler/core/deletetaskhandler.go | 24 + .../core/getcomputilitystatisticshandler.go | 16 + .../handler/core/getcomputingpowerhandler.go | 16 + .../handler/core/getdomainresourcehandler.go | 17 + .../handler/core/getgeneralinfohandler.go | 16 + .../handler/core/getpublicflavorhandler.go | 28 + .../handler/core/getpublicimagehandler.go | 28 + .../handler/core/getpublicnetworkhandler.go | 28 + internal/handler/core/getregionhandler.go | 16 + .../core/getresourcepanelconfighandler.go | 16 + .../handler/core/getscreencharthandler.go | 17 + internal/handler/core/getscreeninfohandler.go | 17 + internal/handler/core/homeoverviewhandler.go | 28 + internal/handler/core/jobtotalhandler.go | 16 + internal/handler/core/listcenterhandler.go | 16 + internal/handler/core/listclusterhandler.go | 24 + internal/handler/core/listnoticehandler.go | 28 + internal/handler/core/listregionhandler.go | 16 + internal/handler/core/metricshandler.go | 11 + internal/handler/core/nodeassetshandler.go | 16 + internal/handler/core/pagelisttaskhandler.go | 24 + .../handler/core/participantlisthandler.go | 16 + internal/handler/core/pulltaskinfohandler.go | 28 + internal/handler/core/pushnoticehandler.go | 28 + .../handler/core/pushresourceinfohandler.go | 28 + internal/handler/core/pushtaskinfohandler.go | 28 + .../core/putresourcepanelconfighandler.go | 24 + .../handler/core/scheduletaskbyyamlhandler.go | 36 + .../handler/core/syncclusterloadhandler.go | 24 + internal/handler/core/taskdetailshandler.go | 24 + internal/handler/core/tasklisthandler.go | 24 + internal/handler/dictionary/adddicthandler.go | 24 + .../handler/dictionary/adddictitemhandler.go | 24 + .../handler/dictionary/deletedicthandler.go | 24 + .../dictionary/deletedictitemhandler.go | 24 + .../handler/dictionary/editdicthandler.go | 24 + .../handler/dictionary/editdictitemhandler.go | 24 + internal/handler/dictionary/getdicthandler.go | 24 + .../handler/dictionary/getdictitemhandler.go | 24 + .../handler/dictionary/listdicthandler.go | 24 + .../dictionary/listdictitembycodehandler.go | 24 + .../handler/dictionary/listdictitemhandler.go | 24 + internal/handler/hpc/adaptersummaryhandler.go | 28 + internal/handler/hpc/commithpctaskhandler.go | 24 + internal/handler/hpc/jobhandler.go | 28 + internal/handler/hpc/overviewhandler.go | 28 + internal/handler/hpc/queueassetshandler.go | 16 + internal/handler/hpc/resourcehandler.go | 28 + .../inference/imageinferencehandler.go | 24 + .../inference/inferencetaskdetailhandler.go | 28 + .../inference/modelnamesbytypehandler.go | 25 + .../handler/inference/modeltypeshandler.go | 16 + .../inference/texttotextinferencehandler.go | 25 + .../handler/monitoring/adapterinfohandler.go | 25 + .../handler/monitoring/alertlisthandler.go | 25 + .../handler/monitoring/alertruleshandler.go | 25 + .../handler/monitoring/clustersloadhandler.go | 25 + .../monitoring/createalertrulehandler.go | 25 + .../monitoring/deletealertrulehandler.go | 25 + .../handler/monitoring/nodesloadtophandler.go | 25 + .../monitoring/schedulesituationhandler.go | 17 + .../monitoring/syncclusteralerthandler.go | 28 + internal/handler/monitoring/tasknumhandler.go | 25 + internal/handler/routes.go | 1306 ++++++ .../schedule/downloadalgothmcodehandler.go | 25 + .../schedule/getclusterbalancebyidhandler.go | 26 + .../getcomputecardsbyclusterhandler.go | 28 + .../schedule/schedulegetaijoblogloghandler.go | 28 + .../schedulegetairesourcetypeshandler.go | 16 + .../schedule/schedulegetaitasktypeshandler.go | 16 + .../schedule/schedulegetalgorithmshandler.go | 24 + .../schedule/schedulegetdatasetshandler.go | 24 + .../schedule/schedulegetoverviewhandler.go | 21 + .../schedule/schedulegetstrategyhandler.go | 16 + .../handler/schedule/schedulesubmithandler.go | 24 + .../schedule/uploadalgothmcodehandler.go | 25 + .../storage/dailypowerscreenhandler.go | 17 + .../storage/percentercomputerpowershandler.go | 17 + .../handler/storage/screenstoragehandler.go | 24 + .../storelink/deletelinkimagehandler.go | 28 + .../storelink/deletelinktaskhandler.go | 28 + .../handler/storelink/getaispecshandler.go | 28 + .../storelink/getlinkimagelisthandler.go | 28 + .../handler/storelink/getlinktaskhandler.go | 28 + .../storelink/getparticipantshandler.go | 28 + .../storelink/submitlinktaskhandler.go | 28 + .../storelink/uploadlinkimagehandler.go | 28 + .../vm/addsecuritygrouptoserverhandler.go | 28 + .../handler/vm/bulkcreatenetworkshandler.go | 28 + .../vm/changeadministrativepasswordhandler.go | 28 + .../handler/vm/createfirewallgrouphandler.go | 28 + .../handler/vm/createfirewallpolicyhandler.go | 28 + .../handler/vm/createfirewallrulehandler.go | 28 + internal/handler/vm/createflavorhandler.go | 28 + .../handler/vm/createfloatingiphandler.go | 28 + internal/handler/vm/createimagehandler.go | 28 + internal/handler/vm/createmulserverhandler.go | 28 + internal/handler/vm/createnetworkhandler.go | 28 + .../vm/createnetworksegmentrangehandler.go | 28 + internal/handler/vm/createnodehandler.go | 28 + internal/handler/vm/createporthandler.go | 28 + internal/handler/vm/createrouterhandler.go | 28 + .../handler/vm/createsecuritygrouphandler.go | 28 + .../vm/createsecuritygrouprulehandler.go | 28 + internal/handler/vm/createserverhandler.go | 28 + internal/handler/vm/createsubnethandler.go | 28 + internal/handler/vm/createvolumehandler.go | 28 + .../handler/vm/createvolumetypeshandler.go | 28 + .../handler/vm/deletefirewallgrouphandler.go | 28 + .../handler/vm/deletefirewallpolicyhandler.go | 28 + .../handler/vm/deletefirewallrulehandler.go | 28 + internal/handler/vm/deleteflavorhandler.go | 28 + .../handler/vm/deletefloatingiphandler.go | 28 + internal/handler/vm/deleteimagehandler.go | 28 + internal/handler/vm/deletenetworkhandler.go | 28 + .../vm/deletenetworksegmentrangeshandler.go | 28 + internal/handler/vm/deletenodehandler.go | 28 + internal/handler/vm/deleteporthandler.go | 28 + internal/handler/vm/deleterouterhandler.go | 28 + .../handler/vm/deletesecuritygrouphandler.go | 28 + .../vm/deletesecuritygrouprulehandler.go | 28 + internal/handler/vm/deleteserverhandler.go | 28 + internal/handler/vm/deletesubnethandler.go | 28 + internal/handler/vm/deletevolumehandler.go | 28 + .../handler/vm/deletevolumetypehandler.go | 28 + .../handler/vm/getcomputelimitshandler.go | 28 + internal/handler/vm/getimagenumhandler.go | 28 + internal/handler/vm/getnetworknumhandler.go | 28 + .../handler/vm/getopenstackoverviewhandler.go | 28 + .../vm/getserversdetailedbyidhandler.go | 28 + .../vm/getvolumedetailedbyidhandler.go | 28 + internal/handler/vm/getvolumelimitshandler.go | 28 + .../handler/vm/listfirewallgroupshandler.go | 28 + .../handler/vm/listfirewallpolicieshandler.go | 28 + .../handler/vm/listfirewallruleshandler.go | 28 + .../handler/vm/listflavorsdetailhandler.go | 28 + internal/handler/vm/listfloatingipshandler.go | 28 + internal/handler/vm/listimageshandler.go | 28 + .../listnetworksegmentrangesrangehandler.go | 28 + internal/handler/vm/listnetworkshandler.go | 28 + internal/handler/vm/listnodeshandler.go | 28 + internal/handler/vm/listportshandler.go | 28 + internal/handler/vm/listroutershandler.go | 28 + .../vm/listsecuritygroupruleshandler.go | 28 + .../handler/vm/listsecuritygroupshandler.go | 28 + internal/handler/vm/listserverhandler.go | 28 + .../handler/vm/listserversdetailedhandler.go | 28 + internal/handler/vm/listsubnetshandler.go | 28 + .../handler/vm/listvolumesdetailhandler.go | 28 + internal/handler/vm/listvolumeshandler.go | 28 + internal/handler/vm/listvolumetypeshandler.go | 28 + internal/handler/vm/migrateserverhandler.go | 28 + internal/handler/vm/pauseserverhandler.go | 28 + internal/handler/vm/rebootserverhandler.go | 28 + .../handler/vm/removesecuritygrouphandler.go | 28 + internal/handler/vm/rescueserverhandler.go | 28 + internal/handler/vm/resizeserverhandler.go | 28 + internal/handler/vm/shelveserverhandler.go | 28 + .../vm/showfirewallgroupdetailshandler.go | 28 + .../vm/showfirewallpolicydetailshandler.go | 28 + .../vm/showfirewallruledetailshandler.go | 28 + .../vm/showfloatingipdetailshandler.go | 28 + .../handler/vm/shownetworkdetailshandler.go | 28 + .../shownetworksegmentrangedetailshandler.go | 28 + internal/handler/vm/shownodedetailshandler.go | 28 + internal/handler/vm/showportdetailshandler.go | 28 + .../handler/vm/showrouterdetailshandler.go | 28 + .../handler/vm/showsecuritygrouphandler.go | 28 + .../vm/showsecuritygrouprulehandler.go | 28 + internal/handler/vm/startserverhandler.go | 28 + internal/handler/vm/stopserverhandler.go | 28 + internal/handler/vm/suspendserverhandler.go | 28 + internal/handler/vm/unpauseserverhandler.go | 28 + internal/handler/vm/unrescuehandler.go | 28 + .../handler/vm/updatefirewallgrouphandler.go | 28 + .../handler/vm/updatefloatingiphandler.go | 28 + internal/handler/vm/updatenetworkhandler.go | 28 + .../vm/updatenetworksegmentrangeshandler.go | 28 + internal/handler/vm/updateporthandler.go | 28 + internal/handler/vm/updaterouterhandler.go | 28 + .../handler/vm/updatesecuritygrouphandler.go | 28 + internal/handler/vm/updateserverhandler.go | 28 + internal/handler/vm/updatesubnethandler.go | 28 + internal/handler/vm/updatevolumehandler.go | 28 + internal/handler/vm/uploadimagehandler.go | 28 + internal/logic/adapters/adapterslistlogic.go | 59 + internal/logic/adapters/clusterlistlogic.go | 80 + internal/logic/adapters/createadapterlogic.go | 67 + internal/logic/adapters/createclusterlogic.go | 66 + internal/logic/adapters/deleteadapterlogic.go | 44 + internal/logic/adapters/deleteclusterlogic.go | 39 + internal/logic/adapters/getadapterlogic.go | 35 + .../logic/adapters/getadapterrelationlogic.go | 89 + internal/logic/adapters/getclusterlogic.go | 36 + internal/logic/adapters/getclustersumlogic.go | 67 + internal/logic/adapters/updateadapterlogic.go | 38 + internal/logic/adapters/updateclusterlogic.go | 38 + internal/logic/ai/createalgorithmlogic.go | 57 + internal/logic/ai/createdatasetlogic.go | 58 + internal/logic/ai/createexporttasklogic.go | 61 + internal/logic/ai/createnotebooklogic.go | 56 + internal/logic/ai/createprocessortasklogic.go | 56 + internal/logic/ai/createservicelogic.go | 58 + internal/logic/ai/createtasklogic.go | 60 + internal/logic/ai/createtrainingjoblogic.go | 60 + .../logic/ai/createvisualizationjoblogic.go | 44 + internal/logic/ai/deletealgorithmlogic.go | 67 + internal/logic/ai/deletedatasetlogic.go | 61 + internal/logic/ai/deleteservicelogic.go | 59 + internal/logic/ai/deletetrainingjoblogic.go | 58 + internal/logic/ai/getcenterlistlogic.go | 43 + internal/logic/ai/getcenteroverviewlogic.go | 164 + internal/logic/ai/getcenterqueueinglogic.go | 73 + internal/logic/ai/getcentertasklistlogic.go | 136 + .../logic/ai/getexporttasksofdatasetlogic.go | 60 + .../ai/getexporttaskstatusofdatasetlogic.go | 59 + internal/logic/ai/getlisttrainingjobslogic.go | 104 + internal/logic/ai/getnotebookstoragelogic.go | 44 + internal/logic/ai/getvisualizationjoblogic.go | 44 + internal/logic/ai/listalgorithmslogic.go | 59 + internal/logic/ai/listclusterslogic.go | 56 + internal/logic/ai/listdatasetlogic.go | 63 + internal/logic/ai/listimportlogic.go | 55 + internal/logic/ai/listnotebooklogic.go | 57 + internal/logic/ai/listserviceslogic.go | 58 + .../logic/ai/mountnotebookstoragelogic.go | 44 + internal/logic/ai/proxyapilogic.go | 91 + internal/logic/ai/showalgorithmbyuuidlogic.go | 62 + internal/logic/ai/showservicelogic.go | 59 + internal/logic/ai/startnotebooklogic.go | 44 + internal/logic/ai/stopnotebooklogic.go | 44 + internal/logic/cloud/cloudlistlogic.go | 50 + internal/logic/cloud/clusterinfologic.go | 30 + .../logic/cloud/commitgeneraltasklogic.go | 168 + .../logic/cloud/controllermetricslogic.go | 46 + internal/logic/cloud/deleteclusterlogic.go | 37 + internal/logic/cloud/deleteyamllogic.go | 44 + internal/logic/cloud/getclusterlistlogic.go | 30 + internal/logic/cloud/listcloudclusterlogic.go | 30 + internal/logic/cloud/podlogslogic.go | 30 + internal/logic/cloud/registerclusterlogic.go | 68 + internal/logic/core/centerresourceslogic.go | 73 + internal/logic/core/committasklogic.go | 66 + internal/logic/core/commitvmtasklogic.go | 170 + internal/logic/core/counttaskstatuslogic.go | 41 + internal/logic/core/deletetasklogic.go | 56 + .../core/getcomputilitystatisticslogic.go | 117 + internal/logic/core/getcomputingpowerlogic.go | 107 + internal/logic/core/getdomainresourcelogic.go | 31 + internal/logic/core/getgeneralinfologic.go | 67 + internal/logic/core/getpublicflavorlogic.go | 40 + internal/logic/core/getpublicimagelogic.go | 40 + internal/logic/core/getpublicnetworklogic.go | 39 + internal/logic/core/getregionlogic.go | 55 + .../logic/core/getresourcepanelconfiglogic.go | 45 + internal/logic/core/getscreenchartlogic.go | 33 + internal/logic/core/getscreeninfologic.go | 30 + internal/logic/core/homeoverviewlogic.go | 73 + internal/logic/core/jobtotallogic.go | 114 + internal/logic/core/listcenterlogic.go | 100 + internal/logic/core/listclusterlogic.go | 76 + internal/logic/core/listnoticelogic.go | 36 + internal/logic/core/listregionlogic.go | 68 + internal/logic/core/metricslogic.go | 28 + internal/logic/core/nodeassetslogic.go | 49 + internal/logic/core/pagelisttasklogic.go | 75 + internal/logic/core/participantlistlogic.go | 49 + internal/logic/core/pulltaskinfologic.go | 95 + internal/logic/core/pushnoticelogic.go | 31 + internal/logic/core/pushresourceinfologic.go | 28 + internal/logic/core/pushtaskinfologic.go | 214 + .../logic/core/putresourcepanelconfiglogic.go | 53 + .../logic/core/scheduletaskbyyamllogic.go | 83 + internal/logic/core/syncclusterloadlogic.go | 35 + internal/logic/core/taskdetailslogic.go | 60 + internal/logic/core/tasklistlogic.go | 175 + internal/logic/dictionary/adddictitemlogic.go | 55 + internal/logic/dictionary/adddictlogic.go | 43 + .../logic/dictionary/deletedictitemlogic.go | 39 + internal/logic/dictionary/deletedictlogic.go | 43 + .../logic/dictionary/editdictitemlogic.go | 39 + internal/logic/dictionary/editdictlogic.go | 41 + internal/logic/dictionary/getdictitemlogic.go | 38 + internal/logic/dictionary/getdictlogic.go | 38 + .../dictionary/listdictitembycodelogic.go | 60 + .../logic/dictionary/listdictitemlogic.go | 88 + internal/logic/dictionary/listdictlogic.go | 59 + internal/logic/hpc/adaptersummarylogic.go | 37 + internal/logic/hpc/commithpctasklogic.go | 135 + internal/logic/hpc/joblogic.go | 36 + internal/logic/hpc/overviewlogic.go | 37 + internal/logic/hpc/queueassetslogic.go | 48 + internal/logic/hpc/resourcelogic.go | 58 + .../logic/inference/imageinferencelogic.go | 139 + .../inference/inferencetaskdetaillogic.go | 58 + .../logic/inference/modelnamesbytypelogic.go | 36 + internal/logic/inference/modeltypeslogic.go | 32 + .../inference/texttotextinferencelogic.go | 150 + internal/logic/monitoring/adapterinfologic.go | 31 + internal/logic/monitoring/alertlistlogic.go | 62 + internal/logic/monitoring/alertruleslogic.go | 40 + .../logic/monitoring/clustersloadlogic.go | 34 + .../logic/monitoring/createalertrulelogic.go | 120 + .../logic/monitoring/deletealertrulelogic.go | 66 + .../logic/monitoring/nodesloadtoplogic.go | 44 + .../monitoring/schedulesituationlogic.go | 82 + .../logic/monitoring/syncclusteralertlogic.go | 44 + internal/logic/monitoring/tasknumlogic.go | 33 + .../schedule/downloadalgothmcodelogic.go | 37 + .../schedule/getclusterbalancebyidlogic.go | 35 + .../schedule/getcomputecardsbyclusterlogic.go | 35 + .../schedule/schedulegetaijoblogloglogic.go | 40 + .../schedulegetairesourcetypeslogic.go | 33 + .../schedule/schedulegetaitasktypeslogic.go | 33 + .../schedule/schedulegetalgorithmslogic.go | 35 + .../schedule/schedulegetdatasetslogic.go | 37 + .../schedule/schedulegetoverviewlogic.go | 30 + .../schedule/schedulegetstrategylogic.go | 32 + .../logic/schedule/schedulesubmitlogic.go | 106 + .../logic/schedule/uploadalgothmcodelogic.go | 35 + .../logic/storage/dailypowerscreenlogic.go | 40 + .../storage/percentercomputerpowerslogic.go | 39 + internal/logic/storage/screenstoragelogic.go | 61 + .../logic/storelink/deletelinkimagelogic.go | 74 + .../logic/storelink/deletelinktasklogic.go | 74 + internal/logic/storelink/getaispecslogic.go | 74 + .../logic/storelink/getlinkimagelistlogic.go | 74 + internal/logic/storelink/getlinktasklogic.go | 75 + .../logic/storelink/getparticipantslogic.go | 60 + .../logic/storelink/submitlinktasklogic.go | 86 + .../logic/storelink/uploadlinkimagelogic.go | 75 + .../logic/vm/addsecuritygrouptoserverlogic.go | 48 + internal/logic/vm/bulkcreatenetworkslogic.go | 61 + .../vm/changeadministrativepasswordlogic.go | 48 + internal/logic/vm/createfirewallgrouplogic.go | 48 + .../logic/vm/createfirewallpolicylogic.go | 48 + internal/logic/vm/createfirewallrulelogic.go | 48 + internal/logic/vm/createflavorlogic.go | 48 + internal/logic/vm/createfloatingiplogic.go | 48 + internal/logic/vm/createimagelogic.go | 61 + internal/logic/vm/createmulserverlogic.go | 82 + internal/logic/vm/createnetworklogic.go | 61 + .../vm/createnetworksegmentrangelogic.go | 48 + internal/logic/vm/createnodelogic.go | 62 + internal/logic/vm/createportlogic.go | 48 + internal/logic/vm/createrouterlogic.go | 48 + internal/logic/vm/createsecuritygrouplogic.go | 48 + .../logic/vm/createsecuritygrouprulelogic.go | 48 + internal/logic/vm/createserverlogic.go | 61 + internal/logic/vm/createsubnetlogic.go | 61 + internal/logic/vm/createvolumelogic.go | 61 + internal/logic/vm/createvolumetypeslogic.go | 62 + internal/logic/vm/deletefirewallgrouplogic.go | 48 + .../logic/vm/deletefirewallpolicylogic.go | 48 + internal/logic/vm/deletefirewallrulelogic.go | 48 + internal/logic/vm/deleteflavorlogic.go | 48 + internal/logic/vm/deletefloatingiplogic.go | 48 + internal/logic/vm/deleteimagelogic.go | 61 + internal/logic/vm/deletenetworklogic.go | 61 + .../vm/deletenetworksegmentrangeslogic.go | 48 + internal/logic/vm/deletenodelogic.go | 62 + internal/logic/vm/deleteportlogic.go | 48 + internal/logic/vm/deleterouterlogic.go | 48 + internal/logic/vm/deletesecuritygrouplogic.go | 48 + .../logic/vm/deletesecuritygrouprulelogic.go | 48 + internal/logic/vm/deleteserverlogic.go | 61 + internal/logic/vm/deletesubnetlogic.go | 48 + internal/logic/vm/deletevolumelogic.go | 61 + internal/logic/vm/deletevolumetypelogic.go | 62 + internal/logic/vm/getcomputelimitslogic.go | 60 + internal/logic/vm/getimagenumlogic.go | 48 + internal/logic/vm/getnetworknumlogic.go | 47 + .../logic/vm/getopenstackoverviewlogic.go | 35 + .../logic/vm/getserversdetailedbyidlogic.go | 62 + .../logic/vm/getvolumedetailedbyidlogic.go | 62 + internal/logic/vm/getvolumelimitslogic.go | 60 + internal/logic/vm/listfirewallgroupslogic.go | 48 + .../logic/vm/listfirewallpolicieslogic.go | 48 + internal/logic/vm/listfirewallruleslogic.go | 48 + internal/logic/vm/listflavorsdetaillogic.go | 61 + internal/logic/vm/listfloatingipslogic.go | 48 + internal/logic/vm/listimageslogic.go | 61 + .../vm/listnetworksegmentrangesrangelogic.go | 48 + internal/logic/vm/listnetworkslogic.go | 61 + internal/logic/vm/listnodeslogic.go | 62 + internal/logic/vm/listportslogic.go | 48 + internal/logic/vm/listrouterslogic.go | 48 + .../logic/vm/listsecuritygroupruleslogic.go | 48 + internal/logic/vm/listsecuritygroupslogic.go | 48 + internal/logic/vm/listserverlogic.go | 60 + internal/logic/vm/listserversdetailedlogic.go | 55 + internal/logic/vm/listsubnetslogic.go | 48 + internal/logic/vm/listvolumesdetaillogic.go | 62 + internal/logic/vm/listvolumeslogic.go | 62 + internal/logic/vm/listvolumetypeslogic.go | 61 + internal/logic/vm/migrateserverlogic.go | 48 + internal/logic/vm/pauseserverlogic.go | 62 + internal/logic/vm/rebootserverlogic.go | 62 + internal/logic/vm/removesecuritygrouplogic.go | 48 + internal/logic/vm/rescueserverlogic.go | 48 + internal/logic/vm/resizeserverlogic.go | 48 + internal/logic/vm/shelveserverlogic.go | 48 + .../logic/vm/showfirewallgroupdetailslogic.go | 48 + .../vm/showfirewallpolicydetailslogic.go | 48 + .../logic/vm/showfirewallruledetailslogic.go | 48 + .../logic/vm/showfloatingipdetailslogic.go | 48 + internal/logic/vm/shownetworkdetailslogic.go | 62 + .../vm/shownetworksegmentrangedetailslogic.go | 48 + internal/logic/vm/shownodedetailslogic.go | 62 + internal/logic/vm/showportdetailslogic.go | 48 + internal/logic/vm/showrouterdetailslogic.go | 48 + internal/logic/vm/showsecuritygrouplogic.go | 48 + .../logic/vm/showsecuritygrouprulelogic.go | 48 + internal/logic/vm/startserverlogic.go | 62 + internal/logic/vm/stopserverlogic.go | 62 + internal/logic/vm/suspendserverlogic.go | 48 + internal/logic/vm/unpauseserverlogic.go | 48 + internal/logic/vm/unrescuelogic.go | 48 + internal/logic/vm/updatefirewallgrouplogic.go | 48 + internal/logic/vm/updatefloatingiplogic.go | 48 + internal/logic/vm/updatenetworklogic.go | 63 + .../vm/updatenetworksegmentrangeslogic.go | 48 + internal/logic/vm/updateportlogic.go | 48 + internal/logic/vm/updaterouterlogic.go | 48 + internal/logic/vm/updatesecuritygrouplogic.go | 48 + internal/logic/vm/updateserverlogic.go | 62 + internal/logic/vm/updatesubnetlogic.go | 48 + internal/logic/vm/updatevolumelogic.go | 62 + internal/logic/vm/uploadimagelogic.go | 61 + internal/mqs/ScheduleAi.go | 49 + internal/mqs/ScheduleCloud.go | 63 + internal/mqs/ScheduleHpc.go | 40 + internal/mqs/ScheduleVm.go | 49 + {api/internal => internal}/mqs/queue.go | 0 .../algorithm/providerPricing/pricing.go | 0 .../algorithm/providerPricing/provider.go | 0 .../algorithm/providerPricing/strategy.go | 0 .../algorithm/providerPricing/task.go | 0 .../weightDistributing/weightDistributing.go | 0 .../scheduler/common/common.go | 0 internal/scheduler/database/aiStorage.go | 368 ++ internal/scheduler/database/cloudStorage.go | 34 + internal/scheduler/database/storage.go | 13 + .../scheduler/entity/entity.go | 0 internal/scheduler/scheduler.go | 170 + internal/scheduler/schedulers/aiScheduler.go | 388 ++ .../scheduler/schedulers/cloudScheduler.go | 190 + internal/scheduler/schedulers/hpcScheduler.go | 55 + .../scheduler/schedulers/option/aiOption.go | 0 .../schedulers/option/cloudOption.go | 0 .../schedulers/option/inferOption.go | 0 .../scheduler/schedulers/option/option.go | 0 .../scheduler/schedulers/option/vmOption.go | 0 internal/scheduler/schedulers/vmScheduler.go | 151 + internal/scheduler/service/aiService.go | 110 + .../scheduler/service/collector/collector.go | 67 + .../scheduler/service/executor/aiExecutor.go | 10 + .../scheduler/service/inference/imageInfer.go | 396 ++ .../service/status/taskStatusSync.go | 337 ++ .../scheduler/strategy/dynamicResources.go | 75 + internal/scheduler/strategy/param/params.go | 9 + .../strategy/param/resourcePricing.go | 34 + .../scheduler/strategy/random.go | 0 .../scheduler/strategy/replication.go | 0 .../scheduler/strategy/resourcePricing.go | 167 + .../scheduler/strategy/singleAssignment.go | 0 internal/scheduler/strategy/staticWeight.go | 50 + .../scheduler/strategy/strategy.go | 0 .../scheduler/strategy/test/strategy_test.go | 251 ++ internal/storeLink/modelarts.go | 399 ++ internal/storeLink/octopus.go | 904 ++++ internal/storeLink/shuguangHpc.go | 268 ++ internal/storeLink/shuguangai.go | 753 ++++ internal/storeLink/storeLink.go | 1035 +++++ internal/svc/servicecontext.go | 141 + {api/internal => internal}/types/types.go | 0 pcm.go | 63 + {api/pkg => pkg}/response/TaskInfo.go | 0 rpc/Dockerfile | 30 - rpc/Makefile | 9 - .../participantservice/participantservice.go | 162 - rpc/client/pcmcore/pcmcore.go | 74 - rpc/etc/pcmcore.yaml | 24 - rpc/internal/config/config.go | 36 - .../participantservice/applylistlogic.go | 35 - .../participantservice/deletelistlogic.go | 36 - .../listparticipantlogic.go | 73 - .../listphyavailablelogic.go | 49 - .../listphyinformationlogic.go | 50 - .../participantservice/listtenantlogic.go | 51 - .../participantservice/pauselistlogic.go | 36 - .../registerparticipantlogic.go | 125 - .../participantservice/registertenantlogic.go | 58 - .../reportavailablelogic.go | 110 - .../reportheartbeatlogic.go | 64 - .../participantservice/restartlistlogic.go | 36 - .../participantservice/startlistlogic.go | 36 - rpc/internal/logic/pcmcore/infolistlogic.go | 72 - rpc/internal/logic/pcmcore/syncinfologic.go | 129 - .../participantserviceserver.go | 101 - rpc/internal/server/pcmcore/pcmcoreserver.go | 35 - rpc/internal/svc/servicecontext.go | 68 - rpc/pb/pcmCore.proto | 345 -- rpc/pcm-coordinator-rpc.yaml | 64 - rpc/pcmCore/pcmCore.pb.go | 3627 ----------------- rpc/pcmCore/pcmCore_grpc.pb.go | 710 ---- rpc/pcmcore.go | 58 - .../grpc/reflection/README.md | 18 - .../grpc/reflection/adapt.go | 57 - .../grpc_reflection_v1/reflection.pb.go | 953 ----- .../grpc_reflection_v1/reflection_grpc.pb.go | 165 - .../grpc_reflection_v1alpha/reflection.pb.go | 1028 ----- .../reflection_grpc.pb.go | 162 - .../grpc/reflection/internal/internal.go | 436 -- .../grpc/reflection/serverreflection.go | 160 - vendor/modules.txt | 4 - 1128 files changed, 28584 insertions(+), 37993 deletions(-) rename api/Dockerfile => Dockerfile (100%) delete mode 100644 api/Makefile delete mode 100644 api/etc/pcm.yaml delete mode 100644 api/internal/cron/aiCronTask.go delete mode 100644 api/internal/cron/cron.go delete mode 100644 api/internal/handler/adapters/adapterslisthandler.go delete mode 100644 api/internal/handler/adapters/clusterlisthandler.go delete mode 100644 api/internal/handler/adapters/createadapterhandler.go delete mode 100644 api/internal/handler/adapters/createclusterhandler.go delete mode 100644 api/internal/handler/adapters/deleteadapterhandler.go delete mode 100644 api/internal/handler/adapters/deleteclusterhandler.go delete mode 100644 api/internal/handler/adapters/getadapterhandler.go delete mode 100644 api/internal/handler/adapters/getadapterrelationhandler.go delete mode 100644 api/internal/handler/adapters/getclusterhandler.go delete mode 100644 api/internal/handler/adapters/getclustersumhandler.go delete mode 100644 api/internal/handler/adapters/updateadapterhandler.go delete mode 100644 api/internal/handler/adapters/updateclusterhandler.go delete mode 100644 api/internal/handler/ai/createalgorithmhandler.go delete mode 100644 api/internal/handler/ai/createdatasethandler.go delete mode 100644 api/internal/handler/ai/createexporttaskhandler.go delete mode 100644 api/internal/handler/ai/createnotebookhandler.go delete mode 100644 api/internal/handler/ai/createprocessortaskhandler.go delete mode 100644 api/internal/handler/ai/createservicehandler.go delete mode 100644 api/internal/handler/ai/createtaskhandler.go delete mode 100644 api/internal/handler/ai/createtrainingjobhandler.go delete mode 100644 api/internal/handler/ai/createvisualizationjobhandler.go delete mode 100644 api/internal/handler/ai/deletealgorithmhandler.go delete mode 100644 api/internal/handler/ai/deletedatasethandler.go delete mode 100644 api/internal/handler/ai/deleteservicehandler.go delete mode 100644 api/internal/handler/ai/deletetrainingjobhandler.go delete mode 100644 api/internal/handler/ai/getcenterlisthandler.go delete mode 100644 api/internal/handler/ai/getcenteroverviewhandler.go delete mode 100644 api/internal/handler/ai/getcenterqueueinghandler.go delete mode 100644 api/internal/handler/ai/getcentertasklisthandler.go delete mode 100644 api/internal/handler/ai/getexporttasksofdatasethandler.go delete mode 100644 api/internal/handler/ai/getexporttaskstatusofdatasethandler.go delete mode 100644 api/internal/handler/ai/getlisttrainingjobshandler.go delete mode 100644 api/internal/handler/ai/getnotebookstoragehandler.go delete mode 100644 api/internal/handler/ai/getvisualizationjobhandler.go delete mode 100644 api/internal/handler/ai/listalgorithmshandler.go delete mode 100644 api/internal/handler/ai/listclustershandler.go delete mode 100644 api/internal/handler/ai/listdatasethandler.go delete mode 100644 api/internal/handler/ai/listimporthandler.go delete mode 100644 api/internal/handler/ai/listnotebookhandler.go delete mode 100644 api/internal/handler/ai/listserviceshandler.go delete mode 100644 api/internal/handler/ai/mountnotebookstoragehandler.go delete mode 100644 api/internal/handler/ai/proxyapihandler.go delete mode 100644 api/internal/handler/ai/showalgorithmbyuuidhandler.go delete mode 100644 api/internal/handler/ai/showservicehandler.go delete mode 100644 api/internal/handler/ai/startnotebookhandler.go delete mode 100644 api/internal/handler/ai/stopnotebookhandler.go delete mode 100644 api/internal/handler/cloud/cloudlisthandler.go delete mode 100644 api/internal/handler/cloud/clusterinfohandler.go delete mode 100644 api/internal/handler/cloud/commitgeneraltaskhandler.go delete mode 100644 api/internal/handler/cloud/controllermetricshandler.go delete mode 100644 api/internal/handler/cloud/deleteclusterhandler.go delete mode 100644 api/internal/handler/cloud/deleteyamlhandler.go delete mode 100644 api/internal/handler/cloud/getclusterlisthandler.go delete mode 100644 api/internal/handler/cloud/podlogshandler.go delete mode 100644 api/internal/handler/cloud/registerclusterhandler.go delete mode 100644 api/internal/handler/core/centerresourceshandler.go delete mode 100644 api/internal/handler/core/committaskhandler.go delete mode 100644 api/internal/handler/core/commitvmtaskhandler.go delete mode 100644 api/internal/handler/core/counttaskstatushandler.go delete mode 100644 api/internal/handler/core/deletetaskhandler.go delete mode 100644 api/internal/handler/core/getcomputilitystatisticshandler.go delete mode 100644 api/internal/handler/core/getcomputingpowerhandler.go delete mode 100644 api/internal/handler/core/getdomainresourcehandler.go delete mode 100644 api/internal/handler/core/getgeneralinfohandler.go delete mode 100644 api/internal/handler/core/getpublicflavorhandler.go delete mode 100644 api/internal/handler/core/getpublicimagehandler.go delete mode 100644 api/internal/handler/core/getpublicnetworkhandler.go delete mode 100644 api/internal/handler/core/getregionhandler.go delete mode 100644 api/internal/handler/core/getresourcepanelconfighandler.go delete mode 100644 api/internal/handler/core/getscreencharthandler.go delete mode 100644 api/internal/handler/core/getscreeninfohandler.go delete mode 100644 api/internal/handler/core/homeoverviewhandler.go delete mode 100644 api/internal/handler/core/jobtotalhandler.go delete mode 100644 api/internal/handler/core/listcenterhandler.go delete mode 100644 api/internal/handler/core/listclusterhandler.go delete mode 100644 api/internal/handler/core/listnoticehandler.go delete mode 100644 api/internal/handler/core/listregionhandler.go delete mode 100644 api/internal/handler/core/metricshandler.go delete mode 100644 api/internal/handler/core/nodeassetshandler.go delete mode 100644 api/internal/handler/core/pagelisttaskhandler.go delete mode 100644 api/internal/handler/core/participantlisthandler.go delete mode 100644 api/internal/handler/core/pulltaskinfohandler.go delete mode 100644 api/internal/handler/core/pushnoticehandler.go delete mode 100644 api/internal/handler/core/pushresourceinfohandler.go delete mode 100644 api/internal/handler/core/pushtaskinfohandler.go delete mode 100644 api/internal/handler/core/putresourcepanelconfighandler.go delete mode 100644 api/internal/handler/core/scheduletaskbyyamlhandler.go delete mode 100644 api/internal/handler/core/syncclusterloadhandler.go delete mode 100644 api/internal/handler/core/taskdetailshandler.go delete mode 100644 api/internal/handler/core/tasklisthandler.go delete mode 100644 api/internal/handler/dictionary/adddicthandler.go delete mode 100644 api/internal/handler/dictionary/adddictitemhandler.go delete mode 100644 api/internal/handler/dictionary/deletedicthandler.go delete mode 100644 api/internal/handler/dictionary/deletedictitemhandler.go delete mode 100644 api/internal/handler/dictionary/editdicthandler.go delete mode 100644 api/internal/handler/dictionary/editdictitemhandler.go delete mode 100644 api/internal/handler/dictionary/getdicthandler.go delete mode 100644 api/internal/handler/dictionary/getdictitemhandler.go delete mode 100644 api/internal/handler/dictionary/listdicthandler.go delete mode 100644 api/internal/handler/dictionary/listdictitembycodehandler.go delete mode 100644 api/internal/handler/dictionary/listdictitemhandler.go delete mode 100644 api/internal/handler/hpc/adaptersummaryhandler.go delete mode 100644 api/internal/handler/hpc/commithpctaskhandler.go delete mode 100644 api/internal/handler/hpc/jobhandler.go delete mode 100644 api/internal/handler/hpc/overviewhandler.go delete mode 100644 api/internal/handler/hpc/queueassetshandler.go delete mode 100644 api/internal/handler/hpc/resourcehandler.go delete mode 100644 api/internal/handler/inference/imageinferencehandler.go delete mode 100644 api/internal/handler/inference/inferencetaskdetailhandler.go delete mode 100644 api/internal/handler/inference/modelnamesbytypehandler.go delete mode 100644 api/internal/handler/inference/modeltypeshandler.go delete mode 100644 api/internal/handler/inference/texttotextinferencehandler.go delete mode 100644 api/internal/handler/monitoring/adapterinfohandler.go delete mode 100644 api/internal/handler/monitoring/alertlisthandler.go delete mode 100644 api/internal/handler/monitoring/alertruleshandler.go delete mode 100644 api/internal/handler/monitoring/clustersloadhandler.go delete mode 100644 api/internal/handler/monitoring/createalertrulehandler.go delete mode 100644 api/internal/handler/monitoring/deletealertrulehandler.go delete mode 100644 api/internal/handler/monitoring/nodesloadtophandler.go delete mode 100644 api/internal/handler/monitoring/schedulesituationhandler.go delete mode 100644 api/internal/handler/monitoring/syncclusteralerthandler.go delete mode 100644 api/internal/handler/monitoring/tasknumhandler.go delete mode 100644 api/internal/handler/routes.go delete mode 100644 api/internal/handler/schedule/downloadalgothmcodehandler.go delete mode 100644 api/internal/handler/schedule/getclusterbalancebyidhandler.go delete mode 100644 api/internal/handler/schedule/getcomputecardsbyclusterhandler.go delete mode 100644 api/internal/handler/schedule/schedulegetaijoblogloghandler.go delete mode 100644 api/internal/handler/schedule/schedulegetairesourcetypeshandler.go delete mode 100644 api/internal/handler/schedule/schedulegetaitasktypeshandler.go delete mode 100644 api/internal/handler/schedule/schedulegetalgorithmshandler.go delete mode 100644 api/internal/handler/schedule/schedulegetdatasetshandler.go delete mode 100644 api/internal/handler/schedule/schedulegetoverviewhandler.go delete mode 100644 api/internal/handler/schedule/schedulegetstrategyhandler.go delete mode 100644 api/internal/handler/schedule/schedulesubmithandler.go delete mode 100644 api/internal/handler/schedule/uploadalgothmcodehandler.go delete mode 100644 api/internal/handler/storage/dailypowerscreenhandler.go delete mode 100644 api/internal/handler/storage/percentercomputerpowershandler.go delete mode 100644 api/internal/handler/storage/screenstoragehandler.go delete mode 100644 api/internal/handler/storelink/deletelinkimagehandler.go delete mode 100644 api/internal/handler/storelink/deletelinktaskhandler.go delete mode 100644 api/internal/handler/storelink/getaispecshandler.go delete mode 100644 api/internal/handler/storelink/getlinkimagelisthandler.go delete mode 100644 api/internal/handler/storelink/getlinktaskhandler.go delete mode 100644 api/internal/handler/storelink/getparticipantshandler.go delete mode 100644 api/internal/handler/storelink/submitlinktaskhandler.go delete mode 100644 api/internal/handler/storelink/uploadlinkimagehandler.go delete mode 100644 api/internal/handler/vm/addsecuritygrouptoserverhandler.go delete mode 100644 api/internal/handler/vm/bulkcreatenetworkshandler.go delete mode 100644 api/internal/handler/vm/changeadministrativepasswordhandler.go delete mode 100644 api/internal/handler/vm/createfirewallgrouphandler.go delete mode 100644 api/internal/handler/vm/createfirewallpolicyhandler.go delete mode 100644 api/internal/handler/vm/createfirewallrulehandler.go delete mode 100644 api/internal/handler/vm/createflavorhandler.go delete mode 100644 api/internal/handler/vm/createfloatingiphandler.go delete mode 100644 api/internal/handler/vm/createimagehandler.go delete mode 100644 api/internal/handler/vm/createmulserverhandler.go delete mode 100644 api/internal/handler/vm/createnetworkhandler.go delete mode 100644 api/internal/handler/vm/createnetworksegmentrangehandler.go delete mode 100644 api/internal/handler/vm/createnodehandler.go delete mode 100644 api/internal/handler/vm/createporthandler.go delete mode 100644 api/internal/handler/vm/createrouterhandler.go delete mode 100644 api/internal/handler/vm/createsecuritygrouphandler.go delete mode 100644 api/internal/handler/vm/createsecuritygrouprulehandler.go delete mode 100644 api/internal/handler/vm/createserverhandler.go delete mode 100644 api/internal/handler/vm/createsubnethandler.go delete mode 100644 api/internal/handler/vm/createvolumehandler.go delete mode 100644 api/internal/handler/vm/createvolumetypeshandler.go delete mode 100644 api/internal/handler/vm/deletefirewallgrouphandler.go delete mode 100644 api/internal/handler/vm/deletefirewallpolicyhandler.go delete mode 100644 api/internal/handler/vm/deletefirewallrulehandler.go delete mode 100644 api/internal/handler/vm/deleteflavorhandler.go delete mode 100644 api/internal/handler/vm/deletefloatingiphandler.go delete mode 100644 api/internal/handler/vm/deleteimagehandler.go delete mode 100644 api/internal/handler/vm/deletenetworkhandler.go delete mode 100644 api/internal/handler/vm/deletenetworksegmentrangeshandler.go delete mode 100644 api/internal/handler/vm/deletenodehandler.go delete mode 100644 api/internal/handler/vm/deleteporthandler.go delete mode 100644 api/internal/handler/vm/deleterouterhandler.go delete mode 100644 api/internal/handler/vm/deletesecuritygrouphandler.go delete mode 100644 api/internal/handler/vm/deletesecuritygrouprulehandler.go delete mode 100644 api/internal/handler/vm/deleteserverhandler.go delete mode 100644 api/internal/handler/vm/deletesubnethandler.go delete mode 100644 api/internal/handler/vm/deletevolumehandler.go delete mode 100644 api/internal/handler/vm/deletevolumetypehandler.go delete mode 100644 api/internal/handler/vm/getcomputelimitshandler.go delete mode 100644 api/internal/handler/vm/getimagenumhandler.go delete mode 100644 api/internal/handler/vm/getnetworknumhandler.go delete mode 100644 api/internal/handler/vm/getopenstackoverviewhandler.go delete mode 100644 api/internal/handler/vm/getserversdetailedbyidhandler.go delete mode 100644 api/internal/handler/vm/getvolumedetailedbyidhandler.go delete mode 100644 api/internal/handler/vm/getvolumelimitshandler.go delete mode 100644 api/internal/handler/vm/listfirewallgroupshandler.go delete mode 100644 api/internal/handler/vm/listfirewallpolicieshandler.go delete mode 100644 api/internal/handler/vm/listfirewallruleshandler.go delete mode 100644 api/internal/handler/vm/listflavorsdetailhandler.go delete mode 100644 api/internal/handler/vm/listfloatingipshandler.go delete mode 100644 api/internal/handler/vm/listimageshandler.go delete mode 100644 api/internal/handler/vm/listnetworksegmentrangesrangehandler.go delete mode 100644 api/internal/handler/vm/listnetworkshandler.go delete mode 100644 api/internal/handler/vm/listnodeshandler.go delete mode 100644 api/internal/handler/vm/listportshandler.go delete mode 100644 api/internal/handler/vm/listroutershandler.go delete mode 100644 api/internal/handler/vm/listsecuritygroupruleshandler.go delete mode 100644 api/internal/handler/vm/listsecuritygroupshandler.go delete mode 100644 api/internal/handler/vm/listserverhandler.go delete mode 100644 api/internal/handler/vm/listserversdetailedhandler.go delete mode 100644 api/internal/handler/vm/listsubnetshandler.go delete mode 100644 api/internal/handler/vm/listvolumesdetailhandler.go delete mode 100644 api/internal/handler/vm/listvolumeshandler.go delete mode 100644 api/internal/handler/vm/listvolumetypeshandler.go delete mode 100644 api/internal/handler/vm/migrateserverhandler.go delete mode 100644 api/internal/handler/vm/pauseserverhandler.go delete mode 100644 api/internal/handler/vm/rebootserverhandler.go delete mode 100644 api/internal/handler/vm/removesecuritygrouphandler.go delete mode 100644 api/internal/handler/vm/rescueserverhandler.go delete mode 100644 api/internal/handler/vm/resizeserverhandler.go delete mode 100644 api/internal/handler/vm/shelveserverhandler.go delete mode 100644 api/internal/handler/vm/showfirewallgroupdetailshandler.go delete mode 100644 api/internal/handler/vm/showfirewallpolicydetailshandler.go delete mode 100644 api/internal/handler/vm/showfirewallruledetailshandler.go delete mode 100644 api/internal/handler/vm/showfloatingipdetailshandler.go delete mode 100644 api/internal/handler/vm/shownetworkdetailshandler.go delete mode 100644 api/internal/handler/vm/shownetworksegmentrangedetailshandler.go delete mode 100644 api/internal/handler/vm/shownodedetailshandler.go delete mode 100644 api/internal/handler/vm/showportdetailshandler.go delete mode 100644 api/internal/handler/vm/showrouterdetailshandler.go delete mode 100644 api/internal/handler/vm/showsecuritygrouphandler.go delete mode 100644 api/internal/handler/vm/showsecuritygrouprulehandler.go delete mode 100644 api/internal/handler/vm/startserverhandler.go delete mode 100644 api/internal/handler/vm/stopserverhandler.go delete mode 100644 api/internal/handler/vm/suspendserverhandler.go delete mode 100644 api/internal/handler/vm/unpauseserverhandler.go delete mode 100644 api/internal/handler/vm/unrescuehandler.go delete mode 100644 api/internal/handler/vm/updatefirewallgrouphandler.go delete mode 100644 api/internal/handler/vm/updatefloatingiphandler.go delete mode 100644 api/internal/handler/vm/updatenetworkhandler.go delete mode 100644 api/internal/handler/vm/updatenetworksegmentrangeshandler.go delete mode 100644 api/internal/handler/vm/updateporthandler.go delete mode 100644 api/internal/handler/vm/updaterouterhandler.go delete mode 100644 api/internal/handler/vm/updatesecuritygrouphandler.go delete mode 100644 api/internal/handler/vm/updateserverhandler.go delete mode 100644 api/internal/handler/vm/updatesubnethandler.go delete mode 100644 api/internal/handler/vm/updatevolumehandler.go delete mode 100644 api/internal/handler/vm/uploadimagehandler.go delete mode 100644 api/internal/logic/adapters/adapterslistlogic.go delete mode 100644 api/internal/logic/adapters/clusterlistlogic.go delete mode 100644 api/internal/logic/adapters/createadapterlogic.go delete mode 100644 api/internal/logic/adapters/createclusterlogic.go delete mode 100644 api/internal/logic/adapters/deleteadapterlogic.go delete mode 100644 api/internal/logic/adapters/deleteclusterlogic.go delete mode 100644 api/internal/logic/adapters/getadapterlogic.go delete mode 100644 api/internal/logic/adapters/getadapterrelationlogic.go delete mode 100644 api/internal/logic/adapters/getclusterlogic.go delete mode 100644 api/internal/logic/adapters/getclustersumlogic.go delete mode 100644 api/internal/logic/adapters/updateadapterlogic.go delete mode 100644 api/internal/logic/adapters/updateclusterlogic.go delete mode 100644 api/internal/logic/ai/createalgorithmlogic.go delete mode 100644 api/internal/logic/ai/createdatasetlogic.go delete mode 100644 api/internal/logic/ai/createexporttasklogic.go delete mode 100644 api/internal/logic/ai/createnotebooklogic.go delete mode 100644 api/internal/logic/ai/createprocessortasklogic.go delete mode 100644 api/internal/logic/ai/createservicelogic.go delete mode 100644 api/internal/logic/ai/createtasklogic.go delete mode 100644 api/internal/logic/ai/createtrainingjoblogic.go delete mode 100644 api/internal/logic/ai/createvisualizationjoblogic.go delete mode 100644 api/internal/logic/ai/deletealgorithmlogic.go delete mode 100644 api/internal/logic/ai/deletedatasetlogic.go delete mode 100644 api/internal/logic/ai/deleteservicelogic.go delete mode 100644 api/internal/logic/ai/deletetrainingjoblogic.go delete mode 100644 api/internal/logic/ai/getcenterlistlogic.go delete mode 100644 api/internal/logic/ai/getcenteroverviewlogic.go delete mode 100644 api/internal/logic/ai/getcenterqueueinglogic.go delete mode 100644 api/internal/logic/ai/getcentertasklistlogic.go delete mode 100644 api/internal/logic/ai/getexporttasksofdatasetlogic.go delete mode 100644 api/internal/logic/ai/getexporttaskstatusofdatasetlogic.go delete mode 100644 api/internal/logic/ai/getlisttrainingjobslogic.go delete mode 100644 api/internal/logic/ai/getnotebookstoragelogic.go delete mode 100644 api/internal/logic/ai/getvisualizationjoblogic.go delete mode 100644 api/internal/logic/ai/listalgorithmslogic.go delete mode 100644 api/internal/logic/ai/listclusterslogic.go delete mode 100644 api/internal/logic/ai/listdatasetlogic.go delete mode 100644 api/internal/logic/ai/listimportlogic.go delete mode 100644 api/internal/logic/ai/listnotebooklogic.go delete mode 100644 api/internal/logic/ai/listserviceslogic.go delete mode 100644 api/internal/logic/ai/mountnotebookstoragelogic.go delete mode 100644 api/internal/logic/ai/proxyapilogic.go delete mode 100644 api/internal/logic/ai/showalgorithmbyuuidlogic.go delete mode 100644 api/internal/logic/ai/showservicelogic.go delete mode 100644 api/internal/logic/ai/startnotebooklogic.go delete mode 100644 api/internal/logic/ai/stopnotebooklogic.go delete mode 100644 api/internal/logic/cloud/cloudlistlogic.go delete mode 100644 api/internal/logic/cloud/clusterinfologic.go delete mode 100644 api/internal/logic/cloud/commitgeneraltasklogic.go delete mode 100644 api/internal/logic/cloud/controllermetricslogic.go delete mode 100644 api/internal/logic/cloud/deleteclusterlogic.go delete mode 100644 api/internal/logic/cloud/deleteyamllogic.go delete mode 100644 api/internal/logic/cloud/getclusterlistlogic.go delete mode 100644 api/internal/logic/cloud/listcloudclusterlogic.go delete mode 100644 api/internal/logic/cloud/podlogslogic.go delete mode 100644 api/internal/logic/cloud/registerclusterlogic.go delete mode 100644 api/internal/logic/core/centerresourceslogic.go delete mode 100644 api/internal/logic/core/committasklogic.go delete mode 100644 api/internal/logic/core/commitvmtasklogic.go delete mode 100644 api/internal/logic/core/counttaskstatuslogic.go delete mode 100644 api/internal/logic/core/deletetasklogic.go delete mode 100644 api/internal/logic/core/getcomputilitystatisticslogic.go delete mode 100644 api/internal/logic/core/getcomputingpowerlogic.go delete mode 100644 api/internal/logic/core/getdomainresourcelogic.go delete mode 100644 api/internal/logic/core/getgeneralinfologic.go delete mode 100644 api/internal/logic/core/getpublicflavorlogic.go delete mode 100644 api/internal/logic/core/getpublicimagelogic.go delete mode 100644 api/internal/logic/core/getpublicnetworklogic.go delete mode 100644 api/internal/logic/core/getregionlogic.go delete mode 100644 api/internal/logic/core/getresourcepanelconfiglogic.go delete mode 100644 api/internal/logic/core/getscreenchartlogic.go delete mode 100644 api/internal/logic/core/getscreeninfologic.go delete mode 100644 api/internal/logic/core/homeoverviewlogic.go delete mode 100644 api/internal/logic/core/jobtotallogic.go delete mode 100644 api/internal/logic/core/listcenterlogic.go delete mode 100644 api/internal/logic/core/listclusterlogic.go delete mode 100644 api/internal/logic/core/listnoticelogic.go delete mode 100644 api/internal/logic/core/listregionlogic.go delete mode 100644 api/internal/logic/core/metricslogic.go delete mode 100644 api/internal/logic/core/nodeassetslogic.go delete mode 100644 api/internal/logic/core/pagelisttasklogic.go delete mode 100644 api/internal/logic/core/participantlistlogic.go delete mode 100644 api/internal/logic/core/pulltaskinfologic.go delete mode 100644 api/internal/logic/core/pushnoticelogic.go delete mode 100644 api/internal/logic/core/pushresourceinfologic.go delete mode 100644 api/internal/logic/core/pushtaskinfologic.go delete mode 100644 api/internal/logic/core/putresourcepanelconfiglogic.go delete mode 100644 api/internal/logic/core/scheduletaskbyyamllogic.go delete mode 100644 api/internal/logic/core/syncclusterloadlogic.go delete mode 100644 api/internal/logic/core/taskdetailslogic.go delete mode 100644 api/internal/logic/core/tasklistlogic.go delete mode 100644 api/internal/logic/dictionary/adddictitemlogic.go delete mode 100644 api/internal/logic/dictionary/adddictlogic.go delete mode 100644 api/internal/logic/dictionary/deletedictitemlogic.go delete mode 100644 api/internal/logic/dictionary/deletedictlogic.go delete mode 100644 api/internal/logic/dictionary/editdictitemlogic.go delete mode 100644 api/internal/logic/dictionary/editdictlogic.go delete mode 100644 api/internal/logic/dictionary/getdictitemlogic.go delete mode 100644 api/internal/logic/dictionary/getdictlogic.go delete mode 100644 api/internal/logic/dictionary/listdictitembycodelogic.go delete mode 100644 api/internal/logic/dictionary/listdictitemlogic.go delete mode 100644 api/internal/logic/dictionary/listdictlogic.go delete mode 100644 api/internal/logic/hpc/adaptersummarylogic.go delete mode 100644 api/internal/logic/hpc/commithpctasklogic.go delete mode 100644 api/internal/logic/hpc/joblogic.go delete mode 100644 api/internal/logic/hpc/overviewlogic.go delete mode 100644 api/internal/logic/hpc/queueassetslogic.go delete mode 100644 api/internal/logic/hpc/resourcelogic.go delete mode 100644 api/internal/logic/inference/imageinferencelogic.go delete mode 100644 api/internal/logic/inference/inferencetaskdetaillogic.go delete mode 100644 api/internal/logic/inference/modelnamesbytypelogic.go delete mode 100644 api/internal/logic/inference/modeltypeslogic.go delete mode 100644 api/internal/logic/inference/texttotextinferencelogic.go delete mode 100644 api/internal/logic/monitoring/adapterinfologic.go delete mode 100644 api/internal/logic/monitoring/alertlistlogic.go delete mode 100644 api/internal/logic/monitoring/alertruleslogic.go delete mode 100644 api/internal/logic/monitoring/clustersloadlogic.go delete mode 100644 api/internal/logic/monitoring/createalertrulelogic.go delete mode 100644 api/internal/logic/monitoring/deletealertrulelogic.go delete mode 100644 api/internal/logic/monitoring/nodesloadtoplogic.go delete mode 100644 api/internal/logic/monitoring/schedulesituationlogic.go delete mode 100644 api/internal/logic/monitoring/syncclusteralertlogic.go delete mode 100644 api/internal/logic/monitoring/tasknumlogic.go delete mode 100644 api/internal/logic/schedule/downloadalgothmcodelogic.go delete mode 100644 api/internal/logic/schedule/getclusterbalancebyidlogic.go delete mode 100644 api/internal/logic/schedule/getcomputecardsbyclusterlogic.go delete mode 100644 api/internal/logic/schedule/schedulegetaijoblogloglogic.go delete mode 100644 api/internal/logic/schedule/schedulegetairesourcetypeslogic.go delete mode 100644 api/internal/logic/schedule/schedulegetaitasktypeslogic.go delete mode 100644 api/internal/logic/schedule/schedulegetalgorithmslogic.go delete mode 100644 api/internal/logic/schedule/schedulegetdatasetslogic.go delete mode 100644 api/internal/logic/schedule/schedulegetoverviewlogic.go delete mode 100644 api/internal/logic/schedule/schedulegetstrategylogic.go delete mode 100644 api/internal/logic/schedule/schedulesubmitlogic.go delete mode 100644 api/internal/logic/schedule/uploadalgothmcodelogic.go delete mode 100644 api/internal/logic/storage/dailypowerscreenlogic.go delete mode 100644 api/internal/logic/storage/percentercomputerpowerslogic.go delete mode 100644 api/internal/logic/storage/screenstoragelogic.go delete mode 100644 api/internal/logic/storelink/deletelinkimagelogic.go delete mode 100644 api/internal/logic/storelink/deletelinktasklogic.go delete mode 100644 api/internal/logic/storelink/getaispecslogic.go delete mode 100644 api/internal/logic/storelink/getlinkimagelistlogic.go delete mode 100644 api/internal/logic/storelink/getlinktasklogic.go delete mode 100644 api/internal/logic/storelink/getparticipantslogic.go delete mode 100644 api/internal/logic/storelink/submitlinktasklogic.go delete mode 100644 api/internal/logic/storelink/uploadlinkimagelogic.go delete mode 100644 api/internal/logic/vm/addsecuritygrouptoserverlogic.go delete mode 100644 api/internal/logic/vm/bulkcreatenetworkslogic.go delete mode 100644 api/internal/logic/vm/changeadministrativepasswordlogic.go delete mode 100644 api/internal/logic/vm/createfirewallgrouplogic.go delete mode 100644 api/internal/logic/vm/createfirewallpolicylogic.go delete mode 100644 api/internal/logic/vm/createfirewallrulelogic.go delete mode 100644 api/internal/logic/vm/createflavorlogic.go delete mode 100644 api/internal/logic/vm/createfloatingiplogic.go delete mode 100644 api/internal/logic/vm/createimagelogic.go delete mode 100644 api/internal/logic/vm/createmulserverlogic.go delete mode 100644 api/internal/logic/vm/createnetworklogic.go delete mode 100644 api/internal/logic/vm/createnetworksegmentrangelogic.go delete mode 100644 api/internal/logic/vm/createnodelogic.go delete mode 100644 api/internal/logic/vm/createportlogic.go delete mode 100644 api/internal/logic/vm/createrouterlogic.go delete mode 100644 api/internal/logic/vm/createsecuritygrouplogic.go delete mode 100644 api/internal/logic/vm/createsecuritygrouprulelogic.go delete mode 100644 api/internal/logic/vm/createserverlogic.go delete mode 100644 api/internal/logic/vm/createsubnetlogic.go delete mode 100644 api/internal/logic/vm/createvolumelogic.go delete mode 100644 api/internal/logic/vm/createvolumetypeslogic.go delete mode 100644 api/internal/logic/vm/deletefirewallgrouplogic.go delete mode 100644 api/internal/logic/vm/deletefirewallpolicylogic.go delete mode 100644 api/internal/logic/vm/deletefirewallrulelogic.go delete mode 100644 api/internal/logic/vm/deleteflavorlogic.go delete mode 100644 api/internal/logic/vm/deletefloatingiplogic.go delete mode 100644 api/internal/logic/vm/deleteimagelogic.go delete mode 100644 api/internal/logic/vm/deletenetworklogic.go delete mode 100644 api/internal/logic/vm/deletenetworksegmentrangeslogic.go delete mode 100644 api/internal/logic/vm/deletenodelogic.go delete mode 100644 api/internal/logic/vm/deleteportlogic.go delete mode 100644 api/internal/logic/vm/deleterouterlogic.go delete mode 100644 api/internal/logic/vm/deletesecuritygrouplogic.go delete mode 100644 api/internal/logic/vm/deletesecuritygrouprulelogic.go delete mode 100644 api/internal/logic/vm/deleteserverlogic.go delete mode 100644 api/internal/logic/vm/deletesubnetlogic.go delete mode 100644 api/internal/logic/vm/deletevolumelogic.go delete mode 100644 api/internal/logic/vm/deletevolumetypelogic.go delete mode 100644 api/internal/logic/vm/getcomputelimitslogic.go delete mode 100644 api/internal/logic/vm/getimagenumlogic.go delete mode 100644 api/internal/logic/vm/getnetworknumlogic.go delete mode 100644 api/internal/logic/vm/getopenstackoverviewlogic.go delete mode 100644 api/internal/logic/vm/getserversdetailedbyidlogic.go delete mode 100644 api/internal/logic/vm/getvolumedetailedbyidlogic.go delete mode 100644 api/internal/logic/vm/getvolumelimitslogic.go delete mode 100644 api/internal/logic/vm/listfirewallgroupslogic.go delete mode 100644 api/internal/logic/vm/listfirewallpolicieslogic.go delete mode 100644 api/internal/logic/vm/listfirewallruleslogic.go delete mode 100644 api/internal/logic/vm/listflavorsdetaillogic.go delete mode 100644 api/internal/logic/vm/listfloatingipslogic.go delete mode 100644 api/internal/logic/vm/listimageslogic.go delete mode 100644 api/internal/logic/vm/listnetworksegmentrangesrangelogic.go delete mode 100644 api/internal/logic/vm/listnetworkslogic.go delete mode 100644 api/internal/logic/vm/listnodeslogic.go delete mode 100644 api/internal/logic/vm/listportslogic.go delete mode 100644 api/internal/logic/vm/listrouterslogic.go delete mode 100644 api/internal/logic/vm/listsecuritygroupruleslogic.go delete mode 100644 api/internal/logic/vm/listsecuritygroupslogic.go delete mode 100644 api/internal/logic/vm/listserverlogic.go delete mode 100644 api/internal/logic/vm/listserversdetailedlogic.go delete mode 100644 api/internal/logic/vm/listsubnetslogic.go delete mode 100644 api/internal/logic/vm/listvolumesdetaillogic.go delete mode 100644 api/internal/logic/vm/listvolumeslogic.go delete mode 100644 api/internal/logic/vm/listvolumetypeslogic.go delete mode 100644 api/internal/logic/vm/migrateserverlogic.go delete mode 100644 api/internal/logic/vm/pauseserverlogic.go delete mode 100644 api/internal/logic/vm/rebootserverlogic.go delete mode 100644 api/internal/logic/vm/removesecuritygrouplogic.go delete mode 100644 api/internal/logic/vm/rescueserverlogic.go delete mode 100644 api/internal/logic/vm/resizeserverlogic.go delete mode 100644 api/internal/logic/vm/shelveserverlogic.go delete mode 100644 api/internal/logic/vm/showfirewallgroupdetailslogic.go delete mode 100644 api/internal/logic/vm/showfirewallpolicydetailslogic.go delete mode 100644 api/internal/logic/vm/showfirewallruledetailslogic.go delete mode 100644 api/internal/logic/vm/showfloatingipdetailslogic.go delete mode 100644 api/internal/logic/vm/shownetworkdetailslogic.go delete mode 100644 api/internal/logic/vm/shownetworksegmentrangedetailslogic.go delete mode 100644 api/internal/logic/vm/shownodedetailslogic.go delete mode 100644 api/internal/logic/vm/showportdetailslogic.go delete mode 100644 api/internal/logic/vm/showrouterdetailslogic.go delete mode 100644 api/internal/logic/vm/showsecuritygrouplogic.go delete mode 100644 api/internal/logic/vm/showsecuritygrouprulelogic.go delete mode 100644 api/internal/logic/vm/startserverlogic.go delete mode 100644 api/internal/logic/vm/stopserverlogic.go delete mode 100644 api/internal/logic/vm/suspendserverlogic.go delete mode 100644 api/internal/logic/vm/unpauseserverlogic.go delete mode 100644 api/internal/logic/vm/unrescuelogic.go delete mode 100644 api/internal/logic/vm/updatefirewallgrouplogic.go delete mode 100644 api/internal/logic/vm/updatefloatingiplogic.go delete mode 100644 api/internal/logic/vm/updatenetworklogic.go delete mode 100644 api/internal/logic/vm/updatenetworksegmentrangeslogic.go delete mode 100644 api/internal/logic/vm/updateportlogic.go delete mode 100644 api/internal/logic/vm/updaterouterlogic.go delete mode 100644 api/internal/logic/vm/updatesecuritygrouplogic.go delete mode 100644 api/internal/logic/vm/updateserverlogic.go delete mode 100644 api/internal/logic/vm/updatesubnetlogic.go delete mode 100644 api/internal/logic/vm/updatevolumelogic.go delete mode 100644 api/internal/logic/vm/uploadimagelogic.go delete mode 100644 api/internal/mqs/ScheduleAi.go delete mode 100644 api/internal/mqs/ScheduleCloud.go delete mode 100644 api/internal/mqs/ScheduleHpc.go delete mode 100644 api/internal/mqs/ScheduleVm.go delete mode 100644 api/internal/scheduler/database/aiStorage.go delete mode 100644 api/internal/scheduler/database/cloudStorage.go delete mode 100644 api/internal/scheduler/database/storage.go delete mode 100644 api/internal/scheduler/scheduler.go delete mode 100644 api/internal/scheduler/schedulers/aiScheduler.go delete mode 100644 api/internal/scheduler/schedulers/cloudScheduler.go delete mode 100644 api/internal/scheduler/schedulers/hpcScheduler.go delete mode 100644 api/internal/scheduler/schedulers/vmScheduler.go delete mode 100644 api/internal/scheduler/service/aiService.go delete mode 100644 api/internal/scheduler/service/collector/collector.go delete mode 100644 api/internal/scheduler/service/executor/aiExecutor.go delete mode 100644 api/internal/scheduler/service/inference/imageInfer.go delete mode 100644 api/internal/scheduler/service/status/taskStatusSync.go delete mode 100644 api/internal/scheduler/strategy/dynamicResources.go delete mode 100644 api/internal/scheduler/strategy/param/params.go delete mode 100644 api/internal/scheduler/strategy/param/resourcePricing.go delete mode 100644 api/internal/scheduler/strategy/resourcePricing.go delete mode 100644 api/internal/scheduler/strategy/staticWeight.go delete mode 100644 api/internal/scheduler/strategy/test/strategy_test.go delete mode 100644 api/internal/storeLink/modelarts.go delete mode 100644 api/internal/storeLink/octopus.go delete mode 100644 api/internal/storeLink/shuguangHpc.go delete mode 100644 api/internal/storeLink/shuguangai.go delete mode 100644 api/internal/storeLink/storeLink.go delete mode 100644 api/internal/svc/servicecontext.go delete mode 100644 api/pcm.go rename {api/client => client}/client.go (100%) rename {api/client => client}/client_impl.go (100%) rename {api/client => client}/notice.go (100%) rename {api/client => client}/notice_impl.go (100%) rename {api/client => client}/task.go (100%) rename {api/client => client}/task_impl.go (100%) rename {api/client => client}/types.go (100%) rename {api => deploy}/pcm-coordinator-api.yaml (100%) rename {api/desc => desc}/ai/pcm-ai.api (100%) rename {api/desc => desc}/cloud/pcm-cloud.api (100%) rename {api/desc => desc}/core/pcm-core.api (100%) rename {api/desc => desc}/hpc/pcm-hpc.api (100%) rename {api/desc => desc}/inference/inference.api (100%) rename {api/desc => desc}/monitoring/pcm-monitoring.api (100%) rename {api/desc => desc}/pcm.api (100%) rename {api/desc => desc}/pcm.json (100%) rename {api/desc => desc}/schedule/pcm-schedule.api (100%) rename {api/desc => desc}/storage/pcm-storage.api (100%) rename {api/desc => desc}/storelink/pcm-storelink.api (100%) rename {api/desc => desc}/vm/pcm-vm.api (100%) create mode 100644 etc/pcm.yaml delete mode 100644 examples/ai/modelArts.yaml delete mode 100644 examples/cloud/nginx.yaml delete mode 100644 examples/hpc/ac.yaml delete mode 100644 examples/hpc/th.yaml rename {api/internal => internal}/config/config.go (100%) create mode 100644 internal/cron/aiCronTask.go create mode 100644 internal/cron/cron.go create mode 100644 internal/handler/adapters/adapterslisthandler.go create mode 100644 internal/handler/adapters/clusterlisthandler.go create mode 100644 internal/handler/adapters/createadapterhandler.go create mode 100644 internal/handler/adapters/createclusterhandler.go create mode 100644 internal/handler/adapters/deleteadapterhandler.go create mode 100644 internal/handler/adapters/deleteclusterhandler.go create mode 100644 internal/handler/adapters/getadapterhandler.go create mode 100644 internal/handler/adapters/getadapterrelationhandler.go create mode 100644 internal/handler/adapters/getclusterhandler.go create mode 100644 internal/handler/adapters/getclustersumhandler.go create mode 100644 internal/handler/adapters/updateadapterhandler.go create mode 100644 internal/handler/adapters/updateclusterhandler.go create mode 100644 internal/handler/ai/createalgorithmhandler.go create mode 100644 internal/handler/ai/createdatasethandler.go create mode 100644 internal/handler/ai/createexporttaskhandler.go create mode 100644 internal/handler/ai/createnotebookhandler.go create mode 100644 internal/handler/ai/createprocessortaskhandler.go create mode 100644 internal/handler/ai/createservicehandler.go create mode 100644 internal/handler/ai/createtaskhandler.go create mode 100644 internal/handler/ai/createtrainingjobhandler.go create mode 100644 internal/handler/ai/createvisualizationjobhandler.go create mode 100644 internal/handler/ai/deletealgorithmhandler.go create mode 100644 internal/handler/ai/deletedatasethandler.go create mode 100644 internal/handler/ai/deleteservicehandler.go create mode 100644 internal/handler/ai/deletetrainingjobhandler.go create mode 100644 internal/handler/ai/getcenterlisthandler.go create mode 100644 internal/handler/ai/getcenteroverviewhandler.go create mode 100644 internal/handler/ai/getcenterqueueinghandler.go create mode 100644 internal/handler/ai/getcentertasklisthandler.go create mode 100644 internal/handler/ai/getexporttasksofdatasethandler.go create mode 100644 internal/handler/ai/getexporttaskstatusofdatasethandler.go create mode 100644 internal/handler/ai/getlisttrainingjobshandler.go create mode 100644 internal/handler/ai/getnotebookstoragehandler.go create mode 100644 internal/handler/ai/getvisualizationjobhandler.go create mode 100644 internal/handler/ai/listalgorithmshandler.go create mode 100644 internal/handler/ai/listclustershandler.go create mode 100644 internal/handler/ai/listdatasethandler.go create mode 100644 internal/handler/ai/listimporthandler.go create mode 100644 internal/handler/ai/listnotebookhandler.go create mode 100644 internal/handler/ai/listserviceshandler.go create mode 100644 internal/handler/ai/mountnotebookstoragehandler.go create mode 100644 internal/handler/ai/proxyapihandler.go create mode 100644 internal/handler/ai/showalgorithmbyuuidhandler.go create mode 100644 internal/handler/ai/showservicehandler.go create mode 100644 internal/handler/ai/startnotebookhandler.go create mode 100644 internal/handler/ai/stopnotebookhandler.go create mode 100644 internal/handler/cloud/cloudlisthandler.go create mode 100644 internal/handler/cloud/clusterinfohandler.go create mode 100644 internal/handler/cloud/commitgeneraltaskhandler.go create mode 100644 internal/handler/cloud/controllermetricshandler.go create mode 100644 internal/handler/cloud/deleteclusterhandler.go create mode 100644 internal/handler/cloud/deleteyamlhandler.go create mode 100644 internal/handler/cloud/getclusterlisthandler.go create mode 100644 internal/handler/cloud/podlogshandler.go create mode 100644 internal/handler/cloud/registerclusterhandler.go create mode 100644 internal/handler/core/centerresourceshandler.go create mode 100644 internal/handler/core/committaskhandler.go create mode 100644 internal/handler/core/commitvmtaskhandler.go create mode 100644 internal/handler/core/counttaskstatushandler.go create mode 100644 internal/handler/core/deletetaskhandler.go create mode 100644 internal/handler/core/getcomputilitystatisticshandler.go create mode 100644 internal/handler/core/getcomputingpowerhandler.go create mode 100644 internal/handler/core/getdomainresourcehandler.go create mode 100644 internal/handler/core/getgeneralinfohandler.go create mode 100644 internal/handler/core/getpublicflavorhandler.go create mode 100644 internal/handler/core/getpublicimagehandler.go create mode 100644 internal/handler/core/getpublicnetworkhandler.go create mode 100644 internal/handler/core/getregionhandler.go create mode 100644 internal/handler/core/getresourcepanelconfighandler.go create mode 100644 internal/handler/core/getscreencharthandler.go create mode 100644 internal/handler/core/getscreeninfohandler.go create mode 100644 internal/handler/core/homeoverviewhandler.go create mode 100644 internal/handler/core/jobtotalhandler.go create mode 100644 internal/handler/core/listcenterhandler.go create mode 100644 internal/handler/core/listclusterhandler.go create mode 100644 internal/handler/core/listnoticehandler.go create mode 100644 internal/handler/core/listregionhandler.go create mode 100644 internal/handler/core/metricshandler.go create mode 100644 internal/handler/core/nodeassetshandler.go create mode 100644 internal/handler/core/pagelisttaskhandler.go create mode 100644 internal/handler/core/participantlisthandler.go create mode 100644 internal/handler/core/pulltaskinfohandler.go create mode 100644 internal/handler/core/pushnoticehandler.go create mode 100644 internal/handler/core/pushresourceinfohandler.go create mode 100644 internal/handler/core/pushtaskinfohandler.go create mode 100644 internal/handler/core/putresourcepanelconfighandler.go create mode 100644 internal/handler/core/scheduletaskbyyamlhandler.go create mode 100644 internal/handler/core/syncclusterloadhandler.go create mode 100644 internal/handler/core/taskdetailshandler.go create mode 100644 internal/handler/core/tasklisthandler.go create mode 100644 internal/handler/dictionary/adddicthandler.go create mode 100644 internal/handler/dictionary/adddictitemhandler.go create mode 100644 internal/handler/dictionary/deletedicthandler.go create mode 100644 internal/handler/dictionary/deletedictitemhandler.go create mode 100644 internal/handler/dictionary/editdicthandler.go create mode 100644 internal/handler/dictionary/editdictitemhandler.go create mode 100644 internal/handler/dictionary/getdicthandler.go create mode 100644 internal/handler/dictionary/getdictitemhandler.go create mode 100644 internal/handler/dictionary/listdicthandler.go create mode 100644 internal/handler/dictionary/listdictitembycodehandler.go create mode 100644 internal/handler/dictionary/listdictitemhandler.go create mode 100644 internal/handler/hpc/adaptersummaryhandler.go create mode 100644 internal/handler/hpc/commithpctaskhandler.go create mode 100644 internal/handler/hpc/jobhandler.go create mode 100644 internal/handler/hpc/overviewhandler.go create mode 100644 internal/handler/hpc/queueassetshandler.go create mode 100644 internal/handler/hpc/resourcehandler.go create mode 100644 internal/handler/inference/imageinferencehandler.go create mode 100644 internal/handler/inference/inferencetaskdetailhandler.go create mode 100644 internal/handler/inference/modelnamesbytypehandler.go create mode 100644 internal/handler/inference/modeltypeshandler.go create mode 100644 internal/handler/inference/texttotextinferencehandler.go create mode 100644 internal/handler/monitoring/adapterinfohandler.go create mode 100644 internal/handler/monitoring/alertlisthandler.go create mode 100644 internal/handler/monitoring/alertruleshandler.go create mode 100644 internal/handler/monitoring/clustersloadhandler.go create mode 100644 internal/handler/monitoring/createalertrulehandler.go create mode 100644 internal/handler/monitoring/deletealertrulehandler.go create mode 100644 internal/handler/monitoring/nodesloadtophandler.go create mode 100644 internal/handler/monitoring/schedulesituationhandler.go create mode 100644 internal/handler/monitoring/syncclusteralerthandler.go create mode 100644 internal/handler/monitoring/tasknumhandler.go create mode 100644 internal/handler/routes.go create mode 100644 internal/handler/schedule/downloadalgothmcodehandler.go create mode 100644 internal/handler/schedule/getclusterbalancebyidhandler.go create mode 100644 internal/handler/schedule/getcomputecardsbyclusterhandler.go create mode 100644 internal/handler/schedule/schedulegetaijoblogloghandler.go create mode 100644 internal/handler/schedule/schedulegetairesourcetypeshandler.go create mode 100644 internal/handler/schedule/schedulegetaitasktypeshandler.go create mode 100644 internal/handler/schedule/schedulegetalgorithmshandler.go create mode 100644 internal/handler/schedule/schedulegetdatasetshandler.go create mode 100644 internal/handler/schedule/schedulegetoverviewhandler.go create mode 100644 internal/handler/schedule/schedulegetstrategyhandler.go create mode 100644 internal/handler/schedule/schedulesubmithandler.go create mode 100644 internal/handler/schedule/uploadalgothmcodehandler.go create mode 100644 internal/handler/storage/dailypowerscreenhandler.go create mode 100644 internal/handler/storage/percentercomputerpowershandler.go create mode 100644 internal/handler/storage/screenstoragehandler.go create mode 100644 internal/handler/storelink/deletelinkimagehandler.go create mode 100644 internal/handler/storelink/deletelinktaskhandler.go create mode 100644 internal/handler/storelink/getaispecshandler.go create mode 100644 internal/handler/storelink/getlinkimagelisthandler.go create mode 100644 internal/handler/storelink/getlinktaskhandler.go create mode 100644 internal/handler/storelink/getparticipantshandler.go create mode 100644 internal/handler/storelink/submitlinktaskhandler.go create mode 100644 internal/handler/storelink/uploadlinkimagehandler.go create mode 100644 internal/handler/vm/addsecuritygrouptoserverhandler.go create mode 100644 internal/handler/vm/bulkcreatenetworkshandler.go create mode 100644 internal/handler/vm/changeadministrativepasswordhandler.go create mode 100644 internal/handler/vm/createfirewallgrouphandler.go create mode 100644 internal/handler/vm/createfirewallpolicyhandler.go create mode 100644 internal/handler/vm/createfirewallrulehandler.go create mode 100644 internal/handler/vm/createflavorhandler.go create mode 100644 internal/handler/vm/createfloatingiphandler.go create mode 100644 internal/handler/vm/createimagehandler.go create mode 100644 internal/handler/vm/createmulserverhandler.go create mode 100644 internal/handler/vm/createnetworkhandler.go create mode 100644 internal/handler/vm/createnetworksegmentrangehandler.go create mode 100644 internal/handler/vm/createnodehandler.go create mode 100644 internal/handler/vm/createporthandler.go create mode 100644 internal/handler/vm/createrouterhandler.go create mode 100644 internal/handler/vm/createsecuritygrouphandler.go create mode 100644 internal/handler/vm/createsecuritygrouprulehandler.go create mode 100644 internal/handler/vm/createserverhandler.go create mode 100644 internal/handler/vm/createsubnethandler.go create mode 100644 internal/handler/vm/createvolumehandler.go create mode 100644 internal/handler/vm/createvolumetypeshandler.go create mode 100644 internal/handler/vm/deletefirewallgrouphandler.go create mode 100644 internal/handler/vm/deletefirewallpolicyhandler.go create mode 100644 internal/handler/vm/deletefirewallrulehandler.go create mode 100644 internal/handler/vm/deleteflavorhandler.go create mode 100644 internal/handler/vm/deletefloatingiphandler.go create mode 100644 internal/handler/vm/deleteimagehandler.go create mode 100644 internal/handler/vm/deletenetworkhandler.go create mode 100644 internal/handler/vm/deletenetworksegmentrangeshandler.go create mode 100644 internal/handler/vm/deletenodehandler.go create mode 100644 internal/handler/vm/deleteporthandler.go create mode 100644 internal/handler/vm/deleterouterhandler.go create mode 100644 internal/handler/vm/deletesecuritygrouphandler.go create mode 100644 internal/handler/vm/deletesecuritygrouprulehandler.go create mode 100644 internal/handler/vm/deleteserverhandler.go create mode 100644 internal/handler/vm/deletesubnethandler.go create mode 100644 internal/handler/vm/deletevolumehandler.go create mode 100644 internal/handler/vm/deletevolumetypehandler.go create mode 100644 internal/handler/vm/getcomputelimitshandler.go create mode 100644 internal/handler/vm/getimagenumhandler.go create mode 100644 internal/handler/vm/getnetworknumhandler.go create mode 100644 internal/handler/vm/getopenstackoverviewhandler.go create mode 100644 internal/handler/vm/getserversdetailedbyidhandler.go create mode 100644 internal/handler/vm/getvolumedetailedbyidhandler.go create mode 100644 internal/handler/vm/getvolumelimitshandler.go create mode 100644 internal/handler/vm/listfirewallgroupshandler.go create mode 100644 internal/handler/vm/listfirewallpolicieshandler.go create mode 100644 internal/handler/vm/listfirewallruleshandler.go create mode 100644 internal/handler/vm/listflavorsdetailhandler.go create mode 100644 internal/handler/vm/listfloatingipshandler.go create mode 100644 internal/handler/vm/listimageshandler.go create mode 100644 internal/handler/vm/listnetworksegmentrangesrangehandler.go create mode 100644 internal/handler/vm/listnetworkshandler.go create mode 100644 internal/handler/vm/listnodeshandler.go create mode 100644 internal/handler/vm/listportshandler.go create mode 100644 internal/handler/vm/listroutershandler.go create mode 100644 internal/handler/vm/listsecuritygroupruleshandler.go create mode 100644 internal/handler/vm/listsecuritygroupshandler.go create mode 100644 internal/handler/vm/listserverhandler.go create mode 100644 internal/handler/vm/listserversdetailedhandler.go create mode 100644 internal/handler/vm/listsubnetshandler.go create mode 100644 internal/handler/vm/listvolumesdetailhandler.go create mode 100644 internal/handler/vm/listvolumeshandler.go create mode 100644 internal/handler/vm/listvolumetypeshandler.go create mode 100644 internal/handler/vm/migrateserverhandler.go create mode 100644 internal/handler/vm/pauseserverhandler.go create mode 100644 internal/handler/vm/rebootserverhandler.go create mode 100644 internal/handler/vm/removesecuritygrouphandler.go create mode 100644 internal/handler/vm/rescueserverhandler.go create mode 100644 internal/handler/vm/resizeserverhandler.go create mode 100644 internal/handler/vm/shelveserverhandler.go create mode 100644 internal/handler/vm/showfirewallgroupdetailshandler.go create mode 100644 internal/handler/vm/showfirewallpolicydetailshandler.go create mode 100644 internal/handler/vm/showfirewallruledetailshandler.go create mode 100644 internal/handler/vm/showfloatingipdetailshandler.go create mode 100644 internal/handler/vm/shownetworkdetailshandler.go create mode 100644 internal/handler/vm/shownetworksegmentrangedetailshandler.go create mode 100644 internal/handler/vm/shownodedetailshandler.go create mode 100644 internal/handler/vm/showportdetailshandler.go create mode 100644 internal/handler/vm/showrouterdetailshandler.go create mode 100644 internal/handler/vm/showsecuritygrouphandler.go create mode 100644 internal/handler/vm/showsecuritygrouprulehandler.go create mode 100644 internal/handler/vm/startserverhandler.go create mode 100644 internal/handler/vm/stopserverhandler.go create mode 100644 internal/handler/vm/suspendserverhandler.go create mode 100644 internal/handler/vm/unpauseserverhandler.go create mode 100644 internal/handler/vm/unrescuehandler.go create mode 100644 internal/handler/vm/updatefirewallgrouphandler.go create mode 100644 internal/handler/vm/updatefloatingiphandler.go create mode 100644 internal/handler/vm/updatenetworkhandler.go create mode 100644 internal/handler/vm/updatenetworksegmentrangeshandler.go create mode 100644 internal/handler/vm/updateporthandler.go create mode 100644 internal/handler/vm/updaterouterhandler.go create mode 100644 internal/handler/vm/updatesecuritygrouphandler.go create mode 100644 internal/handler/vm/updateserverhandler.go create mode 100644 internal/handler/vm/updatesubnethandler.go create mode 100644 internal/handler/vm/updatevolumehandler.go create mode 100644 internal/handler/vm/uploadimagehandler.go create mode 100644 internal/logic/adapters/adapterslistlogic.go create mode 100644 internal/logic/adapters/clusterlistlogic.go create mode 100644 internal/logic/adapters/createadapterlogic.go create mode 100644 internal/logic/adapters/createclusterlogic.go create mode 100644 internal/logic/adapters/deleteadapterlogic.go create mode 100644 internal/logic/adapters/deleteclusterlogic.go create mode 100644 internal/logic/adapters/getadapterlogic.go create mode 100644 internal/logic/adapters/getadapterrelationlogic.go create mode 100644 internal/logic/adapters/getclusterlogic.go create mode 100644 internal/logic/adapters/getclustersumlogic.go create mode 100644 internal/logic/adapters/updateadapterlogic.go create mode 100644 internal/logic/adapters/updateclusterlogic.go create mode 100644 internal/logic/ai/createalgorithmlogic.go create mode 100644 internal/logic/ai/createdatasetlogic.go create mode 100644 internal/logic/ai/createexporttasklogic.go create mode 100644 internal/logic/ai/createnotebooklogic.go create mode 100644 internal/logic/ai/createprocessortasklogic.go create mode 100644 internal/logic/ai/createservicelogic.go create mode 100644 internal/logic/ai/createtasklogic.go create mode 100644 internal/logic/ai/createtrainingjoblogic.go create mode 100644 internal/logic/ai/createvisualizationjoblogic.go create mode 100644 internal/logic/ai/deletealgorithmlogic.go create mode 100644 internal/logic/ai/deletedatasetlogic.go create mode 100644 internal/logic/ai/deleteservicelogic.go create mode 100644 internal/logic/ai/deletetrainingjoblogic.go create mode 100644 internal/logic/ai/getcenterlistlogic.go create mode 100644 internal/logic/ai/getcenteroverviewlogic.go create mode 100644 internal/logic/ai/getcenterqueueinglogic.go create mode 100644 internal/logic/ai/getcentertasklistlogic.go create mode 100644 internal/logic/ai/getexporttasksofdatasetlogic.go create mode 100644 internal/logic/ai/getexporttaskstatusofdatasetlogic.go create mode 100644 internal/logic/ai/getlisttrainingjobslogic.go create mode 100644 internal/logic/ai/getnotebookstoragelogic.go create mode 100644 internal/logic/ai/getvisualizationjoblogic.go create mode 100644 internal/logic/ai/listalgorithmslogic.go create mode 100644 internal/logic/ai/listclusterslogic.go create mode 100644 internal/logic/ai/listdatasetlogic.go create mode 100644 internal/logic/ai/listimportlogic.go create mode 100644 internal/logic/ai/listnotebooklogic.go create mode 100644 internal/logic/ai/listserviceslogic.go create mode 100644 internal/logic/ai/mountnotebookstoragelogic.go create mode 100644 internal/logic/ai/proxyapilogic.go create mode 100644 internal/logic/ai/showalgorithmbyuuidlogic.go create mode 100644 internal/logic/ai/showservicelogic.go create mode 100644 internal/logic/ai/startnotebooklogic.go create mode 100644 internal/logic/ai/stopnotebooklogic.go create mode 100644 internal/logic/cloud/cloudlistlogic.go create mode 100644 internal/logic/cloud/clusterinfologic.go create mode 100644 internal/logic/cloud/commitgeneraltasklogic.go create mode 100644 internal/logic/cloud/controllermetricslogic.go create mode 100644 internal/logic/cloud/deleteclusterlogic.go create mode 100644 internal/logic/cloud/deleteyamllogic.go create mode 100644 internal/logic/cloud/getclusterlistlogic.go create mode 100644 internal/logic/cloud/listcloudclusterlogic.go create mode 100644 internal/logic/cloud/podlogslogic.go create mode 100644 internal/logic/cloud/registerclusterlogic.go create mode 100644 internal/logic/core/centerresourceslogic.go create mode 100644 internal/logic/core/committasklogic.go create mode 100644 internal/logic/core/commitvmtasklogic.go create mode 100644 internal/logic/core/counttaskstatuslogic.go create mode 100644 internal/logic/core/deletetasklogic.go create mode 100644 internal/logic/core/getcomputilitystatisticslogic.go create mode 100644 internal/logic/core/getcomputingpowerlogic.go create mode 100644 internal/logic/core/getdomainresourcelogic.go create mode 100644 internal/logic/core/getgeneralinfologic.go create mode 100644 internal/logic/core/getpublicflavorlogic.go create mode 100644 internal/logic/core/getpublicimagelogic.go create mode 100644 internal/logic/core/getpublicnetworklogic.go create mode 100644 internal/logic/core/getregionlogic.go create mode 100644 internal/logic/core/getresourcepanelconfiglogic.go create mode 100644 internal/logic/core/getscreenchartlogic.go create mode 100644 internal/logic/core/getscreeninfologic.go create mode 100644 internal/logic/core/homeoverviewlogic.go create mode 100644 internal/logic/core/jobtotallogic.go create mode 100644 internal/logic/core/listcenterlogic.go create mode 100644 internal/logic/core/listclusterlogic.go create mode 100644 internal/logic/core/listnoticelogic.go create mode 100644 internal/logic/core/listregionlogic.go create mode 100644 internal/logic/core/metricslogic.go create mode 100644 internal/logic/core/nodeassetslogic.go create mode 100644 internal/logic/core/pagelisttasklogic.go create mode 100644 internal/logic/core/participantlistlogic.go create mode 100644 internal/logic/core/pulltaskinfologic.go create mode 100644 internal/logic/core/pushnoticelogic.go create mode 100644 internal/logic/core/pushresourceinfologic.go create mode 100644 internal/logic/core/pushtaskinfologic.go create mode 100644 internal/logic/core/putresourcepanelconfiglogic.go create mode 100644 internal/logic/core/scheduletaskbyyamllogic.go create mode 100644 internal/logic/core/syncclusterloadlogic.go create mode 100644 internal/logic/core/taskdetailslogic.go create mode 100644 internal/logic/core/tasklistlogic.go create mode 100644 internal/logic/dictionary/adddictitemlogic.go create mode 100644 internal/logic/dictionary/adddictlogic.go create mode 100644 internal/logic/dictionary/deletedictitemlogic.go create mode 100644 internal/logic/dictionary/deletedictlogic.go create mode 100644 internal/logic/dictionary/editdictitemlogic.go create mode 100644 internal/logic/dictionary/editdictlogic.go create mode 100644 internal/logic/dictionary/getdictitemlogic.go create mode 100644 internal/logic/dictionary/getdictlogic.go create mode 100644 internal/logic/dictionary/listdictitembycodelogic.go create mode 100644 internal/logic/dictionary/listdictitemlogic.go create mode 100644 internal/logic/dictionary/listdictlogic.go create mode 100644 internal/logic/hpc/adaptersummarylogic.go create mode 100644 internal/logic/hpc/commithpctasklogic.go create mode 100644 internal/logic/hpc/joblogic.go create mode 100644 internal/logic/hpc/overviewlogic.go create mode 100644 internal/logic/hpc/queueassetslogic.go create mode 100644 internal/logic/hpc/resourcelogic.go create mode 100644 internal/logic/inference/imageinferencelogic.go create mode 100644 internal/logic/inference/inferencetaskdetaillogic.go create mode 100644 internal/logic/inference/modelnamesbytypelogic.go create mode 100644 internal/logic/inference/modeltypeslogic.go create mode 100644 internal/logic/inference/texttotextinferencelogic.go create mode 100644 internal/logic/monitoring/adapterinfologic.go create mode 100644 internal/logic/monitoring/alertlistlogic.go create mode 100644 internal/logic/monitoring/alertruleslogic.go create mode 100644 internal/logic/monitoring/clustersloadlogic.go create mode 100644 internal/logic/monitoring/createalertrulelogic.go create mode 100644 internal/logic/monitoring/deletealertrulelogic.go create mode 100644 internal/logic/monitoring/nodesloadtoplogic.go create mode 100644 internal/logic/monitoring/schedulesituationlogic.go create mode 100644 internal/logic/monitoring/syncclusteralertlogic.go create mode 100644 internal/logic/monitoring/tasknumlogic.go create mode 100644 internal/logic/schedule/downloadalgothmcodelogic.go create mode 100644 internal/logic/schedule/getclusterbalancebyidlogic.go create mode 100644 internal/logic/schedule/getcomputecardsbyclusterlogic.go create mode 100644 internal/logic/schedule/schedulegetaijoblogloglogic.go create mode 100644 internal/logic/schedule/schedulegetairesourcetypeslogic.go create mode 100644 internal/logic/schedule/schedulegetaitasktypeslogic.go create mode 100644 internal/logic/schedule/schedulegetalgorithmslogic.go create mode 100644 internal/logic/schedule/schedulegetdatasetslogic.go create mode 100644 internal/logic/schedule/schedulegetoverviewlogic.go create mode 100644 internal/logic/schedule/schedulegetstrategylogic.go create mode 100644 internal/logic/schedule/schedulesubmitlogic.go create mode 100644 internal/logic/schedule/uploadalgothmcodelogic.go create mode 100644 internal/logic/storage/dailypowerscreenlogic.go create mode 100644 internal/logic/storage/percentercomputerpowerslogic.go create mode 100644 internal/logic/storage/screenstoragelogic.go create mode 100644 internal/logic/storelink/deletelinkimagelogic.go create mode 100644 internal/logic/storelink/deletelinktasklogic.go create mode 100644 internal/logic/storelink/getaispecslogic.go create mode 100644 internal/logic/storelink/getlinkimagelistlogic.go create mode 100644 internal/logic/storelink/getlinktasklogic.go create mode 100644 internal/logic/storelink/getparticipantslogic.go create mode 100644 internal/logic/storelink/submitlinktasklogic.go create mode 100644 internal/logic/storelink/uploadlinkimagelogic.go create mode 100644 internal/logic/vm/addsecuritygrouptoserverlogic.go create mode 100644 internal/logic/vm/bulkcreatenetworkslogic.go create mode 100644 internal/logic/vm/changeadministrativepasswordlogic.go create mode 100644 internal/logic/vm/createfirewallgrouplogic.go create mode 100644 internal/logic/vm/createfirewallpolicylogic.go create mode 100644 internal/logic/vm/createfirewallrulelogic.go create mode 100644 internal/logic/vm/createflavorlogic.go create mode 100644 internal/logic/vm/createfloatingiplogic.go create mode 100644 internal/logic/vm/createimagelogic.go create mode 100644 internal/logic/vm/createmulserverlogic.go create mode 100644 internal/logic/vm/createnetworklogic.go create mode 100644 internal/logic/vm/createnetworksegmentrangelogic.go create mode 100644 internal/logic/vm/createnodelogic.go create mode 100644 internal/logic/vm/createportlogic.go create mode 100644 internal/logic/vm/createrouterlogic.go create mode 100644 internal/logic/vm/createsecuritygrouplogic.go create mode 100644 internal/logic/vm/createsecuritygrouprulelogic.go create mode 100644 internal/logic/vm/createserverlogic.go create mode 100644 internal/logic/vm/createsubnetlogic.go create mode 100644 internal/logic/vm/createvolumelogic.go create mode 100644 internal/logic/vm/createvolumetypeslogic.go create mode 100644 internal/logic/vm/deletefirewallgrouplogic.go create mode 100644 internal/logic/vm/deletefirewallpolicylogic.go create mode 100644 internal/logic/vm/deletefirewallrulelogic.go create mode 100644 internal/logic/vm/deleteflavorlogic.go create mode 100644 internal/logic/vm/deletefloatingiplogic.go create mode 100644 internal/logic/vm/deleteimagelogic.go create mode 100644 internal/logic/vm/deletenetworklogic.go create mode 100644 internal/logic/vm/deletenetworksegmentrangeslogic.go create mode 100644 internal/logic/vm/deletenodelogic.go create mode 100644 internal/logic/vm/deleteportlogic.go create mode 100644 internal/logic/vm/deleterouterlogic.go create mode 100644 internal/logic/vm/deletesecuritygrouplogic.go create mode 100644 internal/logic/vm/deletesecuritygrouprulelogic.go create mode 100644 internal/logic/vm/deleteserverlogic.go create mode 100644 internal/logic/vm/deletesubnetlogic.go create mode 100644 internal/logic/vm/deletevolumelogic.go create mode 100644 internal/logic/vm/deletevolumetypelogic.go create mode 100644 internal/logic/vm/getcomputelimitslogic.go create mode 100644 internal/logic/vm/getimagenumlogic.go create mode 100644 internal/logic/vm/getnetworknumlogic.go create mode 100644 internal/logic/vm/getopenstackoverviewlogic.go create mode 100644 internal/logic/vm/getserversdetailedbyidlogic.go create mode 100644 internal/logic/vm/getvolumedetailedbyidlogic.go create mode 100644 internal/logic/vm/getvolumelimitslogic.go create mode 100644 internal/logic/vm/listfirewallgroupslogic.go create mode 100644 internal/logic/vm/listfirewallpolicieslogic.go create mode 100644 internal/logic/vm/listfirewallruleslogic.go create mode 100644 internal/logic/vm/listflavorsdetaillogic.go create mode 100644 internal/logic/vm/listfloatingipslogic.go create mode 100644 internal/logic/vm/listimageslogic.go create mode 100644 internal/logic/vm/listnetworksegmentrangesrangelogic.go create mode 100644 internal/logic/vm/listnetworkslogic.go create mode 100644 internal/logic/vm/listnodeslogic.go create mode 100644 internal/logic/vm/listportslogic.go create mode 100644 internal/logic/vm/listrouterslogic.go create mode 100644 internal/logic/vm/listsecuritygroupruleslogic.go create mode 100644 internal/logic/vm/listsecuritygroupslogic.go create mode 100644 internal/logic/vm/listserverlogic.go create mode 100644 internal/logic/vm/listserversdetailedlogic.go create mode 100644 internal/logic/vm/listsubnetslogic.go create mode 100644 internal/logic/vm/listvolumesdetaillogic.go create mode 100644 internal/logic/vm/listvolumeslogic.go create mode 100644 internal/logic/vm/listvolumetypeslogic.go create mode 100644 internal/logic/vm/migrateserverlogic.go create mode 100644 internal/logic/vm/pauseserverlogic.go create mode 100644 internal/logic/vm/rebootserverlogic.go create mode 100644 internal/logic/vm/removesecuritygrouplogic.go create mode 100644 internal/logic/vm/rescueserverlogic.go create mode 100644 internal/logic/vm/resizeserverlogic.go create mode 100644 internal/logic/vm/shelveserverlogic.go create mode 100644 internal/logic/vm/showfirewallgroupdetailslogic.go create mode 100644 internal/logic/vm/showfirewallpolicydetailslogic.go create mode 100644 internal/logic/vm/showfirewallruledetailslogic.go create mode 100644 internal/logic/vm/showfloatingipdetailslogic.go create mode 100644 internal/logic/vm/shownetworkdetailslogic.go create mode 100644 internal/logic/vm/shownetworksegmentrangedetailslogic.go create mode 100644 internal/logic/vm/shownodedetailslogic.go create mode 100644 internal/logic/vm/showportdetailslogic.go create mode 100644 internal/logic/vm/showrouterdetailslogic.go create mode 100644 internal/logic/vm/showsecuritygrouplogic.go create mode 100644 internal/logic/vm/showsecuritygrouprulelogic.go create mode 100644 internal/logic/vm/startserverlogic.go create mode 100644 internal/logic/vm/stopserverlogic.go create mode 100644 internal/logic/vm/suspendserverlogic.go create mode 100644 internal/logic/vm/unpauseserverlogic.go create mode 100644 internal/logic/vm/unrescuelogic.go create mode 100644 internal/logic/vm/updatefirewallgrouplogic.go create mode 100644 internal/logic/vm/updatefloatingiplogic.go create mode 100644 internal/logic/vm/updatenetworklogic.go create mode 100644 internal/logic/vm/updatenetworksegmentrangeslogic.go create mode 100644 internal/logic/vm/updateportlogic.go create mode 100644 internal/logic/vm/updaterouterlogic.go create mode 100644 internal/logic/vm/updatesecuritygrouplogic.go create mode 100644 internal/logic/vm/updateserverlogic.go create mode 100644 internal/logic/vm/updatesubnetlogic.go create mode 100644 internal/logic/vm/updatevolumelogic.go create mode 100644 internal/logic/vm/uploadimagelogic.go create mode 100644 internal/mqs/ScheduleAi.go create mode 100644 internal/mqs/ScheduleCloud.go create mode 100644 internal/mqs/ScheduleHpc.go create mode 100644 internal/mqs/ScheduleVm.go rename {api/internal => internal}/mqs/queue.go (100%) rename {api/internal => internal}/scheduler/algorithm/providerPricing/pricing.go (100%) rename {api/internal => internal}/scheduler/algorithm/providerPricing/provider.go (100%) rename {api/internal => internal}/scheduler/algorithm/providerPricing/strategy.go (100%) rename {api/internal => internal}/scheduler/algorithm/providerPricing/task.go (100%) rename {api/internal => internal}/scheduler/algorithm/weightDistributing/weightDistributing.go (100%) rename {api/internal => internal}/scheduler/common/common.go (100%) create mode 100644 internal/scheduler/database/aiStorage.go create mode 100644 internal/scheduler/database/cloudStorage.go create mode 100644 internal/scheduler/database/storage.go rename {api/internal => internal}/scheduler/entity/entity.go (100%) create mode 100644 internal/scheduler/scheduler.go create mode 100644 internal/scheduler/schedulers/aiScheduler.go create mode 100644 internal/scheduler/schedulers/cloudScheduler.go create mode 100644 internal/scheduler/schedulers/hpcScheduler.go rename {api/internal => internal}/scheduler/schedulers/option/aiOption.go (100%) rename {api/internal => internal}/scheduler/schedulers/option/cloudOption.go (100%) rename {api/internal => internal}/scheduler/schedulers/option/inferOption.go (100%) rename {api/internal => internal}/scheduler/schedulers/option/option.go (100%) rename {api/internal => internal}/scheduler/schedulers/option/vmOption.go (100%) create mode 100644 internal/scheduler/schedulers/vmScheduler.go create mode 100644 internal/scheduler/service/aiService.go create mode 100644 internal/scheduler/service/collector/collector.go create mode 100644 internal/scheduler/service/executor/aiExecutor.go create mode 100644 internal/scheduler/service/inference/imageInfer.go create mode 100644 internal/scheduler/service/status/taskStatusSync.go create mode 100644 internal/scheduler/strategy/dynamicResources.go create mode 100644 internal/scheduler/strategy/param/params.go create mode 100644 internal/scheduler/strategy/param/resourcePricing.go rename {api/internal => internal}/scheduler/strategy/random.go (100%) rename {api/internal => internal}/scheduler/strategy/replication.go (100%) create mode 100644 internal/scheduler/strategy/resourcePricing.go rename {api/internal => internal}/scheduler/strategy/singleAssignment.go (100%) create mode 100644 internal/scheduler/strategy/staticWeight.go rename {api/internal => internal}/scheduler/strategy/strategy.go (100%) create mode 100644 internal/scheduler/strategy/test/strategy_test.go create mode 100644 internal/storeLink/modelarts.go create mode 100644 internal/storeLink/octopus.go create mode 100644 internal/storeLink/shuguangHpc.go create mode 100644 internal/storeLink/shuguangai.go create mode 100644 internal/storeLink/storeLink.go create mode 100644 internal/svc/servicecontext.go rename {api/internal => internal}/types/types.go (100%) create mode 100644 pcm.go rename {api/pkg => pkg}/response/TaskInfo.go (100%) delete mode 100644 rpc/Dockerfile delete mode 100644 rpc/Makefile delete mode 100644 rpc/client/participantservice/participantservice.go delete mode 100644 rpc/client/pcmcore/pcmcore.go delete mode 100644 rpc/etc/pcmcore.yaml delete mode 100644 rpc/internal/config/config.go delete mode 100644 rpc/internal/logic/participantservice/applylistlogic.go delete mode 100644 rpc/internal/logic/participantservice/deletelistlogic.go delete mode 100644 rpc/internal/logic/participantservice/listparticipantlogic.go delete mode 100644 rpc/internal/logic/participantservice/listphyavailablelogic.go delete mode 100644 rpc/internal/logic/participantservice/listphyinformationlogic.go delete mode 100644 rpc/internal/logic/participantservice/listtenantlogic.go delete mode 100644 rpc/internal/logic/participantservice/pauselistlogic.go delete mode 100644 rpc/internal/logic/participantservice/registerparticipantlogic.go delete mode 100644 rpc/internal/logic/participantservice/registertenantlogic.go delete mode 100644 rpc/internal/logic/participantservice/reportavailablelogic.go delete mode 100644 rpc/internal/logic/participantservice/reportheartbeatlogic.go delete mode 100644 rpc/internal/logic/participantservice/restartlistlogic.go delete mode 100644 rpc/internal/logic/participantservice/startlistlogic.go delete mode 100644 rpc/internal/logic/pcmcore/infolistlogic.go delete mode 100644 rpc/internal/logic/pcmcore/syncinfologic.go delete mode 100644 rpc/internal/server/participantservice/participantserviceserver.go delete mode 100644 rpc/internal/server/pcmcore/pcmcoreserver.go delete mode 100644 rpc/internal/svc/servicecontext.go delete mode 100644 rpc/pb/pcmCore.proto delete mode 100644 rpc/pcm-coordinator-rpc.yaml delete mode 100644 rpc/pcmCore/pcmCore.pb.go delete mode 100644 rpc/pcmCore/pcmCore_grpc.pb.go delete mode 100644 rpc/pcmcore.go delete mode 100644 vendor/google.golang.org/grpc/reflection/README.md delete mode 100644 vendor/google.golang.org/grpc/reflection/adapt.go delete mode 100644 vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go delete mode 100644 vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go delete mode 100644 vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go delete mode 100644 vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go delete mode 100644 vendor/google.golang.org/grpc/reflection/internal/internal.go delete mode 100644 vendor/google.golang.org/grpc/reflection/serverreflection.go diff --git a/api/Dockerfile b/Dockerfile similarity index 100% rename from api/Dockerfile rename to Dockerfile diff --git a/Makefile b/Makefile index 1d87b2d5..663d2dba 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,8 @@ -pcm-core-api: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-core-api api/pcm.go +api-gen: + goctl api go -api desc/pcm.api -dir . -style gozero --home ../deploy/goctl -pcm-core-rpc: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-core-rpc rpc/pcmcore.go +Generate-AMD64: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-coordinator-api pcm.go -all-build: pcm-core-rpc pcm-core-api - -.PHONY: pcm-core-rpc pcm-core-api \ No newline at end of file +Generate-ARM64: + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -o pcm-coordinator-api pcm.go diff --git a/api/Makefile b/api/Makefile deleted file mode 100644 index 663d2dba..00000000 --- a/api/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -api-gen: - goctl api go -api desc/pcm.api -dir . -style gozero --home ../deploy/goctl - -Generate-AMD64: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-coordinator-api pcm.go - -Generate-ARM64: - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -o pcm-coordinator-api pcm.go diff --git a/api/etc/pcm.yaml b/api/etc/pcm.yaml deleted file mode 100644 index ef1e3250..00000000 --- a/api/etc/pcm.yaml +++ /dev/null @@ -1,85 +0,0 @@ -Name: pcm.core.api -Host: 0.0.0.0 -Port: 8999 -MaxBytes: 524288000 - -Timeout: 50000 - -DB: - DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local - # DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local -Redis: - Host: 10.206.0.12:6379 - Pass: redisPW123 - -Monitoring: - PromUrl: http://47.92.39.128:30877 - AlertUrl: 47.92.39.128:32243 - -#rpc -THRpcConf: - target: nacos://10.206.0.12:8848/pcm.th.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - # Endpoints: - # - 127.0.0.1:8888 - NonBlock: true - -#rpc -ModelArtsRpcConf: - # target: nacos://10.206.0.12:8848/pcm.modelarts.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - Endpoints: - - 127.0.0.1:2002 - NonBlock: true - Timeout: 20000 - -#rpc -ModelArtsImgRpcConf: - target: nacos://10.206.0.12:8848/pcm.modelarts.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - # Endpoints: - # - 127.0.0.1:2002 - NonBlock: true - -#rpc -ACRpcConf: - target: nacos://10.206.0.12:8848/pcm.ac.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - # Endpoints: - # - 127.0.0.1:8888 - NonBlock: true - Timeout: 50000 - -#rpc -CephRpcConf: - # target: nacos://10.206.0.12:8848/pcm.ceph.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - Endpoints: - - pcm-participant-ceph-service:2008 - NonBlock: true - Timeout: 50000 - -OctopusRpcConf: - target: nacos://10.206.0.12:8848/pcm.octopus.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - # Endpoints: - # - 127.0.0.1:8888 - NonBlock: true - Timeout: 20000 - -OpenstackRpcConf: - # target: nacos://10.206.0.12:8848/pcm.openstack.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - Endpoints: - - 127.0.0.1:2010 - NonBlock: true - Timeout: 20000 - -# core rpc -PcmCoreRpcConf: - # target: nacos://10.206.0.12:8848/pcm.core.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api - Endpoints: - - pcm-core-rpc:2004 - NonBlock: true - Timeout: 20000 - -MinioConf: - Secret: minio_xnu122@_ - AccessKey: minioadmin - Endpoint: http://121.89.220.60:9000 - -SnowflakeConf: - MachineId: 1 \ No newline at end of file diff --git a/api/internal/cron/aiCronTask.go b/api/internal/cron/aiCronTask.go deleted file mode 100644 index 458a243e..00000000 --- a/api/internal/cron/aiCronTask.go +++ /dev/null @@ -1,250 +0,0 @@ -package cron - -import ( - "errors" - "fmt" - "github.com/zeromicro/go-zero/core/logx" - "github.com/zeromicro/go-zero/zrpc" - hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/executor" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" - "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" - "net/http" - "strconv" - "sync" -) - -const ( - OCTOPUS = "octopus" - MODELARTS = "modelarts" - SHUGUANGAI = "shuguangAi" -) - -func GetTaskList(svc *svc.ServiceContext) ([]*types.TaskModel, error) { - limit := 10 - offset := 0 - var list []*types.TaskModel - db := svc.DbEngin.Model(&types.TaskModel{}).Table("task") - - db = db.Where("deleted_at is null") - - //count total - var total int64 - err := db.Count(&total).Error - db.Limit(limit).Offset(offset) - - if err != nil { - return nil, err - } - err = db.Order("created_time desc").Find(&list).Error - if err != nil { - return nil, err - } - return list, nil -} - -func UpdateAiAdapterMaps(svc *svc.ServiceContext) { - var aiType = "1" - adapterIds, err := svc.Scheduler.AiStorages.GetAdapterIdsByType(aiType) - if err != nil { - msg := fmt.Sprintf("###UpdateAiAdapterMaps###, error: %v \n", err.Error()) - logx.Errorf(errors.New(msg).Error()) - return - } - if len(adapterIds) == 0 { - return - } - - for _, id := range adapterIds { - clusters, err := svc.Scheduler.AiStorages.GetClustersByAdapterId(id) - if err != nil { - msg := fmt.Sprintf("###UpdateAiAdapterMaps###, error: %v \n", err.Error()) - logx.Errorf(errors.New(msg).Error()) - return - } - if len(clusters.List) == 0 { - continue - } - if isAdapterExist(svc, id, len(clusters.List)) { - continue - } else { - if isAdapterEmpty(svc, id) { - exeClusterMap, colClusterMap := InitAiClusterMap(&svc.Config, clusters.List) - svc.Scheduler.AiService.AiExecutorAdapterMap[id] = exeClusterMap - svc.Scheduler.AiService.AiCollectorAdapterMap[id] = colClusterMap - } else { - UpdateClusterMaps(svc, id, clusters.List) - } - } - } -} - -func UpdateClusterMaps(svc *svc.ServiceContext, adapterId string, clusters []types.ClusterInfo) { - for _, c := range clusters { - _, ok := svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] - _, ok2 := svc.Scheduler.AiService.AiCollectorAdapterMap[adapterId][c.Id] - if !ok && !ok2 { - switch c.Name { - case OCTOPUS: - id, _ := strconv.ParseInt(c.Id, 10, 64) - octopusRpc := octopusclient.NewOctopus(zrpc.MustNewClient(svc.Config.OctopusRpcConf)) - octopus := storeLink.NewOctopusLink(octopusRpc, c.Nickname, id) - svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = octopus - svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = octopus - case MODELARTS: - id, _ := strconv.ParseInt(c.Id, 10, 64) - modelArtsRpc := modelartsservice.NewModelArtsService(zrpc.MustNewClient(svc.Config.ModelArtsRpcConf)) - modelArtsImgRpc := imagesservice.NewImagesService(zrpc.MustNewClient(svc.Config.ModelArtsImgRpcConf)) - modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, c.Name, id, c.Nickname) - svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = modelarts - svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = modelarts - case SHUGUANGAI: - id, _ := strconv.ParseInt(c.Id, 10, 64) - aCRpc := hpcacclient.NewHpcAC(zrpc.MustNewClient(svc.Config.ACRpcConf)) - sgai := storeLink.NewShuguangAi(aCRpc, c.Nickname, id) - svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = sgai - svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = sgai - } - } else { - continue - } - } - -} - -func isAdapterExist(svc *svc.ServiceContext, id string, clusterNum int) bool { - emap, ok := svc.Scheduler.AiService.AiExecutorAdapterMap[id] - cmap, ok2 := svc.Scheduler.AiService.AiCollectorAdapterMap[id] - if ok && ok2 { - if len(emap) == clusterNum && len(cmap) == clusterNum { - return true - } - } - return false -} - -func isAdapterEmpty(svc *svc.ServiceContext, id string) bool { - _, ok := svc.Scheduler.AiService.AiExecutorAdapterMap[id] - _, ok2 := svc.Scheduler.AiService.AiCollectorAdapterMap[id] - if !ok && !ok2 { - return true - } - return false -} - -func InitAiClusterMap(conf *config.Config, clusters []types.ClusterInfo) (map[string]executor.AiExecutor, map[string]collector.AiCollector) { - executorMap := make(map[string]executor.AiExecutor) - collectorMap := make(map[string]collector.AiCollector) - for _, c := range clusters { - switch c.Name { - case OCTOPUS: - id, _ := strconv.ParseInt(c.Id, 10, 64) - octopusRpc := octopusclient.NewOctopus(zrpc.MustNewClient(conf.OctopusRpcConf)) - octopus := storeLink.NewOctopusLink(octopusRpc, c.Nickname, id) - collectorMap[c.Id] = octopus - executorMap[c.Id] = octopus - case MODELARTS: - id, _ := strconv.ParseInt(c.Id, 10, 64) - modelArtsRpc := modelartsservice.NewModelArtsService(zrpc.MustNewClient(conf.ModelArtsRpcConf)) - modelArtsImgRpc := imagesservice.NewImagesService(zrpc.MustNewClient(conf.ModelArtsImgRpcConf)) - modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, c.Name, id, c.Nickname) - collectorMap[c.Id] = modelarts - executorMap[c.Id] = modelarts - case SHUGUANGAI: - id, _ := strconv.ParseInt(c.Id, 10, 64) - aCRpc := hpcacclient.NewHpcAC(zrpc.MustNewClient(conf.ACRpcConf)) - sgai := storeLink.NewShuguangAi(aCRpc, c.Nickname, id) - collectorMap[c.Id] = sgai - executorMap[c.Id] = sgai - } - } - - return executorMap, collectorMap -} - -func UpdateClusterResource(svc *svc.ServiceContext) { - list, err := svc.Scheduler.AiStorages.GetAdaptersByType("1") - if err != nil { - return - } - var wg sync.WaitGroup - for _, adapter := range list { - clusters, err := svc.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) - if err != nil { - continue - } - for _, cluster := range clusters.List { - c := cluster - clusterResource, err := svc.Scheduler.AiStorages.GetClusterResourcesById(c.Id) - if err != nil { - continue - } - wg.Add(1) - go func() { - _, ok := svc.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id] - if !ok { - wg.Done() - return - } - h := http.Request{} - stat, err := svc.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id].GetResourceStats(h.Context()) - if err != nil { - wg.Done() - return - } - if stat == nil { - wg.Done() - return - } - clusterType, err := strconv.ParseInt(adapter.Type, 10, 64) - if err != nil { - wg.Done() - return - } - var cardTotal int64 - var topsTotal float64 - for _, card := range stat.CardsAvail { - cardTotal += int64(card.CardNum) - topsTotal += card.TOpsAtFp16 * float64(card.CardNum) - } - - if (models.TClusterResource{} == *clusterResource) { - err = svc.Scheduler.AiStorages.SaveClusterResources(adapter.Id, c.Id, c.Name, clusterType, float64(stat.CpuCoreAvail), float64(stat.CpuCoreTotal), - stat.MemAvail, stat.MemTotal, stat.DiskAvail, stat.DiskTotal, float64(stat.GpuAvail), float64(stat.GpuTotal), cardTotal, topsTotal) - if err != nil { - wg.Done() - return - } - } else { - if stat.CpuCoreTotal == 0 || stat.MemTotal == 0 || stat.DiskTotal == 0 { - wg.Done() - return - } - clusterResource.CardTotal = cardTotal - clusterResource.CardTopsTotal = topsTotal - clusterResource.CpuAvail = float64(stat.CpuCoreAvail) - clusterResource.CpuTotal = float64(stat.CpuCoreTotal) - clusterResource.MemAvail = stat.MemAvail - clusterResource.MemTotal = stat.MemTotal - clusterResource.DiskAvail = stat.DiskAvail - clusterResource.DiskTotal = stat.DiskTotal - - err := svc.Scheduler.AiStorages.UpdateClusterResources(clusterResource) - if err != nil { - wg.Done() - return - } - } - wg.Done() - }() - } - } - wg.Wait() -} diff --git a/api/internal/cron/cron.go b/api/internal/cron/cron.go deleted file mode 100644 index a571195c..00000000 --- a/api/internal/cron/cron.go +++ /dev/null @@ -1,42 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package cron - -import ( - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/status" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func AddCronGroup(svc *svc.ServiceContext) { - - svc.Cron.AddFunc("*/5 * * * * ?", func() { - list, err := GetTaskList(svc) - if err != nil { - logx.Errorf(err.Error()) - return - } - status.UpdateTaskStatus(svc, list) - status.UpdateAiTaskStatus(svc, list) - }) - - svc.Cron.AddFunc("*/5 * * * * ?", func() { - UpdateAiAdapterMaps(svc) - }) - - svc.Cron.AddFunc("*/59 * * * * ?", func() { - UpdateClusterResource(svc) - }) -} diff --git a/api/internal/handler/adapters/adapterslisthandler.go b/api/internal/handler/adapters/adapterslisthandler.go deleted file mode 100644 index 6ae5c320..00000000 --- a/api/internal/handler/adapters/adapterslisthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func AdaptersListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AdapterQueryReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewAdaptersListLogic(r.Context(), svcCtx) - resp, err := l.AdaptersList(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/clusterlisthandler.go b/api/internal/handler/adapters/clusterlisthandler.go deleted file mode 100644 index bf168fbc..00000000 --- a/api/internal/handler/adapters/clusterlisthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ClusterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ClusterReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewClusterListLogic(r.Context(), svcCtx) - resp, err := l.ClusterList(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/createadapterhandler.go b/api/internal/handler/adapters/createadapterhandler.go deleted file mode 100644 index be20ca49..00000000 --- a/api/internal/handler/adapters/createadapterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AdapterCreateReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewCreateAdapterLogic(r.Context(), svcCtx) - resp, err := l.CreateAdapter(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/createclusterhandler.go b/api/internal/handler/adapters/createclusterhandler.go deleted file mode 100644 index 47e1e8b6..00000000 --- a/api/internal/handler/adapters/createclusterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ClusterCreateReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewCreateClusterLogic(r.Context(), svcCtx) - resp, err := l.CreateCluster(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/deleteadapterhandler.go b/api/internal/handler/adapters/deleteadapterhandler.go deleted file mode 100644 index 3b2fb374..00000000 --- a/api/internal/handler/adapters/deleteadapterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AdapterDelReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewDeleteAdapterLogic(r.Context(), svcCtx) - resp, err := l.DeleteAdapter(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/deleteclusterhandler.go b/api/internal/handler/adapters/deleteclusterhandler.go deleted file mode 100644 index 2f9d3c9e..00000000 --- a/api/internal/handler/adapters/deleteclusterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.FId - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewDeleteClusterLogic(r.Context(), svcCtx) - resp, err := l.DeleteCluster(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/getadapterhandler.go b/api/internal/handler/adapters/getadapterhandler.go deleted file mode 100644 index 3967cc56..00000000 --- a/api/internal/handler/adapters/getadapterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AdapterDelReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewGetAdapterLogic(r.Context(), svcCtx) - resp, err := l.GetAdapter(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/getadapterrelationhandler.go b/api/internal/handler/adapters/getadapterrelationhandler.go deleted file mode 100644 index 1f265676..00000000 --- a/api/internal/handler/adapters/getadapterrelationhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetAdapterRelationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AdapterRelationQueryReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewGetAdapterRelationLogic(r.Context(), svcCtx) - resp, err := l.GetAdapterRelation(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/getclusterhandler.go b/api/internal/handler/adapters/getclusterhandler.go deleted file mode 100644 index 7fe828e9..00000000 --- a/api/internal/handler/adapters/getclusterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.FId - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewGetClusterLogic(r.Context(), svcCtx) - resp, err := l.GetCluster(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/getclustersumhandler.go b/api/internal/handler/adapters/getclustersumhandler.go deleted file mode 100644 index bcd6d6af..00000000 --- a/api/internal/handler/adapters/getclustersumhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetClusterSumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ClusterSumReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewGetClusterSumLogic(r.Context(), svcCtx) - resp, err := l.GetClusterSum(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/updateadapterhandler.go b/api/internal/handler/adapters/updateadapterhandler.go deleted file mode 100644 index 2f9ee8fa..00000000 --- a/api/internal/handler/adapters/updateadapterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func UpdateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AdapterReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewUpdateAdapterLogic(r.Context(), svcCtx) - resp, err := l.UpdateAdapter(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/adapters/updateclusterhandler.go b/api/internal/handler/adapters/updateclusterhandler.go deleted file mode 100644 index 197d0198..00000000 --- a/api/internal/handler/adapters/updateclusterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package adapters - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func UpdateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ClusterCreateReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := adapters.NewUpdateClusterLogic(r.Context(), svcCtx) - resp, err := l.UpdateCluster(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createalgorithmhandler.go b/api/internal/handler/ai/createalgorithmhandler.go deleted file mode 100644 index f6c4e3bb..00000000 --- a/api/internal/handler/ai/createalgorithmhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateAlgorithmHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateAlgorithmReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateAlgorithmLogic(r.Context(), svcCtx) - resp, err := l.CreateAlgorithm(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createdatasethandler.go b/api/internal/handler/ai/createdatasethandler.go deleted file mode 100644 index 424005b4..00000000 --- a/api/internal/handler/ai/createdatasethandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateDataSetReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateDataSetLogic(r.Context(), svcCtx) - resp, err := l.CreateDataSet(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createexporttaskhandler.go b/api/internal/handler/ai/createexporttaskhandler.go deleted file mode 100644 index 7dbf1228..00000000 --- a/api/internal/handler/ai/createexporttaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateExportTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateExportTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateExportTaskLogic(r.Context(), svcCtx) - resp, err := l.CreateExportTask(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createnotebookhandler.go b/api/internal/handler/ai/createnotebookhandler.go deleted file mode 100644 index 14dd0460..00000000 --- a/api/internal/handler/ai/createnotebookhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateNotebookReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateNotebookLogic(r.Context(), svcCtx) - resp, err := l.CreateNotebook(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createprocessortaskhandler.go b/api/internal/handler/ai/createprocessortaskhandler.go deleted file mode 100644 index 00167d1e..00000000 --- a/api/internal/handler/ai/createprocessortaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateProcessorTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateProcessorTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateProcessorTaskLogic(r.Context(), svcCtx) - resp, err := l.CreateProcessorTask(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createservicehandler.go b/api/internal/handler/ai/createservicehandler.go deleted file mode 100644 index 4d9159ac..00000000 --- a/api/internal/handler/ai/createservicehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateServiceReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateServiceLogic(r.Context(), svcCtx) - resp, err := l.CreateService(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createtaskhandler.go b/api/internal/handler/ai/createtaskhandler.go deleted file mode 100644 index 85c62920..00000000 --- a/api/internal/handler/ai/createtaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ImportTaskDataReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateTaskLogic(r.Context(), svcCtx) - resp, err := l.CreateTask(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createtrainingjobhandler.go b/api/internal/handler/ai/createtrainingjobhandler.go deleted file mode 100644 index f0c3eb9b..00000000 --- a/api/internal/handler/ai/createtrainingjobhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateTrainingJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateTrainingJobReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateTrainingJobLogic(r.Context(), svcCtx) - resp, err := l.CreateTrainingJob(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/createvisualizationjobhandler.go b/api/internal/handler/ai/createvisualizationjobhandler.go deleted file mode 100644 index 971404ea..00000000 --- a/api/internal/handler/ai/createvisualizationjobhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CreateVisualizationJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateVisualizationJobReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewCreateVisualizationJobLogic(r.Context(), svcCtx) - resp, err := l.CreateVisualizationJob(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/deletealgorithmhandler.go b/api/internal/handler/ai/deletealgorithmhandler.go deleted file mode 100644 index 74597272..00000000 --- a/api/internal/handler/ai/deletealgorithmhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteAlgorithmHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteAlgorithmReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewDeleteAlgorithmLogic(r.Context(), svcCtx) - resp, err := l.DeleteAlgorithm(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/deletedatasethandler.go b/api/internal/handler/ai/deletedatasethandler.go deleted file mode 100644 index 7457bee0..00000000 --- a/api/internal/handler/ai/deletedatasethandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteDataSetReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewDeleteDataSetLogic(r.Context(), svcCtx) - resp, err := l.DeleteDataSet(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/deleteservicehandler.go b/api/internal/handler/ai/deleteservicehandler.go deleted file mode 100644 index b65826fb..00000000 --- a/api/internal/handler/ai/deleteservicehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteServiceReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewDeleteServiceLogic(r.Context(), svcCtx) - resp, err := l.DeleteService(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/deletetrainingjobhandler.go b/api/internal/handler/ai/deletetrainingjobhandler.go deleted file mode 100644 index ae789acb..00000000 --- a/api/internal/handler/ai/deletetrainingjobhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteTrainingJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteTrainingJobReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewDeleteTrainingJobLogic(r.Context(), svcCtx) - resp, err := l.DeleteTrainingJob(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/getcenterlisthandler.go b/api/internal/handler/ai/getcenterlisthandler.go deleted file mode 100644 index 40a7dc01..00000000 --- a/api/internal/handler/ai/getcenterlisthandler.go +++ /dev/null @@ -1,21 +0,0 @@ -package ai - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func GetCenterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := ai.NewGetCenterListLogic(r.Context(), svcCtx) - resp, err := l.GetCenterList() - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/ai/getcenteroverviewhandler.go b/api/internal/handler/ai/getcenteroverviewhandler.go deleted file mode 100644 index 84b97958..00000000 --- a/api/internal/handler/ai/getcenteroverviewhandler.go +++ /dev/null @@ -1,21 +0,0 @@ -package ai - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func GetCenterOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := ai.NewGetCenterOverviewLogic(r.Context(), svcCtx) - resp, err := l.GetCenterOverview() - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/ai/getcenterqueueinghandler.go b/api/internal/handler/ai/getcenterqueueinghandler.go deleted file mode 100644 index 6577b34c..00000000 --- a/api/internal/handler/ai/getcenterqueueinghandler.go +++ /dev/null @@ -1,21 +0,0 @@ -package ai - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func GetCenterQueueingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := ai.NewGetCenterQueueingLogic(r.Context(), svcCtx) - resp, err := l.GetCenterQueueing() - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/ai/getcentertasklisthandler.go b/api/internal/handler/ai/getcentertasklisthandler.go deleted file mode 100644 index 37312b25..00000000 --- a/api/internal/handler/ai/getcentertasklisthandler.go +++ /dev/null @@ -1,21 +0,0 @@ -package ai - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func GetCenterTaskListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := ai.NewGetCenterTaskListLogic(r.Context(), svcCtx) - resp, err := l.GetCenterTaskList() - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/ai/getexporttasksofdatasethandler.go b/api/internal/handler/ai/getexporttasksofdatasethandler.go deleted file mode 100644 index f500affd..00000000 --- a/api/internal/handler/ai/getexporttasksofdatasethandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetExportTasksOfDatasetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetExportTasksOfDatasetReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewGetExportTasksOfDatasetLogic(r.Context(), svcCtx) - resp, err := l.GetExportTasksOfDataset(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/getexporttaskstatusofdatasethandler.go b/api/internal/handler/ai/getexporttaskstatusofdatasethandler.go deleted file mode 100644 index eb41f009..00000000 --- a/api/internal/handler/ai/getexporttaskstatusofdatasethandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetExportTaskStatusOfDatasetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetExportTaskStatusOfDatasetReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewGetExportTaskStatusOfDatasetLogic(r.Context(), svcCtx) - resp, err := l.GetExportTaskStatusOfDataset(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/getlisttrainingjobshandler.go b/api/internal/handler/ai/getlisttrainingjobshandler.go deleted file mode 100644 index 51002c46..00000000 --- a/api/internal/handler/ai/getlisttrainingjobshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetListTrainingJobsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListTrainingJobsreq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewGetListTrainingJobsLogic(r.Context(), svcCtx) - resp, err := l.GetListTrainingJobs(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/getnotebookstoragehandler.go b/api/internal/handler/ai/getnotebookstoragehandler.go deleted file mode 100644 index 9d7de093..00000000 --- a/api/internal/handler/ai/getnotebookstoragehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetNotebookStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetNotebookStorageReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewGetNotebookStorageLogic(r.Context(), svcCtx) - resp, err := l.GetNotebookStorage(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/getvisualizationjobhandler.go b/api/internal/handler/ai/getvisualizationjobhandler.go deleted file mode 100644 index 629b9707..00000000 --- a/api/internal/handler/ai/getvisualizationjobhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetVisualizationJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetVisualizationJobReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewGetVisualizationJobLogic(r.Context(), svcCtx) - resp, err := l.GetVisualizationJob(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/listalgorithmshandler.go b/api/internal/handler/ai/listalgorithmshandler.go deleted file mode 100644 index 9e3b0035..00000000 --- a/api/internal/handler/ai/listalgorithmshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListAlgorithmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListAlgorithmsReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewListAlgorithmsLogic(r.Context(), svcCtx) - resp, err := l.ListAlgorithms(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/listclustershandler.go b/api/internal/handler/ai/listclustershandler.go deleted file mode 100644 index 261d2512..00000000 --- a/api/internal/handler/ai/listclustershandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListClustersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListClustersReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewListClustersLogic(r.Context(), svcCtx) - resp, err := l.ListClusters(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/listdatasethandler.go b/api/internal/handler/ai/listdatasethandler.go deleted file mode 100644 index bb134718..00000000 --- a/api/internal/handler/ai/listdatasethandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DataSetReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewListDataSetLogic(r.Context(), svcCtx) - resp, err := l.ListDataSet(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/listimporthandler.go b/api/internal/handler/ai/listimporthandler.go deleted file mode 100644 index 2faa5689..00000000 --- a/api/internal/handler/ai/listimporthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListImportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListImportTasksReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewListImportLogic(r.Context(), svcCtx) - resp, err := l.ListImport(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/listnotebookhandler.go b/api/internal/handler/ai/listnotebookhandler.go deleted file mode 100644 index a8da51d5..00000000 --- a/api/internal/handler/ai/listnotebookhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListNotebookReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewListNotebookLogic(r.Context(), svcCtx) - resp, err := l.ListNotebook(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/listserviceshandler.go b/api/internal/handler/ai/listserviceshandler.go deleted file mode 100644 index 0f2266a6..00000000 --- a/api/internal/handler/ai/listserviceshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListServicesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListServicesReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewListServicesLogic(r.Context(), svcCtx) - resp, err := l.ListServices(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/mountnotebookstoragehandler.go b/api/internal/handler/ai/mountnotebookstoragehandler.go deleted file mode 100644 index 3b1ac77d..00000000 --- a/api/internal/handler/ai/mountnotebookstoragehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func MountNotebookStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.MountNotebookStorageReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewMountNotebookStorageLogic(r.Context(), svcCtx) - resp, err := l.MountNotebookStorage(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/proxyapihandler.go b/api/internal/handler/ai/proxyapihandler.go deleted file mode 100644 index b86ce9d2..00000000 --- a/api/internal/handler/ai/proxyapihandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ProxyApiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ChatReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewProxyApiLogic(r.Context(), svcCtx) - resp, err := l.ProxyApi(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/showalgorithmbyuuidhandler.go b/api/internal/handler/ai/showalgorithmbyuuidhandler.go deleted file mode 100644 index 73bdde4f..00000000 --- a/api/internal/handler/ai/showalgorithmbyuuidhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ShowAlgorithmByUuidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowAlgorithmByUuidReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewShowAlgorithmByUuidLogic(r.Context(), svcCtx) - resp, err := l.ShowAlgorithmByUuid(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/showservicehandler.go b/api/internal/handler/ai/showservicehandler.go deleted file mode 100644 index c63b177f..00000000 --- a/api/internal/handler/ai/showservicehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ShowServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowServiceReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewShowServiceLogic(r.Context(), svcCtx) - resp, err := l.ShowService(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/startnotebookhandler.go b/api/internal/handler/ai/startnotebookhandler.go deleted file mode 100644 index 39706c24..00000000 --- a/api/internal/handler/ai/startnotebookhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func StartNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.StartNotebookReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewStartNotebookLogic(r.Context(), svcCtx) - resp, err := l.StartNotebook(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/ai/stopnotebookhandler.go b/api/internal/handler/ai/stopnotebookhandler.go deleted file mode 100644 index 4fc89e79..00000000 --- a/api/internal/handler/ai/stopnotebookhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package ai - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/ai" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func StopNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.StopNotebookReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := ai.NewStopNotebookLogic(r.Context(), svcCtx) - resp, err := l.StopNotebook(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/cloudlisthandler.go b/api/internal/handler/cloud/cloudlisthandler.go deleted file mode 100644 index 524dc511..00000000 --- a/api/internal/handler/cloud/cloudlisthandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package cloud - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CloudListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := cloud.NewCloudListLogic(r.Context(), svcCtx) - resp, err := l.CloudList() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/clusterinfohandler.go b/api/internal/handler/cloud/clusterinfohandler.go deleted file mode 100644 index 51522ea4..00000000 --- a/api/internal/handler/cloud/clusterinfohandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package cloud - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ClusterInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ClusterInfoReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := cloud.NewClusterInfoLogic(r.Context(), svcCtx) - resp, err := l.ClusterInfo(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/commitgeneraltaskhandler.go b/api/internal/handler/cloud/commitgeneraltaskhandler.go deleted file mode 100644 index 692b7d56..00000000 --- a/api/internal/handler/cloud/commitgeneraltaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloud - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CommitGeneralTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GeneralTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := cloud.NewCommitGeneralTaskLogic(r.Context(), svcCtx) - err := l.CommitGeneralTask(&req) - result.HttpResult(r, w, nil, err) - } -} diff --git a/api/internal/handler/cloud/controllermetricshandler.go b/api/internal/handler/cloud/controllermetricshandler.go deleted file mode 100644 index 83aa7595..00000000 --- a/api/internal/handler/cloud/controllermetricshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloud - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ControllerMetricsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ControllerMetricsReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := cloud.NewControllerMetricsLogic(r.Context(), svcCtx) - resp, err := l.ControllerMetrics(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/deleteclusterhandler.go b/api/internal/handler/cloud/deleteclusterhandler.go deleted file mode 100644 index 7c27c7d0..00000000 --- a/api/internal/handler/cloud/deleteclusterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloud - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteClusterReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := cloud.NewDeleteClusterLogic(r.Context(), svcCtx) - resp, err := l.DeleteCluster(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/deleteyamlhandler.go b/api/internal/handler/cloud/deleteyamlhandler.go deleted file mode 100644 index d4eb7b7b..00000000 --- a/api/internal/handler/cloud/deleteyamlhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloud - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ApplyReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := cloud.NewDeleteYamlLogic(r.Context(), svcCtx) - resp, err := l.DeleteYaml(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/getclusterlisthandler.go b/api/internal/handler/cloud/getclusterlisthandler.go deleted file mode 100644 index 0363e174..00000000 --- a/api/internal/handler/cloud/getclusterlisthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloud - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetClusterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetClusterListReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := cloud.NewGetClusterListLogic(r.Context(), svcCtx) - resp, err := l.GetClusterList(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/podlogshandler.go b/api/internal/handler/cloud/podlogshandler.go deleted file mode 100644 index 78824344..00000000 --- a/api/internal/handler/cloud/podlogshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloud - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func PodLogsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.PodLogsReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := cloud.NewPodLogsLogic(r.Context(), svcCtx, w) - resp, err := l.PodLogs(&req, w) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/cloud/registerclusterhandler.go b/api/internal/handler/cloud/registerclusterhandler.go deleted file mode 100644 index 54deafb0..00000000 --- a/api/internal/handler/cloud/registerclusterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package cloud - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func RegisterClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.RegisterClusterReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := cloud.NewRegisterClusterLogic(r.Context(), svcCtx) - resp, err := l.RegisterCluster(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/centerresourceshandler.go b/api/internal/handler/core/centerresourceshandler.go deleted file mode 100644 index 31aef57b..00000000 --- a/api/internal/handler/core/centerresourceshandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CenterResourcesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewCenterResourcesLogic(r.Context(), svcCtx) - resp, err := l.CenterResources() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/committaskhandler.go b/api/internal/handler/core/committaskhandler.go deleted file mode 100644 index b0642b7c..00000000 --- a/api/internal/handler/core/committaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CommitTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CommitTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewCommitTaskLogic(r.Context(), svcCtx) - err := l.CommitTask(&req) - result.HttpResult(r, w, nil, err) - } -} diff --git a/api/internal/handler/core/commitvmtaskhandler.go b/api/internal/handler/core/commitvmtaskhandler.go deleted file mode 100644 index 7f8ab825..00000000 --- a/api/internal/handler/core/commitvmtaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CommitVmTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CommitVmTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewCommitVmTaskLogic(r.Context(), svcCtx) - resp, err := l.CommitVmTask(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/counttaskstatushandler.go b/api/internal/handler/core/counttaskstatushandler.go deleted file mode 100644 index 6f46929d..00000000 --- a/api/internal/handler/core/counttaskstatushandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CountTaskStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewCountTaskStatusLogic(r.Context(), svcCtx) - resp, err := l.CountTaskStatus() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/deletetaskhandler.go b/api/internal/handler/core/deletetaskhandler.go deleted file mode 100644 index b922b88b..00000000 --- a/api/internal/handler/core/deletetaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewDeleteTaskLogic(r.Context(), svcCtx) - err := l.DeleteTask(&req) - result.HttpResult(r, w, nil, err) - } -} diff --git a/api/internal/handler/core/getcomputilitystatisticshandler.go b/api/internal/handler/core/getcomputilitystatisticshandler.go deleted file mode 100644 index 06183c83..00000000 --- a/api/internal/handler/core/getcomputilitystatisticshandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -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() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/getcomputingpowerhandler.go b/api/internal/handler/core/getcomputingpowerhandler.go deleted file mode 100644 index 9f031ac0..00000000 --- a/api/internal/handler/core/getcomputingpowerhandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetComputingPowerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewGetComputingPowerLogic(r.Context(), svcCtx) - resp, err := l.GetComputingPower() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/getdomainresourcehandler.go b/api/internal/handler/core/getdomainresourcehandler.go deleted file mode 100644 index 6ab31112..00000000 --- a/api/internal/handler/core/getdomainresourcehandler.go +++ /dev/null @@ -1,17 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func GetDomainResourceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewGetDomainResourceLogic(r.Context(), svcCtx) - resp, err := l.GetDomainResource() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/getgeneralinfohandler.go b/api/internal/handler/core/getgeneralinfohandler.go deleted file mode 100644 index 614e1954..00000000 --- a/api/internal/handler/core/getgeneralinfohandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetGeneralInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewGetGeneralInfoLogic(r.Context(), svcCtx) - resp, err := l.GetGeneralInfo() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/getpublicflavorhandler.go b/api/internal/handler/core/getpublicflavorhandler.go deleted file mode 100644 index 0fc1942a..00000000 --- a/api/internal/handler/core/getpublicflavorhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetPublicFlavorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.PublicFlavorReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewGetPublicFlavorLogic(r.Context(), svcCtx) - resp, err := l.GetPublicFlavor(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/getpublicimagehandler.go b/api/internal/handler/core/getpublicimagehandler.go deleted file mode 100644 index de2b1033..00000000 --- a/api/internal/handler/core/getpublicimagehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetPublicImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.PublicImageReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewGetPublicImageLogic(r.Context(), svcCtx) - resp, err := l.GetPublicImage(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/getpublicnetworkhandler.go b/api/internal/handler/core/getpublicnetworkhandler.go deleted file mode 100644 index 7450740d..00000000 --- a/api/internal/handler/core/getpublicnetworkhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetPublicNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.PublicNetworkReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewGetPublicNetworkLogic(r.Context(), svcCtx) - resp, err := l.GetPublicNetwork(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/getregionhandler.go b/api/internal/handler/core/getregionhandler.go deleted file mode 100644 index 3b884280..00000000 --- a/api/internal/handler/core/getregionhandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewGetRegionLogic(r.Context(), svcCtx) - resp, err := l.GetRegion() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/getresourcepanelconfighandler.go b/api/internal/handler/core/getresourcepanelconfighandler.go deleted file mode 100644 index bc84d068..00000000 --- a/api/internal/handler/core/getresourcepanelconfighandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetResourcePanelConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewGetResourcePanelConfigLogic(r.Context(), svcCtx) - resp, err := l.GetResourcePanelConfig() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/getscreencharthandler.go b/api/internal/handler/core/getscreencharthandler.go deleted file mode 100644 index 64f7ea93..00000000 --- a/api/internal/handler/core/getscreencharthandler.go +++ /dev/null @@ -1,17 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func GetScreenChartHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewGetScreenChartLogic(r.Context(), svcCtx) - resp, err := l.GetScreenChart() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/getscreeninfohandler.go b/api/internal/handler/core/getscreeninfohandler.go deleted file mode 100644 index 65a28a6e..00000000 --- a/api/internal/handler/core/getscreeninfohandler.go +++ /dev/null @@ -1,17 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func GetScreenInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewGetScreenInfoLogic(r.Context(), svcCtx) - resp, err := l.GetScreenInfo() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/homeoverviewhandler.go b/api/internal/handler/core/homeoverviewhandler.go deleted file mode 100644 index 3cf4ac59..00000000 --- a/api/internal/handler/core/homeoverviewhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func HomeOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.HomeOverviewReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewHomeOverviewLogic(r.Context(), svcCtx) - resp, err := l.HomeOverview(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/jobtotalhandler.go b/api/internal/handler/core/jobtotalhandler.go deleted file mode 100644 index 0d59f6bc..00000000 --- a/api/internal/handler/core/jobtotalhandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func JobTotalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewJobTotalLogic(r.Context(), svcCtx) - resp, err := l.JobTotal() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/listcenterhandler.go b/api/internal/handler/core/listcenterhandler.go deleted file mode 100644 index 0c7b8c4f..00000000 --- a/api/internal/handler/core/listcenterhandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListCenterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewListCenterLogic(r.Context(), svcCtx) - resp, err := l.ListCenter() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/listclusterhandler.go b/api/internal/handler/core/listclusterhandler.go deleted file mode 100644 index 96fa7279..00000000 --- a/api/internal/handler/core/listclusterhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListClusterReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewListClusterLogic(r.Context(), svcCtx) - resp, err := l.ListCluster(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/listnoticehandler.go b/api/internal/handler/core/listnoticehandler.go deleted file mode 100644 index 9df28753..00000000 --- a/api/internal/handler/core/listnoticehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func ListNoticeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req clientCore.ListNoticeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewListNoticeLogic(r.Context(), svcCtx) - resp, err := l.ListNotice(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/listregionhandler.go b/api/internal/handler/core/listregionhandler.go deleted file mode 100644 index 80d60ef8..00000000 --- a/api/internal/handler/core/listregionhandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewListRegionLogic(r.Context(), svcCtx) - resp, err := l.ListRegion() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/metricshandler.go b/api/internal/handler/core/metricshandler.go deleted file mode 100644 index bec78bfc..00000000 --- a/api/internal/handler/core/metricshandler.go +++ /dev/null @@ -1,11 +0,0 @@ -package core - -import ( - "github.com/prometheus/client_golang/prometheus/promhttp" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "net/http" -) - -func MetricsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return promhttp.Handler().ServeHTTP -} diff --git a/api/internal/handler/core/nodeassetshandler.go b/api/internal/handler/core/nodeassetshandler.go deleted file mode 100644 index 9117fb16..00000000 --- a/api/internal/handler/core/nodeassetshandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func NodeAssetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewNodeAssetsLogic(r.Context(), svcCtx) - resp, err := l.NodeAssets() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/pagelisttaskhandler.go b/api/internal/handler/core/pagelisttaskhandler.go deleted file mode 100644 index 42912e04..00000000 --- a/api/internal/handler/core/pagelisttaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func PageListTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.PageTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewPageListTaskLogic(r.Context(), svcCtx) - resp, err := l.PageListTask(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/participantlisthandler.go b/api/internal/handler/core/participantlisthandler.go deleted file mode 100644 index c6795eef..00000000 --- a/api/internal/handler/core/participantlisthandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ParticipantListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := core.NewParticipantListLogic(r.Context(), svcCtx) - resp, err := l.ParticipantList() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/pulltaskinfohandler.go b/api/internal/handler/core/pulltaskinfohandler.go deleted file mode 100644 index ed98c682..00000000 --- a/api/internal/handler/core/pulltaskinfohandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func PullTaskInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req clientCore.PullTaskInfoReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewPullTaskInfoLogic(r.Context(), svcCtx) - resp, err := l.PullTaskInfo((*clientCore.PullTaskInfoReq)(&req)) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/pushnoticehandler.go b/api/internal/handler/core/pushnoticehandler.go deleted file mode 100644 index f9205846..00000000 --- a/api/internal/handler/core/pushnoticehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func PushNoticeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req clientCore.PushNoticeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewPushNoticeLogic(r.Context(), svcCtx) - resp, err := l.PushNotice(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/pushresourceinfohandler.go b/api/internal/handler/core/pushresourceinfohandler.go deleted file mode 100644 index 1212a898..00000000 --- a/api/internal/handler/core/pushresourceinfohandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func PushResourceInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req clientCore.PushResourceInfoReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewPushResourceInfoLogic(r.Context(), svcCtx) - resp, err := l.PushResourceInfo(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/pushtaskinfohandler.go b/api/internal/handler/core/pushtaskinfohandler.go deleted file mode 100644 index fa7f5e91..00000000 --- a/api/internal/handler/core/pushtaskinfohandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func PushTaskInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req clientCore.PushTaskInfoReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := core.NewPushTaskInfoLogic(r.Context(), svcCtx) - resp, err := l.PushTaskInfo(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/core/putresourcepanelconfighandler.go b/api/internal/handler/core/putresourcepanelconfighandler.go deleted file mode 100644 index 0700c6cd..00000000 --- a/api/internal/handler/core/putresourcepanelconfighandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func PutResourcePanelConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ResourcePanelConfigReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewPutResourcePanelConfigLogic(r.Context(), svcCtx) - err := l.PutResourcePanelConfig(&req) - result.HttpResult(r, w, nil, err) - } -} diff --git a/api/internal/handler/core/scheduletaskbyyamlhandler.go b/api/internal/handler/core/scheduletaskbyyamlhandler.go deleted file mode 100644 index c3447137..00000000 --- a/api/internal/handler/core/scheduletaskbyyamlhandler.go +++ /dev/null @@ -1,36 +0,0 @@ -package core - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ScheduleTaskByYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ScheduleTaskByYamlReq - if err := httpx.Parse(r, &req); err != nil { - result.HttpResult(r, w, nil, err) - return - } - // 解析yaml文件 - _, fileHeader, err := r.FormFile("file") - if err != nil { - result.HttpResult(r, w, nil, err) - return - } - err = utils.Yaml2struct(fileHeader, &req) - if err != nil { - result.HttpResult(r, w, nil, err) - return - } - l := core.NewScheduleTaskByYamlLogic(r.Context(), svcCtx) - resp, err := l.ScheduleTaskByYaml(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/syncclusterloadhandler.go b/api/internal/handler/core/syncclusterloadhandler.go deleted file mode 100644 index da5f6f1b..00000000 --- a/api/internal/handler/core/syncclusterloadhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func SyncClusterLoadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.SyncClusterLoadReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewSyncClusterLoadLogic(r.Context(), svcCtx) - err := l.SyncClusterLoad(&req) - result.HttpResult(r, w, nil, err) - } -} diff --git a/api/internal/handler/core/taskdetailshandler.go b/api/internal/handler/core/taskdetailshandler.go deleted file mode 100644 index cc3ac448..00000000 --- a/api/internal/handler/core/taskdetailshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func TaskDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.FId - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewTaskDetailsLogic(r.Context(), svcCtx) - resp, err := l.TaskDetails(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/core/tasklisthandler.go b/api/internal/handler/core/tasklisthandler.go deleted file mode 100644 index 3a16cb02..00000000 --- a/api/internal/handler/core/tasklisthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package core - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func TaskListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.TaskListReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := core.NewTaskListLogic(r.Context(), svcCtx) - resp, err := l.TaskList(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/adddicthandler.go b/api/internal/handler/dictionary/adddicthandler.go deleted file mode 100644 index f97da1bb..00000000 --- a/api/internal/handler/dictionary/adddicthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func AddDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DictEditReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewAddDictLogic(r.Context(), svcCtx) - resp, err := l.AddDict(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/adddictitemhandler.go b/api/internal/handler/dictionary/adddictitemhandler.go deleted file mode 100644 index 44dbe883..00000000 --- a/api/internal/handler/dictionary/adddictitemhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func AddDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DictItemEditReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewAddDictItemLogic(r.Context(), svcCtx) - resp, err := l.AddDictItem(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/deletedicthandler.go b/api/internal/handler/dictionary/deletedicthandler.go deleted file mode 100644 index e65e54c2..00000000 --- a/api/internal/handler/dictionary/deletedicthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CId - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewDeleteDictLogic(r.Context(), svcCtx) - resp, err := l.DeleteDict(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/deletedictitemhandler.go b/api/internal/handler/dictionary/deletedictitemhandler.go deleted file mode 100644 index 65139c09..00000000 --- a/api/internal/handler/dictionary/deletedictitemhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func DeleteDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CId - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewDeleteDictItemLogic(r.Context(), svcCtx) - resp, err := l.DeleteDictItem(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/editdicthandler.go b/api/internal/handler/dictionary/editdicthandler.go deleted file mode 100644 index fe0ef391..00000000 --- a/api/internal/handler/dictionary/editdicthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func EditDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DictEditReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewEditDictLogic(r.Context(), svcCtx) - resp, err := l.EditDict(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/editdictitemhandler.go b/api/internal/handler/dictionary/editdictitemhandler.go deleted file mode 100644 index 295e9095..00000000 --- a/api/internal/handler/dictionary/editdictitemhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func EditDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DictItemEditReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewEditDictItemLogic(r.Context(), svcCtx) - resp, err := l.EditDictItem(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/getdicthandler.go b/api/internal/handler/dictionary/getdicthandler.go deleted file mode 100644 index b1b56d0d..00000000 --- a/api/internal/handler/dictionary/getdicthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CId - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewGetDictLogic(r.Context(), svcCtx) - resp, err := l.GetDict(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/getdictitemhandler.go b/api/internal/handler/dictionary/getdictitemhandler.go deleted file mode 100644 index bbfe113f..00000000 --- a/api/internal/handler/dictionary/getdictitemhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func GetDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CId - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewGetDictItemLogic(r.Context(), svcCtx) - resp, err := l.GetDictItem(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/listdicthandler.go b/api/internal/handler/dictionary/listdicthandler.go deleted file mode 100644 index 72dac7c8..00000000 --- a/api/internal/handler/dictionary/listdicthandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DictReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewListDictLogic(r.Context(), svcCtx) - resp, err := l.ListDict(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/listdictitembycodehandler.go b/api/internal/handler/dictionary/listdictitembycodehandler.go deleted file mode 100644 index c6400185..00000000 --- a/api/internal/handler/dictionary/listdictitembycodehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListDictItemByCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DictCodeReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewListDictItemByCodeLogic(r.Context(), svcCtx) - resp, err := l.ListDictItemByCode(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/dictionary/listdictitemhandler.go b/api/internal/handler/dictionary/listdictitemhandler.go deleted file mode 100644 index 16df182d..00000000 --- a/api/internal/handler/dictionary/listdictitemhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package dictionary - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ListDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DictItemReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := dictionary.NewListDictItemLogic(r.Context(), svcCtx) - resp, err := l.ListDictItem(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/hpc/adaptersummaryhandler.go b/api/internal/handler/hpc/adaptersummaryhandler.go deleted file mode 100644 index f5178829..00000000 --- a/api/internal/handler/hpc/adaptersummaryhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package hpc - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/hpc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func AdapterSummaryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.HpcAdapterSummaryReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := hpc.NewAdapterSummaryLogic(r.Context(), svcCtx) - resp, err := l.AdapterSummary(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/hpc/commithpctaskhandler.go b/api/internal/handler/hpc/commithpctaskhandler.go deleted file mode 100644 index 7408b559..00000000 --- a/api/internal/handler/hpc/commithpctaskhandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package hpc - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/hpc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CommitHpcTaskReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := hpc.NewCommitHpcTaskLogic(r.Context(), svcCtx) - resp, err := l.CommitHpcTask(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/hpc/jobhandler.go b/api/internal/handler/hpc/jobhandler.go deleted file mode 100644 index ce1725c1..00000000 --- a/api/internal/handler/hpc/jobhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package hpc - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/hpc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func JobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.HpcJobReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := hpc.NewJobLogic(r.Context(), svcCtx) - resp, err := l.Job(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/hpc/overviewhandler.go b/api/internal/handler/hpc/overviewhandler.go deleted file mode 100644 index 3cb75018..00000000 --- a/api/internal/handler/hpc/overviewhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package hpc - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/hpc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func OverViewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.HpcOverViewReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := hpc.NewOverViewLogic(r.Context(), svcCtx) - resp, err := l.OverView(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/hpc/queueassetshandler.go b/api/internal/handler/hpc/queueassetshandler.go deleted file mode 100644 index 135d88bd..00000000 --- a/api/internal/handler/hpc/queueassetshandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package hpc - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/hpc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func QueueAssetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := hpc.NewQueueAssetsLogic(r.Context(), svcCtx) - resp, err := l.QueueAssets() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/hpc/resourcehandler.go b/api/internal/handler/hpc/resourcehandler.go deleted file mode 100644 index 2f321824..00000000 --- a/api/internal/handler/hpc/resourcehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package hpc - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/hpc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ResourceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.HpcResourceReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := hpc.NewResourceLogic(r.Context(), svcCtx) - resp, err := l.Resource(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/inference/imageinferencehandler.go b/api/internal/handler/inference/imageinferencehandler.go deleted file mode 100644 index 04ae9f78..00000000 --- a/api/internal/handler/inference/imageinferencehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package inference - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ImageInferenceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ImageInferenceReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := inference.NewImageInferenceLogic(r.Context(), svcCtx) - resp, err := l.ImageInfer(r, &req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/inference/inferencetaskdetailhandler.go b/api/internal/handler/inference/inferencetaskdetailhandler.go deleted file mode 100644 index a1f5a30f..00000000 --- a/api/internal/handler/inference/inferencetaskdetailhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package inference - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func InferenceTaskDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.InferenceTaskDetailReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := inference.NewInferenceTaskDetailLogic(r.Context(), svcCtx) - resp, err := l.InferenceTaskDetail(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/inference/modelnamesbytypehandler.go b/api/internal/handler/inference/modelnamesbytypehandler.go deleted file mode 100644 index 86f1e339..00000000 --- a/api/internal/handler/inference/modelnamesbytypehandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package inference - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" -) - -func ModelNamesByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ModelNamesReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := inference.NewModelNamesByTypeLogic(r.Context(), svcCtx) - resp, err := l.ModelNamesByType(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/inference/modeltypeshandler.go b/api/internal/handler/inference/modeltypeshandler.go deleted file mode 100644 index 1ee33432..00000000 --- a/api/internal/handler/inference/modeltypeshandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package inference - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ModelTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := inference.NewModelTypesLogic(r.Context(), svcCtx) - resp, err := l.ModelTypes() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/inference/texttotextinferencehandler.go b/api/internal/handler/inference/texttotextinferencehandler.go deleted file mode 100644 index d291d60e..00000000 --- a/api/internal/handler/inference/texttotextinferencehandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package inference - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func TextToTextInferenceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.TextToTextInferenceReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := inference.NewTextToTextInferenceLogic(r.Context(), svcCtx) - resp, err := l.TextToTextInference(&req) - result.HttpResult(r, w, resp, err) - - } -} diff --git a/api/internal/handler/monitoring/adapterinfohandler.go b/api/internal/handler/monitoring/adapterinfohandler.go deleted file mode 100644 index 4869213f..00000000 --- a/api/internal/handler/monitoring/adapterinfohandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func AdapterInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AdapterInfoReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewAdapterInfoLogic(r.Context(), svcCtx) - resp, err := l.AdapterInfo(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/monitoring/alertlisthandler.go b/api/internal/handler/monitoring/alertlisthandler.go deleted file mode 100644 index 227e45cb..00000000 --- a/api/internal/handler/monitoring/alertlisthandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func AlertListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AlertListReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewAlertListLogic(r.Context(), svcCtx) - resp, err := l.AlertList(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/monitoring/alertruleshandler.go b/api/internal/handler/monitoring/alertruleshandler.go deleted file mode 100644 index dd7c8607..00000000 --- a/api/internal/handler/monitoring/alertruleshandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func AlertRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AlertRulesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewAlertRulesLogic(r.Context(), svcCtx) - resp, err := l.AlertRules(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/monitoring/clustersloadhandler.go b/api/internal/handler/monitoring/clustersloadhandler.go deleted file mode 100644 index 6758c46a..00000000 --- a/api/internal/handler/monitoring/clustersloadhandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ClustersLoadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ClustersLoadReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewClustersLoadLogic(r.Context(), svcCtx) - resp, err := l.ClustersLoad(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/monitoring/createalertrulehandler.go b/api/internal/handler/monitoring/createalertrulehandler.go deleted file mode 100644 index 292ca021..00000000 --- a/api/internal/handler/monitoring/createalertrulehandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateAlertRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateAlertRuleReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewCreateAlertRuleLogic(r.Context(), svcCtx) - err := l.CreateAlertRule(&req) - result.HttpResult(r, w, nil, err) - } -} diff --git a/api/internal/handler/monitoring/deletealertrulehandler.go b/api/internal/handler/monitoring/deletealertrulehandler.go deleted file mode 100644 index e7593a92..00000000 --- a/api/internal/handler/monitoring/deletealertrulehandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteAlertRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteAlertRuleReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewDeleteAlertRuleLogic(r.Context(), svcCtx) - err := l.DeleteAlertRule(&req) - result.HttpResult(r, w, nil, err) - } -} diff --git a/api/internal/handler/monitoring/nodesloadtophandler.go b/api/internal/handler/monitoring/nodesloadtophandler.go deleted file mode 100644 index 81630285..00000000 --- a/api/internal/handler/monitoring/nodesloadtophandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func NodesLoadTopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.NodesLoadTopReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewNodesLoadTopLogic(r.Context(), svcCtx) - resp, err := l.NodesLoadTop(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/monitoring/schedulesituationhandler.go b/api/internal/handler/monitoring/schedulesituationhandler.go deleted file mode 100644 index 4677a111..00000000 --- a/api/internal/handler/monitoring/schedulesituationhandler.go +++ /dev/null @@ -1,17 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func ScheduleSituationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := monitoring.NewScheduleSituationLogic(r.Context(), svcCtx) - resp, err := l.ScheduleSituation() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/monitoring/syncclusteralerthandler.go b/api/internal/handler/monitoring/syncclusteralerthandler.go deleted file mode 100644 index 8aac80f6..00000000 --- a/api/internal/handler/monitoring/syncclusteralerthandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package monitoring - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func SyncClusterAlertHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.SyncClusterAlertReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewSyncClusterAlertLogic(r.Context(), svcCtx) - err := l.SyncClusterAlert(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.Ok(w) - } - } -} diff --git a/api/internal/handler/monitoring/tasknumhandler.go b/api/internal/handler/monitoring/tasknumhandler.go deleted file mode 100644 index 4b7751bc..00000000 --- a/api/internal/handler/monitoring/tasknumhandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package monitoring - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func TaskNumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.TaskNumReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := monitoring.NewTaskNumLogic(r.Context(), svcCtx) - resp, err := l.TaskNum(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go deleted file mode 100644 index c3315879..00000000 --- a/api/internal/handler/routes.go +++ /dev/null @@ -1,1306 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -package handler - -import ( - "net/http" - - adapters "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/adapters" - ai "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/ai" - cloud "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/cloud" - core "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/core" - dictionary "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/dictionary" - hpc "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/hpc" - inference "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/inference" - monitoring "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/monitoring" - schedule "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/schedule" - storage "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/storage" - storelink "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/storelink" - vm "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - - "github.com/zeromicro/go-zero/rest" -) - -func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodGet, - Path: "/core/participantList", - Handler: core.ParticipantListHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/scheduleTaskByYaml", - Handler: core.ScheduleTaskByYamlHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/commitTask", - Handler: core.CommitTaskHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/commitVmTask", - Handler: core.CommitVmTaskHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/core/deleteTask/:id", - Handler: core.DeleteTaskHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/taskList", - Handler: core.TaskListHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/jobTotal", - Handler: core.JobTotalHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/listCenter", - Handler: core.ListCenterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/listCluster/:centerId", - Handler: core.ListClusterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getRegion", - Handler: core.GetRegionHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/listRegion", - Handler: core.ListRegionHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getComputingPower", - Handler: core.GetComputingPowerHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getGeneralInfo", - Handler: core.GetGeneralInfoHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getResourcePanelConfigHandler", - Handler: core.GetResourcePanelConfigHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/core/resourcePanelConfigHandler", - Handler: core.PutResourcePanelConfigHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getComputilityStatistics", - Handler: core.GetComputilityStatisticsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/assets", - Handler: core.NodeAssetsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/centerResources", - Handler: core.CenterResourcesHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/syncClusterLoad", - Handler: core.SyncClusterLoadHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/metrics", - Handler: core.MetricsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/pullTaskInfo", - Handler: core.PullTaskInfoHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/pushTaskInfo", - Handler: core.PushTaskInfoHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/pushResourceInfo", - Handler: core.PushResourceInfoHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/core/pushNotice", - Handler: core.PushNoticeHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/listNotice", - Handler: core.ListNoticeHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/task/list", - Handler: core.PageListTaskHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/task/countTaskStatus", - Handler: core.CountTaskStatusHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/homeOverview", - Handler: core.HomeOverviewHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/task/details", - Handler: core.TaskDetailsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getPublicImage", - Handler: core.GetPublicImageHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getPublicFlavor", - Handler: core.GetPublicFlavorHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getPublicNetwork", - Handler: core.GetPublicNetworkHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getDomainResource", - Handler: core.GetDomainResourceHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getScreenInfo", - Handler: core.GetScreenInfoHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/getScreenChart", - Handler: core.GetScreenChartHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodPost, - Path: "/hpc/commitHpcTask", - Handler: hpc.CommitHpcTaskHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/hpc/overview", - Handler: hpc.OverViewHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/hpc/adapterSummary", - Handler: hpc.AdapterSummaryHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/hpc/job", - Handler: hpc.JobHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/hpc/resource", - Handler: hpc.ResourceHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/hpc/queueAssets", - 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), - }, - { - Method: http.MethodGet, - Path: "/cloud/controller/Metrics", - Handler: cloud.ControllerMetricsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/cloud/registerCluster", - Handler: cloud.RegisterClusterHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/cloud/deleteCluster", - Handler: cloud.DeleteClusterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/core/clusterList", - Handler: cloud.GetClusterListHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/cloud/task/create", - Handler: cloud.CommitGeneralTaskHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/cloud/pod/logs", - Handler: cloud.PodLogsHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodGet, - Path: "/ai/getCenterOverview", - Handler: ai.GetCenterOverviewHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/getCenterQueueing", - Handler: ai.GetCenterQueueingHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/getCenterList", - Handler: ai.GetCenterListHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/getCenterTaskList", - Handler: ai.GetCenterTaskListHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/listDataSet/:projectId", - Handler: ai.ListDataSetHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/createDataSet/:projectId", - Handler: ai.CreateDataSetHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/ai/deleteDataSet/:projectId/:datasetId", - Handler: ai.DeleteDataSetHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/CreateTask/:projectId/:datasetId", - Handler: ai.CreateTaskHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/ListImport/:projectId/:datasetId", - Handler: ai.ListImportHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/GetListTrainingJobs/:projectId", - Handler: ai.GetListTrainingJobsHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/ai/DeleteTrainingJob/:projectId/:trainingJobId", - Handler: ai.DeleteTrainingJobHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/CreateAlgorithm/:projectId", - Handler: ai.CreateAlgorithmHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/ListAlgorithms/:projectId", - Handler: ai.ListAlgorithmsHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/ai/DeleteAlgorithm/:projectId/:algorithmId", - Handler: ai.DeleteAlgorithmHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/CreateTrainingJob/:projectId", - Handler: ai.CreateTrainingJobHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/ShowAlgorithmByUuid/:projectId/:algorithmId", - Handler: ai.ShowAlgorithmByUuidHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/CreateExportTask/:projectId/:datasetId", - Handler: ai.CreateExportTaskHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/GetExportTasksOfDataset/:projectId/:datasetId", - Handler: ai.GetExportTasksOfDatasetHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/GetExportTaskStatusOfDataset/:projectId/:resourceId/:taskId", - Handler: ai.GetExportTaskStatusOfDatasetHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/CreateProcessorTask", - Handler: ai.CreateProcessorTaskHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/CreateService/:projectId", - Handler: ai.CreateServiceHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/ListServices/:projectId", - Handler: ai.ListServicesHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/ShowService/:projectId/:serviceId", - Handler: ai.ShowServiceHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/ai/DeleteService/:projectId/:serviceId", - Handler: ai.DeleteServiceHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/ListClusters", - Handler: ai.ListClustersHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/listNotebook", - Handler: ai.ListNotebookHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/createNotebook", - Handler: ai.CreateNotebookHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/startNotebook", - Handler: ai.StartNotebookHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/stopNotebook", - Handler: ai.StopNotebookHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/getNotebookStorage", - Handler: ai.GetNotebookStorageHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/mountNotebookStorage", - Handler: ai.MountNotebookStorageHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/ai/getVisualizationJob", - Handler: ai.GetVisualizationJobHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/CreateVisualizationJob", - Handler: ai.CreateVisualizationJobHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/ai/chat", - Handler: ai.ProxyApiHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodGet, - Path: "/storage/screenStorage", - Handler: storage.ScreenStorageHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/storage/dailyPowerScreen", - Handler: storage.DailyPowerScreenHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/storage/perCenterComputerPowers", - Handler: storage.PerCenterComputerPowersHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - 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/getNetworkNum", - Handler: vm.GetNetworkNumHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/getImageNum", - Handler: vm.GetImageNumHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/getOpenstackOverview", - Handler: vm.GetOpenstackOverviewHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listServer", - Handler: vm.ListServerHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listServersDetailed", - Handler: vm.ListServersDetailedHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteServer", - Handler: vm.DeleteServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createServer", - Handler: vm.CreateServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createMulServer", - Handler: vm.CreateMulServerHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/getServersDetailedById", - Handler: vm.GetServersDetailedByIdHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateServer", - Handler: vm.UpdateServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/startServer", - Handler: vm.StartServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/stopServer", - Handler: vm.StopServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/rebootServer", - Handler: vm.RebootServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/pauseServer", - Handler: vm.PauseServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/unpauseServer", - Handler: vm.UnpauseServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/resizeServer", - Handler: vm.ResizeServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/migrateServer", - Handler: vm.MigrateServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/shelveServer", - Handler: vm.ShelveServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/changeAdministrativePassword", - Handler: vm.ChangeAdministrativePasswordHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/rescueServer", - Handler: vm.RescueServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/unRescueServer", - Handler: vm.UnRescueHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/suspendServer", - Handler: vm.SuspendServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/addSecurityGroupToServer", - Handler: vm.AddSecurityGroupToServerHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/removeSecurityGroup", - Handler: vm.RemoveSecurityGroupHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createFlavor", - Handler: vm.CreateFlavorHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/deleteFlavor", - Handler: vm.DeleteFlavorHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listImages", - Handler: vm.ListImagesHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteImage", - Handler: vm.DeleteImageHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createImage", - Handler: vm.CreateImageHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/uploadImage", - Handler: vm.UploadImageHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listNetworks", - Handler: vm.ListNetworksHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteNetwork", - Handler: vm.DeleteNetworkHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createNetwork", - Handler: vm.CreateNetworkHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createSubnet", - Handler: vm.CreateSubnetHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showNetworkDetails", - Handler: vm.ShowNetworkDetailsHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateNetwork", - Handler: vm.UpdateNetworkHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/bulkCreateNetworks", - Handler: vm.BulkCreateNetworksHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listSubnets", - Handler: vm.ListSubnetsHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteSubnet", - Handler: vm.DeleteSubnetHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateSubnet", - Handler: vm.UpdateSubnetHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listNetworkSegmentRanges", - Handler: vm.ListNetworkSegmentRangesRangeHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createNetworkSegmentRange", - Handler: vm.CreateNetworkSegmentRangeHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteNetworkSegmentRanges", - Handler: vm.DeleteNetworkSegmentRangesHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateNetworkSegmentRanges", - Handler: vm.UpdateNetworkSegmentRangesHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showNetworkSegmentRangeDetails", - Handler: vm.ShowNetworkSegmentRangeDetailsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createPort", - Handler: vm.CreatePortHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listPortsReq", - Handler: vm.ListPortsHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deletePort", - Handler: vm.DeletePortHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updatePort", - Handler: vm.UpdatePortHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showPortDetails", - Handler: vm.ShowPortDetailsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createRouter", - Handler: vm.CreateRouterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listRouters", - Handler: vm.ListRoutersHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteRouter", - Handler: vm.DeleteRouterHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateRouter", - Handler: vm.UpdateRouterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showRouterDetails", - Handler: vm.ShowRouterDetailsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createFloatingIP", - Handler: vm.CreateFloatingIPHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listFloatingIPs", - Handler: vm.ListFloatingIPsHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteFloatingIP", - Handler: vm.DeleteFloatingIPHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateFloatingIP", - Handler: vm.UpdateFloatingIPHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showFloatingIPDetails", - Handler: vm.ShowFloatingIPDetailsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createFirewallGroup", - Handler: vm.CreateFirewallGroupHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listFirewallGroups", - Handler: vm.ListFirewallGroupsHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteFirewallGroup", - Handler: vm.DeleteFirewallGroupHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateFirewallGroup", - Handler: vm.UpdateFirewallGroupHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showFirewallGroupDetails", - Handler: vm.ShowFirewallGroupDetailsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createFirewallPolicy", - Handler: vm.CreateFirewallPolicyHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listFirewallPolicies", - Handler: vm.ListFirewallPoliciesHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteFirewallPolicy", - Handler: vm.DeleteFirewallPolicyHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showFirewallRuleDetails", - Handler: vm.ShowFirewallRuleDetailsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showFirewallPolicyDetails", - Handler: vm.ShowFirewallPolicyDetailsHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createFirewallRule", - Handler: vm.CreateFirewallRuleHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listFirewallRules", - Handler: vm.ListFirewallRulesHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteFirewallRule", - Handler: vm.DeleteFirewallRuleHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createSecurityGroup", - Handler: vm.CreateSecurityGroupHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listSecurityGroups", - Handler: vm.ListSecurityGroupsHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteSecurityGroup", - Handler: vm.DeleteSecurityGroupHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateSecurityGroup", - Handler: vm.UpdateSecurityGroupHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showSecurityGroup", - Handler: vm.ShowSecurityGroupHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createSecurityGroupRule", - Handler: vm.CreateSecurityGroupRuleHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listSecurityGroupRules", - Handler: vm.ListSecurityGroupRulesHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteSecurityGroupRule", - Handler: vm.DeleteSecurityGroupRuleHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showSecurityGroupRule", - Handler: vm.ShowSecurityGroupRuleHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listVolumesDetail", - Handler: vm.ListVolumesDetailHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteVolume", - Handler: vm.DeleteVolumeHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createVolume", - Handler: vm.CreateVolumeHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listFlavorsDetail", - Handler: vm.ListFlavorsDetailHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listVolumeTypes", - Handler: vm.ListVolumeTypesHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/vm/updateVolume", - Handler: vm.UpdateVolumeHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createVolumeTypes", - Handler: vm.CreateVolumeTypesHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteVolumeType", - Handler: vm.DeleteVolumeTypeHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listVolumes", - Handler: vm.ListVolumesHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/getVolumeDetailedById", - Handler: vm.GetVolumeDetailedByIdHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/listNodes", - Handler: vm.ListNodesHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/vm/createNode", - Handler: vm.CreateNodeHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/vm/deleteNode", - Handler: vm.DeleteNodeHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/vm/showNodeDetails", - Handler: vm.ShowNodeDetailsHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodPost, - Path: "/storelink/uploadImage", - Handler: storelink.UploadLinkImageHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/storelink/getImageList", - Handler: storelink.GetLinkImageListHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/storelink/deleteImage", - Handler: storelink.DeleteLinkImageHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/storelink/submitTask", - Handler: storelink.SubmitLinkTaskHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/storelink/getTask", - Handler: storelink.GetLinkTaskHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/storelink/deleteTask", - Handler: storelink.DeleteLinkTaskHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/storelink/getParticipants", - Handler: storelink.GetParticipantsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/storelink/getResourceSpecs", - Handler: storelink.GetAISpecsHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodGet, - Path: "/adapter/list", - Handler: adapters.AdaptersListHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/adapter/create", - Handler: adapters.CreateAdapterHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/adapter/update", - Handler: adapters.UpdateAdapterHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/adapter/delete", - Handler: adapters.DeleteAdapterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/adapter/get", - Handler: adapters.GetAdapterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/adapter/cluster/list", - Handler: adapters.ClusterListHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/adapter/cluster/create", - Handler: adapters.CreateClusterHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/adapter/cluster/update", - Handler: adapters.UpdateClusterHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/adapter/cluster/delete", - Handler: adapters.DeleteClusterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/adapter/cluster/get", - Handler: adapters.GetClusterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/adapter/relation", - Handler: adapters.GetAdapterRelationHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/adapter/clusterSum", - Handler: adapters.GetClusterSumHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodGet, - Path: "/schedule/ai/getResourceTypes", - Handler: schedule.ScheduleGetAiResourceTypesHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/ai/getTaskTypes", - Handler: schedule.ScheduleGetAiTaskTypesHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/ai/getDatasets/:adapterId", - Handler: schedule.ScheduleGetDatasetsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/ai/getStrategies", - Handler: schedule.ScheduleGetStrategyHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/ai/getAlgorithms/:adapterId/:resourceType/:taskType/:dataset", - Handler: schedule.ScheduleGetAlgorithmsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/ai/getJobLog/:adapterId/:clusterId/:taskId/:instanceNum", - Handler: schedule.ScheduleGetAiJobLogLogHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/schedule/submit", - Handler: schedule.ScheduleSubmitHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/schedule/getOverview", - Handler: schedule.ScheduleGetOverviewHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/downloadAlgorithmCode", - Handler: schedule.DownloadAlgothmCodeHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/schedule/uploadAlgorithmCode", - Handler: schedule.UploadAlgothmCodeHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/getComputeCardsByCluster/:adapterId/:clusterId", - Handler: schedule.GetComputeCardsByClusterHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/schedule/getClusterBalanceById/:adapterId/:clusterId", - Handler: schedule.GetClusterBalanceByIdHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodPost, - Path: "/inference/text", - Handler: inference.TextToTextInferenceHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/inference/images", - Handler: inference.ImageInferenceHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/inference/modelTypes", - Handler: inference.ModelTypesHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/inference/modelNames", - Handler: inference.ModelNamesByTypeHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/inference/taskDetail", - Handler: inference.InferenceTaskDetailHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodGet, - Path: "/dict/:id", - Handler: dictionary.GetDictHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/dicts", - Handler: dictionary.ListDictHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/dict", - Handler: dictionary.AddDictHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/dict", - Handler: dictionary.EditDictHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/dict/:id", - Handler: dictionary.DeleteDictHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/dictItem/:id", - Handler: dictionary.GetDictItemHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/dictItems", - Handler: dictionary.ListDictItemHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/dictItem", - Handler: dictionary.AddDictItemHandler(serverCtx), - }, - { - Method: http.MethodPut, - Path: "/dictItem", - Handler: dictionary.EditDictItemHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/dictItem/:id", - Handler: dictionary.DeleteDictItemHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/dictItem/code/:dictCode", - Handler: dictionary.ListDictItemByCodeHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) - - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodPost, - Path: "/monitoring/alert/rule", - Handler: monitoring.CreateAlertRuleHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/monitoring/alert/rule", - Handler: monitoring.AlertRulesHandler(serverCtx), - }, - { - Method: http.MethodDelete, - Path: "/monitoring/alert/rule", - Handler: monitoring.DeleteAlertRuleHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/monitoring/cluster/load", - Handler: monitoring.ClustersLoadHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/monitoring/node/top", - Handler: monitoring.NodesLoadTopHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/monitoring/alert/list", - Handler: monitoring.AlertListHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/monitoring/syncClusterAlert", - Handler: monitoring.SyncClusterAlertHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/monitoring/task/num", - Handler: monitoring.TaskNumHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/monitoring/adapter/info", - Handler: monitoring.AdapterInfoHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/monitoring/schedule/situation", - Handler: monitoring.ScheduleSituationHandler(serverCtx), - }, - }, - rest.WithPrefix("/pcm/v1"), - ) -} diff --git a/api/internal/handler/schedule/downloadalgothmcodehandler.go b/api/internal/handler/schedule/downloadalgothmcodehandler.go deleted file mode 100644 index e70d85ea..00000000 --- a/api/internal/handler/schedule/downloadalgothmcodehandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package schedule - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" -) - -func DownloadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DownloadAlgorithmCodeReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := schedule.NewDownloadAlgothmCodeLogic(r.Context(), svcCtx) - resp, err := l.DownloadAlgorithmCode(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/schedule/getclusterbalancebyidhandler.go b/api/internal/handler/schedule/getclusterbalancebyidhandler.go deleted file mode 100644 index 27e273f4..00000000 --- a/api/internal/handler/schedule/getclusterbalancebyidhandler.go +++ /dev/null @@ -1,26 +0,0 @@ -package schedule - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetClusterBalanceByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetClusterBalanceByIdReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := schedule.NewGetClusterBalanceByIdLogic(r.Context(), svcCtx) - resp, err := l.GetClusterBalanceById(&req) - result.HttpResult(r, w, resp, err) - - } -} diff --git a/api/internal/handler/schedule/getcomputecardsbyclusterhandler.go b/api/internal/handler/schedule/getcomputecardsbyclusterhandler.go deleted file mode 100644 index 2c4393e1..00000000 --- a/api/internal/handler/schedule/getcomputecardsbyclusterhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package schedule - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetComputeCardsByClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetComputeCardsByClusterReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := schedule.NewGetComputeCardsByClusterLogic(r.Context(), svcCtx) - resp, err := l.GetComputeCardsByCluster(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/schedule/schedulegetaijoblogloghandler.go b/api/internal/handler/schedule/schedulegetaijoblogloghandler.go deleted file mode 100644 index 9eecc66d..00000000 --- a/api/internal/handler/schedule/schedulegetaijoblogloghandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package schedule - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ScheduleGetAiJobLogLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AiJobLogReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := schedule.NewScheduleGetAiJobLogLogLogic(r.Context(), svcCtx) - resp, err := l.ScheduleGetAiJobLogLog(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/schedule/schedulegetairesourcetypeshandler.go b/api/internal/handler/schedule/schedulegetairesourcetypeshandler.go deleted file mode 100644 index 82b876ae..00000000 --- a/api/internal/handler/schedule/schedulegetairesourcetypeshandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package schedule - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ScheduleGetAiResourceTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := schedule.NewScheduleGetAiResourceTypesLogic(r.Context(), svcCtx) - resp, err := l.ScheduleGetAiResourceTypes() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/schedule/schedulegetaitasktypeshandler.go b/api/internal/handler/schedule/schedulegetaitasktypeshandler.go deleted file mode 100644 index db45b9c5..00000000 --- a/api/internal/handler/schedule/schedulegetaitasktypeshandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package schedule - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ScheduleGetAiTaskTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := schedule.NewScheduleGetAiTaskTypesLogic(r.Context(), svcCtx) - resp, err := l.ScheduleGetAiTaskTypes() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/schedule/schedulegetalgorithmshandler.go b/api/internal/handler/schedule/schedulegetalgorithmshandler.go deleted file mode 100644 index a1f28eab..00000000 --- a/api/internal/handler/schedule/schedulegetalgorithmshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package schedule - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ScheduleGetAlgorithmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AiAlgorithmsReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := schedule.NewScheduleGetAlgorithmsLogic(r.Context(), svcCtx) - resp, err := l.ScheduleGetAlgorithms(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/schedule/schedulegetdatasetshandler.go b/api/internal/handler/schedule/schedulegetdatasetshandler.go deleted file mode 100644 index 6dae2970..00000000 --- a/api/internal/handler/schedule/schedulegetdatasetshandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package schedule - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ScheduleGetDatasetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AiDatasetsReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := schedule.NewScheduleGetDatasetsLogic(r.Context(), svcCtx) - resp, err := l.ScheduleGetDatasets(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/schedule/schedulegetoverviewhandler.go b/api/internal/handler/schedule/schedulegetoverviewhandler.go deleted file mode 100644 index bbf66cc7..00000000 --- a/api/internal/handler/schedule/schedulegetoverviewhandler.go +++ /dev/null @@ -1,21 +0,0 @@ -package schedule - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func ScheduleGetOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := schedule.NewScheduleGetOverviewLogic(r.Context(), svcCtx) - resp, err := l.ScheduleGetOverview() - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/schedule/schedulegetstrategyhandler.go b/api/internal/handler/schedule/schedulegetstrategyhandler.go deleted file mode 100644 index 4771495c..00000000 --- a/api/internal/handler/schedule/schedulegetstrategyhandler.go +++ /dev/null @@ -1,16 +0,0 @@ -package schedule - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ScheduleGetStrategyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := schedule.NewScheduleGetStrategyLogic(r.Context(), svcCtx) - resp, err := l.ScheduleGetStrategy() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/schedule/schedulesubmithandler.go b/api/internal/handler/schedule/schedulesubmithandler.go deleted file mode 100644 index d6e2a538..00000000 --- a/api/internal/handler/schedule/schedulesubmithandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package schedule - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ScheduleSubmitHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ScheduleReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := schedule.NewScheduleSubmitLogic(r.Context(), svcCtx) - resp, err := l.ScheduleSubmit(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/schedule/uploadalgothmcodehandler.go b/api/internal/handler/schedule/uploadalgothmcodehandler.go deleted file mode 100644 index 681715e2..00000000 --- a/api/internal/handler/schedule/uploadalgothmcodehandler.go +++ /dev/null @@ -1,25 +0,0 @@ -package schedule - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" -) - -func UploadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UploadAlgorithmCodeReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := schedule.NewUploadAlgothmCodeLogic(r.Context(), svcCtx) - resp, err := l.UploadAlgorithmCode(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/storage/dailypowerscreenhandler.go b/api/internal/handler/storage/dailypowerscreenhandler.go deleted file mode 100644 index a71c2331..00000000 --- a/api/internal/handler/storage/dailypowerscreenhandler.go +++ /dev/null @@ -1,17 +0,0 @@ -package storage - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func DailyPowerScreenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := storage.NewDailyPowerScreenLogic(r.Context(), svcCtx) - resp, err := l.DailyPowerScreen() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/storage/percentercomputerpowershandler.go b/api/internal/handler/storage/percentercomputerpowershandler.go deleted file mode 100644 index b21a330b..00000000 --- a/api/internal/handler/storage/percentercomputerpowershandler.go +++ /dev/null @@ -1,17 +0,0 @@ -package storage - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -func PerCenterComputerPowersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := storage.NewPerCenterComputerPowersLogic(r.Context(), svcCtx) - resp, err := l.PerCenterComputerPowers() - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/storage/screenstoragehandler.go b/api/internal/handler/storage/screenstoragehandler.go deleted file mode 100644 index 2a6d8901..00000000 --- a/api/internal/handler/storage/screenstoragehandler.go +++ /dev/null @@ -1,24 +0,0 @@ -package storage - -import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "net/http" -) - -func ScreenStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.StorageScreenReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - - l := storage.NewScreenStorageLogic(r.Context(), svcCtx) - resp, err := l.ScreenStorage(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/api/internal/handler/storelink/deletelinkimagehandler.go b/api/internal/handler/storelink/deletelinkimagehandler.go deleted file mode 100644 index fc56fe9d..00000000 --- a/api/internal/handler/storelink/deletelinkimagehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteLinkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteLinkImageReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewDeleteLinkImageLogic(r.Context(), svcCtx) - resp, err := l.DeleteLinkImage(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/storelink/deletelinktaskhandler.go b/api/internal/handler/storelink/deletelinktaskhandler.go deleted file mode 100644 index 536b3ae9..00000000 --- a/api/internal/handler/storelink/deletelinktaskhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteLinkTaskReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewDeleteLinkTaskLogic(r.Context(), svcCtx) - resp, err := l.DeleteLinkTask(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/storelink/getaispecshandler.go b/api/internal/handler/storelink/getaispecshandler.go deleted file mode 100644 index 8e97d294..00000000 --- a/api/internal/handler/storelink/getaispecshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetAISpecsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetResourceSpecsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewGetAISpecsLogic(r.Context(), svcCtx) - resp, err := l.GetAISpecs(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/storelink/getlinkimagelisthandler.go b/api/internal/handler/storelink/getlinkimagelisthandler.go deleted file mode 100644 index b83198f6..00000000 --- a/api/internal/handler/storelink/getlinkimagelisthandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetLinkImageListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetLinkImageListReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewGetLinkImageListLogic(r.Context(), svcCtx) - resp, err := l.GetLinkImageList(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/storelink/getlinktaskhandler.go b/api/internal/handler/storelink/getlinktaskhandler.go deleted file mode 100644 index af477e23..00000000 --- a/api/internal/handler/storelink/getlinktaskhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetLinkTaskReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewGetLinkTaskLogic(r.Context(), svcCtx) - resp, err := l.GetLinkTask(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/storelink/getparticipantshandler.go b/api/internal/handler/storelink/getparticipantshandler.go deleted file mode 100644 index 07c88f83..00000000 --- a/api/internal/handler/storelink/getparticipantshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetParticipantsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetParticipantsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewGetParticipantsLogic(r.Context(), svcCtx) - resp, err := l.GetParticipants(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/storelink/submitlinktaskhandler.go b/api/internal/handler/storelink/submitlinktaskhandler.go deleted file mode 100644 index 5da13f4b..00000000 --- a/api/internal/handler/storelink/submitlinktaskhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func SubmitLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.SubmitLinkTaskReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewSubmitLinkTaskLogic(r.Context(), svcCtx) - resp, err := l.SubmitLinkTask(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/storelink/uploadlinkimagehandler.go b/api/internal/handler/storelink/uploadlinkimagehandler.go deleted file mode 100644 index 9adec263..00000000 --- a/api/internal/handler/storelink/uploadlinkimagehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package storelink - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storelink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UploadLinkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UploadLinkImageReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := storelink.NewUploadLinkImageLogic(r.Context(), svcCtx) - resp, err := l.UploadLinkImage(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/addsecuritygrouptoserverhandler.go b/api/internal/handler/vm/addsecuritygrouptoserverhandler.go deleted file mode 100644 index 86553cbf..00000000 --- a/api/internal/handler/vm/addsecuritygrouptoserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func AddSecurityGroupToServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AddSecurityGroupToServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewAddSecurityGroupToServerLogic(r.Context(), svcCtx) - resp, err := l.AddSecurityGroupToServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/bulkcreatenetworkshandler.go b/api/internal/handler/vm/bulkcreatenetworkshandler.go deleted file mode 100644 index 84cad5c6..00000000 --- a/api/internal/handler/vm/bulkcreatenetworkshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func BulkCreateNetworksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.BulkCreateNetworksReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewBulkCreateNetworksLogic(r.Context(), svcCtx) - resp, err := l.BulkCreateNetworks(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/changeadministrativepasswordhandler.go b/api/internal/handler/vm/changeadministrativepasswordhandler.go deleted file mode 100644 index ecf1c6bc..00000000 --- a/api/internal/handler/vm/changeadministrativepasswordhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ChangeAdministrativePasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ChangeAdministrativePasswordReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewChangeAdministrativePasswordLogic(r.Context(), svcCtx) - resp, err := l.ChangeAdministrativePassword(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createfirewallgrouphandler.go b/api/internal/handler/vm/createfirewallgrouphandler.go deleted file mode 100644 index f6f5b3a1..00000000 --- a/api/internal/handler/vm/createfirewallgrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateFirewallGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateFirewallGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateFirewallGroupLogic(r.Context(), svcCtx) - resp, err := l.CreateFirewallGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createfirewallpolicyhandler.go b/api/internal/handler/vm/createfirewallpolicyhandler.go deleted file mode 100644 index 77d8d1cf..00000000 --- a/api/internal/handler/vm/createfirewallpolicyhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateFirewallPolicyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateFirewallPolicyReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateFirewallPolicyLogic(r.Context(), svcCtx) - resp, err := l.CreateFirewallPolicy(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createfirewallrulehandler.go b/api/internal/handler/vm/createfirewallrulehandler.go deleted file mode 100644 index 3995c08a..00000000 --- a/api/internal/handler/vm/createfirewallrulehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateFirewallRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateFirewallRuleReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateFirewallRuleLogic(r.Context(), svcCtx) - resp, err := l.CreateFirewallRule(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createflavorhandler.go b/api/internal/handler/vm/createflavorhandler.go deleted file mode 100644 index f32dc8f2..00000000 --- a/api/internal/handler/vm/createflavorhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateFlavorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateFlavorReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateFlavorLogic(r.Context(), svcCtx) - resp, err := l.CreateFlavor(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createfloatingiphandler.go b/api/internal/handler/vm/createfloatingiphandler.go deleted file mode 100644 index 797a4a55..00000000 --- a/api/internal/handler/vm/createfloatingiphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateFloatingIPHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateFloatingIPReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateFloatingIPLogic(r.Context(), svcCtx) - resp, err := l.CreateFloatingIP(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createimagehandler.go b/api/internal/handler/vm/createimagehandler.go deleted file mode 100644 index 5f5e4f81..00000000 --- a/api/internal/handler/vm/createimagehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/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/createmulserverhandler.go b/api/internal/handler/vm/createmulserverhandler.go deleted file mode 100644 index 613f1ca2..00000000 --- a/api/internal/handler/vm/createmulserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateMulServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateMulServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateMulServerLogic(r.Context(), svcCtx) - resp, err := l.CreateMulServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createnetworkhandler.go b/api/internal/handler/vm/createnetworkhandler.go deleted file mode 100644 index 2da207be..00000000 --- a/api/internal/handler/vm/createnetworkhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateNetworkReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateNetworkLogic(r.Context(), svcCtx) - resp, err := l.CreateNetwork(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createnetworksegmentrangehandler.go b/api/internal/handler/vm/createnetworksegmentrangehandler.go deleted file mode 100644 index 47f7e5fa..00000000 --- a/api/internal/handler/vm/createnetworksegmentrangehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateNetworkSegmentRangeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateNetworkSegmentRangeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateNetworkSegmentRangeLogic(r.Context(), svcCtx) - resp, err := l.CreateNetworkSegmentRange(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createnodehandler.go b/api/internal/handler/vm/createnodehandler.go deleted file mode 100644 index 5df9dd56..00000000 --- a/api/internal/handler/vm/createnodehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateNodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateNodeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateNodeLogic(r.Context(), svcCtx) - resp, err := l.CreateNode(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createporthandler.go b/api/internal/handler/vm/createporthandler.go deleted file mode 100644 index 0ea408b7..00000000 --- a/api/internal/handler/vm/createporthandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreatePortHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreatePortReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreatePortLogic(r.Context(), svcCtx) - resp, err := l.CreatePort(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createrouterhandler.go b/api/internal/handler/vm/createrouterhandler.go deleted file mode 100644 index 45390b39..00000000 --- a/api/internal/handler/vm/createrouterhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateRouterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateRouterReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateRouterLogic(r.Context(), svcCtx) - resp, err := l.CreateRouter(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createsecuritygrouphandler.go b/api/internal/handler/vm/createsecuritygrouphandler.go deleted file mode 100644 index 2fcfd935..00000000 --- a/api/internal/handler/vm/createsecuritygrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateSecurityGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateSecurityGroupLogic(r.Context(), svcCtx) - resp, err := l.CreateSecurityGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createsecuritygrouprulehandler.go b/api/internal/handler/vm/createsecuritygrouprulehandler.go deleted file mode 100644 index 11ffe7ea..00000000 --- a/api/internal/handler/vm/createsecuritygrouprulehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateSecurityGroupRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateSecurityGroupRuleReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateSecurityGroupRuleLogic(r.Context(), svcCtx) - resp, err := l.CreateSecurityGroupRule(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createserverhandler.go b/api/internal/handler/vm/createserverhandler.go deleted file mode 100644 index 1afd92f1..00000000 --- a/api/internal/handler/vm/createserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateServerLogic(r.Context(), svcCtx) - resp, err := l.CreateServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createsubnethandler.go b/api/internal/handler/vm/createsubnethandler.go deleted file mode 100644 index 931121f3..00000000 --- a/api/internal/handler/vm/createsubnethandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateSubnetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateSubnetReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateSubnetLogic(r.Context(), svcCtx) - resp, err := l.CreateSubnet(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createvolumehandler.go b/api/internal/handler/vm/createvolumehandler.go deleted file mode 100644 index 4e6c56b3..00000000 --- a/api/internal/handler/vm/createvolumehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateVolumeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateVolumeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateVolumeLogic(r.Context(), svcCtx) - resp, err := l.CreateVolume(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/createvolumetypeshandler.go b/api/internal/handler/vm/createvolumetypeshandler.go deleted file mode 100644 index 955b889f..00000000 --- a/api/internal/handler/vm/createvolumetypeshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func CreateVolumeTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.CreateVolumeTypeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewCreateVolumeTypesLogic(r.Context(), svcCtx) - resp, err := l.CreateVolumeTypes(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletefirewallgrouphandler.go b/api/internal/handler/vm/deletefirewallgrouphandler.go deleted file mode 100644 index 240f1ceb..00000000 --- a/api/internal/handler/vm/deletefirewallgrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteFirewallGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteFirewallGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteFirewallGroupLogic(r.Context(), svcCtx) - resp, err := l.DeleteFirewallGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletefirewallpolicyhandler.go b/api/internal/handler/vm/deletefirewallpolicyhandler.go deleted file mode 100644 index ee0f12fa..00000000 --- a/api/internal/handler/vm/deletefirewallpolicyhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteFirewallPolicyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteFirewallPolicyReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteFirewallPolicyLogic(r.Context(), svcCtx) - resp, err := l.DeleteFirewallPolicy(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletefirewallrulehandler.go b/api/internal/handler/vm/deletefirewallrulehandler.go deleted file mode 100644 index 44c60272..00000000 --- a/api/internal/handler/vm/deletefirewallrulehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteFirewallRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteFirewallRuleReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteFirewallRuleLogic(r.Context(), svcCtx) - resp, err := l.DeleteFirewallRule(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deleteflavorhandler.go b/api/internal/handler/vm/deleteflavorhandler.go deleted file mode 100644 index 7bf5fe04..00000000 --- a/api/internal/handler/vm/deleteflavorhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteFlavorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteFlavorReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteFlavorLogic(r.Context(), svcCtx) - resp, err := l.DeleteFlavor(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletefloatingiphandler.go b/api/internal/handler/vm/deletefloatingiphandler.go deleted file mode 100644 index 3f7abdf3..00000000 --- a/api/internal/handler/vm/deletefloatingiphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteFloatingIPHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteFloatingIPReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteFloatingIPLogic(r.Context(), svcCtx) - resp, err := l.DeleteFloatingIP(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deleteimagehandler.go b/api/internal/handler/vm/deleteimagehandler.go deleted file mode 100644 index 6ba84ce0..00000000 --- a/api/internal/handler/vm/deleteimagehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteImageReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteImageLogic(r.Context(), svcCtx) - resp, err := l.DeleteImage(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletenetworkhandler.go b/api/internal/handler/vm/deletenetworkhandler.go deleted file mode 100644 index 182f3747..00000000 --- a/api/internal/handler/vm/deletenetworkhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteNetworkReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteNetworkLogic(r.Context(), svcCtx) - resp, err := l.DeleteNetwork(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletenetworksegmentrangeshandler.go b/api/internal/handler/vm/deletenetworksegmentrangeshandler.go deleted file mode 100644 index b4cfc237..00000000 --- a/api/internal/handler/vm/deletenetworksegmentrangeshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteNetworkSegmentRangesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteNetworkSegmentRangesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteNetworkSegmentRangesLogic(r.Context(), svcCtx) - resp, err := l.DeleteNetworkSegmentRanges(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletenodehandler.go b/api/internal/handler/vm/deletenodehandler.go deleted file mode 100644 index 19f67962..00000000 --- a/api/internal/handler/vm/deletenodehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteNodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteNodeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteNodeLogic(r.Context(), svcCtx) - resp, err := l.DeleteNode(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deleteporthandler.go b/api/internal/handler/vm/deleteporthandler.go deleted file mode 100644 index 45d4a17a..00000000 --- a/api/internal/handler/vm/deleteporthandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeletePortHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeletePortReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeletePortLogic(r.Context(), svcCtx) - resp, err := l.DeletePort(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deleterouterhandler.go b/api/internal/handler/vm/deleterouterhandler.go deleted file mode 100644 index 0184dbed..00000000 --- a/api/internal/handler/vm/deleterouterhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteRouterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteRouterReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteRouterLogic(r.Context(), svcCtx) - resp, err := l.DeleteRouter(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletesecuritygrouphandler.go b/api/internal/handler/vm/deletesecuritygrouphandler.go deleted file mode 100644 index 482ba147..00000000 --- a/api/internal/handler/vm/deletesecuritygrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteSecurityGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteSecurityGroupLogic(r.Context(), svcCtx) - resp, err := l.DeleteSecurityGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletesecuritygrouprulehandler.go b/api/internal/handler/vm/deletesecuritygrouprulehandler.go deleted file mode 100644 index 5dcf49cf..00000000 --- a/api/internal/handler/vm/deletesecuritygrouprulehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteSecurityGroupRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteSecurityGroupRuleReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteSecurityGroupRuleLogic(r.Context(), svcCtx) - resp, err := l.DeleteSecurityGroupRule(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deleteserverhandler.go b/api/internal/handler/vm/deleteserverhandler.go deleted file mode 100644 index 412ee0a4..00000000 --- a/api/internal/handler/vm/deleteserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteServerLogic(r.Context(), svcCtx) - resp, err := l.DeleteServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletesubnethandler.go b/api/internal/handler/vm/deletesubnethandler.go deleted file mode 100644 index cb8e0b40..00000000 --- a/api/internal/handler/vm/deletesubnethandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteSubnetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteSubnetReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteSubnetLogic(r.Context(), svcCtx) - resp, err := l.DeleteSubnet(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletevolumehandler.go b/api/internal/handler/vm/deletevolumehandler.go deleted file mode 100644 index d7e91490..00000000 --- a/api/internal/handler/vm/deletevolumehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteVolumeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteVolumeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteVolumeLogic(r.Context(), svcCtx) - resp, err := l.DeleteVolume(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/deletevolumetypehandler.go b/api/internal/handler/vm/deletevolumetypehandler.go deleted file mode 100644 index 6467de46..00000000 --- a/api/internal/handler/vm/deletevolumetypehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func DeleteVolumeTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.DeleteVolumeTypeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewDeleteVolumeTypeLogic(r.Context(), svcCtx) - resp, err := l.DeleteVolumeType(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/getcomputelimitshandler.go b/api/internal/handler/vm/getcomputelimitshandler.go deleted file mode 100644 index e52d0fb9..00000000 --- a/api/internal/handler/vm/getcomputelimitshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetComputeLimitsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetComputeLimitsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewGetComputeLimitsLogic(r.Context(), svcCtx) - resp, err := l.GetComputeLimits(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/getimagenumhandler.go b/api/internal/handler/vm/getimagenumhandler.go deleted file mode 100644 index ecaf4ea1..00000000 --- a/api/internal/handler/vm/getimagenumhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetImageNumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListImagesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewGetImageNumLogic(r.Context(), svcCtx) - resp, err := l.GetImageNum(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/getnetworknumhandler.go b/api/internal/handler/vm/getnetworknumhandler.go deleted file mode 100644 index d1115cdf..00000000 --- a/api/internal/handler/vm/getnetworknumhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetNetworkNumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListNetworksReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewGetNetworkNumLogic(r.Context(), svcCtx) - resp, err := l.GetNetworkNum(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/getopenstackoverviewhandler.go b/api/internal/handler/vm/getopenstackoverviewhandler.go deleted file mode 100644 index 871f814c..00000000 --- a/api/internal/handler/vm/getopenstackoverviewhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetOpenstackOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.OpenstackOverviewReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewGetOpenstackOverviewLogic(r.Context(), svcCtx) - resp, err := l.GetOpenstackOverview(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/getserversdetailedbyidhandler.go b/api/internal/handler/vm/getserversdetailedbyidhandler.go deleted file mode 100644 index 884d5412..00000000 --- a/api/internal/handler/vm/getserversdetailedbyidhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetServersDetailedByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetServersDetailedByIdReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewGetServersDetailedByIdLogic(r.Context(), svcCtx) - resp, err := l.GetServersDetailedById(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/getvolumedetailedbyidhandler.go b/api/internal/handler/vm/getvolumedetailedbyidhandler.go deleted file mode 100644 index fa08be98..00000000 --- a/api/internal/handler/vm/getvolumedetailedbyidhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetVolumeDetailedByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetVolumeDetailedByIdReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewGetVolumeDetailedByIdLogic(r.Context(), svcCtx) - resp, err := l.GetVolumeDetailedById(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/getvolumelimitshandler.go b/api/internal/handler/vm/getvolumelimitshandler.go deleted file mode 100644 index 07e9af2d..00000000 --- a/api/internal/handler/vm/getvolumelimitshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func GetVolumeLimitsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.GetVolumeLimitsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewGetVolumeLimitsLogic(r.Context(), svcCtx) - resp, err := l.GetVolumeLimits(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listfirewallgroupshandler.go b/api/internal/handler/vm/listfirewallgroupshandler.go deleted file mode 100644 index 01041333..00000000 --- a/api/internal/handler/vm/listfirewallgroupshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListFirewallGroupsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListFirewallGroupsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListFirewallGroupsLogic(r.Context(), svcCtx) - resp, err := l.ListFirewallGroups(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listfirewallpolicieshandler.go b/api/internal/handler/vm/listfirewallpolicieshandler.go deleted file mode 100644 index 877c2806..00000000 --- a/api/internal/handler/vm/listfirewallpolicieshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListFirewallPoliciesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListFirewallPoliciesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListFirewallPoliciesLogic(r.Context(), svcCtx) - resp, err := l.ListFirewallPolicies(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listfirewallruleshandler.go b/api/internal/handler/vm/listfirewallruleshandler.go deleted file mode 100644 index b630593c..00000000 --- a/api/internal/handler/vm/listfirewallruleshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListFirewallRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListFirewallRulesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListFirewallRulesLogic(r.Context(), svcCtx) - resp, err := l.ListFirewallRules(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listflavorsdetailhandler.go b/api/internal/handler/vm/listflavorsdetailhandler.go deleted file mode 100644 index 09362f69..00000000 --- a/api/internal/handler/vm/listflavorsdetailhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListFlavorsDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListFlavorsDetailReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListFlavorsDetailLogic(r.Context(), svcCtx) - resp, err := l.ListFlavorsDetail(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listfloatingipshandler.go b/api/internal/handler/vm/listfloatingipshandler.go deleted file mode 100644 index f723634c..00000000 --- a/api/internal/handler/vm/listfloatingipshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListFloatingIPsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListFloatingIPsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListFloatingIPsLogic(r.Context(), svcCtx) - resp, err := l.ListFloatingIPs(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listimageshandler.go b/api/internal/handler/vm/listimageshandler.go deleted file mode 100644 index cf5844cb..00000000 --- a/api/internal/handler/vm/listimageshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListImagesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListImagesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListImagesLogic(r.Context(), svcCtx) - resp, err := l.ListImages(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listnetworksegmentrangesrangehandler.go b/api/internal/handler/vm/listnetworksegmentrangesrangehandler.go deleted file mode 100644 index 27b3478f..00000000 --- a/api/internal/handler/vm/listnetworksegmentrangesrangehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListNetworkSegmentRangesRangeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListNetworkSegmentRangesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListNetworkSegmentRangesRangeLogic(r.Context(), svcCtx) - resp, err := l.ListNetworkSegmentRangesRange(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listnetworkshandler.go b/api/internal/handler/vm/listnetworkshandler.go deleted file mode 100644 index c7078abf..00000000 --- a/api/internal/handler/vm/listnetworkshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListNetworksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListNetworksReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListNetworksLogic(r.Context(), svcCtx) - resp, err := l.ListNetworks(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listnodeshandler.go b/api/internal/handler/vm/listnodeshandler.go deleted file mode 100644 index fcc192d2..00000000 --- a/api/internal/handler/vm/listnodeshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListNodesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListNodesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListNodesLogic(r.Context(), svcCtx) - resp, err := l.ListNodes(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listportshandler.go b/api/internal/handler/vm/listportshandler.go deleted file mode 100644 index ac134170..00000000 --- a/api/internal/handler/vm/listportshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListPortsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListPortsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListPortsLogic(r.Context(), svcCtx) - resp, err := l.ListPorts(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listroutershandler.go b/api/internal/handler/vm/listroutershandler.go deleted file mode 100644 index e7b6bc11..00000000 --- a/api/internal/handler/vm/listroutershandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListRoutersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListRoutersReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListRoutersLogic(r.Context(), svcCtx) - resp, err := l.ListRouters(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listsecuritygroupruleshandler.go b/api/internal/handler/vm/listsecuritygroupruleshandler.go deleted file mode 100644 index 2b31f7e8..00000000 --- a/api/internal/handler/vm/listsecuritygroupruleshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListSecurityGroupRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListSecurityGroupRulesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListSecurityGroupRulesLogic(r.Context(), svcCtx) - resp, err := l.ListSecurityGroupRules(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listsecuritygroupshandler.go b/api/internal/handler/vm/listsecuritygroupshandler.go deleted file mode 100644 index be559d8d..00000000 --- a/api/internal/handler/vm/listsecuritygroupshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListSecurityGroupsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListSecurityGroupsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListSecurityGroupsLogic(r.Context(), svcCtx) - resp, err := l.ListSecurityGroups(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listserverhandler.go b/api/internal/handler/vm/listserverhandler.go deleted file mode 100644 index 4c859136..00000000 --- a/api/internal/handler/vm/listserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListServersReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListServerLogic(r.Context(), svcCtx) - resp, err := l.ListServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listserversdetailedhandler.go b/api/internal/handler/vm/listserversdetailedhandler.go deleted file mode 100644 index 1dc3daaf..00000000 --- a/api/internal/handler/vm/listserversdetailedhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListServersDetailedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListServersDetailedReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListServersDetailedLogic(r.Context(), svcCtx) - resp, err := l.ListServersDetailed(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listsubnetshandler.go b/api/internal/handler/vm/listsubnetshandler.go deleted file mode 100644 index a148ccc5..00000000 --- a/api/internal/handler/vm/listsubnetshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListSubnetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListSubnetsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListSubnetsLogic(r.Context(), svcCtx) - resp, err := l.ListSubnets(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listvolumesdetailhandler.go b/api/internal/handler/vm/listvolumesdetailhandler.go deleted file mode 100644 index fd0e6bb2..00000000 --- a/api/internal/handler/vm/listvolumesdetailhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListVolumesDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListVolumesDetailReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListVolumesDetailLogic(r.Context(), svcCtx) - resp, err := l.ListVolumesDetail(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/listvolumeshandler.go b/api/internal/handler/vm/listvolumeshandler.go deleted file mode 100644 index 330fc958..00000000 --- a/api/internal/handler/vm/listvolumeshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ListVolumesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ListVolumesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewListVolumesLogic(r.Context(), svcCtx) - resp, err := l.ListVolumes(&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 deleted file mode 100644 index 711a2f75..00000000 --- a/api/internal/handler/vm/listvolumetypeshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/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/migrateserverhandler.go b/api/internal/handler/vm/migrateserverhandler.go deleted file mode 100644 index 2a7dbe82..00000000 --- a/api/internal/handler/vm/migrateserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func MigrateServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.MigrateServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewMigrateServerLogic(r.Context(), svcCtx) - resp, err := l.MigrateServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/pauseserverhandler.go b/api/internal/handler/vm/pauseserverhandler.go deleted file mode 100644 index 610c4193..00000000 --- a/api/internal/handler/vm/pauseserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func PauseServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.PauseServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewPauseServerLogic(r.Context(), svcCtx) - resp, err := l.PauseServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/rebootserverhandler.go b/api/internal/handler/vm/rebootserverhandler.go deleted file mode 100644 index 31da26be..00000000 --- a/api/internal/handler/vm/rebootserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func RebootServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.RebootServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewRebootServerLogic(r.Context(), svcCtx) - resp, err := l.RebootServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/removesecuritygrouphandler.go b/api/internal/handler/vm/removesecuritygrouphandler.go deleted file mode 100644 index 40b21349..00000000 --- a/api/internal/handler/vm/removesecuritygrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func RemoveSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.RemoveSecurityGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewRemoveSecurityGroupLogic(r.Context(), svcCtx) - resp, err := l.RemoveSecurityGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/rescueserverhandler.go b/api/internal/handler/vm/rescueserverhandler.go deleted file mode 100644 index 97c18bd2..00000000 --- a/api/internal/handler/vm/rescueserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func RescueServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.RescueServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewRescueServerLogic(r.Context(), svcCtx) - resp, err := l.RescueServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/resizeserverhandler.go b/api/internal/handler/vm/resizeserverhandler.go deleted file mode 100644 index 81d8be1e..00000000 --- a/api/internal/handler/vm/resizeserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ResizeServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ResizeServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewResizeServerLogic(r.Context(), svcCtx) - resp, err := l.ResizeServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/shelveserverhandler.go b/api/internal/handler/vm/shelveserverhandler.go deleted file mode 100644 index 927c78c3..00000000 --- a/api/internal/handler/vm/shelveserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShelveServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShelveServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShelveServerLogic(r.Context(), svcCtx) - resp, err := l.ShelveServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showfirewallgroupdetailshandler.go b/api/internal/handler/vm/showfirewallgroupdetailshandler.go deleted file mode 100644 index 6e1e07ae..00000000 --- a/api/internal/handler/vm/showfirewallgroupdetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowFirewallGroupDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowFirewallGroupDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowFirewallGroupDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowFirewallGroupDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showfirewallpolicydetailshandler.go b/api/internal/handler/vm/showfirewallpolicydetailshandler.go deleted file mode 100644 index 1b562893..00000000 --- a/api/internal/handler/vm/showfirewallpolicydetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowFirewallPolicyDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowFirewallPolicyDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowFirewallPolicyDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowFirewallPolicyDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showfirewallruledetailshandler.go b/api/internal/handler/vm/showfirewallruledetailshandler.go deleted file mode 100644 index b026c434..00000000 --- a/api/internal/handler/vm/showfirewallruledetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowFirewallRuleDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowFirewallRuleDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowFirewallRuleDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowFirewallRuleDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showfloatingipdetailshandler.go b/api/internal/handler/vm/showfloatingipdetailshandler.go deleted file mode 100644 index 91e09a44..00000000 --- a/api/internal/handler/vm/showfloatingipdetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowFloatingIPDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowFloatingIPDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowFloatingIPDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowFloatingIPDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/shownetworkdetailshandler.go b/api/internal/handler/vm/shownetworkdetailshandler.go deleted file mode 100644 index 113a0e7e..00000000 --- a/api/internal/handler/vm/shownetworkdetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowNetworkDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowNetworkDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowNetworkDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowNetworkDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/shownetworksegmentrangedetailshandler.go b/api/internal/handler/vm/shownetworksegmentrangedetailshandler.go deleted file mode 100644 index 309c7533..00000000 --- a/api/internal/handler/vm/shownetworksegmentrangedetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowNetworkSegmentRangeDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowNetworkSegmentRangeDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowNetworkSegmentRangeDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowNetworkSegmentRangeDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/shownodedetailshandler.go b/api/internal/handler/vm/shownodedetailshandler.go deleted file mode 100644 index 1a025f73..00000000 --- a/api/internal/handler/vm/shownodedetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowNodeDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowNodeDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowNodeDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowNodeDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showportdetailshandler.go b/api/internal/handler/vm/showportdetailshandler.go deleted file mode 100644 index 2066679e..00000000 --- a/api/internal/handler/vm/showportdetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowPortDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowPortDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowPortDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowPortDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showrouterdetailshandler.go b/api/internal/handler/vm/showrouterdetailshandler.go deleted file mode 100644 index 395e03d2..00000000 --- a/api/internal/handler/vm/showrouterdetailshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowRouterDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowRouterDetailsReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowRouterDetailsLogic(r.Context(), svcCtx) - resp, err := l.ShowRouterDetails(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showsecuritygrouphandler.go b/api/internal/handler/vm/showsecuritygrouphandler.go deleted file mode 100644 index 0cf2ecfa..00000000 --- a/api/internal/handler/vm/showsecuritygrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowSecurityGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowSecurityGroupLogic(r.Context(), svcCtx) - resp, err := l.ShowSecurityGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/showsecuritygrouprulehandler.go b/api/internal/handler/vm/showsecuritygrouprulehandler.go deleted file mode 100644 index 3dcdc0ed..00000000 --- a/api/internal/handler/vm/showsecuritygrouprulehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func ShowSecurityGroupRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.ShowSecurityGroupRuleReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewShowSecurityGroupRuleLogic(r.Context(), svcCtx) - resp, err := l.ShowSecurityGroupRule(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/startserverhandler.go b/api/internal/handler/vm/startserverhandler.go deleted file mode 100644 index 00fc4257..00000000 --- a/api/internal/handler/vm/startserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func StartServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.StartServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewStartServerLogic(r.Context(), svcCtx) - resp, err := l.StartServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/stopserverhandler.go b/api/internal/handler/vm/stopserverhandler.go deleted file mode 100644 index 1941ade0..00000000 --- a/api/internal/handler/vm/stopserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func StopServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.StopServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewStopServerLogic(r.Context(), svcCtx) - resp, err := l.StopServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/suspendserverhandler.go b/api/internal/handler/vm/suspendserverhandler.go deleted file mode 100644 index fd9826e8..00000000 --- a/api/internal/handler/vm/suspendserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func SuspendServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.SuspendServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewSuspendServerLogic(r.Context(), svcCtx) - resp, err := l.SuspendServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/unpauseserverhandler.go b/api/internal/handler/vm/unpauseserverhandler.go deleted file mode 100644 index 3095d1e8..00000000 --- a/api/internal/handler/vm/unpauseserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UnpauseServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UnpauseServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUnpauseServerLogic(r.Context(), svcCtx) - resp, err := l.UnpauseServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/unrescuehandler.go b/api/internal/handler/vm/unrescuehandler.go deleted file mode 100644 index e07adec8..00000000 --- a/api/internal/handler/vm/unrescuehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UnRescueHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UnRescueServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUnRescueLogic(r.Context(), svcCtx) - resp, err := l.UnRescue(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updatefirewallgrouphandler.go b/api/internal/handler/vm/updatefirewallgrouphandler.go deleted file mode 100644 index 1d072d0b..00000000 --- a/api/internal/handler/vm/updatefirewallgrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateFirewallGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateFirewallGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateFirewallGroupLogic(r.Context(), svcCtx) - resp, err := l.UpdateFirewallGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updatefloatingiphandler.go b/api/internal/handler/vm/updatefloatingiphandler.go deleted file mode 100644 index 16493a84..00000000 --- a/api/internal/handler/vm/updatefloatingiphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateFloatingIPHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateFloatingIPReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateFloatingIPLogic(r.Context(), svcCtx) - resp, err := l.UpdateFloatingIP(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updatenetworkhandler.go b/api/internal/handler/vm/updatenetworkhandler.go deleted file mode 100644 index fc1b3a0c..00000000 --- a/api/internal/handler/vm/updatenetworkhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateNetworkReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateNetworkLogic(r.Context(), svcCtx) - resp, err := l.UpdateNetwork(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updatenetworksegmentrangeshandler.go b/api/internal/handler/vm/updatenetworksegmentrangeshandler.go deleted file mode 100644 index c91e38eb..00000000 --- a/api/internal/handler/vm/updatenetworksegmentrangeshandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateNetworkSegmentRangesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateNetworkSegmentRangesReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateNetworkSegmentRangesLogic(r.Context(), svcCtx) - resp, err := l.UpdateNetworkSegmentRanges(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updateporthandler.go b/api/internal/handler/vm/updateporthandler.go deleted file mode 100644 index 37e34376..00000000 --- a/api/internal/handler/vm/updateporthandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdatePortHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdatePortReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdatePortLogic(r.Context(), svcCtx) - resp, err := l.UpdatePort(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updaterouterhandler.go b/api/internal/handler/vm/updaterouterhandler.go deleted file mode 100644 index 262ee32a..00000000 --- a/api/internal/handler/vm/updaterouterhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateRouterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateRouterReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateRouterLogic(r.Context(), svcCtx) - resp, err := l.UpdateRouter(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updatesecuritygrouphandler.go b/api/internal/handler/vm/updatesecuritygrouphandler.go deleted file mode 100644 index 2d0d5de2..00000000 --- a/api/internal/handler/vm/updatesecuritygrouphandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateSecurityGroupReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateSecurityGroupLogic(r.Context(), svcCtx) - resp, err := l.UpdateSecurityGroup(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updateserverhandler.go b/api/internal/handler/vm/updateserverhandler.go deleted file mode 100644 index acd162a4..00000000 --- a/api/internal/handler/vm/updateserverhandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateServerReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateServerLogic(r.Context(), svcCtx) - resp, err := l.UpdateServer(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updatesubnethandler.go b/api/internal/handler/vm/updatesubnethandler.go deleted file mode 100644 index a8093754..00000000 --- a/api/internal/handler/vm/updatesubnethandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateSubnetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateSubnetReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateSubnetLogic(r.Context(), svcCtx) - resp, err := l.UpdateSubnet(&req) - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } - } -} diff --git a/api/internal/handler/vm/updatevolumehandler.go b/api/internal/handler/vm/updatevolumehandler.go deleted file mode 100644 index 80389014..00000000 --- a/api/internal/handler/vm/updatevolumehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -func UpdateVolumeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.UpdateVolumeReq - if err := httpx.Parse(r, &req); err != nil { - httpx.ErrorCtx(r.Context(), w, err) - return - } - - l := vm.NewUpdateVolumeLogic(r.Context(), svcCtx) - resp, err := l.UpdateVolume(&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 deleted file mode 100644 index 0682d12f..00000000 --- a/api/internal/handler/vm/uploadimagehandler.go +++ /dev/null @@ -1,28 +0,0 @@ -package vm - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/vm" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/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/adapters/adapterslistlogic.go b/api/internal/logic/adapters/adapterslistlogic.go deleted file mode 100644 index 5f4aba2a..00000000 --- a/api/internal/logic/adapters/adapterslistlogic.go +++ /dev/null @@ -1,59 +0,0 @@ -package adapters - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AdaptersListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAdaptersListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdaptersListLogic { - return &AdaptersListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AdaptersListLogic) AdaptersList(req *types.AdapterQueryReq) (resp *types.PageResult, err error) { - limit := req.PageSize - offset := req.PageSize * (req.PageNum - 1) - resp = &types.PageResult{} - var list []types.AdapterInfo - db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") - - if req.Name != "" { - db = db.Where("name LIKE ?", "%"+req.Name+"%") - } - if req.Nickname != "" { - db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%") - } - if req.Type != "" { - db = db.Where("type = ?", req.Type) - } - if req.Version != "" { - db = db.Where("version = ?", req.Version) - } - var total int64 - err = db.Count(&total).Error - - if err != nil { - return resp, err - } - db = db.Where("deleted_at is null").Limit(limit).Offset(offset) - err = db.Order("create_time desc").Find(&list).Error - - resp.List = list - resp.PageSize = req.PageSize - resp.PageNum = req.PageNum - resp.Total = total - - return resp, nil -} diff --git a/api/internal/logic/adapters/clusterlistlogic.go b/api/internal/logic/adapters/clusterlistlogic.go deleted file mode 100644 index fb3f25e3..00000000 --- a/api/internal/logic/adapters/clusterlistlogic.go +++ /dev/null @@ -1,80 +0,0 @@ -package adapters - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ClusterListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterListLogic { - return &ClusterListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.PageResult, err error) { - limit := req.PageSize - offset := req.PageSize * (req.PageNum - 1) - resp = &types.PageResult{} - var list []types.ClusterInfo - db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_cluster") - - db = db.Joins("left join t_adapter on t_adapter.id = t_cluster.adapter_id"). - Where("t_cluster.deleted_at is null") - if req.Name != "" { - db = db.Where("t_cluster.name LIKE ?", "%"+req.Name+"%") - } - if req.AdapterId != "" { - db = db.Where("t_cluster.adapter_id = ?", req.AdapterId) - } - if req.Nickname != "" { - db = db.Where("t_cluster.nickname LIKE ?", "%"+req.Nickname+"%") - } - if req.Label != "" { - db = db.Where("t_cluster.label = ?", req.Label) - } - if req.Version != "" { - db = db.Where("t_cluster.version = ?", req.Version) - } - if req.ProducerDict != "" { - db = db.Where("t_cluster.producer_dict = ?", req.ProducerDict) - } - if req.RegionDict != "" { - db = db.Where("t_cluster.region_dict = ?", req.RegionDict) - } - if req.Type != "" { - db = db.Where("t_adapter.type = ?", req.Type) - } - if req.ResourceType != "" { - db = db.Where("t_adapter.resource_type = ?", req.ResourceType) - } - - //count total - var total int64 - err = db.Select("*").Count(&total).Error - if err != nil { - return resp, err - } - - db = db.Limit(limit).Offset(offset) - err = db.Select("t_cluster.*").Order("t_cluster.create_time desc").Scan(&list).Error - if err != nil { - return resp, err - } - resp.List = list - resp.PageSize = req.PageSize - resp.PageNum = req.PageNum - resp.Total = total - - return resp, nil -} diff --git a/api/internal/logic/adapters/createadapterlogic.go b/api/internal/logic/adapters/createadapterlogic.go deleted file mode 100644 index 6febb282..00000000 --- a/api/internal/logic/adapters/createadapterlogic.go +++ /dev/null @@ -1,67 +0,0 @@ -package adapters - -import ( - "context" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - "time" -) - -type CreateAdapterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAdapterLogic { - return &CreateAdapterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateAdapterLogic) CreateAdapter(req *types.AdapterCreateReq) (resp *types.AdapterResp, err error) { - adapter := types.AdapterInfo{} - utils.Convert(req, &adapter) - //check name - exist := l.svcCtx.DbEngin.Table("t_adapter").Where("name = ?", req.Name).First(&types.AdapterInfo{}).Error - if !errors.Is(exist, gorm.ErrRecordNotFound) { - return nil, errors.New("name already exists") - } - //check type - var arr = [...]string{"0", "1", "2"} - found := false - for _, str := range arr { - if str == req.Type { - found = true - break - } - } - if found == false { - return nil, errors.New("type not found") - } - - //check resourceTypeDict - sql := `select t_dict_item.item_value - from t_dict - join t_dict_item on t_dict.id = t_dict_item.dict_id - where dict_code = 'adapter_type' and item_value = ? - and t_dict_item.parent_id != 0` - err = l.svcCtx.DbEngin.Raw(sql, req.ResourceType).First(&types.DictItemInfo{}).Error - if errors.Is(err, gorm.ErrRecordNotFound) { - return nil, errors.New("resourceType error, please check!") - } - adapter.Id = utils.GenSnowflakeIDStr() - adapter.CreateTime = time.Now().Format("2006-01-02 15:04:05") - result := l.svcCtx.DbEngin.Table("t_adapter").Create(&adapter) - if result.Error != nil { - return nil, result.Error - } - - return -} diff --git a/api/internal/logic/adapters/createclusterlogic.go b/api/internal/logic/adapters/createclusterlogic.go deleted file mode 100644 index f8d8a356..00000000 --- a/api/internal/logic/adapters/createclusterlogic.go +++ /dev/null @@ -1,66 +0,0 @@ -package adapters - -import ( - "context" - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateClusterLogic { - return &CreateClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) { - adapter := &types.AdapterInfo{} - result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.AdapterId) - if errors.Is(result.Error, gorm.ErrRecordNotFound) { - return nil, errors.New("adapter does not exist") - } - cluster := types.ClusterInfo{} - utils.Convert(req, &cluster) - cluster.Id = utils.GenSnowflakeIDStr() - cluster.CreateTime = time.Now().Format("2006-01-02 15:04:05") - cluster.OwnerId = "0" - tx := l.svcCtx.DbEngin.Table("t_cluster").Create(&cluster) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return nil, errors.New("cluster create failed") - } - - // push cluster info to adapter - var adapterServer string - l.svcCtx.DbEngin.Raw("select server from t_adapter where id = ?", req.AdapterId).Scan(&adapterServer) - response, err := l.svcCtx.HttpClient.R(). - SetBody(&types.ClusterInfo{ - Name: req.Name, - Server: req.Server, - Token: req.Token, - MonitorServer: req.MonitorServer, - }). - ForceContentType("application/json"). - Post(adapterServer + "/api/v1/cluster/info") - if err != nil { - return nil, err - } - if response.IsError() { - return nil, errors.New(string(response.Body())) - } - return -} diff --git a/api/internal/logic/adapters/deleteadapterlogic.go b/api/internal/logic/adapters/deleteadapterlogic.go deleted file mode 100644 index 44e87fa6..00000000 --- a/api/internal/logic/adapters/deleteadapterlogic.go +++ /dev/null @@ -1,44 +0,0 @@ -package adapters - -import ( - "context" - "github.com/pkg/errors" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteAdapterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAdapterLogic { - return &DeleteAdapterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteAdapterLogic) DeleteAdapter(req *types.AdapterDelReq) (resp *types.AdapterResp, err error) { - var sId int64 - l.svcCtx.DbEngin.Table("t_adapter").Raw("select a.id from t_cluster c left join t_adapter a on c.adapter_id=a.id where a.id = ? ", req.Id).Scan(&sId) - if sId != 0 { - return nil, errors.New("Delete failed,The adapter is associated with a cluster") - } - db := l.svcCtx.DbEngin.Table("t_adapter").Where("id = ?", req.Id).First(&types.AdapterInfo{}) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Adapter does not exist") - } - tx := l.svcCtx.DbEngin.Table("t_adapter").Delete(types.AdapterInfo{}, req.Id) - if tx.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Delete adapter failed") - } - return -} diff --git a/api/internal/logic/adapters/deleteclusterlogic.go b/api/internal/logic/adapters/deleteclusterlogic.go deleted file mode 100644 index 5fd39ed6..00000000 --- a/api/internal/logic/adapters/deleteclusterlogic.go +++ /dev/null @@ -1,39 +0,0 @@ -package adapters - -import ( - "context" - "github.com/pkg/errors" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClusterLogic { - return &DeleteClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteClusterLogic) DeleteCluster(req *types.FId) (resp *types.ClusterResp, err error) { - db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&types.ClusterInfo{}) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Cluster does not exist") - } - tx := l.svcCtx.DbEngin.Table("t_cluster").Delete(types.AdapterInfo{}, req.Id) - if tx.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Delete Cluster failed") - } - return -} diff --git a/api/internal/logic/adapters/getadapterlogic.go b/api/internal/logic/adapters/getadapterlogic.go deleted file mode 100644 index 70e3c556..00000000 --- a/api/internal/logic/adapters/getadapterlogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package adapters - -import ( - "context" - "github.com/pkg/errors" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetAdapterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdapterLogic { - return &GetAdapterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetAdapterLogic) GetAdapter(req *types.AdapterDelReq) (resp *types.AdapterInfo, err error) { - resp = &types.AdapterInfo{} - db := l.svcCtx.DbEngin.Table("t_adapter").Where("id = ?", req.Id).First(&resp) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Adapter does not exist") - } - return -} diff --git a/api/internal/logic/adapters/getadapterrelationlogic.go b/api/internal/logic/adapters/getadapterrelationlogic.go deleted file mode 100644 index cb1617bc..00000000 --- a/api/internal/logic/adapters/getadapterrelationlogic.go +++ /dev/null @@ -1,89 +0,0 @@ -package adapters - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetAdapterRelationLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetAdapterRelationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdapterRelationLogic { - return &GetAdapterRelationLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterRelationQueryReq) (resp *types.PageResult, err error) { - resp = &types.PageResult{} - var list []types.AdapterInfo - db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") - - if req.Name != "" { - db = db.Where("name LIKE ?", "%"+req.Name+"%") - } - if req.Nickname != "" { - db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%") - } - if req.Type != "" { - db = db.Where("type = ?", req.Type) - } - if req.Version != "" { - db = db.Where("version = ?", req.Version) - } - - err = db.Where("deleted_at is null").Order("create_time desc").Find(&list).Error - - if err != nil { - return resp, err - } - - rlist := make([]*types.ClusterRelationInfo, 0) - for _, v := range list { - cr := &types.ClusterRelationInfo{} - utils.Convert(&v, &cr) - clusters := make([]*types.ClusterInfo, 0) - l.svcCtx.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL and adapter_id = ? ORDER BY create_time Desc", v.Id).Scan(&clusters) - for _, c := range clusters { - cr = &types.ClusterRelationInfo{} - utils.Convert(&v, &cr) - cr.CId = c.Id - cr.CAdapterId = c.AdapterId - cr.CName = c.Name - cr.CNickname = c.Nickname - cr.CDescription = c.Description - cr.CServer = c.Server - cr.CMonitorServer = c.MonitorServer - cr.CUsername = c.Username - cr.CPassword = c.Password - cr.CToken = c.Token - cr.CAk = c.Ak - cr.CSk = c.Sk - cr.CRegion = c.Region - cr.CProjectId = c.ProjectId - cr.CVersion = c.Version - cr.CLabel = c.Label - cr.COwnerId = c.OwnerId - cr.CAuthType = c.AuthType - cr.CRegionDict = c.RegionDict - cr.CProducerDict = c.ProducerDict - cr.CCreateTime = c.CreateTime - rlist = append(rlist, cr) - } - if len(clusters) == 0 { - rlist = append(rlist, cr) - } - } - resp.List = rlist - return resp, nil -} diff --git a/api/internal/logic/adapters/getclusterlogic.go b/api/internal/logic/adapters/getclusterlogic.go deleted file mode 100644 index ba5fb31c..00000000 --- a/api/internal/logic/adapters/getclusterlogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package adapters - -import ( - "context" - "github.com/pkg/errors" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterLogic { - return &GetClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetClusterLogic) GetCluster(req *types.FId) (resp *types.ClusterInfo, err error) { - resp = &types.ClusterInfo{} - db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&resp) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Adapter does not exist") - } - - return -} diff --git a/api/internal/logic/adapters/getclustersumlogic.go b/api/internal/logic/adapters/getclustersumlogic.go deleted file mode 100644 index 6beab051..00000000 --- a/api/internal/logic/adapters/getclustersumlogic.go +++ /dev/null @@ -1,67 +0,0 @@ -package adapters - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetClusterSumLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetClusterSumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterSumLogic { - return &GetClusterSumLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetClusterSumLogic) GetClusterSum(req *types.ClusterSumReq) (resp *types.ClusterSumReqResp, err error) { - // todo: add your logic here and delete this line - resp = &types.ClusterSumReqResp{} - - var AdapterSum int // - var podSum int // - var vmSum int // - var TaskSum int // - // - sqlStr := "SELECT COUNT(*) FROM `t_adapter` t where t.type ='0' and deleted_at is null" - tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&AdapterSum) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error - } - //vm - sqlStrVm := "SELECT COUNT(*) FROM `t_adapter` t left join t_cluster tc on t.id=tc.adapter_id where t.type = '0' and t.resource_type='02' and tc.deleted_at is null" - txClusterVm := l.svcCtx.DbEngin.Raw(sqlStrVm).Scan(&vmSum) - if txClusterVm.Error != nil { - logx.Error(err) - return nil, txClusterVm.Error - } - //pod - sqlStrPod := "SELECT COUNT(*) FROM `t_adapter` t left join t_cluster tc on t.id=tc.adapter_id where t.type = '0' and t.resource_type='02' and tc.deleted_at is null" - txClusterPod := l.svcCtx.DbEngin.Raw(sqlStrPod).Scan(&podSum) - if txClusterPod.Error != nil { - logx.Error(err) - return nil, txClusterPod.Error - } - // - sqlStrTask := "SELECT COUNT(*) FROM `task` where adapter_type_dict = '0'" - txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&TaskSum) - if txTask.Error != nil { - logx.Error(err) - return nil, txTask.Error - } - resp.TaskSum = TaskSum - resp.VmSum = vmSum - resp.PodSum = podSum - resp.AdapterSum = AdapterSum - return resp, nil -} diff --git a/api/internal/logic/adapters/updateadapterlogic.go b/api/internal/logic/adapters/updateadapterlogic.go deleted file mode 100644 index abf19b63..00000000 --- a/api/internal/logic/adapters/updateadapterlogic.go +++ /dev/null @@ -1,38 +0,0 @@ -package adapters - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateAdapterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAdapterLogic { - return &UpdateAdapterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateAdapterLogic) UpdateAdapter(req *types.AdapterReq) (resp *types.AdapterResp, err error) { - adapter := &types.AdapterInfo{} - result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.Id) - if errors.Is(result.Error, gorm.ErrRecordNotFound) { - return nil, errors.New("adapter does not exist") - } - utils.Convert(req, &adapter) - l.svcCtx.DbEngin.Table("t_adapter").Model(&adapter).Updates(&adapter) - return -} diff --git a/api/internal/logic/adapters/updateclusterlogic.go b/api/internal/logic/adapters/updateclusterlogic.go deleted file mode 100644 index 360b18a8..00000000 --- a/api/internal/logic/adapters/updateclusterlogic.go +++ /dev/null @@ -1,38 +0,0 @@ -package adapters - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateClusterLogic { - return &UpdateClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) { - cluster := &types.ClusterInfo{} - result := l.svcCtx.DbEngin.Table("t_cluster").First(&cluster, req.Id) - if errors.Is(result.Error, gorm.ErrRecordNotFound) { - return nil, errors.New("cluster does not exist") - } - utils.Convert(req, &cluster) - l.svcCtx.DbEngin.Table("t_cluster").Model(&cluster).Updates(&cluster) - return -} diff --git a/api/internal/logic/ai/createalgorithmlogic.go b/api/internal/logic/ai/createalgorithmlogic.go deleted file mode 100644 index bd46ddb7..00000000 --- a/api/internal/logic/ai/createalgorithmlogic.go +++ /dev/null @@ -1,57 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" -) - -type CreateAlgorithmLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlgorithmLogic { - return &CreateAlgorithmLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateAlgorithmLogic) CreateAlgorithm(req *types.CreateAlgorithmReq) (resp *types.CreateAlgorithmResp, err error) { - modelartsReq := &modelarts.CreateAlgorithmReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - ListAlgorithmsResp, err := l.svcCtx.ModelArtsRpc.CreateAlgorithm(l.ctx, modelartsReq) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&ListAlgorithmsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListAlgorithmsResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/createdatasetlogic.go b/api/internal/logic/ai/createdatasetlogic.go deleted file mode 100644 index bff8de2f..00000000 --- a/api/internal/logic/ai/createdatasetlogic.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateDataSetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetLogic { - return &CreateDataSetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateDataSetLogic) CreateDataSet(req *types.CreateDataSetReq) (resp *types.CreateDataSetResp, err error) { - // todo: add your logic here and delete this line - - modelartsReq := &modelarts.CreateDataSetReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - CreateDataSetResp, err := l.svcCtx.ModelArtsRpc.CreateDataSet(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - resp = &types.CreateDataSetResp{} - - err = copier.CopyWithOption(&resp, &CreateDataSetResp, copier.Option{Converters: utils.Converters}) - return resp, nil - -} diff --git a/api/internal/logic/ai/createexporttasklogic.go b/api/internal/logic/ai/createexporttasklogic.go deleted file mode 100644 index f2e7e67b..00000000 --- a/api/internal/logic/ai/createexporttasklogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateExportTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateExportTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateExportTaskLogic { - return &CreateExportTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateExportTaskLogic) CreateExportTask(req *types.CreateExportTaskReq) (resp *types.ExportTaskDataResp, err error) { - - modelartsReq := &modelarts.ExportTaskReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - CreateExportTaskResp, err := l.svcCtx.ModelArtsRpc.ExportTask(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateExportTaskResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateExportTaskResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/createnotebooklogic.go b/api/internal/logic/ai/createnotebooklogic.go deleted file mode 100644 index 9d7384b1..00000000 --- a/api/internal/logic/ai/createnotebooklogic.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateNotebookLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNotebookLogic { - return &CreateNotebookLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateNotebookLogic) CreateNotebook(req *types.CreateNotebookReq) (resp *types.CreateNotebookResp, err error) { - modelartsReq := &modelarts.CreateNotebookReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - createNotebookResp, err := l.svcCtx.ModelArtsRpc.CreateNotebook(l.ctx, modelartsReq) - - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to create notebook"), "Failed to create notebook err : %v ,req:%+v", err, req) - } - resp = &types.CreateNotebookResp{} - err = copier.CopyWithOption(resp, createNotebookResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - - return resp, nil -} diff --git a/api/internal/logic/ai/createprocessortasklogic.go b/api/internal/logic/ai/createprocessortasklogic.go deleted file mode 100644 index e071fe54..00000000 --- a/api/internal/logic/ai/createprocessortasklogic.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateProcessorTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProcessorTaskLogic { - return &CreateProcessorTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateProcessorTaskLogic) CreateProcessorTask(req *types.CreateProcessorTaskReq) (resp *types.CreateProcessorTaskResp, err error) { - modelartsReq := &modelarts.CreateProcessorTaskReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - CreateProcessorTaskResp, err := l.svcCtx.ModelArtsRpc.CreateProcessorTask(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - resp = &types.CreateProcessorTaskResp{} - - err = copier.CopyWithOption(&resp, &CreateProcessorTaskResp, copier.Option{Converters: utils.Converters}) - - return resp, nil -} diff --git a/api/internal/logic/ai/createservicelogic.go b/api/internal/logic/ai/createservicelogic.go deleted file mode 100644 index ed02a7b5..00000000 --- a/api/internal/logic/ai/createservicelogic.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateServiceLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic { - return &CreateServiceLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *types.CreateServiceResp, err error) { - modelartsReq := &modelarts.CreateServiceReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - CreateServiceResp, err := l.svcCtx.ModelArtsRpc.CreateService(l.ctx, modelartsReq) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&CreateServiceResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateServiceResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/createtasklogic.go b/api/internal/logic/ai/createtasklogic.go deleted file mode 100644 index 25bacfcf..00000000 --- a/api/internal/logic/ai/createtasklogic.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTaskLogic { - return &CreateTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateTaskLogic) CreateTask(req *types.ImportTaskDataReq) (resp *types.ImportTaskDataResp, err error) { - modelartsReq := &modelarts.ImportTaskDataReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - ImportTaskDataResp, err := l.svcCtx.ModelArtsRpc.CreateTask(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ImportTaskDataResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ImportTaskDataResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/createtrainingjoblogic.go b/api/internal/logic/ai/createtrainingjoblogic.go deleted file mode 100644 index 983e71f4..00000000 --- a/api/internal/logic/ai/createtrainingjoblogic.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateTrainingJobLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic { - return &CreateTrainingJobLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateTrainingJobLogic) CreateTrainingJob(req *types.CreateTrainingJobReq) (resp *types.CreateTrainingJobResp, err error) { - // todo: add your logic here and delete this line - //modelartsType := req.ModelartsType - modelartsReq := &modelarts.CreateTrainingJobReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - CreateTrainingJobResp, err := l.svcCtx.ModelArtsRpc.CreateTrainingJob(l.ctx, modelartsReq) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&CreateTrainingJobResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateTrainingJobResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/createvisualizationjoblogic.go b/api/internal/logic/ai/createvisualizationjoblogic.go deleted file mode 100644 index d38aa7d0..00000000 --- a/api/internal/logic/ai/createvisualizationjoblogic.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateVisualizationJobLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVisualizationJobLogic { - return &CreateVisualizationJobLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateVisualizationJobLogic) CreateVisualizationJob(req *types.CreateVisualizationJobReq) (resp *types.CreateVisualizationJobResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/ai/deletealgorithmlogic.go b/api/internal/logic/ai/deletealgorithmlogic.go deleted file mode 100644 index 3297ee84..00000000 --- a/api/internal/logic/ai/deletealgorithmlogic.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - "strings" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteAlgorithmLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlgorithmLogic { - return &DeleteAlgorithmLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteAlgorithmLogic) DeleteAlgorithm(req *types.DeleteAlgorithmReq) (resp *types.DeleteAlgorithmResp, err error) { - modelartsReq := &modelarts.DeleteAlgorithmsReq{} - reqByte, err := json.Marshal(req) - if err != nil { - return nil, err - } - payload := strings.NewReader(string(reqByte)) - println(payload) - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - DeleteAlgorithmResp, err := l.svcCtx.ModelArtsRpc.DeleteAlgorithms(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteAlgorithmResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteAlgorithmResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/deletedatasetlogic.go b/api/internal/logic/ai/deletedatasetlogic.go deleted file mode 100644 index 853b8d86..00000000 --- a/api/internal/logic/ai/deletedatasetlogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteDataSetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDataSetLogic { - return &DeleteDataSetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteDataSetLogic) DeleteDataSet(req *types.DeleteDataSetReq) (resp *types.DeleteDataSetResp, err error) { - // todo: add your logic here and delete this line - modelartsReq := &modelarts.DeleteDataSetReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - deleteDataSetResp, err := l.svcCtx.ModelArtsRpc.DeleteDataSet(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&deleteDataSetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &deleteDataSetResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/deleteservicelogic.go b/api/internal/logic/ai/deleteservicelogic.go deleted file mode 100644 index c6c6b51b..00000000 --- a/api/internal/logic/ai/deleteservicelogic.go +++ /dev/null @@ -1,59 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteServiceLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServiceLogic { - return &DeleteServiceLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteServiceLogic) DeleteService(req *types.DeleteServiceReq) (resp *types.DeleteServiceResp, err error) { - modelartsReq := &modelarts.DeleteServiceReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - deleteServiceResp, err := l.svcCtx.ModelArtsRpc.DeleteService(l.ctx, modelartsReq) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&deleteServiceResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &deleteServiceResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/deletetrainingjoblogic.go b/api/internal/logic/ai/deletetrainingjoblogic.go deleted file mode 100644 index 37792f27..00000000 --- a/api/internal/logic/ai/deletetrainingjoblogic.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteTrainingJobLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobLogic { - return &DeleteTrainingJobLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteTrainingJobLogic) DeleteTrainingJob(req *types.DeleteTrainingJobReq) (resp *types.DeleteTrainingJobResp, err error) { - modelartsReq := &modelarts.DeleteTrainingJobReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - deleteTrainingJobResp, err := l.svcCtx.ModelArtsRpc.DeleteTrainingJob(l.ctx, modelartsReq) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&deleteTrainingJobResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &deleteTrainingJobResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/getcenterlistlogic.go b/api/internal/logic/ai/getcenterlistlogic.go deleted file mode 100644 index 2de25ad5..00000000 --- a/api/internal/logic/ai/getcenterlistlogic.go +++ /dev/null @@ -1,43 +0,0 @@ -package ai - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetCenterListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetCenterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterListLogic { - return &GetCenterListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetCenterListLogic) GetCenterList() (resp *types.CenterListResp, err error) { - resp = &types.CenterListResp{} - - adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") - if err != nil { - return nil, err - } - - for _, adapter := range adapterList { - a := &types.AiCenter{ - Name: adapter.Name, - StackName: adapter.Nickname, - Version: adapter.Version, - } - resp.List = append(resp.List, a) - } - - return resp, nil -} diff --git a/api/internal/logic/ai/getcenteroverviewlogic.go b/api/internal/logic/ai/getcenteroverviewlogic.go deleted file mode 100644 index 0363edb7..00000000 --- a/api/internal/logic/ai/getcenteroverviewlogic.go +++ /dev/null @@ -1,164 +0,0 @@ -package ai - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "strconv" - "sync" - "time" -) - -type GetCenterOverviewLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetCenterOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterOverviewLogic { - return &GetCenterOverviewLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetCenterOverviewLogic) GetCenterOverview() (resp *types.CenterOverviewResp, err error) { - resp = &types.CenterOverviewResp{} - var mu sync.RWMutex - ch := make(chan struct{}) - - var centerNum int32 - var taskNum int32 - var cardNum int32 - var totalTops float64 - - adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") - if err != nil { - return nil, err - } - centerNum = int32(len(adapterList)) - resp.CenterNum = centerNum - - go l.updateClusterResource(&mu, ch, adapterList) - - for _, adapter := range adapterList { - taskList, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByAdapterId(adapter.Id) - if err != nil { - continue - } - taskNum += int32(len(taskList)) - } - resp.TaskNum = taskNum - - for _, adapter := range adapterList { - clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) - if err != nil { - continue - } - for _, cluster := range clusters.List { - mu.RLock() - clusterResource, err := l.svcCtx.Scheduler.AiStorages.GetClusterResourcesById(cluster.Id) - mu.RUnlock() - - if err != nil { - continue - } - cardNum += int32(clusterResource.CardTotal) - totalTops += clusterResource.CardTopsTotal - } - } - resp.CardNum = cardNum - resp.PowerInTops = totalTops - - select { - case _ = <-ch: - return resp, nil - case <-time.After(1 * time.Second): - return resp, nil - } -} - -func (l *GetCenterOverviewLogic) updateClusterResource(mu *sync.RWMutex, ch chan<- struct{}, list []*types.AdapterInfo) { - var wg sync.WaitGroup - for _, adapter := range list { - clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) - if err != nil { - continue - } - for _, cluster := range clusters.List { - c := cluster - mu.RLock() - clusterResource, err := l.svcCtx.Scheduler.AiStorages.GetClusterResourcesById(c.Id) - mu.RUnlock() - if err != nil { - continue - } - wg.Add(1) - go func() { - _, ok := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id] - if !ok { - wg.Done() - return - } - stat, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id].GetResourceStats(l.ctx) - if err != nil { - wg.Done() - return - } - if stat == nil { - wg.Done() - return - } - clusterType, err := strconv.ParseInt(adapter.Type, 10, 64) - if err != nil { - wg.Done() - return - } - var cardTotal int64 - var topsTotal float64 - for _, card := range stat.CardsAvail { - cardTotal += int64(card.CardNum) - topsTotal += card.TOpsAtFp16 * float64(card.CardNum) - } - - mu.Lock() - if (models.TClusterResource{} == *clusterResource) { - err = l.svcCtx.Scheduler.AiStorages.SaveClusterResources(adapter.Id, c.Id, c.Name, clusterType, float64(stat.CpuCoreAvail), float64(stat.CpuCoreTotal), - stat.MemAvail, stat.MemTotal, stat.DiskAvail, stat.DiskTotal, float64(stat.GpuAvail), float64(stat.GpuTotal), cardTotal, topsTotal) - if err != nil { - mu.Unlock() - wg.Done() - return - } - } else { - if stat.CpuCoreTotal == 0 || stat.MemTotal == 0 || stat.DiskTotal == 0 { - wg.Done() - return - } - clusterResource.CardTotal = cardTotal - clusterResource.CardTopsTotal = topsTotal - clusterResource.CpuAvail = float64(stat.CpuCoreAvail) - clusterResource.CpuTotal = float64(stat.CpuCoreTotal) - clusterResource.MemAvail = stat.MemAvail - clusterResource.MemTotal = stat.MemTotal - clusterResource.DiskAvail = stat.DiskAvail - clusterResource.DiskTotal = stat.DiskTotal - - err := l.svcCtx.Scheduler.AiStorages.UpdateClusterResources(clusterResource) - if err != nil { - mu.Unlock() - wg.Done() - return - } - } - mu.Unlock() - wg.Done() - }() - } - } - wg.Wait() - ch <- struct{}{} -} diff --git a/api/internal/logic/ai/getcenterqueueinglogic.go b/api/internal/logic/ai/getcenterqueueinglogic.go deleted file mode 100644 index e7405298..00000000 --- a/api/internal/logic/ai/getcenterqueueinglogic.go +++ /dev/null @@ -1,73 +0,0 @@ -package ai - -import ( - "context" - "sort" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetCenterQueueingLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetCenterQueueingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterQueueingLogic { - return &GetCenterQueueingLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetCenterQueueingLogic) GetCenterQueueing() (resp *types.CenterQueueingResp, err error) { - resp = &types.CenterQueueingResp{} - - adapters, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") - if err != nil { - return nil, err - } - - for _, adapter := range adapters { - clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) - if err != nil { - continue - } - for _, cluster := range clusters.List { - queues, err := l.svcCtx.Scheduler.AiStorages.GetClusterTaskQueues(adapter.Id, cluster.Id) - if err != nil { - continue - } - if queues == nil { - continue - } - //todo sync current task queues - current := &types.CenterQueue{ - Name: cluster.Name, - QueueingNum: int32(queues[0].QueueNum), - } - history := &types.CenterQueue{ - Name: cluster.Name, - QueueingNum: int32(queues[0].QueueNum), - } - resp.Current = append(resp.Current, current) - resp.History = append(resp.History, history) - - } - } - - sortQueueingNum(resp.Current) - sortQueueingNum(resp.History) - - return resp, nil -} - -func sortQueueingNum(q []*types.CenterQueue) { - sort.Slice(q, func(i, j int) bool { - return q[i].QueueingNum > q[j].QueueingNum - }) -} diff --git a/api/internal/logic/ai/getcentertasklistlogic.go b/api/internal/logic/ai/getcentertasklistlogic.go deleted file mode 100644 index b7fa034f..00000000 --- a/api/internal/logic/ai/getcentertasklistlogic.go +++ /dev/null @@ -1,136 +0,0 @@ -package ai - -import ( - "context" - "errors" - "fmt" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "strconv" - "sync" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetCenterTaskListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetCenterTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterTaskListLogic { - return &GetCenterTaskListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetCenterTaskListLogic) GetCenterTaskList() (resp *types.CenterTaskListResp, err error) { - resp = &types.CenterTaskListResp{} - var mu sync.RWMutex - ch := make(chan struct{}) - - adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") - if err != nil { - return nil, err - } - - go l.updateAiTaskStatus(&mu, ch, adapterList) - - for _, adapter := range adapterList { - mu.RLock() - taskList, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByAdapterId(adapter.Id) - mu.RUnlock() - if err != nil { - continue - } - if len(taskList) == 0 { - continue - } - for _, task := range taskList { - var elapsed time.Duration - switch task.Status { - case constants.Completed: - end, err := time.ParseInLocation(constants.Layout, task.EndTime, time.Local) - if err != nil { - elapsed = time.Duration(0) - } - start, err := time.ParseInLocation(constants.Layout, task.StartTime, time.Local) - if err != nil { - elapsed = time.Duration(0) - } - elapsed = end.Sub(start) - case constants.Running: - elapsed = time.Now().Sub(task.CommitTime) - default: - elapsed = 0 - } - - t := &types.AiTask{ - Name: task.Name, - Status: task.Status, - Cluster: task.ClusterName, - Card: task.Card, - TimeElapsed: int32(elapsed.Seconds()), - } - resp.List = append(resp.List, t) - } - } - - select { - case _ = <-ch: - return resp, nil - case <-time.After(2 * time.Second): - return resp, nil - } -} - -func (l *GetCenterTaskListLogic) updateAiTaskStatus(mu *sync.RWMutex, ch chan<- struct{}, list []*types.AdapterInfo) { - var wg sync.WaitGroup - for _, adapter := range list { - taskList, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByAdapterId(adapter.Id) - if err != nil { - continue - } - if len(taskList) == 0 { - continue - } - for _, task := range taskList { - t := task - if t.Status == constants.Completed || task.Status == constants.Failed || task.Status == constants.Stopped { - continue - } - wg.Add(1) - go func() { - trainingTask, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][strconv.FormatInt(t.ClusterId, 10)].GetTrainingTask(l.ctx, t.JobId) - if err != nil { - msg := fmt.Sprintf("AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) - logx.Errorf(errors.New(msg).Error()) - wg.Done() - return - } - if trainingTask == nil { - wg.Done() - return - } - t.Status = trainingTask.Status - t.StartTime = trainingTask.Start - t.EndTime = trainingTask.End - mu.Lock() - err = l.svcCtx.Scheduler.AiStorages.UpdateAiTask(t) - mu.Unlock() - if err != nil { - wg.Done() - return - } - wg.Done() - }() - } - } - wg.Wait() - ch <- struct{}{} -} diff --git a/api/internal/logic/ai/getexporttasksofdatasetlogic.go b/api/internal/logic/ai/getexporttasksofdatasetlogic.go deleted file mode 100644 index 3d053fa2..00000000 --- a/api/internal/logic/ai/getexporttasksofdatasetlogic.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetExportTasksOfDatasetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetExportTasksOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTasksOfDatasetLogic { - return &GetExportTasksOfDatasetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetExportTasksOfDatasetLogic) GetExportTasksOfDataset(req *types.GetExportTasksOfDatasetReq) (resp *types.GetExportTasksOfDatasetResp, err error) { - modelartsReq := &modelarts.GetExportTasksOfDatasetReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - GetExportTasksOfDatasetResp, err := l.svcCtx.ModelArtsRpc.GetExportTasksOfDataset(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&GetExportTasksOfDatasetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &GetExportTasksOfDatasetResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/getexporttaskstatusofdatasetlogic.go b/api/internal/logic/ai/getexporttaskstatusofdatasetlogic.go deleted file mode 100644 index 2caae709..00000000 --- a/api/internal/logic/ai/getexporttaskstatusofdatasetlogic.go +++ /dev/null @@ -1,59 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetExportTaskStatusOfDatasetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetExportTaskStatusOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTaskStatusOfDatasetLogic { - return &GetExportTaskStatusOfDatasetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetExportTaskStatusOfDatasetLogic) GetExportTaskStatusOfDataset(req *types.GetExportTaskStatusOfDatasetReq) (resp *types.GetExportTaskStatusOfDatasetResp, err error) { - modelartsReq := &modelarts.GetExportTaskStatusOfDatasetReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - GetExportTaskStatusOfDatasetResp, err := l.svcCtx.ModelArtsRpc.GetExportTaskStatusOfDataset(l.ctx, modelartsReq) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&GetExportTaskStatusOfDatasetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &GetExportTaskStatusOfDatasetResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/getlisttrainingjobslogic.go b/api/internal/logic/ai/getlisttrainingjobslogic.go deleted file mode 100644 index 12316436..00000000 --- a/api/internal/logic/ai/getlisttrainingjobslogic.go +++ /dev/null @@ -1,104 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetListTrainingJobsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetListTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetListTrainingJobsLogic { - return &GetListTrainingJobsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetListTrainingJobsLogic) GetListTrainingJobs(req *types.ListTrainingJobsreq) (resp *types.ListTrainingJobsresp, err error) { - modelartsReq := &modelarts.ListTrainingJobsreq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetListTrainingJobs(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&listDataSetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: utils.Converters}) - return resp, nil - /* modelartsType := req.ModelartsType - switch modelartsType { - case "octops": - octopusReq := &octopus.GetTrainJobListReq{} - err = copier.CopyWithOption(octopusReq, req, copier.Option{Converters: utils.Converters}) - listTrainJobResp, err := l.svcCtx.OctopusRpc.GetTrainJobList(l.ctx, octopusReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db TrainJobs list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&listTrainJobResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &listTrainJobResp, copier.Option{Converters: utils.Converters}) - case "cn-north-4.myhuawei": - modelartsReq := &modelarts.ListTrainingJobsreq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetListTrainingJobs(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db TrainJobs list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&listDataSetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: utils.Converters}) - case "cn-east-293.njaci": - modelartsReq := &modelarts.ListTrainingJobsreq{} - - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetListTrainingJobs(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db TrainJobs list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&listDataSetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: utils.Converters}) - }*/ - -} diff --git a/api/internal/logic/ai/getnotebookstoragelogic.go b/api/internal/logic/ai/getnotebookstoragelogic.go deleted file mode 100644 index 574520d5..00000000 --- a/api/internal/logic/ai/getnotebookstoragelogic.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetNotebookStorageLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNotebookStorageLogic { - return &GetNotebookStorageLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetNotebookStorageLogic) GetNotebookStorage(req *types.GetNotebookStorageReq) (resp *types.GetNotebookStorageResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/ai/getvisualizationjoblogic.go b/api/internal/logic/ai/getvisualizationjoblogic.go deleted file mode 100644 index ca26aadf..00000000 --- a/api/internal/logic/ai/getvisualizationjoblogic.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetVisualizationJobLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVisualizationJobLogic { - return &GetVisualizationJobLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetVisualizationJobLogic) GetVisualizationJob(req *types.GetVisualizationJobReq) (resp *types.GetVisualizationJobResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/ai/listalgorithmslogic.go b/api/internal/logic/ai/listalgorithmslogic.go deleted file mode 100644 index 3e4eaa26..00000000 --- a/api/internal/logic/ai/listalgorithmslogic.go +++ /dev/null @@ -1,59 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListAlgorithmsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAlgorithmsLogic { - return &ListAlgorithmsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListAlgorithmsLogic) ListAlgorithms(req *types.ListAlgorithmsReq) (resp *types.ListAlgorithmsResp, err error) { - modelartsReq := &modelarts.ListAlgorithmsReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: false, DeepCopy: true, Converters: utils.Converters}) - ListAlgorithmsResp, err := l.svcCtx.ModelArtsRpc.ListAlgorithms(l.ctx, modelartsReq) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&ListAlgorithmsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListAlgorithmsResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/listclusterslogic.go b/api/internal/logic/ai/listclusterslogic.go deleted file mode 100644 index 2ee7057c..00000000 --- a/api/internal/logic/ai/listclusterslogic.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListClustersLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListClustersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClustersLogic { - return &ListClustersLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListClustersLogic) ListClusters(req *types.ListClustersReq) (resp *types.ListClustersResp, err error) { - // todo: add your logic here and delete this line - modelartsReq := &modelarts.ListClustersReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - ListClustersResp, err := l.svcCtx.ModelArtsRpc.ListClusters(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - resp = &types.ListClustersResp{} - err = copier.CopyWithOption(&resp, &ListClustersResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/listdatasetlogic.go b/api/internal/logic/ai/listdatasetlogic.go deleted file mode 100644 index 6089719a..00000000 --- a/api/internal/logic/ai/listdatasetlogic.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListDataSetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDataSetLogic { - return &ListDataSetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListDataSetLogic) ListDataSet(req *types.DataSetReq) (resp *types.DataSetResp, err error) { - // todo: add your logic here and delete this line - modelartsReq := &modelarts.DataSetReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - //err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - DataSetResp, err := l.svcCtx.ModelArtsRpc.GetDatasetList(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DataSetResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DataSetResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/listimportlogic.go b/api/internal/logic/ai/listimportlogic.go deleted file mode 100644 index e03fabe7..00000000 --- a/api/internal/logic/ai/listimportlogic.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListImportLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListImportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListImportLogic { - return &ListImportLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListImportLogic) ListImport(req *types.ListImportTasksReq) (resp *types.ListImportTasksResp, err error) { - modelartsReq := &modelarts.ListImportTasksReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetImportTaskList(l.ctx, modelartsReq) - marshal, err := json.Marshal(&listDataSetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/listnotebooklogic.go b/api/internal/logic/ai/listnotebooklogic.go deleted file mode 100644 index 24808982..00000000 --- a/api/internal/logic/ai/listnotebooklogic.go +++ /dev/null @@ -1,57 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListNotebookLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNotebookLogic { - return &ListNotebookLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListNotebookLogic) ListNotebook(req *types.ListNotebookReq) (resp *types.ListNotebookResp, err error) { - modelartsReq := &modelarts.ListNotebookReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - - listNotebookResp, err := l.svcCtx.ModelArtsRpc.ListNotebook(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get notebook list"), "Failed to get notebook list err : %v ,req:%+v", err, req) - } - - resp = &types.ListNotebookResp{} - err = copier.CopyWithOption(resp, listNotebookResp, copier.Option{Converters: utils.Converters}) - - return resp, nil -} diff --git a/api/internal/logic/ai/listserviceslogic.go b/api/internal/logic/ai/listserviceslogic.go deleted file mode 100644 index ad3cc184..00000000 --- a/api/internal/logic/ai/listserviceslogic.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListServicesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServicesLogic { - return &ListServicesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListServicesLogic) ListServices(req *types.ListServicesReq) (resp *types.ListServicesResp, err error) { - modelartsReq := &modelarts.ListServicesReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - ListServicesResp, err := l.svcCtx.ModelArtsRpc.ListServices(l.ctx, modelartsReq) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&ListServicesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListServicesResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/mountnotebookstoragelogic.go b/api/internal/logic/ai/mountnotebookstoragelogic.go deleted file mode 100644 index 52eb5fda..00000000 --- a/api/internal/logic/ai/mountnotebookstoragelogic.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type MountNotebookStorageLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewMountNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MountNotebookStorageLogic { - return &MountNotebookStorageLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *MountNotebookStorageLogic) MountNotebookStorage(req *types.MountNotebookStorageReq) (resp *types.MountNotebookStorageResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/ai/proxyapilogic.go b/api/internal/logic/ai/proxyapilogic.go deleted file mode 100644 index adec665f..00000000 --- a/api/internal/logic/ai/proxyapilogic.go +++ /dev/null @@ -1,91 +0,0 @@ -package ai - -import ( - "bytes" - "context" - "crypto/tls" - "encoding/json" - "github.com/go-resty/resty/v2" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/hws" - "net/http" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ProxyApiLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewProxyApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProxyApiLogic { - return &ProxyApiLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -const ( - XProjectID = "d18190e28e3f45a281ef0b0696ec9d52" - XStage = "RELEASE" - ContentType = "application/json" -) - -func (l *ProxyApiLogic) ProxyApi(req *types.ChatReq) (resp *types.ChatResult, err error) { - logx.Infof("【开始处理请求,目标URL: %s】", req.ApiUrl) - - jsonBytes, err := json.Marshal(&req.ReqData) - if err != nil { - logx.Errorf("【序列化请求数据失败: %v】", err) - return nil, errors.New("请求数据序列化失败") - } - - resp = &types.ChatResult{} - - // 构建 HTTP 请求 - request, err := http.NewRequest("POST", req.ApiUrl, bytes.NewBuffer(jsonBytes)) - if err != nil { - logx.Errorf("【构建 HTTP 请求失败: %v】", err) - return nil, errors.New("网络错误,请稍后重试") - } - - signer := &hws.Signer{ - Key: "UNEHPHO4Z7YSNPKRXFE4", - Secret: "JWXCE9qcYbc7RjpSRIWt4WgG3ZKF6Q4lPzkJReX9", - } - - if err := signer.Sign(request); err != nil { - logx.Errorf("【接口签名错误: %v】", err) - return nil, errors.New("网络错误,请稍后重试") - } - - client := resty.New().SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) - - response, err := client.R(). - SetHeader("X-Project-Id", XProjectID). - SetHeader("x-stage", XStage). - SetHeader("Content-Type", ContentType). - SetHeader("Authorization", request.Header.Get(hws.HeaderXAuthorization)). - SetHeader("X-Sdk-Date", request.Header.Get(hws.HeaderXDateTime)). - SetBody(jsonBytes). - SetResult(&resp). - Post(req.ApiUrl) - - if err != nil { - logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", req.ApiUrl, err.Error()) - return nil, errors.New("网络错误,请稍后重试") - } - - if response.StatusCode() != 200 { - logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", req.ApiUrl, response.Body()) - return nil, errors.New("网络错误,请稍后重试") - } - - logx.Infof("【请求处理成功,目标URL: %s】", req.ApiUrl) - return resp, nil -} diff --git a/api/internal/logic/ai/showalgorithmbyuuidlogic.go b/api/internal/logic/ai/showalgorithmbyuuidlogic.go deleted file mode 100644 index 6cf7c127..00000000 --- a/api/internal/logic/ai/showalgorithmbyuuidlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowAlgorithmByUuidLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowAlgorithmByUuidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowAlgorithmByUuidLogic { - return &ShowAlgorithmByUuidLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowAlgorithmByUuidLogic) ShowAlgorithmByUuid(req *types.ShowAlgorithmByUuidReq) (resp *types.ShowAlgorithmByUuidResp, err error) { - - modelartsReq := &modelarts.ShowAlgorithmByUuidReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - ShowAlgorithmByUuidResp, err := l.svcCtx.ModelArtsRpc.ShowAlgorithmByUuid(l.ctx, modelartsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowAlgorithmByUuidResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowAlgorithmByUuidResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/showservicelogic.go b/api/internal/logic/ai/showservicelogic.go deleted file mode 100644 index 19136a4c..00000000 --- a/api/internal/logic/ai/showservicelogic.go +++ /dev/null @@ -1,59 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - "github.com/jinzhu/copier" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowServiceLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowServiceLogic { - return &ShowServiceLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowServiceLogic) ShowService(req *types.ShowServiceReq) (resp *types.ShowServiceResp, err error) { - modelartsReq := &modelarts.ShowServiceReq{} - err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) - ShowServiceResp, err := l.svcCtx.ModelArtsRpc.ShowService(l.ctx, modelartsReq) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - marshal, err := json.Marshal(&ShowServiceResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowServiceResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/ai/startnotebooklogic.go b/api/internal/logic/ai/startnotebooklogic.go deleted file mode 100644 index 9a08d646..00000000 --- a/api/internal/logic/ai/startnotebooklogic.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type StartNotebookLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewStartNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartNotebookLogic { - return &StartNotebookLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *StartNotebookLogic) StartNotebook(req *types.StartNotebookReq) (resp *types.StartNotebookResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/ai/stopnotebooklogic.go b/api/internal/logic/ai/stopnotebooklogic.go deleted file mode 100644 index 3a6e3ca2..00000000 --- a/api/internal/logic/ai/stopnotebooklogic.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package ai - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type StopNotebookLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewStopNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopNotebookLogic { - return &StopNotebookLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *StopNotebookLogic) StopNotebook(req *types.StopNotebookReq) (resp *types.StopNotebookResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/cloud/cloudlistlogic.go b/api/internal/logic/cloud/cloudlistlogic.go deleted file mode 100644 index 353853c2..00000000 --- a/api/internal/logic/cloud/cloudlistlogic.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package cloud - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" -) - -type CloudListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCloudListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CloudListLogic { - return &CloudListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CloudListLogic) CloudList() (resp *types.CloudListResp, err error) { - // 查询数据库中数算任务列表 - var clouds []*models.Cloud - tx := l.svcCtx.DbEngin.Find(&clouds) - if tx.Error != nil { - return nil, tx.Error - } - result := types.CloudListResp{} - utils.Convert(clouds, &result.Clouds) - return &result, nil -} diff --git a/api/internal/logic/cloud/clusterinfologic.go b/api/internal/logic/cloud/clusterinfologic.go deleted file mode 100644 index a14fea99..00000000 --- a/api/internal/logic/cloud/clusterinfologic.go +++ /dev/null @@ -1,30 +0,0 @@ -package cloud - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ClusterInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewClusterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterInfoLogic { - return &ClusterInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ClusterInfoLogic) ClusterInfo(req *types.ClusterInfoReq) (resp *types.ClusterInfoResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/cloud/commitgeneraltasklogic.go b/api/internal/logic/cloud/commitgeneraltasklogic.go deleted file mode 100644 index 4fd561ae..00000000 --- a/api/internal/logic/cloud/commitgeneraltasklogic.go +++ /dev/null @@ -1,168 +0,0 @@ -package cloud - -import ( - "bytes" - "context" - "github.com/pkg/errors" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "io" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - syaml "k8s.io/apimachinery/pkg/runtime/serializer/yaml" - kyaml "k8s.io/apimachinery/pkg/util/yaml" - "strconv" - "strings" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CommitGeneralTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCommitGeneralTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitGeneralTaskLogic { - return &CommitGeneralTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) error { - tx := l.svcCtx.DbEngin.Begin() - // 执行回滚或者提交操作 - defer func() { - if p := recover(); p != nil { - tx.Rollback() - logx.Error(p) - } else if tx.Error != nil { - logx.Info("rollback, error", tx.Error) - tx.Rollback() - } else { - tx = tx.Commit() - logx.Info("commit success") - } - }() - //TODO adapter - adapterId, _ := strconv.ParseUint(req.AdapterIds[0], 10, 64) - var clusters []*models.CloudModel - err := tx.Raw("SELECT * FROM `t_cluster` where adapter_id in ? and id in ?", req.AdapterIds, req.ClusterIds).Scan(&clusters).Error - if err != nil { - logx.Errorf("CommitGeneralTask() => sql execution error: %v", err) - return errors.Errorf("the cluster does not match the drive resources. Check the data") - } - taskCloud := cloud.TaskCloudModel{} - opt := &option.CloudOption{} - utils.Convert(&req, &opt) - sc, _ := schedulers.NewCloudScheduler(l.ctx, "", l.svcCtx.Scheduler, opt, tx, l.svcCtx.PromClient) - - results, err := l.svcCtx.Scheduler.AssignAndSchedule(sc) - if err != nil { - logx.Errorf("AssignAndSchedule() => execution error: %v", err) - return err - } - - rs := (results).([]*schedulers.CloudResult) - - var synergyStatus int64 - if len(rs) > 1 { - synergyStatus = 1 - } - var strategy int64 - sqlStr := `select t_dict_item.item_value - from t_dict - left join t_dict_item on t_dict.id = t_dict_item.dict_id - where item_text = ? - and t_dict.dict_code = 'schedule_Strategy'` - //查询调度策略 - err = tx.Raw(sqlStr, req.Strategy).Scan(&strategy).Error - taskModel := models.Task{ - Id: utils.GenSnowflakeID(), - Status: constants.Saved, - Name: req.Name, - CommitTime: time.Now(), - YamlString: strings.Join(req.ReqBody, "\n---\n"), - AdapterTypeDict: "0", - SynergyStatus: synergyStatus, - Strategy: strategy, - } - var taskClouds []cloud.TaskCloudModel - adapterName := "" - tx.Table("t_adapter").Select("name").Where("id=?", adapterId).Find(&adapterName) - for _, r := range rs { - for _, s := range req.ReqBody { - sStruct := UnMarshalK8sStruct(s, int64(r.Replica)) - unString, _ := sStruct.MarshalJSON() - taskCloud.Id = utils.GenSnowflakeIDUint() - taskCloud.Name = sStruct.GetName() + "-" + sStruct.GetKind() - taskCloud.TaskId = uint(taskModel.Id) - clusterId, _ := strconv.ParseUint(r.ClusterId, 10, 64) - taskCloud.AdapterId = uint(adapterId) - taskCloud.AdapterName = adapterName - taskCloud.ClusterId = uint(clusterId) - taskCloud.ClusterName = r.ClusterName - taskCloud.Status = constants.Saved - taskCloud.YamlString = string(unString) - taskCloud.Kind = sStruct.GetKind() - taskCloud.Namespace = sStruct.GetNamespace() - taskClouds = append(taskClouds, taskCloud) - } - } - noticeInfo := clientCore.NoticeInfo{ - AdapterId: int64(adapterId), - AdapterName: adapterName, - NoticeType: "create", - TaskName: req.Name, - Incident: "任务创建中", - CreatedTime: time.Now(), - } - 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") - } - return nil -} - -func UnMarshalK8sStruct(yamlString string, replica int64) *unstructured.Unstructured { - unstructuredObj := &unstructured.Unstructured{} - d := kyaml.NewYAMLOrJSONDecoder(bytes.NewBufferString(yamlString), 4096) - var err error - for { - var rawObj runtime.RawExtension - err = d.Decode(&rawObj) - if err == io.EOF { - break - } - obj := &unstructured.Unstructured{} - syaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme).Decode(rawObj.Raw, nil, obj) - unstructuredMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) - if err != nil { - logx.Errorf("UnMarshalK8sStruct() => Execution failure err:%v", err) - } - unstructuredObj = &unstructured.Unstructured{Object: unstructuredMap} - // 命名空间为空 设置默认值 - if len(unstructuredObj.GetNamespace()) == 0 { - unstructuredObj.SetNamespace("default") - } - //设置副本数 - if unstructuredObj.GetKind() == "Deployment" || unstructuredObj.GetKind() == "StatefulSet" { - unstructured.SetNestedField(unstructuredObj.Object, replica, "spec", "replicas") - } - } - return unstructuredObj -} diff --git a/api/internal/logic/cloud/controllermetricslogic.go b/api/internal/logic/cloud/controllermetricslogic.go deleted file mode 100644 index 50409bf6..00000000 --- a/api/internal/logic/cloud/controllermetricslogic.go +++ /dev/null @@ -1,46 +0,0 @@ -package cloud - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - "time" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ControllerMetricsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewControllerMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ControllerMetricsLogic { - return &ControllerMetricsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ControllerMetricsLogic) ControllerMetrics(req *types.ControllerMetricsReq) (resp *types.ControllerMetricsResp, err error) { - resp = &types.ControllerMetricsResp{} - if _, ok := l.svcCtx.MonitorClient[req.ParticipantId]; ok { - if len(req.Pod) != 0 { - resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.PodOption{ - PodName: req.Pod, - }) - } else { - - resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.ControllerOption{ - WorkloadName: req.WorkloadName, - }) - } - } else { - return nil, error2.NewCodeError(400, "prometheus endpoint invalid!") - } - - return resp, nil -} diff --git a/api/internal/logic/cloud/deleteclusterlogic.go b/api/internal/logic/cloud/deleteclusterlogic.go deleted file mode 100644 index a51c2d74..00000000 --- a/api/internal/logic/cloud/deleteclusterlogic.go +++ /dev/null @@ -1,37 +0,0 @@ -package cloud - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClusterLogic { - return &DeleteClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteClusterLogic) DeleteCluster(req *types.DeleteClusterReq) (*types.CloudResp, error) { - // 删除集群信息 - var resp types.CloudResp - tx := l.svcCtx.DbEngin.Where("name = ?", req.Name).Delete(&models.ScParticipantPhyInfo{}) - if tx.Error != nil { - return nil, tx.Error - } - resp.Code = string(200) - resp.Msg = "success" - resp.Data = "" - return &resp, nil -} diff --git a/api/internal/logic/cloud/deleteyamllogic.go b/api/internal/logic/cloud/deleteyamllogic.go deleted file mode 100644 index c2d8838c..00000000 --- a/api/internal/logic/cloud/deleteyamllogic.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package cloud - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteYamlLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteYamlLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteYamlLogic { - return &DeleteYamlLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteYamlLogic) DeleteYaml(req *types.ApplyReq) (resp *types.DeleteResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/cloud/getclusterlistlogic.go b/api/internal/logic/cloud/getclusterlistlogic.go deleted file mode 100644 index 710550e6..00000000 --- a/api/internal/logic/cloud/getclusterlistlogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package cloud - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetClusterListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterListLogic { - return &GetClusterListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetClusterListLogic) GetClusterList(req *types.GetClusterListReq) (resp *types.GetClusterListResp, err error) { - resp = &types.GetClusterListResp{} - //clusters := []models.ScParticipantPhyInfo{} - l.svcCtx.DbEngin.Find(resp.Clusters).Where("id", req.Id) - return resp, nil -} diff --git a/api/internal/logic/cloud/listcloudclusterlogic.go b/api/internal/logic/cloud/listcloudclusterlogic.go deleted file mode 100644 index c3d73625..00000000 --- a/api/internal/logic/cloud/listcloudclusterlogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package cloud - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListCloudClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListCloudClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListCloudClusterLogic { - return &ListCloudClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListCloudClusterLogic) ListCloudCluster(req *types.ListClusterReq) (resp *types.CloudListResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/cloud/podlogslogic.go b/api/internal/logic/cloud/podlogslogic.go deleted file mode 100644 index 480c2d21..00000000 --- a/api/internal/logic/cloud/podlogslogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package cloud - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "net/http" -) - -type PodLogsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext - w http.ResponseWriter -} - -func NewPodLogsLogic(ctx context.Context, svcCtx *svc.ServiceContext, w http.ResponseWriter) *PodLogsLogic { - return &PodLogsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - w: w, - } -} - -func (l *PodLogsLogic) PodLogs(req *types.PodLogsReq, w http.ResponseWriter) (resp string, err error) { - // todo: add your logic here and delete this line - return -} diff --git a/api/internal/logic/cloud/registerclusterlogic.go b/api/internal/logic/cloud/registerclusterlogic.go deleted file mode 100644 index 141fe851..00000000 --- a/api/internal/logic/cloud/registerclusterlogic.go +++ /dev/null @@ -1,68 +0,0 @@ -package cloud - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "strconv" - - "github.com/zeromicro/go-zero/core/logx" -) - -type RegisterClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewRegisterClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterClusterLogic { - return &RegisterClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (*types.CloudResp, error) { - var phyInfos []models.ScParticipantPhyInfo - var resp types.CloudResp - - l.svcCtx.DbEngin.Raw("select * from sc_participant_phy_info where `name` = ?", req.Name).Scan(&phyInfos) - if len(phyInfos) != 0 { - resp.Code = "400" - resp.Msg = "cluster name already exist" - resp.Data = "" - return &resp, nil - } - - participant := models.ScParticipantPhyInfo{ - Token: req.Token, - Name: req.Name, - Address: req.Address, - Type: "CLOUD", - Id: utils.GenSnowflakeID(), - MetricsUrl: req.MetricsUrl, - } - tx := l.svcCtx.DbEngin.Create(&participant) - if tx.Error != nil { - return nil, tx.Error - } - - labelInfo := models.ScParticipantLabelInfo{ - Id: utils.GenSnowflakeID(), - ParticipantId: participant.Id, - Key: "cloud", - Value: "sealos", - } - tx2 := l.svcCtx.DbEngin.Create(&labelInfo) - if tx2.Error != nil { - return nil, tx.Error - } - - resp.Code = string(200) - resp.Msg = "success" - resp.Data = "participantId:" + strconv.FormatInt(participant.Id, 10) - return &resp, nil -} diff --git a/api/internal/logic/core/centerresourceslogic.go b/api/internal/logic/core/centerresourceslogic.go deleted file mode 100644 index 1775f68d..00000000 --- a/api/internal/logic/core/centerresourceslogic.go +++ /dev/null @@ -1,73 +0,0 @@ -package core - -import ( - "context" - "github.com/prometheus/common/model" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - "strconv" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CenterResourcesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCenterResourcesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CenterResourcesLogic { - return &CenterResourcesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CenterResourcesLogic) CenterResources() (resp *types.CenterResourcesResp, err error) { - resp = &types.CenterResourcesResp{} - rawData, err := l.svcCtx.PromClient.GetRawData("center_top3", tracker.AdapterOption{}) - if err != nil { - return nil, err - } - var centersIndex []*types.CenterIndex - data := rawData.(model.Vector) - for _, d := range data { - for _, v := range d.Metric { - num, err := strconv.ParseInt(string(v), 10, 64) - if err != nil { - return nil, err - } - centersIndex = append(centersIndex, &types.CenterIndex{Id: num}) - } - } - for _, centerIndex := range centersIndex { - // Query the types of resource centers - l.svcCtx.DbEngin.Raw("select name,type as CenterType from t_adapter where id = ?", centerIndex.Id).Scan(¢erIndex) - var clustersName string - l.svcCtx.DbEngin.Raw("SELECT GROUP_CONCAT(name SEPARATOR '|' ) as clustersName from t_cluster where adapter_id = ?", centerIndex.Id).Scan(&clustersName) - cpuRawData, err := l.svcCtx.PromClient.GetRawData("center_cpu_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName}) - cpuData := cpuRawData.(model.Vector) - if err != nil { - return nil, err - } - centerIndex.Cpu = cpuData[0].Value.String() - memoryRawData, err := l.svcCtx.PromClient.GetRawData("center_memory_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName}) - if err != nil { - return nil, err - } - memoryData := memoryRawData.(model.Vector) - - centerIndex.Memory = memoryData[0].Value.String() - diskRawData, err := l.svcCtx.PromClient.GetRawData("center_disk_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName}) - if err != nil { - return nil, err - } - diskData := diskRawData.(model.Vector) - centerIndex.Storage = diskData[0].Value.String() - resp.CentersIndex = append(resp.CentersIndex, *centerIndex) - } - return resp, nil -} diff --git a/api/internal/logic/core/committasklogic.go b/api/internal/logic/core/committasklogic.go deleted file mode 100644 index 0ed31cd4..00000000 --- a/api/internal/logic/core/committasklogic.go +++ /dev/null @@ -1,66 +0,0 @@ -package core - -import ( - "context" - "github.com/ghodss/yaml" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/mqs" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "strings" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CommitTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCommitTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitTaskLogic { - return &CommitTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CommitTaskLogic) CommitTask(req *types.CommitTaskReq) error { - //req.YamlList转换为json - var yamlStr []string - for _, s := range req.YamlList { - j2, err := yaml.YAMLToJSON([]byte(s)) - if err != nil { - logx.Errorf("Failed to convert yaml to JSON, err: %v", err) - return err - } - yamlStr = append(yamlStr, string(j2)) - } - result := strings.Join(yamlStr, ",") - taskModel := models.Task{ - Status: constants.Saved, - Name: req.Name, - CommitTime: time.Now(), - NsID: req.NsID, - YamlString: "[" + result + "]", - } - // 保存任务数据到数据库 - tx := l.svcCtx.DbEngin.Create(&taskModel) - if tx.Error != nil { - return tx.Error - } - task := response.TaskInfo{ - TaskId: taskModel.Id, - MatchLabels: req.MatchLabels, - NsID: req.NsID, - Metadata: req.YamlList, - Replicas: req.Replicas, - } - mqs.InsQueue.Beta.Add(&task) - return nil -} diff --git a/api/internal/logic/core/commitvmtasklogic.go b/api/internal/logic/core/commitvmtasklogic.go deleted file mode 100644 index aebf4f48..00000000 --- a/api/internal/logic/core/commitvmtasklogic.go +++ /dev/null @@ -1,170 +0,0 @@ -package core - -import ( - "context" - "fmt" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "strconv" - "time" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CommitVmTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCommitVmTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitVmTaskLogic { - return &CommitVmTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *types.CommitVmTaskResp, err error) { - // todo: add your logic here and delete this line - resp = &types.CommitVmTaskResp{} - tx := l.svcCtx.DbEngin.Begin() - var adaptersName string - var clusterName string - //Building the main task structure - defer func() { - if p := recover(); p != nil { - tx.Rollback() - logx.Error(p) - } else if tx.Error != nil { - logx.Info("rollback, error", tx.Error) - tx.Rollback() - } else { - tx = tx.Commit() - logx.Info("commit success") - } - }() - //TODO adapter - adapterId, _ := strconv.ParseUint(req.AdapterIds[0], 10, 64) - taskVm := models.TaskVm{} - //TODO 执行策略返回集群跟 Replica - opt := &option.VmOption{} - utils.Convert(&req, &opt) - // 2、Initialize scheduler - vmSchdl, _ := schedulers.NewVmScheduler(l.ctx, "", l.svcCtx.Scheduler, opt, l.svcCtx.DbEngin, l.svcCtx.PromClient) - if err != nil { - return nil, err - } - // 3、Return scheduling results - results, err := l.svcCtx.Scheduler.AssignAndSchedule(vmSchdl) - if err != nil { - logx.Errorf("AssignAndSchedule() => execution error: %v", err) - return nil, err - } - rs := (results).([]*schedulers.VmResult) - var synergyStatus int64 - if len(rs) > 1 { - synergyStatus = 1 - } - var strategy int64 - sqlStr := `select t_dict_item.item_value - from t_dict - left join t_dict_item on t_dict.id = t_dict_item.dict_id - where item_text = ? - and t_dict.dict_code = 'schedule_Strategy'` - //查询调度策略 - err = tx.Raw(sqlStr, req.Strategy).Scan(&strategy).Error - taskModel := models.Task{ - Id: utils.GenSnowflakeID(), - Status: constants.Saved, - Name: req.Name, - CommitTime: time.Now(), - Description: "vm task", - AdapterTypeDict: "0", - SynergyStatus: synergyStatus, - Strategy: strategy, - } - //var taskVms models.TaskVm - var VmObject types.TaskVm - for _, r := range rs { - for _, clusterId := range req.ClusterIds { - if r.Replica > 0 && r.ClusterId == clusterId { - fmt.Println("", clusterId) - sql := `SELECT vi.image_id as image,vf.flavor_id as flavor,vn.network_id as uuid,vi.cluster_name as platform FROM - vm_flavor vf - LEFT JOIN vm_image vi ON vf.cluster_id = vi.cluster_id - LEFT JOIN vm_network vn ON vf.cluster_id = vn.cluster_id - WHERE - vi.cluster_id = ? - AND vf.public_flavor_id = ? - AND vi.public_image_id = ? - AND vn.public_network_id = ?` - txVm := l.svcCtx.DbEngin.Raw(sql, clusterId, req.FlavorRef, req.ImageRef, req.Uuid).Scan(&VmObject) - if txVm.Error != nil { - logx.Error(err) - return nil, txVm.Error - } - /* if err2 != nil { - logx.Errorf("CommitGeneralTask() => sql execution error: %v", err) - //return errors.Errorf("the cluster does not match the drive resources. Check the data"), nil - }*/ - taskVm.Name = req.Name - taskVm.TaskId = taskModel.Id - taskVm.Status = "Saved" - taskVm.StartTime = time.Now().String() - taskVm.MinCount = req.MinCount - taskVm.ImageRef = VmObject.Image - taskVm.FlavorRef = VmObject.Flavor - taskVm.Uuid = VmObject.Uuid - taskVm.Platform = VmObject.Platform - taskVm.AdapterId = int64(adapterId) - l.svcCtx.DbEngin.Raw("select name from t_adapter where id= ?", int64(adapterId)).Scan(&adaptersName) - taskVm.AdapterName = adaptersName - l.svcCtx.DbEngin.Raw("select name from t_cluster where id= ?", r.ClusterId).Scan(&clusterName) - taskVm.ClusterName = clusterName - taskVm.ClusterId, err = strconv.ParseInt(clusterId, 10, 64) - taskVm.VmName = req.VmName - taskVm.Replicas = req.Replicas - if err != nil { - fmt.Println("Error converting string to int64:", err) - return - } - tx = l.svcCtx.DbEngin.Create(&taskVm) - if tx.Error != nil { - return nil, tx.Error - } - } - } - } - adapterName := "" - tx.Table("t_adapter").Select("name").Where("id=?", adapterId).Find(&adapterName) - noticeInfo := clientCore.NoticeInfo{ - AdapterId: int64(adapterId), - AdapterName: adapterName, - NoticeType: "create", - TaskName: req.Name, - Incident: "任务创建中", - CreatedTime: time.Now(), - } - // Save task data to database - - tf := l.svcCtx.DbEngin.Create(&taskModel) - if tf.Error != nil { - return nil, tf.Error - } - result := l.svcCtx.DbEngin.Table("task_vm").Create(&taskVm) - result = l.svcCtx.DbEngin.Table("t_notice").Create(¬iceInfo) - if result.Error != nil { - logx.Errorf("Task creation failure, err: %v", result.Error) - } - - resp.Code = 200 - resp.Msg = "Success" - return resp, nil -} diff --git a/api/internal/logic/core/counttaskstatuslogic.go b/api/internal/logic/core/counttaskstatuslogic.go deleted file mode 100644 index 3abe9797..00000000 --- a/api/internal/logic/core/counttaskstatuslogic.go +++ /dev/null @@ -1,41 +0,0 @@ -package core - -import ( - "context" - "github.com/pkg/errors" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CountTaskStatusLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCountTaskStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CountTaskStatusLogic { - return &CountTaskStatusLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CountTaskStatusLogic) CountTaskStatus() (resp *types.TaskStatusResp, err error) { - resp = &types.TaskStatusResp{} - sqlStr := `SELECT - COUNT(CASE WHEN status = 'Succeeded' THEN 1 END) AS Succeeded, - COUNT(CASE WHEN status = 'Failed' THEN 1 END) AS Failed, - COUNT(CASE WHEN status = 'Running' THEN 1 END) AS Running, - COUNT(CASE WHEN status = 'Saved' THEN 1 END) AS Saved - FROM task;` - err = l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp).Error - if err != nil { - logx.Errorf("CountTaskStatus() => sql execution error: %v", err) - return nil, errors.Errorf("Description Failed to collect statistics on the status of a task. Please try again later") - } - return -} diff --git a/api/internal/logic/core/deletetasklogic.go b/api/internal/logic/core/deletetasklogic.go deleted file mode 100644 index 3ba8f6d2..00000000 --- a/api/internal/logic/core/deletetasklogic.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTaskLogic { - return &DeleteTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteTaskLogic) DeleteTask(req *types.DeleteTaskReq) error { - // 删除主任务信息 - l.svcCtx.DbEngin.Model(&models.Task{}).Where("id", req.Id).Update("status", "Deleted") - tx := l.svcCtx.DbEngin.Delete(&models.Task{}, req.Id) - if tx.Error != nil { - return tx.Error - } - // 将子任务状态修改为待删除 - tx = l.svcCtx.DbEngin.Model(&models.Cloud{}).Where("task_id", req.Id).Update("status", constants.WaitDelete) - l.svcCtx.DbEngin.Where("task_id = ?", req.Id).Delete(&models.Cloud{}, req.Id) - if tx.Error != nil { - return tx.Error - } - return nil -} diff --git a/api/internal/logic/core/getcomputilitystatisticslogic.go b/api/internal/logic/core/getcomputilitystatisticslogic.go deleted file mode 100644 index 56c4a900..00000000 --- a/api/internal/logic/core/getcomputilitystatisticslogic.go +++ /dev/null @@ -1,117 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "fmt" - "strconv" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/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/core/getcomputingpowerlogic.go b/api/internal/logic/core/getcomputingpowerlogic.go deleted file mode 100644 index 40ec24fd..00000000 --- a/api/internal/logic/core/getcomputingpowerlogic.go +++ /dev/null @@ -1,107 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-octopus/octopus" - "log" -) - -type GetComputingPowerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetComputingPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputingPowerLogic { - return &GetComputingPowerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -type client struct { -} - -func (c *client) getComputingPower(cp computingPower, l *GetComputingPowerLogic) float32 { - return cp.GetComputing(l) -} - -type OctopusComputingPower struct { -} - -type AcComputingPower struct { -} - -type computingPower interface { - GetComputing(l *GetComputingPowerLogic) float32 -} - -// 启智章鱼资源算力 -func (cp OctopusComputingPower) GetComputing(l *GetComputingPowerLogic) float32 { - octopusCpReq := &octopus.ResourceReq{} - octopusCpResp, err := l.svcCtx.OctopusRpc.GetComputingPower(l.ctx, octopusCpReq) - if err != nil { - log.Println("OctopusRpc 算力请求失败", err) - } - return octopusCpResp.POpsAtFp16 -} - -// 曙光账号算力 -func (cp AcComputingPower) GetComputing(l *GetComputingPowerLogic) float32 { - acCpReq := &hpcAC.ResourceReq{} - acCpResp, err := l.svcCtx.ACRpc.GetComputingPower(l.ctx, acCpReq) - if err != nil { - log.Println("ACRpc 算力请求失败", err) - } - return acCpResp.POpsAtFp16 -} - -func (l *GetComputingPowerLogic) GetComputingPower() (resp *types.CpResp, err error) { - - apiResp := types.CpResp{} - - c := client{} - ot := OctopusComputingPower{} - ac := AcComputingPower{} - a := c.getComputingPower(ot, l) - b := c.getComputingPower(ac, l) - - apiResp.POpsAtFp16 = a + b - ////启智章鱼资源算力 - //octopusCpReq := &octopus.ResourceReq{} - //octopusCpResp, err := l.svcCtx.OctopusRpc.GetComputingPower(l.ctx, octopusCpReq) - //if err != nil { - // log.Println("OctopusRpc 算力请求失败", err) - //} - // - ////曙光账号算力 - //acCpReq := &hpcAC.ResourceReq{} - //acCpResp, err := l.svcCtx.ACRpc.GetComputingPower(l.ctx, acCpReq) - //if err != nil { - // log.Println("ACRpc 算力请求失败", err) - //} - // - //computingPowerAggregated := acCpResp.POpsAtFp16 + octopusCpResp.POpsAtFp16 - //apiResp.POpsAtFp16 = computingPowerAggregated - - return &apiResp, nil -} diff --git a/api/internal/logic/core/getdomainresourcelogic.go b/api/internal/logic/core/getdomainresourcelogic.go deleted file mode 100644 index f7f2acb0..00000000 --- a/api/internal/logic/core/getdomainresourcelogic.go +++ /dev/null @@ -1,31 +0,0 @@ -package core - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetDomainResourceLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetDomainResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDomainResourceLogic { - return &GetDomainResourceLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetDomainResourceLogic) GetDomainResource() (resp *types.DomainResourceResp, err error) { - resp = &types.DomainResourceResp{} - l.svcCtx.DbEngin.Raw("select * from screen_domain where delete_flag = 0").Scan(&resp.DomainResourceList) - return resp, nil - -} diff --git a/api/internal/logic/core/getgeneralinfologic.go b/api/internal/logic/core/getgeneralinfologic.go deleted file mode 100644 index 8d0e3461..00000000 --- a/api/internal/logic/core/getgeneralinfologic.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-octopus/octopus" - "log" -) - -type GetGeneralInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetGeneralInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGeneralInfoLogic { - return &GetGeneralInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetGeneralInfoLogic) GetGeneralInfo() (resp *types.GiResp, err error) { - apiResp := types.GiResp{} - - //启智章鱼资源统计 - octopusGiReq := &octopus.ResourceReq{} - octopusGiResp, err := l.svcCtx.OctopusRpc.GetGeneralInfo(l.ctx, octopusGiReq) - if err != nil { - log.Println("OctopusRpc 资源请求失败", err) - } - - //曙光账号资源统计 - acGiReq := &hpcAC.ResourceReq{} - acGiResp, err := l.svcCtx.ACRpc.GetGeneralInfo(l.ctx, acGiReq) - if err != nil { - log.Println("ACRpc 资源请求失败", err) - } - - cpu := octopusGiResp.CpuCoreNum + acGiResp.CpuCoreNum - storage := acGiResp.StorageInGib - mem := octopusGiResp.MemoryInGib + acGiResp.MemoryInGib - - apiResp.StorageInGib = storage - apiResp.CpuNum = cpu - apiResp.MemoryInGib = mem - - return &apiResp, nil -} diff --git a/api/internal/logic/core/getpublicflavorlogic.go b/api/internal/logic/core/getpublicflavorlogic.go deleted file mode 100644 index 14d4be55..00000000 --- a/api/internal/logic/core/getpublicflavorlogic.go +++ /dev/null @@ -1,40 +0,0 @@ -package core - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetPublicFlavorLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetPublicFlavorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicFlavorLogic { - return &GetPublicFlavorLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetPublicFlavorLogic) GetPublicFlavor(req *types.PublicFlavorReq) (resp *types.PublicFlavorResp, err error) { - // todo: add your logic here and delete this line - resp = &types.PublicFlavorResp{} - var flavorDict []types.FlavorDict - sqlStrTask := "SELECT * FROM `vm_flavor_dict`" - txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&flavorDict) - if txTask.Error != nil { - logx.Error(err) - return nil, txTask.Error - } - resp.Code = 200 - resp.Message = "success" - resp.FlavorDict = flavorDict - return resp, nil -} diff --git a/api/internal/logic/core/getpublicimagelogic.go b/api/internal/logic/core/getpublicimagelogic.go deleted file mode 100644 index a3dafc16..00000000 --- a/api/internal/logic/core/getpublicimagelogic.go +++ /dev/null @@ -1,40 +0,0 @@ -package core - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetPublicImageLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetPublicImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicImageLogic { - return &GetPublicImageLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetPublicImageLogic) GetPublicImage(req *types.PublicImageReq) (resp *types.PublicImageResp, err error) { - // todo: add your logic here and delete this line - resp = &types.PublicImageResp{} - var iamgeDict []types.ImageDict - sqlStrTask := "SELECT * FROM `vm_image_dict`" - txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&iamgeDict) - if txTask.Error != nil { - logx.Error(err) - return nil, txTask.Error - } - resp.Code = 200 - resp.Message = "success" - resp.ImageDict = iamgeDict - return resp, nil -} diff --git a/api/internal/logic/core/getpublicnetworklogic.go b/api/internal/logic/core/getpublicnetworklogic.go deleted file mode 100644 index b0d38bb0..00000000 --- a/api/internal/logic/core/getpublicnetworklogic.go +++ /dev/null @@ -1,39 +0,0 @@ -package core - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetPublicNetworkLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetPublicNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicNetworkLogic { - return &GetPublicNetworkLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetPublicNetworkLogic) GetPublicNetwork(req *types.PublicNetworkReq) (resp *types.PublicNetworkResp, err error) { - // todo: add your logic here and delete this line - resp = &types.PublicNetworkResp{} - var networkDict []types.NetworkDict - sqlStrTask := "SELECT * FROM `vm_network_dict`" - txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&networkDict) - if txTask.Error != nil { - logx.Error(err) - return nil, txTask.Error - } - resp.Code = 200 - resp.Message = "success" - resp.NetworkDict = networkDict - return resp, nil -} diff --git a/api/internal/logic/core/getregionlogic.go b/api/internal/logic/core/getregionlogic.go deleted file mode 100644 index 19d578ab..00000000 --- a/api/internal/logic/core/getregionlogic.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetRegionLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetRegionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRegionLogic { - return &GetRegionLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetRegionLogic) GetRegion() (resp *types.GetRegionResp, err error) { - resp = &types.GetRegionResp{} - var regionSlurmArray []models.RegionSlurm - regionNameDb := l.svcCtx.DbEngin.Find(®ionSlurmArray).Not("RegionName = ?", "") - softStackDb := l.svcCtx.DbEngin.Find(®ionSlurmArray).Not("SoftStack = ?", "") - resp = &types.GetRegionResp{ - Code: 200, - Msg: "Success", - Data: types.RegionNum{ - RegionSum: regionNameDb.RowsAffected, - SoftStackSum: softStackDb.RowsAffected, - }, - } - return resp, err -} diff --git a/api/internal/logic/core/getresourcepanelconfiglogic.go b/api/internal/logic/core/getresourcepanelconfiglogic.go deleted file mode 100644 index cd24e227..00000000 --- a/api/internal/logic/core/getresourcepanelconfiglogic.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" -) - -type GetResourcePanelConfigLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetResourcePanelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetResourcePanelConfigLogic { - return &GetResourcePanelConfigLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetResourcePanelConfigLogic) GetResourcePanelConfig() (resp *types.ResourcePanelConfigResp, err error) { - rpcModel := models.ResourcePanelConfig{} - l.svcCtx.DbEngin.Find(&rpcModel) - utils.Convert(rpcModel, &resp) - return resp, nil -} diff --git a/api/internal/logic/core/getscreenchartlogic.go b/api/internal/logic/core/getscreenchartlogic.go deleted file mode 100644 index 06085cf9..00000000 --- a/api/internal/logic/core/getscreenchartlogic.go +++ /dev/null @@ -1,33 +0,0 @@ -package core - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetScreenChartLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetScreenChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenChartLogic { - return &GetScreenChartLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetScreenChartLogic) GetScreenChart() (resp *types.ScreenChartResp, err error) { - resp = &types.ScreenChartResp{} - l.svcCtx.DbEngin.Raw("select cpu_avg from screen_chart").Scan(&resp.CpuAvg) - l.svcCtx.DbEngin.Raw("select cpu_load from screen_chart").Scan(&resp.CpuLoad) - l.svcCtx.DbEngin.Raw("select memory_avg from screen_chart").Scan(&resp.MemoryAvg) - l.svcCtx.DbEngin.Raw("select memory_load from screen_chart").Scan(&resp.MemoryLoad) - return -} diff --git a/api/internal/logic/core/getscreeninfologic.go b/api/internal/logic/core/getscreeninfologic.go deleted file mode 100644 index efeb6f5f..00000000 --- a/api/internal/logic/core/getscreeninfologic.go +++ /dev/null @@ -1,30 +0,0 @@ -package core - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetScreenInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetScreenInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenInfoLogic { - return &GetScreenInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetScreenInfoLogic) GetScreenInfo() (resp *types.ScreenInfoResp, err error) { - resp = &types.ScreenInfoResp{} - l.svcCtx.DbEngin.Raw("select * from screen").Scan(resp) - return -} diff --git a/api/internal/logic/core/homeoverviewlogic.go b/api/internal/logic/core/homeoverviewlogic.go deleted file mode 100644 index 927a9f85..00000000 --- a/api/internal/logic/core/homeoverviewlogic.go +++ /dev/null @@ -1,73 +0,0 @@ -package core - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type HomeOverviewLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewHomeOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HomeOverviewLogic { - return &HomeOverviewLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *HomeOverviewLogic) HomeOverview(req *types.HomeOverviewReq) (resp *types.HomeOverviewResp, err error) { - // todo: add your logic here and delete this line - resp = &types.HomeOverviewResp{} - var AdapterSum int // - var StorageSum float32 // - var ClusterSum int // - var TaskSum int // - //Task - sqlStrTask := "SELECT COUNT(*) FROM `task`" - txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&TaskSum) - if txTask.Error != nil { - logx.Error(err) - return nil, txTask.Error - } - - //Storage - sqlStrStorage := "SELECT SUM(t.storage_space) as storageSum FROM `t_storage_device` t" - txStorage := l.svcCtx.DbEngin.Raw(sqlStrStorage).Scan(&StorageSum) - if txTask.Error != nil { - logx.Error(err) - return nil, txStorage.Error - } - - //Cluster - sqlStrCluster := "SELECT COUNT(*) FROM `t_cluster`" - txCluster := l.svcCtx.DbEngin.Raw(sqlStrCluster).Scan(&ClusterSum) - if txTask.Error != nil { - logx.Error(err) - return nil, txCluster.Error - } - - //Adapter - sqlStrAdapter := "SELECT COUNT(*) FROM `t_adapter`" - txAdapter := l.svcCtx.DbEngin.Raw(sqlStrAdapter).Scan(&AdapterSum) - if txTask.Error != nil { - logx.Error(err) - return nil, txAdapter.Error - } - - resp.Data.TaskSum = int64(TaskSum) - resp.Data.StorageSum = StorageSum - resp.Data.AdaptSum = int64(AdapterSum) - resp.Data.ClusterSum = int64(ClusterSum) - - resp.Code = 200 - resp.Message = "Success" - return resp, nil -} diff --git a/api/internal/logic/core/jobtotallogic.go b/api/internal/logic/core/jobtotallogic.go deleted file mode 100644 index 9ad52198..00000000 --- a/api/internal/logic/core/jobtotallogic.go +++ /dev/null @@ -1,114 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/enum" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" - "k8s.io/apimachinery/pkg/util/json" -) - -type JobTotalLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -type Job struct { - TotalSize int `json:"totalSize"` - OtJobs []OtJob `json:"otJobs"` -} - -type OtJob struct { - Name string `json:"name"` - Status string `json:"status"` - Tasks []Task `json:"tasks"` -} - -type Task struct { - CenterName []string `json:"centerName"` -} - -func NewJobTotalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobTotalLogic { - return &JobTotalLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *JobTotalLogic) JobTotal() (resp *types.JobTotalResp, err error) { - // 获取任务时间信息 - resp = &types.JobTotalResp{} - bytes, err := httputils.HttpGet("GET", "http://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/alljobinfo") - if err != nil { - return nil, err - } - json.Unmarshal(bytes, resp) - - // 获取其他任务信息 - jobs := &Job{} - jobBytes, err := httputils.HttpGet("GET", "http://grampus.openi.org.cn/openapi/v1/sharescreen/trainjob?pageIndex=1&pageSize=10") - if err != nil { - return nil, err - } - json.Unmarshal(jobBytes, jobs) - - for _, job := range jobs.OtJobs { - trainJob := types.TrainJob{ - Name: job.Name, - Status: enum.ExternalStatus(job.Status).String(), - Strategy: 0, - SynergyStatus: "未协同", - } - if job.Tasks[0].CenterName != nil { - trainJob.ParticipantName = job.Tasks[0].CenterName[0] - } - resp.TrainJobs = append(resp.TrainJobs, trainJob) - } - - var tasks []models.Task - tx := l.svcCtx.DbEngin.Find(&tasks) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error - } - if len(tasks) == 0 { - return nil, nil - } - for _, task := range tasks { - var participantName string - tx := l.svcCtx.DbEngin.Raw("SELECT name from sc_participant_phy_info where id in (SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.participant_id) ,GROUP_CONCAT(DISTINCT a.participant_id) ,GROUP_CONCAT(DISTINCT c.participant_id))as service_name from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?)", task.Id).Scan(&participantName) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error - } - // 承接方转义 - resp.TrainJobs = append(resp.TrainJobs, types.TrainJob{ - ParticipantName: participantName, - Name: task.Name, - Strategy: int(task.Strategy), - SynergyStatus: enum.SynergyStatus(task.SynergyStatus).String(), - Status: task.Status, - }) - - } - return resp, nil -} diff --git a/api/internal/logic/core/listcenterlogic.go b/api/internal/logic/core/listcenterlogic.go deleted file mode 100644 index f79d1a3d..00000000 --- a/api/internal/logic/core/listcenterlogic.go +++ /dev/null @@ -1,100 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" -) - -type ListCenterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListCenterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListCenterLogic { - return &ListCenterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListCenterLogic) ListCenter() (*types.ListCenterResp, error) { - var centers []types.Center - var centersModel *[]models.CenterOverview - - //var centersModel []models.ComputeCenter - var resp types.ListCenterResp - - l.svcCtx.DbEngin.Raw("select cc.*, ac.cluster_num, ac.node_num, ac.cpu_num, ac.gpu_num, ac.managed_flops, ac.unmanaged_flops, ac.managed_storage, ac.unmanaged_storage, hc.cluster_num, c.node_num, hc.cpu_num, hc.gpu_num, hc.managed_flops, hc.unmanaged_flops, hc.managed_storage, hc.unmanaged_storage, c.cluster_num, c.node_num, c.cpu_num, c.gpu_num, c.managed_flops, c.unmanaged_flops, c.managed_storage, c.unmanaged_storage, ct.edwc, ct.ydyl\nfrom compute_center cc\nleft join ai_center ac on cc.id = ac.id\nleft join hpc_center hc on cc.id = hc.id\nleft join cloud_center c on cc.id = c.id\nleft join center_tag ct on cc.id = ct.id").Scan(¢ersModel) - - var centerModelV = *centersModel - - for _, overview := range centerModelV { - var center types.Center - center.Id = overview.Id.Int64 - center.CenterSource = overview.CenterSource.String - center.SourceId = overview.SourceId.String - center.Name = overview.Name.String - center.Description = overview.Description.String - center.Type = overview.Type.String - center.Area = overview.Area.String - center.City = overview.City.String - center.Longitude = overview.Longitude.Float64 - center.Latitude = overview.Latitude.Float64 - center.Status = overview.Status.String - center.UserNum = overview.UserNum.Int64 - center.CloudClusterNum = overview.CloudClusterNum.Int64 - center.AiClusterNum = overview.AiClusterNum.Int64 - center.HpcClusterNum = overview.HpcClusterNum.Int64 - center.CloudNodeNum = overview.CloudNodeNum.Int64 - center.AiNodeNum = overview.AiNodeNum.Int64 - center.HpcNodeNum = overview.HpcNodeNum.Int64 - center.CloudCpuNum = overview.CloudCpuNum.Int64 - center.AiCpuNum = overview.AiCpuNum.Int64 - center.HpcCpuNum = overview.HpcCpuNum.Int64 - center.CloudGpuNum = overview.CloudGpuNum.Int64 - center.AiGpuNum = overview.AiGpuNum.Int64 - center.HpcGpuNum = overview.HpcGpuNum.Int64 - center.CloudMngFlops = overview.CloudMngFlops.Int64 - center.AiMngFlops = overview.AiMngFlops.Int64 - center.HpcMngFlops = overview.HpcMngFlops.Int64 - center.CloudUmngFlops = overview.CloudUmngFlops.Int64 - center.AiUmngFlops = overview.AiUmngFlops.Int64 - center.HpcUmngFlops = overview.HpcUmngFlops.Int64 - center.CloudMngStorage = overview.CloudMngStorage.Int64 - center.AiMngStorage = overview.AiMngStorage.Int64 - center.HpcMngStorage = overview.HpcMngStorage.Int64 - center.CloudUmngStorage = overview.CloudUmngStorage.Int64 - center.AiUmngStorage = overview.AiUmngStorage.Int64 - center.HpcUmngStorage = overview.HpcUmngStorage.Int64 - center.Edwc = overview.Edwc.Bool - center.Ydyl = overview.Ydyl.Bool - center.HubCode = overview.HubCode.Int64 - center.DeletedFlag = overview.DeletedFlag.Int64 - centers = append(centers, center) - } - - resp.Code = 200 - resp.Msg = "success" - resp.Data.TotalCount = len(centers) - resp.Data.Centers = centers - return &resp, nil -} diff --git a/api/internal/logic/core/listclusterlogic.go b/api/internal/logic/core/listclusterlogic.go deleted file mode 100644 index ccace405..00000000 --- a/api/internal/logic/core/listclusterlogic.go +++ /dev/null @@ -1,76 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" -) - -type ListClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClusterLogic { - return &ListClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListClusterLogic) ListCluster(req *types.ListClusterReq) (*types.ListClusterResp, error) { - - var clusters []types.ComputeCluster - var clustersModel *[]models.ComputeCluster - - //var centersModel []models.ComputeCenter - var resp types.ListClusterResp - - l.svcCtx.DbEngin.Raw("select * from compute_cluster where center_id = ?", req.CenterId).Scan(&clustersModel) - - if clustersModel == nil { - resp.Code = 200 - resp.Msg = "success" - resp.Data.TotalCount = 0 - return &resp, nil - } - var clustersModelV = *clustersModel - - for _, clusterModel := range clustersModelV { - var cluster types.ComputeCluster - cluster.Id = clusterModel.Id - cluster.Name = clusterModel.Name.String - cluster.Type = clusterModel.Type.String - cluster.JcceDomainId = clusterModel.JcceDomainId.Int64 - cluster.JcceDomainName = clusterModel.JcceDomainName.String - cluster.Longitude = clusterModel.Longitude.Float64 - cluster.Latitude = clusterModel.Latitude.Float64 - cluster.Description = clusterModel.Description.String - clusters = append(clusters, cluster) - } - - resp.Code = 200 - resp.Msg = "success" - resp.Data.TotalCount = len(clusters) - resp.Data.Clusters = clusters - return &resp, nil - -} diff --git a/api/internal/logic/core/listnoticelogic.go b/api/internal/logic/core/listnoticelogic.go deleted file mode 100644 index fec7499e..00000000 --- a/api/internal/logic/core/listnoticelogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -type ListNoticeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNoticeLogic { - return &ListNoticeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListNoticeLogic) ListNotice(req *clientCore.ListNoticeReq) (*clientCore.ListNoticeResp, error) { - var notices []clientCore.NoticeInfo - - var resp clientCore.ListNoticeResp - - l.svcCtx.DbEngin.Raw("select * from t_notice order by created_time desc").Scan(¬ices) - for _, notice := range notices { - resp.Data = append(resp.Data, notice) - } - resp.Code = 200 - resp.Msg = "success" - return &resp, nil -} diff --git a/api/internal/logic/core/listregionlogic.go b/api/internal/logic/core/listregionlogic.go deleted file mode 100644 index 0168b66b..00000000 --- a/api/internal/logic/core/listregionlogic.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" -) - -type ListRegionLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListRegionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListRegionLogic { - return &ListRegionLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListRegionLogic) ListRegion() (resp *types.ListRegionResp, err error) { - // todo: add your logic here and delete this line - var regionSlurmArray []models.RegionSlurm - var regions []types.Region - var jobCount int64 - var regionResult []types.Region - l.svcCtx.DbEngin.Find(®ionSlurmArray) - utils.Convert(regionSlurmArray, ®ions) - // 查询超算上的job todo - for _, region := range regions { - if region.RegionName == "Changsha HPC Center" { - l.svcCtx.DbEngin.Raw("select count(*) from task t join hpc h on t.id = h.task_id and t.status != 'Completed' and h.service_name = 'th'").Scan(&jobCount) - region.RunningJobs = jobCount - } - if region.RegionName == "Zhijiang HPC Center" { - l.svcCtx.DbEngin.Raw("select count(*) from task t join hpc h on t.id = h.task_id and t.status != 'Completed' and h.service_name = 'ac'").Scan(&jobCount) - region.RunningJobs = jobCount - } - regionResult = append(regionResult, region) - - } - - resp = &types.ListRegionResp{ - Code: 200, - Msg: "Success", - Data: regionResult, - } - return -} diff --git a/api/internal/logic/core/metricslogic.go b/api/internal/logic/core/metricslogic.go deleted file mode 100644 index 9f947fe3..00000000 --- a/api/internal/logic/core/metricslogic.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - "context" - - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -type MetricsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MetricsLogic { - return &MetricsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *MetricsLogic) Metrics() error { - // todo: add your logic here and delete this line - - return nil -} diff --git a/api/internal/logic/core/nodeassetslogic.go b/api/internal/logic/core/nodeassetslogic.go deleted file mode 100644 index 0dead70d..00000000 --- a/api/internal/logic/core/nodeassetslogic.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type NodeAssetsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewNodeAssetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NodeAssetsLogic { - return &NodeAssetsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *NodeAssetsLogic) NodeAssets() (resp *types.NodeAssetsResp, err error) { - // 查询数据库系节点动态资源信息 - - nodeResp := types.NodeAssetsResp{} - tx := l.svcCtx.DbEngin.Raw("SELECT ppi.`name`,nai.* FROM sc_node_avail_info nai left join sc_participant_phy_info ppi on ppi.id = nai.participant_id WHERE nai.id IN ( SELECT MAX( id ) FROM sc_node_avail_info WHERE deleted_flag = 0 GROUP BY participant_id, node_name) ").Scan(&nodeResp.NodeAssets) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error - } - return &nodeResp, nil -} diff --git a/api/internal/logic/core/pagelisttasklogic.go b/api/internal/logic/core/pagelisttasklogic.go deleted file mode 100644 index c8bf7450..00000000 --- a/api/internal/logic/core/pagelisttasklogic.go +++ /dev/null @@ -1,75 +0,0 @@ -package core - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/status" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils" - "time" - - "github.com/zeromicro/go-zero/core/logx" -) - -type PageListTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPageListTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PageListTaskLogic { - return &PageListTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.PageResult, err error) { - limit := req.PageSize - offset := req.PageSize * (req.PageNum - 1) - resp = &types.PageResult{} - var list []*types.TaskModel - db := l.svcCtx.DbEngin.Model(&types.TaskModel{}).Table("task") - - db = db.Where("deleted_at is null") - if req.Name != "" { - db = db.Where("name LIKE ?", "%"+req.Name+"%") - } - - //count total - var total int64 - err = db.Count(&total).Error - db.Limit(limit).Offset(offset) - - if err != nil { - return resp, err - } - err = db.Order("created_time desc").Find(&list).Error - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - - // 更新智算任务状态 - go status.UpdateTaskStatus(l.svcCtx, list) - go status.UpdateAiTaskStatus(l.svcCtx, list) - - for _, model := range list { - if model.StartTime != "" && model.EndTime == "" { - startTime := timeutils.TimeStringToGoTime(model.StartTime) - model.RunningTime = int64(time.Now().Sub(startTime).Seconds()) - } - if model.StartTime != "" && model.EndTime != "" { - startTime := timeutils.TimeStringToGoTime(model.StartTime) - endTime := timeutils.TimeStringToGoTime(model.EndTime) - model.RunningTime = int64(endTime.Sub(startTime).Seconds()) - } - } - resp.List = &list - resp.PageSize = req.PageSize - resp.PageNum = req.PageNum - resp.Total = total - - return -} diff --git a/api/internal/logic/core/participantlistlogic.go b/api/internal/logic/core/participantlistlogic.go deleted file mode 100644 index 5da5a14c..00000000 --- a/api/internal/logic/core/participantlistlogic.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" -) - -type ParticipantListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewParticipantListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ParticipantListLogic { - return &ParticipantListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ParticipantListLogic) ParticipantList() (resp *types.ParticipantListResp, err error) { - var participants []types.Participant - - tx := l.svcCtx.DbEngin.Raw("SELECT ppi.id,ppi.name,ppi.address,ppi.metrics_url ,ti.tenant_name,(CASE ppi.type WHEN '0' THEN '数算' WHEN '1' THEN '智算' WHEN '2' THEN '超算' ELSE '' END) as type_name from sc_participant_phy_info ppi LEFT JOIN sc_tenant_info ti on ti.id = ppi.tenant_id where ppi.deleted_flag = '0'").Scan(&participants) - if tx.Error != nil { - return nil, tx.Error - } - result := types.ParticipantListResp{} - utils.Convert(participants, &result.Participants) - return &result, nil -} diff --git a/api/internal/logic/core/pulltaskinfologic.go b/api/internal/logic/core/pulltaskinfologic.go deleted file mode 100644 index 79fff62a..00000000 --- a/api/internal/logic/core/pulltaskinfologic.go +++ /dev/null @@ -1,95 +0,0 @@ -package core - -import ( - "context" - "github.com/jinzhu/copier" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -type PullTaskInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPullTaskInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PullTaskInfoLogic { - return &PullTaskInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PullTaskInfoLogic) PullTaskInfo(req *clientCore.PullTaskInfoReq) (*clientCore.PullTaskInfoResp, error) { - resp := clientCore.PullTaskInfoResp{} - - // check the kind of adapter - var kind int32 - l.svcCtx.DbEngin.Raw("select type as kind from `t_adapter` where id = ?", req.AdapterId).Scan(&kind) - // pull task list from database - switch kind { - case 2: - var hpcModelList []models.TaskHpc - err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &hpcModelList) - if err != nil { - return nil, err - } - utils.Convert(hpcModelList, &resp.HpcInfoList) - if len(resp.HpcInfoList) > 0 { - for i, hpcInfo := range hpcModelList { - err := copier.CopyWithOption(resp.HpcInfoList[i], hpcInfo, copier.Option{Converters: utils.Converters}) - if err != nil { - return nil, err - } - var clusterType string - l.svcCtx.DbEngin.Raw("SELECT label FROM `t_cluster` where id = ? ", hpcInfo.ClusterId).Scan(&clusterType) - - resp.HpcInfoList[i].ClusterType = clusterType - } - } - case 0: - var resourceType int32 - l.svcCtx.DbEngin.Raw("select resource_type as resourceType from `t_adapter` where id = ?", req.AdapterId).Scan(&resourceType) - switch resourceType { - case 01: - var cloudModelList []cloud.TaskCloudModel - err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &cloudModelList) - if err != nil { - return nil, err - } - utils.Convert(cloudModelList, &resp.CloudInfoList) - case 02: - var vmModelList []models.TaskVm - err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &vmModelList) - if err != nil { - return nil, err - } - utils.Convert(vmModelList, &resp.VmInfoList) - } - - case 1: - var aiModelList []models.Ai - err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &aiModelList) - if err != nil { - return nil, err - } - utils.Convert(aiModelList, &resp.AiInfoList) - } - return &resp, nil -} - -func findModelList(adapterId int64, dbEngin *gorm.DB, data interface{}) error { - tx := dbEngin.Where("cluster_id in (select id from t_cluster where adapter_id = ?) AND status not in "+ - "('Deleted', 'Succeeded', 'COMPLETED', 'Completed', 'Failed','FAIL','statC','statE')", adapterId).Find(data) - if tx.Error != nil { - return tx.Error - } - return nil -} diff --git a/api/internal/logic/core/pushnoticelogic.go b/api/internal/logic/core/pushnoticelogic.go deleted file mode 100644 index e816cb5d..00000000 --- a/api/internal/logic/core/pushnoticelogic.go +++ /dev/null @@ -1,31 +0,0 @@ -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -type PushNoticeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPushNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushNoticeLogic { - return &PushNoticeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PushNoticeLogic) PushNotice(req *clientCore.PushNoticeReq) (resp *clientCore.PushNoticeResp, err error) { - result := l.svcCtx.DbEngin.Table("t_notice").Create(&req.NoticeInfo) - if result.Error != nil { - return nil, result.Error - } - - return -} diff --git a/api/internal/logic/core/pushresourceinfologic.go b/api/internal/logic/core/pushresourceinfologic.go deleted file mode 100644 index c11bad6f..00000000 --- a/api/internal/logic/core/pushresourceinfologic.go +++ /dev/null @@ -1,28 +0,0 @@ -package core - -import ( - "context" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -type PushResourceInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPushResourceInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushResourceInfoLogic { - return &PushResourceInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PushResourceInfoLogic) PushResourceInfo(req *clientCore.PushResourceInfoReq) (resp *clientCore.PushResourceInfoResp, err error) { - - return -} diff --git a/api/internal/logic/core/pushtaskinfologic.go b/api/internal/logic/core/pushtaskinfologic.go deleted file mode 100644 index a989b01f..00000000 --- a/api/internal/logic/core/pushtaskinfologic.go +++ /dev/null @@ -1,214 +0,0 @@ -package core - -import ( - "context" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/logx" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gorm.io/gorm" - "strings" - "time" -) - -type PushTaskInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPushTaskInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushTaskInfoLogic { - return &PushTaskInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PushTaskInfoLogic) PushTaskInfo(req *clientCore.PushTaskInfoReq) (*clientCore.PushTaskInfoResp, error) { - resp := clientCore.PushTaskInfoResp{} - var kind int32 - l.svcCtx.DbEngin.Raw("select type as kind from t_adapter where id = ?", req.AdapterId).Scan(&kind) - switch kind { - case 0: - var resourceType int32 - l.svcCtx.DbEngin.Raw("select resource_type as resourceType from `t_adapter` where id = ?", req.AdapterId).Scan(&resourceType) - switch resourceType { - case 01: - for _, cloudInfo := range req.CloudInfoList { - var taskId uint - result := l.svcCtx.DbEngin.Table("task_cloud").Select("task_id").Where("task_id = ?", cloudInfo.TaskId).Find(&taskId) - if errors.Is(result.Error, gorm.ErrRecordNotFound) { - return nil, errors.New("Record does not exist") - } - l.svcCtx.DbEngin.Exec("update task_cloud set status = ?,start_time = ?,result = ? where task_id = ?", - cloudInfo.Status, cloudInfo.StartTime, cloudInfo.Result, cloudInfo.TaskId) - var taskName string - l.svcCtx.DbEngin.Raw("select name as kind from task where id = ?", taskId).Scan(&taskName) - noticeInfo := clientCore.NoticeInfo{ - TaskId: cloudInfo.TaskId, - AdapterId: cloudInfo.AdapterId, - AdapterName: cloudInfo.AdapterName, - ClusterId: cloudInfo.ClusterId, - ClusterName: cloudInfo.ClusterName, - TaskName: taskName, - } - syncTask(l.svcCtx.DbEngin, noticeInfo) - } - case 02: - for _, vmInfo := range req.VmInfoList { - l.svcCtx.DbEngin.Exec("update task_vm set status = ?,start_time = ? where cluster_id = ? and task_id = ? and name = ?", - vmInfo.Status, vmInfo.StartTime, vmInfo.ClusterId, vmInfo.TaskId, vmInfo.Name) - noticeInfo := clientCore.NoticeInfo{ - TaskId: vmInfo.TaskId, - AdapterId: vmInfo.AdapterId, - AdapterName: vmInfo.AdapterName, - ClusterId: vmInfo.ClusterId, - ClusterName: vmInfo.ClusterName, - TaskName: vmInfo.Name, - } - syncTask(l.svcCtx.DbEngin, noticeInfo) - } - } - - case 2: - for _, hpcInfo := range req.HpcInfoList { - l.svcCtx.DbEngin.Exec("update task_hpc set status = ?,start_time = ?,job_id = ? where cluster_id = ? and task_id = ? and name = ?", - hpcInfo.Status, hpcInfo.StartTime, hpcInfo.JobId, hpcInfo.ClusterId, hpcInfo.TaskId, hpcInfo.Name) - noticeInfo := clientCore.NoticeInfo{ - TaskId: hpcInfo.TaskId, - AdapterId: hpcInfo.AdapterId, - AdapterName: hpcInfo.AdapterName, - ClusterId: hpcInfo.ClusterId, - ClusterName: hpcInfo.ClusterName, - TaskName: hpcInfo.Name, - } - syncTask(l.svcCtx.DbEngin, noticeInfo) - } - case 1: - for _, aiInfo := range req.AiInfoList { - l.svcCtx.DbEngin.Exec("update task_ai set status = ?,start_time = ?,project_id = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?", - aiInfo.Status, aiInfo.StartTime, aiInfo.ProjectId, aiInfo.JobId, req.AdapterId, aiInfo.TaskId, aiInfo.Name) - noticeInfo := clientCore.NoticeInfo{ - TaskId: aiInfo.TaskId, - AdapterId: aiInfo.AdapterId, - AdapterName: aiInfo.AdapterName, - ClusterId: aiInfo.ClusterId, - ClusterName: aiInfo.ClusterName, - TaskName: aiInfo.Name, - } - syncTask(l.svcCtx.DbEngin, noticeInfo) - } - } - return &resp, nil -} - -func syncTask(gorm *gorm.DB, noticeInfo clientCore.NoticeInfo) { - - var allStatus string - tx := gorm.Raw("SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.status) ,GROUP_CONCAT(DISTINCT a.status) ,GROUP_CONCAT(DISTINCT c.status))as status from task t left join task_hpc h on t.id = h.task_id left join task_cloud c on t.id = c.task_id left join task_vm v on t.id = v.task_id left join task_ai a on t.id = a.task_id where t.id = ?", noticeInfo.TaskId).Scan(&allStatus) - if tx.Error != nil { - logx.Error(tx.Error) - } - allStatus = strings.ToUpper(allStatus) - for pcmStatus, ProviderStatus := range clientCore.StatusMapping { - for _, originalStatus := range ProviderStatus { - // if Failed type status appears in subTask then update mainTask to Failed - if pcmStatus == "Failed" && strings.Contains(allStatus, originalStatus) { - updateTask(gorm, noticeInfo.TaskId, constants.Failed) - noticeInfo := clientCore.NoticeInfo{ - AdapterId: noticeInfo.AdapterId, - AdapterName: noticeInfo.AdapterName, - ClusterId: noticeInfo.ClusterId, - ClusterName: noticeInfo.ClusterName, - NoticeType: "failed", - TaskName: noticeInfo.TaskName, - Incident: "任务执行失败,请查看日志!", - CreatedTime: time.Now(), - } - gorm.Table("t_notice").Create(¬iceInfo) - return - // no Failed type status in subTask,if Saved type status appears in subTask then update mainTask to Saved - } else if pcmStatus == "Saved" && strings.Contains(allStatus, originalStatus) { - if getTaskStatus(gorm, noticeInfo.TaskId) != "Saved" { - updateTask(gorm, noticeInfo.TaskId, constants.Saved) - noticeInfo := clientCore.NoticeInfo{ - AdapterId: noticeInfo.AdapterId, - AdapterName: noticeInfo.AdapterName, - ClusterId: noticeInfo.ClusterId, - ClusterName: noticeInfo.ClusterName, - NoticeType: "saved", - TaskName: noticeInfo.TaskName, - Incident: "任务已处于队列中!", - CreatedTime: time.Now(), - } - gorm.Table("t_notice").Create(¬iceInfo) - return - } else { - return - } - // no Failed and Saved type status in subTask,if Running type status appears in subTask then update mainTask to Running - } else if pcmStatus == "Running" && strings.Contains(allStatus, originalStatus) { - if getTaskStatus(gorm, noticeInfo.TaskId) != "Running" { - updateTask(gorm, noticeInfo.TaskId, constants.Running) - noticeInfo := clientCore.NoticeInfo{ - AdapterId: noticeInfo.AdapterId, - AdapterName: noticeInfo.AdapterName, - ClusterId: noticeInfo.ClusterId, - ClusterName: noticeInfo.ClusterName, - NoticeType: "running", - TaskName: noticeInfo.TaskName, - Incident: "任务状态切换为运行中!", - CreatedTime: time.Now(), - } - gorm.Table("t_notice").Create(¬iceInfo) - return - } else { - return - } - - // at last, mainTask should be succeeded - } else { - if strings.Contains(allStatus, originalStatus) { - updateTask(gorm, noticeInfo.TaskId, constants.Succeeded) - noticeInfo := clientCore.NoticeInfo{ - AdapterId: noticeInfo.AdapterId, - AdapterName: noticeInfo.AdapterName, - ClusterId: noticeInfo.ClusterId, - ClusterName: noticeInfo.ClusterName, - NoticeType: "succeeded", - TaskName: noticeInfo.TaskName, - Incident: "任务执行完成!", - CreatedTime: time.Now(), - } - gorm.Table("t_notice").Create(¬iceInfo) - return - } - } - } - } -} - -func updateTask(gorm *gorm.DB, taskId int64, status string) { - now := time.Now() - var task models.Task - gorm.Where("id = ? ", taskId).Find(&task) - if task.Status != status { - task.Status = status - if status == constants.Running { - task.StartTime = &now - } - if task.Status == constants.Failed || task.Status == constants.Succeeded { - task.EndTime = &now - } - gorm.Updates(&task) - } -} - -func getTaskStatus(gorm *gorm.DB, taskId int64) (status string) { - var task models.Task - gorm.Where("id = ? ", taskId).Find(&task) - return task.Status -} diff --git a/api/internal/logic/core/putresourcepanelconfiglogic.go b/api/internal/logic/core/putresourcepanelconfiglogic.go deleted file mode 100644 index 97d01533..00000000 --- a/api/internal/logic/core/putresourcepanelconfiglogic.go +++ /dev/null @@ -1,53 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "time" -) - -type PutResourcePanelConfigLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPutResourcePanelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PutResourcePanelConfigLogic { - return &PutResourcePanelConfigLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PutResourcePanelConfigLogic) PutResourcePanelConfig(req *types.ResourcePanelConfigReq) error { - rpcModel := models.ResourcePanelConfig{} - utils.Convert(req, &rpcModel) - rpcModel.UpdateTime = time.Now() - - update := l.svcCtx.DbEngin.Model(&rpcModel).Updates(rpcModel) - err := update.Error - if err != nil { - logx.WithContext(l.ctx).Errorf("PCM 资源面板数据更新失败 err: %s", err.Error()) - return err - } - return nil -} diff --git a/api/internal/logic/core/scheduletaskbyyamllogic.go b/api/internal/logic/core/scheduletaskbyyamllogic.go deleted file mode 100644 index 2118e5fa..00000000 --- a/api/internal/logic/core/scheduletaskbyyamllogic.go +++ /dev/null @@ -1,83 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "k8s.io/apimachinery/pkg/util/json" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleTaskByYamlLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleTaskByYamlLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleTaskByYamlLogic { - return &ScheduleTaskByYamlLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleTaskByYamlLogic) ScheduleTaskByYaml(req *types.ScheduleTaskByYamlReq) (resp *types.ScheduleTaskByYamlResp, err error) { - resp = &types.ScheduleTaskByYamlResp{} - bytes, err := json.Marshal(req) - if err != nil { - return nil, err - } - // 构建主任务结构体 - taskModel := models.Task{ - Status: constants.Saved, - Description: req.Description, - Name: req.Name, - YamlString: string(bytes), - CommitTime: time.Now(), - NsID: req.NsID, - } - // 保存任务数据到数据库 - tx := l.svcCtx.DbEngin.Create(&taskModel) - if tx.Error != nil { - return nil, tx.Error - } - - // 遍历子任务放入任务队列中 - for _, task := range req.Tasks { - task.NsID = req.NsID - task.TaskId = taskModel.Id - - // 将任务数据转换成消息体 - reqMessage, err := json.Marshal(task) - if err != nil { - logx.Error(err) - return nil, err - } - publish := l.svcCtx.RedisClient.Publish(context.Background(), task.TaskType, reqMessage) - if publish.Err() != nil { - return nil, publish.Err() - } - } - resp.TaskId = taskModel.Id - return resp, nil -} diff --git a/api/internal/logic/core/syncclusterloadlogic.go b/api/internal/logic/core/syncclusterloadlogic.go deleted file mode 100644 index 034fc176..00000000 --- a/api/internal/logic/core/syncclusterloadlogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package core - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" -) - -type SyncClusterLoadLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewSyncClusterLoadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncClusterLoadLogic { - return &SyncClusterLoadLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *SyncClusterLoadLogic) SyncClusterLoad(req *types.SyncClusterLoadReq) error { - if nil != req.ClusterLoadRecords { - for _, record := range req.ClusterLoadRecords { - var param tracker.ClusterLoadRecord - tool.Convert(record, ¶m) - tracker.SyncClusterLoad(param) - } - } - return nil -} diff --git a/api/internal/logic/core/taskdetailslogic.go b/api/internal/logic/core/taskdetailslogic.go deleted file mode 100644 index 2352974b..00000000 --- a/api/internal/logic/core/taskdetailslogic.go +++ /dev/null @@ -1,60 +0,0 @@ -package core - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - - "github.com/zeromicro/go-zero/core/logx" -) - -type TaskDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewTaskDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskDetailsLogic { - return &TaskDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsResp, err error) { - resp = &types.TaskDetailsResp{} - task := &models.Task{} - if errors.Is(l.svcCtx.DbEngin.Where("id", req.Id).First(&task).Error, gorm.ErrRecordNotFound) { - return nil, errors.New("记录不存在") - } - clusterIds := make([]string, 0) - var cList []*types.ClusterInfo - var subList []*types.SubTaskInfo - switch task.AdapterTypeDict { - case "0": - l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", task.Id).Scan(&subList) - if len(subList) <= 0 { - l.svcCtx.DbEngin.Table("task_vm").Where("task_id", task.Id).Find(&subList) - } - case "1": - l.svcCtx.DbEngin.Table("task_ai").Where("task_id", task.Id).Scan(&subList) - case "2": - l.svcCtx.DbEngin.Table("task_hpc").Where("task_id", task.Id).Scan(&subList) - } - for _, sub := range subList { - clusterIds = append(clusterIds, sub.ClusterId) - } - err = l.svcCtx.DbEngin.Table("t_cluster").Where("id in ?", clusterIds).Scan(&cList).Error - if err != nil { - return resp, err - } - utils.Convert(&task, &resp) - resp.ClusterInfos = cList - resp.SubTaskInfos = subList - return -} diff --git a/api/internal/logic/core/tasklistlogic.go b/api/internal/logic/core/tasklistlogic.go deleted file mode 100644 index fbbdcc91..00000000 --- a/api/internal/logic/core/tasklistlogic.go +++ /dev/null @@ -1,175 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package core - -import ( - "context" - "fmt" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "strconv" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type TaskListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskListLogic { - return &TaskListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *TaskListLogic) TaskList(req *types.TaskListReq) (resp *types.TaskListResp, err error) { - resp = &types.TaskListResp{} - - // 查询任务数据 - var tasks []models.Task - offset := (req.PageNum - 1) * req.PageSize - tx := l.svcCtx.DbEngin.Order("created_time desc").Offset(offset).Limit(req.PageSize).Find(&tasks) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error - } - if len(tasks) == 0 { - return nil, nil - } - - // 更新智算任务状态 - var ch = make(chan struct{}) - go l.updateAitaskStatus(tasks, ch) - - // 查询任务总数 - l.svcCtx.DbEngin.Model(&models.Task{}).Count(&resp.TotalCount) - - // 查询任务异常数 - l.svcCtx.DbEngin.Model(&models.Task{}).Where("status = ?", "Failed").Count(&resp.AlarmCount) - - // 正常任务数 - resp.NormalCount = resp.TotalCount - resp.AlarmCount - for _, task := range tasks { - type PInfo struct { - Id int64 - Name string - Address string - } - pInfo := PInfo{} - tx := l.svcCtx.DbEngin.Raw("SELECT id,name,address from sc_participant_phy_info where id in (SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.participant_id) ,GROUP_CONCAT(DISTINCT a.participant_id) ,GROUP_CONCAT(DISTINCT c.participant_id))as service_name from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?)", task.Id).Scan(&pInfo) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error - } - // 获取p端状态 - pStatus := "Unknown" - key := fmt.Sprintf("ps_%s-%d", pInfo.Address, pInfo.Id) - hGetAll := l.svcCtx.RedisClient.HGetAll(l.ctx, key) - if hGetAll.Err() != nil { - return nil, err - } - if len(hGetAll.Val()) != 0 { - parseInt, err := strconv.ParseInt(hGetAll.Val()["lastHeartbeat"], 10, 64) - if err != nil { - return nil, err - } - - if (time.Now().Unix() - parseInt) < 15 { - - pStatus = "Normal" - } - } - resp.Tasks = append(resp.Tasks, types.Task{ - Id: task.Id, - Name: task.Name, - Status: task.Status, - StartTime: task.StartTime.Format("2006-01-02 15:04:05"), - EndTime: task.EndTime.Format("2006-01-02 15:04:05"), - ParticipantId: pInfo.Id, - ParticipantName: pInfo.Name, - ParticipantStatus: pStatus, - }) - - } - - select { - case _ = <-ch: - return resp, nil - case <-time.After(1 * time.Second): - return resp, nil - } -} - -func (l *TaskListLogic) updateAitaskStatus(tasks []models.Task, ch chan<- struct{}) { - for _, task := range tasks { - if task.AdapterTypeDict != "1" { - continue - } - if task.Status == constants.Succeeded { - continue - } - - var aiTask []*models.TaskAi - tx := l.svcCtx.DbEngin.Raw("select * from task_ai where `task_id` = ? ", task.Id).Scan(&aiTask) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return - } - - start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local) - end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local) - var status = constants.Succeeded - for _, a := range aiTask { - s, _ := time.ParseInLocation(constants.Layout, a.StartTime, time.Local) - e, _ := time.ParseInLocation(constants.Layout, a.EndTime, time.Local) - - if s.Before(start) { - start = s - } - - if e.After(end) { - end = e - } - - if a.Status == constants.Failed { - status = a.Status - break - } - - if a.Status == constants.Running { - status = a.Status - continue - } - } - - task.Status = status - task.StartTime = &start - task.EndTime = &end - - tx = l.svcCtx.DbEngin.Updates(task) - if tx.Error != nil { - return - } - } - ch <- struct{}{} -} diff --git a/api/internal/logic/dictionary/adddictitemlogic.go b/api/internal/logic/dictionary/adddictitemlogic.go deleted file mode 100644 index 11892d8e..00000000 --- a/api/internal/logic/dictionary/adddictitemlogic.go +++ /dev/null @@ -1,55 +0,0 @@ -package dictionary - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AddDictItemLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAddDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddDictItemLogic { - return &AddDictItemLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AddDictItemLogic) AddDictItem(req *types.DictItemEditReq) (resp *types.DictItemResp, err error) { - dict := &types.DictInfo{} - result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.DictId) - if errors.Is(result.Error, gorm.ErrRecordNotFound) { - return nil, errors.New("Dictionary does not exist") - } - var dictItem types.DictItemInfo - dictItem.DictId = req.DictId - dictItem.ItemText = req.ItemText - dictItem.ItemValue = req.ItemValue - dictItem.Description = req.Description - dictItem.SortOrder = req.SortOrder - dictItem.ParentId = "0" - if req.ParentId != "" { - dictItem.ParentId = req.ParentId - } - dictItem.Status = req.Status - dictItem.Id = utils.GenSnowflakeIDStr() - dictItem.CreateTime = time.Now().Format("2006-01-02 15:04:05") - result = l.svcCtx.DbEngin.Table("t_dict_item").Create(&dictItem) - if result.Error != nil { - logx.Errorf("Failed to create dictionary item , errors: %s", result.Error) - return nil, result.Error - } - return -} diff --git a/api/internal/logic/dictionary/adddictlogic.go b/api/internal/logic/dictionary/adddictlogic.go deleted file mode 100644 index fa8b01bd..00000000 --- a/api/internal/logic/dictionary/adddictlogic.go +++ /dev/null @@ -1,43 +0,0 @@ -package dictionary - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AddDictLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAddDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddDictLogic { - return &AddDictLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AddDictLogic) AddDict(req *types.DictEditReq) (resp *types.DictResp, err error) { - dict := &types.DictInfo{} - dict.DictName = req.DictName - dict.DictCode = req.DictCode - dict.Type = req.Type - dict.Description = req.Description - dict.Id = utils.GenSnowflakeIDStr() - dict.CreateTime = time.Now().Format("2006-01-02 15:04:05") - dict.Status = req.Status - result := l.svcCtx.DbEngin.Table("t_dict").Create(&dict) - if result.Error != nil { - logx.Errorf("Failed to create dictionary , errors: %s", result.Error) - return nil, result.Error - } - return -} diff --git a/api/internal/logic/dictionary/deletedictitemlogic.go b/api/internal/logic/dictionary/deletedictitemlogic.go deleted file mode 100644 index a65a5069..00000000 --- a/api/internal/logic/dictionary/deletedictitemlogic.go +++ /dev/null @@ -1,39 +0,0 @@ -package dictionary - -import ( - "context" - "github.com/pkg/errors" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteDictItemLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictItemLogic { - return &DeleteDictItemLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteDictItemLogic) DeleteDictItem(req *types.CId) (resp *types.DictItemResp, err error) { - db := l.svcCtx.DbEngin.Table("t_dict_item").Where("id = ?", req.Id).First(&types.DictItemInfo{}) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Dictionary item does not exist") - } - tx := l.svcCtx.DbEngin.Table("t_dict_item").Delete(types.DictItemInfo{}, req.Id) - if tx.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Delete dictionary item failed") - } - return -} diff --git a/api/internal/logic/dictionary/deletedictlogic.go b/api/internal/logic/dictionary/deletedictlogic.go deleted file mode 100644 index 47eb68f8..00000000 --- a/api/internal/logic/dictionary/deletedictlogic.go +++ /dev/null @@ -1,43 +0,0 @@ -package dictionary - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteDictLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictLogic { - return &DeleteDictLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteDictLogic) DeleteDict(req *types.CId) (resp *types.DictResp, err error) { - var sId int64 - l.svcCtx.DbEngin.Table("t_dict").Raw("select d.id from t_dict_item di left join t_dict d on di.dict_id=d.id where d.id=? limit 1", req.Id).Scan(&sId) - if sId != 0 { - return nil, errors.New("Delete failed,The dictionary is associated with a dictionary item") - } - db := l.svcCtx.DbEngin.Table("t_dict").Where("id = ?", req.Id).First(&types.DictInfo{}) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Dictionary does not exist") - } - tx := l.svcCtx.DbEngin.Table("t_dict").Delete(types.DictInfo{}, req.Id) - if tx.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Delete dictionary failed") - } - return -} diff --git a/api/internal/logic/dictionary/editdictitemlogic.go b/api/internal/logic/dictionary/editdictitemlogic.go deleted file mode 100644 index 60cadbd0..00000000 --- a/api/internal/logic/dictionary/editdictitemlogic.go +++ /dev/null @@ -1,39 +0,0 @@ -package dictionary - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type EditDictItemLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewEditDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditDictItemLogic { - return &EditDictItemLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *EditDictItemLogic) EditDictItem(req *types.DictItemEditReq) (resp *types.DictItemResp, err error) { - dictItem := &types.DictItemInfo{} - result := l.svcCtx.DbEngin.Table("t_dict_item").First(&dictItem, req.Id) - if errors.Is(result.Error, gorm.ErrRecordNotFound) { - logx.Errorf("Dictionary data editing failure. errors: %s", result.Error) - return nil, errors.New("DictItem does not exist") - } - utils.Convert(req, &dictItem) - l.svcCtx.DbEngin.Table("t_dict_item").Model(&dictItem).Updates(&dictItem) - return -} diff --git a/api/internal/logic/dictionary/editdictlogic.go b/api/internal/logic/dictionary/editdictlogic.go deleted file mode 100644 index 735718a2..00000000 --- a/api/internal/logic/dictionary/editdictlogic.go +++ /dev/null @@ -1,41 +0,0 @@ -package dictionary - -import ( - "context" - "fmt" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type EditDictLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewEditDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditDictLogic { - return &EditDictLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *EditDictLogic) EditDict(req *types.DictEditReq) (resp *types.DictResp, err error) { - dict := &types.DictInfo{} - result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.Id) - if errors.Is(result.Error, gorm.ErrRecordNotFound) { - logx.Errorf("Dictionary editing failure. errors: %s", result.Error) - return nil, errors.New("Dict does not exist") - } - utils.Convert(req, &dict) - tx := l.svcCtx.DbEngin.Table("t_dict").Model(&dict).Updates(&dict) - fmt.Println(tx) - return -} diff --git a/api/internal/logic/dictionary/getdictitemlogic.go b/api/internal/logic/dictionary/getdictitemlogic.go deleted file mode 100644 index 3fa71aec..00000000 --- a/api/internal/logic/dictionary/getdictitemlogic.go +++ /dev/null @@ -1,38 +0,0 @@ -package dictionary - -import ( - "context" - "github.com/pkg/errors" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetDictItemLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictItemLogic { - return &GetDictItemLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetDictItemLogic) GetDictItem(req *types.CId) (resp *types.DictItemResp, err error) { - resp = &types.DictItemResp{} - item := &types.DictItemInfo{} - db := l.svcCtx.DbEngin.Table("t_dict_item").Where("id = ?", req.Id).First(&item) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Dictionary item does not exist") - } - tool.Convert(item, &resp) - return -} diff --git a/api/internal/logic/dictionary/getdictlogic.go b/api/internal/logic/dictionary/getdictlogic.go deleted file mode 100644 index cb230204..00000000 --- a/api/internal/logic/dictionary/getdictlogic.go +++ /dev/null @@ -1,38 +0,0 @@ -package dictionary - -import ( - "context" - "github.com/pkg/errors" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetDictLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictLogic { - return &GetDictLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetDictLogic) GetDict(req *types.CId) (resp *types.DictResp, err error) { - resp = &types.DictResp{} - dict := &types.DictInfo{} - db := l.svcCtx.DbEngin.Table("t_dict").Where("id = ?", req.Id).First(&dict) - if db.Error != nil { - logx.Errorf("err %v", db.Error.Error()) - return nil, errors.New("Dictionary does not exist") - } - tool.Convert(dict, &resp) - return -} diff --git a/api/internal/logic/dictionary/listdictitembycodelogic.go b/api/internal/logic/dictionary/listdictitembycodelogic.go deleted file mode 100644 index aedb6d71..00000000 --- a/api/internal/logic/dictionary/listdictitembycodelogic.go +++ /dev/null @@ -1,60 +0,0 @@ -package dictionary - -import ( - "context" - "github.com/pkg/errors" - "sort" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListDictItemByCodeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListDictItemByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictItemByCodeLogic { - return &ListDictItemByCodeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListDictItemByCodeLogic) ListDictItemByCode(req *types.DictCodeReq) (resp *types.PageResult, err error) { - var dictList []types.DictItemInfo - resp = &types.PageResult{} - db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict") - - // 左连接查询 - err = db.Select("t_dict_item.*").Joins("left join t_dict_item on t_dict.id = t_dict_item.dict_id"). - Where("t_dict.dict_code = ?", req.DictCode). - Where("t_dict_item.status", 1). - Order("t_dict_item.sort_order").Scan(&dictList).Error - if err != nil { - logx.Errorf("ListDictItemByCode()=> failed %s", err.Error()) - return nil, errors.New("description Failed to query dictionary entry data") - } - - // 找出第一级字典项,(父字典项id为0) - dictItemFormat := make([]types.DictItemInfo, 0) - for _, item := range dictList { - if item.ParentId == "0" { - dictItemFormat = append(dictItemFormat, item) - } - } - // 排序 - sort.Slice(dictItemFormat, func(i, j int) bool { - return dictItemFormat[i].SortOrder < dictItemFormat[j].SortOrder - }) - - // 递归找出一级路由下面的子路由 - getTreeMap(dictItemFormat, dictList) - - resp.List = dictItemFormat - return resp, nil -} diff --git a/api/internal/logic/dictionary/listdictitemlogic.go b/api/internal/logic/dictionary/listdictitemlogic.go deleted file mode 100644 index 047a8296..00000000 --- a/api/internal/logic/dictionary/listdictitemlogic.go +++ /dev/null @@ -1,88 +0,0 @@ -package dictionary - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "sort" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListDictItemLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictItemLogic { - return &ListDictItemLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListDictItemLogic) ListDictItem(req *types.DictItemReq) (resp *types.PageResult, err error) { - resp = &types.PageResult{} - var dictList []types.DictItemInfo - db := l.svcCtx.DbEngin.Model(&types.DictItemInfo{}).Table("t_dict_item") - - if req.ItemText != "" { - db = db.Where("item_text LIKE ?", "%"+req.ItemText+"%") - } - if req.ItemValue != "" { - db = db.Where("item_value LIKE ?", "%"+req.ItemValue+"%") - } - if req.Type != "" { - db = db.Where("type = ?", req.Type) - } - if req.ParentId != "" { - db = db.Where("parent_id = ?", req.ParentId) - } - if req.Status != "" { - db = db.Where("status = ?", req.Status) - } - if req.DictId != "" { - db = db.Where("dict_id = ?", req.DictId) - } - err = db.Order("sort_order").Find(&dictList).Error - - // 找出第一级字典项,(父字典项id为0) - dictItemFormat := make([]types.DictItemInfo, 0) - for _, item := range dictList { - if item.ParentId == "0" { - dictItemFormat = append(dictItemFormat, item) - } - } - // 排序 - sort.Slice(dictItemFormat, func(i, j int) bool { - return dictItemFormat[i].SortOrder < dictItemFormat[j].SortOrder - }) - - // 递归找出一级路由下面的子路由 - getTreeMap(dictItemFormat, dictList) - - resp.List = dictItemFormat - - return resp, nil -} - -func getTreeMap(dictItemFormat []types.DictItemInfo, dictItems []types.DictItemInfo) { - for index, itemF := range dictItemFormat { - for _, dictItem := range dictItems { - if itemF.Id == dictItem.ParentId { - // itemF 只是个复制值 - //itemF.Children = append(itemF.Children, dictItem) - dictItemFormat[index].Children = append(dictItemFormat[index].Children, dictItem) - } - } - if len(dictItemFormat[index].Children) > 0 { - // 排序 - sort.Slice(dictItemFormat[index].Children, func(i, j int) bool { - return dictItemFormat[index].Children[i].SortOrder < dictItemFormat[index].Children[j].SortOrder - }) - getTreeMap(dictItemFormat[index].Children, dictItems) - } - } -} diff --git a/api/internal/logic/dictionary/listdictlogic.go b/api/internal/logic/dictionary/listdictlogic.go deleted file mode 100644 index 35122a3e..00000000 --- a/api/internal/logic/dictionary/listdictlogic.go +++ /dev/null @@ -1,59 +0,0 @@ -package dictionary - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListDictLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictLogic { - return &ListDictLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListDictLogic) ListDict(req *types.DictReq) (resp *types.PageResult, err error) { - limit := req.PageSize - offset := req.PageSize * (req.PageNum - 1) - resp = &types.PageResult{} - var dictList []types.DictInfo - db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict") - - if req.DictName != "" { - db = db.Where("dict_name LIKE ?", "%"+req.DictName+"%") - } - if req.DictCode != "" { - db = db.Where("dict_code LIKE ?", "%"+req.DictCode+"%") - } - if req.Type != "" { - db = db.Where("type = ?", req.Type) - } - if req.Status != "" { - db = db.Where("status = ?", req.Status) - } - var total int64 - err = db.Count(&total).Error - - if err != nil { - return resp, err - } - db = db.Limit(limit).Offset(offset) - err = db.Order("create_time desc").Find(&dictList).Error - - resp.List = dictList - resp.PageSize = req.PageSize - resp.PageNum = req.PageNum - resp.Total = total - - return resp, nil -} diff --git a/api/internal/logic/hpc/adaptersummarylogic.go b/api/internal/logic/hpc/adaptersummarylogic.go deleted file mode 100644 index 2bdbe614..00000000 --- a/api/internal/logic/hpc/adaptersummarylogic.go +++ /dev/null @@ -1,37 +0,0 @@ -package hpc - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AdapterSummaryLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAdapterSummaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdapterSummaryLogic { - return &AdapterSummaryLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AdapterSummaryLogic) AdapterSummary(req *types.HpcAdapterSummaryReq) (resp *types.HpcAdapterSummaryResp, err error) { - var hpcAdapterSummary []types.HPCAdapterSummary - - l.svcCtx.DbEngin.Raw("SELECT ta.NAME AS adapter_name,count( DISTINCT label ) as stack_count,count( DISTINCT tc.id ) as cluster_count,count( DISTINCT th.id) as task_count FROM t_adapter ta LEFT JOIN t_cluster tc ON ta.id = tc.adapter_id LEFT JOIN task_hpc th ON ta.id = th.adapter_id WHERE ta.type = 2 GROUP BY ta.id").Scan(&hpcAdapterSummary) - - resp = &types.HpcAdapterSummaryResp{ - Code: 200, - Msg: "success", - Data: hpcAdapterSummary, - } - return resp, nil -} diff --git a/api/internal/logic/hpc/commithpctasklogic.go b/api/internal/logic/hpc/commithpctasklogic.go deleted file mode 100644 index 00f7e3e1..00000000 --- a/api/internal/logic/hpc/commithpctasklogic.go +++ /dev/null @@ -1,135 +0,0 @@ -package hpc - -import ( - "context" - "errors" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "k8s.io/apimachinery/pkg/util/json" - "math/rand" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CommitHpcTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCommitHpcTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitHpcTaskLogic { - return &CommitHpcTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *types.CommitHpcTaskResp, err error) { - - // 构建主任务结构体 - taskModel := models.Task{ - Name: req.Name, - Description: req.Description, - Status: constants.Saved, - Strategy: 0, - SynergyStatus: 0, - CommitTime: time.Now(), - AdapterTypeDict: "2", - } - - // 保存任务数据到数据库 - tx := l.svcCtx.DbEngin.Create(&taskModel) - if tx.Error != nil { - return nil, tx.Error - } - - var clusterIds []int64 - l.svcCtx.DbEngin.Raw("SELECT id FROM `t_cluster` where adapter_id in ? and label = ?", req.AdapterIds, req.ClusterType).Scan(&clusterIds) - if len(clusterIds) == 0 || clusterIds == nil { - resp.Code = 400 - resp.Msg = "no cluster found" - return resp, nil - } - - var clusterName string - var adapterId int64 - var adapterName string - clusterId := clusterIds[rand.Intn(len(clusterIds))] - l.svcCtx.DbEngin.Raw("SELECT nickname FROM `t_cluster` where id = ?", clusterId).Scan(&clusterName) - l.svcCtx.DbEngin.Raw("SELECT adapter_id FROM `t_cluster` where id = ?", clusterId).Scan(&adapterId) - l.svcCtx.DbEngin.Raw("SELECT name FROM `t_adapter` where id = ?", adapterId).Scan(&adapterName) - if len(adapterName) == 0 || adapterName == "" { - return nil, errors.New("no corresponding adapter found") - } - env, _ := json.Marshal(req.Environment) - - hpcInfo := models.TaskHpc{ - TaskId: taskModel.Id, - AdapterId: uint(adapterId), - AdapterName: adapterName, - ClusterId: uint(clusterId), - ClusterName: clusterName, - Name: taskModel.Name, - Status: "Saved", - CmdScript: req.CmdScript, - StartTime: time.Now().String(), - CardCount: req.CardCount, - WorkDir: req.WorkDir, - WallTime: req.WallTime, - AppType: req.AppType, - AppName: req.AppName, - Queue: req.Queue, - SubmitType: req.SubmitType, - NNode: req.NNode, - StdOutFile: req.StdOutFile, - StdErrFile: req.StdErrFile, - StdInput: req.StdInput, - DeletedFlag: 0, - CreatedBy: 0, - CreatedTime: time.Now(), - UpdatedBy: 0, - UpdatedTime: time.Now(), - Environment: string(env), - } - - tx = l.svcCtx.DbEngin.Create(&hpcInfo) - if tx.Error != nil { - return nil, tx.Error - } - noticeInfo := clientCore.NoticeInfo{ - AdapterId: adapterId, - AdapterName: adapterName, - ClusterId: clusterId, - ClusterName: clusterName, - NoticeType: "create", - TaskName: req.Name, - Incident: "任务创建中", - CreatedTime: time.Now(), - } - result := l.svcCtx.DbEngin.Table("t_notice").Create(¬iceInfo) - if result.Error != nil { - logx.Errorf("Task creation failure, err: %v", result.Error) - } - // todo mq task manage - //reqMessage, err := json.Marshal(mqInfo) - //if err != nil { - // logx.Error(err) - // return nil, err - //} - //publish := l.svcCtx.RedisClient.Publish(context.Background(), mqInfo.TaskType, reqMessage) - //if publish.Err() != nil { - // return nil, publish.Err() - //} - resp = &types.CommitHpcTaskResp{ - Code: 200, - Msg: "success", - TaskId: taskModel.Id, - } - return resp, nil -} diff --git a/api/internal/logic/hpc/joblogic.go b/api/internal/logic/hpc/joblogic.go deleted file mode 100644 index 29ac6ea9..00000000 --- a/api/internal/logic/hpc/joblogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package hpc - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type JobLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobLogic { - return &JobLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *JobLogic) Job(req *types.HpcJobReq) (resp *types.HpcJobResp, err error) { - - var job []types.Job - l.svcCtx.DbEngin.Raw("SELECT th.NAME as job_name,t.description as job_desc,t.commit_time as submit_time,th.STATUS as job_status,ta.name as adapter_name,tc.name as cluster_name,tc.label as cluster_type FROM task_hpc th LEFT JOIN task t ON t.id = th.task_id JOIN t_cluster tc on th.cluster_id = tc.id JOIN t_adapter ta on tc.adapter_id = ta.id").Scan(&job) - resp = &types.HpcJobResp{ - Code: 200, - Msg: "success", - Data: job, - } - return resp, nil -} diff --git a/api/internal/logic/hpc/overviewlogic.go b/api/internal/logic/hpc/overviewlogic.go deleted file mode 100644 index b3a447ab..00000000 --- a/api/internal/logic/hpc/overviewlogic.go +++ /dev/null @@ -1,37 +0,0 @@ -package hpc - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type OverViewLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewOverViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OverViewLogic { - return &OverViewLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *OverViewLogic) OverView(req *types.HpcOverViewReq) (resp *types.HpcOverViewResp, err error) { - - var overView types.HPCOverView - tx := l.svcCtx.DbEngin.Raw("SELECT count( DISTINCT a.id ) as adapter_count,count( DISTINCT label ) as stack_count,count( c.id ) as cluster_count,(select count(*) from task_hpc) as task_count FROM t_cluster c JOIN t_adapter a ON c.adapter_id = a.id AND a.type = 2 ").Scan(&overView) - - println(tx) - resp = &types.HpcOverViewResp{ - Code: 200, - Msg: "success", - Data: overView, - } - return resp, nil -} diff --git a/api/internal/logic/hpc/queueassetslogic.go b/api/internal/logic/hpc/queueassetslogic.go deleted file mode 100644 index aa434574..00000000 --- a/api/internal/logic/hpc/queueassetslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package hpc - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type QueueAssetsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewQueueAssetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueueAssetsLogic { - return &QueueAssetsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *QueueAssetsLogic) QueueAssets() (resp *types.QueueAssetsResp, err error) { - // 查询数据库队列资源信息 - var queueAssetsResp types.QueueAssetsResp - tx := l.svcCtx.DbEngin.Raw("SELECT qpi.*,ti.tenant_name FROM sc_queue_phy_info qpi left join sc_participant_phy_info ppi on ppi.id = qpi.participant_id left JOIN sc_tenant_info ti on ti.id = ppi.tenant_id WHERE qpi.created_time IN ( SELECT MAX( created_time ) FROM sc_queue_phy_info WHERE deleted_flag = 0 GROUP BY participant_id, queue_name ) ").Scan(&queueAssetsResp.QueueAssets) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error - } - return &queueAssetsResp, nil -} diff --git a/api/internal/logic/hpc/resourcelogic.go b/api/internal/logic/hpc/resourcelogic.go deleted file mode 100644 index 1556c265..00000000 --- a/api/internal/logic/hpc/resourcelogic.go +++ /dev/null @@ -1,58 +0,0 @@ -package hpc - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ResourceLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResourceLogic { - return &ResourceLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ResourceLogic) Resource(req *types.HpcResourceReq) (resp *types.HpcResourceResp, err error) { - - type hpcResourceOV struct { - CpuAvail float64 `json:"cpu_avail"` - CpuTotal float64 `json:"cpu_total"` - MemAvail float64 `json:"mem_avail"` - MemTotal float64 `json:"mem_total"` - DiskAvail float64 `json:"disk_avail"` - DiskTotal float64 `json:"disk_total"` - GpuAvail float64 `json:"gpu_avail"` - GpuTotal float64 `json:"gpu_total"` - } - var hrov hpcResourceOV - l.svcCtx.DbEngin.Raw("SELECT sum(cpu_avail) as cpu_avail,sum(cpu_total) as cpu_total,sum(mem_avail) as mem_avail,sum(mem_total) as mem_total,sum(disk_avail) as disk_avail,sum(disk_total) as disk_total,sum(gpu_avail) as gpu_avail,sum(gpu_total) as gpu_total FROM t_cluster_resource where cluster_type = 2").Scan(&hrov) - - hpcResource := types.HPCResource{ - GPUCardsTotal: hrov.GpuTotal, - CPUCoresTotal: hrov.CpuTotal, - RAMTotal: hrov.MemTotal, - GPUCardsUsed: hrov.GpuTotal - hrov.GpuAvail, - CPUCoresUsed: hrov.CpuTotal - hrov.CpuAvail, - RAMUsed: hrov.MemTotal - hrov.MemAvail, - GPURate: (hrov.GpuTotal - hrov.GpuAvail) / hrov.GpuTotal, - CPURate: (hrov.CpuTotal - hrov.CpuAvail) / hrov.CpuTotal, - RAMRate: (hrov.MemTotal - hrov.MemAvail) / hrov.MemTotal, - } - - resp = &types.HpcResourceResp{ - Code: 200, - Msg: "success", - Data: hpcResource, - } - return resp, nil -} diff --git a/api/internal/logic/inference/imageinferencelogic.go b/api/internal/logic/inference/imageinferencelogic.go deleted file mode 100644 index cbef1eb5..00000000 --- a/api/internal/logic/inference/imageinferencelogic.go +++ /dev/null @@ -1,139 +0,0 @@ -package inference - -import ( - "context" - "errors" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/inference" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "net/http" -) - -type ImageInferenceLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewImageInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ImageInferenceLogic { - return &ImageInferenceLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -// -//func (l *ImageInferenceLogic) ImageInference(req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) { -// return nil, nil -//} - -func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) { - resp = &types.ImageInferenceResp{} - opt := &option.InferOption{ - TaskName: req.TaskName, - TaskDesc: req.TaskDesc, - AdapterId: req.AdapterId, - AiClusterIds: req.AiClusterIds, - ModelName: req.ModelName, - ModelType: req.ModelType, - Strategy: req.Strategy, - StaticWeightMap: req.StaticWeightMap, - } - - var ts []*inference.ImageFile - - uploadedFiles := r.MultipartForm.File - - if len(uploadedFiles) == 0 { - return nil, errors.New("Images does not exist") - } - - if len(uploadedFiles["images"]) == 0 { - return nil, errors.New("Images does not exist") - } - - for _, header := range uploadedFiles["images"] { - file, err := header.Open() - if err != nil { - return nil, err - } - defer file.Close() - var ir types.ImageResult - ir.ImageName = header.Filename - t := inference.ImageFile{ - ImageResult: &ir, - File: file, - } - ts = append(ts, &t) - } - - _, ok := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[opt.AdapterId] - if !ok { - return nil, errors.New("AdapterId does not exist") - } - - var strat strategy.Strategy - switch opt.Strategy { - case strategy.STATIC_WEIGHT: - strat = strategy.NewStaticWeightStrategy(opt.StaticWeightMap, int32(len(ts))) - if err != nil { - return nil, err - } - default: - return nil, errors.New("no strategy has been chosen") - } - clusters, err := strat.Schedule() - if err != nil { - return nil, err - } - - if clusters == nil || len(clusters) == 0 { - return nil, errors.New("clusters is nil") - } - - //save task - var synergystatus int64 - if len(clusters) > 1 { - synergystatus = 1 - } - - strategyCode, err := l.svcCtx.Scheduler.AiStorages.GetStrategyCode(opt.Strategy) - if err != nil { - return nil, err - } - adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId) - if err != nil { - return nil, err - } - id, err := l.svcCtx.Scheduler.AiStorages.SaveTask(opt.TaskName, strategyCode, synergystatus, "11") - if err != nil { - return nil, err - } - - l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "create", "任务创建中") - - for i := len(clusters) - 1; i >= 0; i-- { - if clusters[i].Replicas == 0 { - clusters = append(clusters[:i], clusters[i+1:]...) - } - } - - //save taskai - for _, c := range clusters { - clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(c.ClusterId) - opt.Replica = c.Replicas - err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, c.ClusterId, clusterName, "", constants.Saved, "") - if err != nil { - return nil, err - } - } - - go l.svcCtx.Scheduler.AiService.ImageInfer(opt, id, adapterName, clusters, ts) - - return resp, nil -} diff --git a/api/internal/logic/inference/inferencetaskdetaillogic.go b/api/internal/logic/inference/inferencetaskdetaillogic.go deleted file mode 100644 index 0638742a..00000000 --- a/api/internal/logic/inference/inferencetaskdetaillogic.go +++ /dev/null @@ -1,58 +0,0 @@ -package inference - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type InferenceTaskDetailLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewInferenceTaskDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InferenceTaskDetailLogic { - return &InferenceTaskDetailLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *InferenceTaskDetailLogic) InferenceTaskDetail(req *types.InferenceTaskDetailReq) (resp *types.InferenceTaskDetailResp, err error) { - // todo: add your logic here and delete this line - - var taskAiSub []*models.TaskAiSub - var results []types.InferenceResult - l.svcCtx.DbEngin.Table("task_ai_sub").Where("task_id", req.TaskId).Scan(&taskAiSub) - - if len(taskAiSub) != 0 { - for _, sub := range taskAiSub { - result := types.InferenceResult{ - TaskName: sub.TaskName, - TaskAiName: sub.TaskAiName, - ImageName: sub.ImageName, - Result: sub.Result, - Card: sub.Card, - ClusterName: sub.ClusterName, - } - results = append(results, result) - } - } else { - return nil, nil - } - - resp = &types.InferenceTaskDetailResp{ - Code: 200, - Msg: "success", - InferenceResults: results, - } - - return resp, nil - -} diff --git a/api/internal/logic/inference/modelnamesbytypelogic.go b/api/internal/logic/inference/modelnamesbytypelogic.go deleted file mode 100644 index 02e127ae..00000000 --- a/api/internal/logic/inference/modelnamesbytypelogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package inference - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ModelNamesByTypeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewModelNamesByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModelNamesByTypeLogic { - return &ModelNamesByTypeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ModelNamesByTypeLogic) ModelNamesByType(req *types.ModelNamesReq) (resp *types.ModelNamesResp, err error) { - resp = &types.ModelNamesResp{} - models, err := storeLink.GetModelNamesByType(req.Type) - if err != nil { - logx.Errorf("ModelNamesByType err: %v", err) - return nil, err - } - resp.ModelNames = models - return resp, nil -} diff --git a/api/internal/logic/inference/modeltypeslogic.go b/api/internal/logic/inference/modeltypeslogic.go deleted file mode 100644 index 430aae8f..00000000 --- a/api/internal/logic/inference/modeltypeslogic.go +++ /dev/null @@ -1,32 +0,0 @@ -package inference - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ModelTypesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewModelTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModelTypesLogic { - return &ModelTypesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ModelTypesLogic) ModelTypes() (resp *types.ModelTypesResp, err error) { - resp = &types.ModelTypesResp{} - mTypes := storeLink.GetModelTypes() - resp.ModelTypes = mTypes - return resp, nil -} diff --git a/api/internal/logic/inference/texttotextinferencelogic.go b/api/internal/logic/inference/texttotextinferencelogic.go deleted file mode 100644 index 58b3edc1..00000000 --- a/api/internal/logic/inference/texttotextinferencelogic.go +++ /dev/null @@ -1,150 +0,0 @@ -package inference - -import ( - "context" - "errors" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "strconv" - "sync" - "time" -) - -type TextToTextInferenceLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewTextToTextInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TextToTextInferenceLogic { - return &TextToTextInferenceLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *TextToTextInferenceLogic) TextToTextInference(req *types.TextToTextInferenceReq) (resp *types.TextToTextInferenceResp, err error) { - resp = &types.TextToTextInferenceResp{} - opt := &option.InferOption{ - TaskName: req.TaskName, - TaskDesc: req.TaskDesc, - AdapterId: req.AdapterId, - AiClusterIds: req.AiClusterIds, - ModelName: req.ModelName, - ModelType: req.ModelType, - } - - _, ok := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[opt.AdapterId] - if !ok { - return nil, errors.New("AdapterId does not exist") - } - - //save task - var synergystatus int64 - var strategyCode int64 - adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId) - if err != nil { - return nil, err - } - - id, err := l.svcCtx.Scheduler.AiStorages.SaveTask(opt.TaskName, strategyCode, synergystatus, "12") - if err != nil { - return nil, err - } - - var wg sync.WaitGroup - var cluster_ch = make(chan struct { - urls []*collector.InferUrl - clusterId string - clusterName string - }, len(opt.AiClusterIds)) - - var cs []struct { - urls []*collector.InferUrl - clusterId string - clusterName string - } - collectorMap := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[opt.AdapterId] - - //save taskai - for _, clusterId := range opt.AiClusterIds { - wg.Add(1) - go func(cId string) { - urls, err := collectorMap[cId].GetInferUrl(l.ctx, opt) - if err != nil { - wg.Done() - return - } - clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(cId) - - s := struct { - urls []*collector.InferUrl - clusterId string - clusterName string - }{ - urls: urls, - clusterId: cId, - clusterName: clusterName, - } - - cluster_ch <- s - wg.Done() - return - }(clusterId) - } - wg.Wait() - close(cluster_ch) - - for s := range cluster_ch { - cs = append(cs, s) - } - - if len(cs) == 0 { - clusterId := opt.AiClusterIds[0] - clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(opt.AiClusterIds[0]) - err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, clusterId, clusterName, "", constants.Failed, "") - if err != nil { - return nil, err - } - l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") - } - - for _, c := range cs { - clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(c.clusterId) - err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, c.clusterId, clusterName, "", constants.Saved, "") - if err != nil { - return nil, err - } - } - - var aiTaskList []*models.TaskAi - tx := l.svcCtx.DbEngin.Raw("select * from task_ai where `task_id` = ? ", id).Scan(&aiTaskList) - if tx.Error != nil { - return nil, tx.Error - - } - - for i, t := range aiTaskList { - if strconv.Itoa(int(t.ClusterId)) == cs[i].clusterId { - t.Status = constants.Completed - t.EndTime = time.Now().Format(time.RFC3339) - url := cs[i].urls[0].Url + storeLink.FORWARD_SLASH + "chat" - t.InferUrl = url - err := l.svcCtx.Scheduler.AiStorages.UpdateAiTask(t) - if err != nil { - logx.Errorf(tx.Error.Error()) - } - } - } - - l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "completed", "任务完成") - - return resp, nil -} diff --git a/api/internal/logic/monitoring/adapterinfologic.go b/api/internal/logic/monitoring/adapterinfologic.go deleted file mode 100644 index 1afc91e4..00000000 --- a/api/internal/logic/monitoring/adapterinfologic.go +++ /dev/null @@ -1,31 +0,0 @@ -package monitoring - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AdapterInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAdapterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdapterInfoLogic { - return &AdapterInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AdapterInfoLogic) AdapterInfo(req *types.AdapterInfoReq) (resp *types.AdapterInfoResp, err error) { - // todo: add your logic here and delete this line - resp = &types.AdapterInfoResp{} - l.svcCtx.DbEngin.Raw("select ta.name , ta.version from t_adapter ta,t_cluster tc where tc.id = ? and tc.adapter_id = ta.id", req.ClusterId).Scan(resp) - return resp, nil -} diff --git a/api/internal/logic/monitoring/alertlistlogic.go b/api/internal/logic/monitoring/alertlistlogic.go deleted file mode 100644 index 099e72d7..00000000 --- a/api/internal/logic/monitoring/alertlistlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -package monitoring - -import ( - "context" - "fmt" - v1 "github.com/prometheus/client_golang/api/prometheus/v1" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AlertListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAlertListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertListLogic { - return &AlertListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -type AlertListResp struct { - Mode int `json:"code"` - Msg string `json:"msg"` - Data map[string][]*v1.Alert `json:"data"` -} - -func (l *AlertListLogic) AlertList(req *types.AlertListReq) (resp *types.AlertListResp, err error) { - resp = &types.AlertListResp{ - AlertMap: make(map[string]interface{}), - } - - // query server http url. - var clusterArray []string - - sql := "select distinct tc.name from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and label = 'kubernetes' and ta.type = ?" - if len(req.AdapterId) > 0 { - sql = fmt.Sprintf("select distinct tc.name from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and label = 'kubernetes' and ta.type = ? and ta.id = %s", req.AdapterId) - } - if len(req.ClusterId) > 0 { - sql = fmt.Sprintf("select distinct tc.name from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and label = 'kubernetes' and ta.type = ? and tc.id = %s", req.ClusterId) - } - l.svcCtx.DbEngin.Raw(sql, req.AlertType).Scan(&clusterArray) - - for _, clusterName := range clusterArray { - getResult := l.svcCtx.RedisClient.Get(l.ctx, clusterName) - if len(getResult.Val()) != 0 { - var alerts []v1.Alert - json.Unmarshal([]byte(getResult.Val()), &alerts) - - resp.AlertMap[clusterName] = alerts - } - - } - return resp, nil -} diff --git a/api/internal/logic/monitoring/alertruleslogic.go b/api/internal/logic/monitoring/alertruleslogic.go deleted file mode 100644 index 7c63dcff..00000000 --- a/api/internal/logic/monitoring/alertruleslogic.go +++ /dev/null @@ -1,40 +0,0 @@ -package monitoring - -import ( - "context" - "fmt" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AlertRulesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAlertRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertRulesLogic { - return &AlertRulesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AlertRulesLogic) AlertRules(req *types.AlertRulesReq) (resp *types.AlertRulesResp, err error) { - resp = &types.AlertRulesResp{} - var alertRules []types.AlertRule - sql := fmt.Sprintf("SELECT ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.alert_type = %s AND ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id", req.AlertType) - if req.AdapterId != "" { - sql = fmt.Sprintf("SELECT ar.*,GROUP_CONCAT( tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',' ) AS cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id JOIN t_adapter ta ON ta.id = tc.adapter_id WHERE ar.alert_type = %s AND ta.id = %s AND ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id", req.AlertType, req.AdapterId) - } - if req.ClusterId != "" { - sql = fmt.Sprintf("SELECT ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.alert_type = %s AND ar.cluster_id = %s AND ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id", req.AlertType, req.ClusterId) - } - l.svcCtx.DbEngin.Raw(sql).Scan(&alertRules) - resp.AlertRules = alertRules - return resp, nil -} diff --git a/api/internal/logic/monitoring/clustersloadlogic.go b/api/internal/logic/monitoring/clustersloadlogic.go deleted file mode 100644 index 184cd5ed..00000000 --- a/api/internal/logic/monitoring/clustersloadlogic.go +++ /dev/null @@ -1,34 +0,0 @@ -package monitoring - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ClustersLoadLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewClustersLoadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClustersLoadLogic { - return &ClustersLoadLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ClustersLoadLogic) ClustersLoad(req *types.ClustersLoadReq) (resp *types.ClustersLoadResp, err error) { - resp = &types.ClustersLoadResp{} - metrics := []string{"cluster_cpu_utilisation", "cluster_cpu_avail", "cluster_cpu_total", "cluster_memory_total", "cluster_memory_avail", "cluster_memory_utilisation", "cluster_disk_utilisation", "cluster_disk_avail", "cluster_disk_total", "cluster_pod_utilisation"} - result := l.svcCtx.PromClient.GetNamedMetrics(metrics, time.Now(), tracker.ClusterOption{ClusterName: req.ClusterName}) - resp.Data = result - return resp, nil -} diff --git a/api/internal/logic/monitoring/createalertrulelogic.go b/api/internal/logic/monitoring/createalertrulelogic.go deleted file mode 100644 index fb19d23f..00000000 --- a/api/internal/logic/monitoring/createalertrulelogic.go +++ /dev/null @@ -1,120 +0,0 @@ -package monitoring - -import ( - "context" - v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - v12 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/apimachinery/pkg/util/json" - "strconv" -) - -type CreateAlertRuleLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateAlertRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlertRuleLogic { - return &CreateAlertRuleLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -type RuleSelectorResp struct { - Code int `json:"code"` - Msg string `json:"msg"` - Prometheus v1.Prometheus `json:"data"` -} - -func (l *CreateAlertRuleLogic) CreateAlertRule(req *types.CreateAlertRuleReq) error { - - // save to db - var alertRule models.AlertRule - tool.Convert(req, &alertRule) - alertRule.ClusterId, _ = strconv.ParseInt(req.CLusterId, 10, 64) - alertRule.Id = tool.GenSnowflakeID() - tx := l.svcCtx.DbEngin.Save(&alertRule) - if tx.Error != nil { - return tx.Error - } - - // query cluster http url. - var server string - l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) - - // rule selector - var ruleSelectorResp RuleSelectorResp - - response, err := l.svcCtx.HttpClient.R(). - SetQueryParams(map[string]string{ - "clusterName": req.ClusterName, - }). - SetResult(&ruleSelectorResp). - ForceContentType("application/json"). - Get(server + "/api/v1/monitoring/rule/selector") - if err != nil || response.IsError() { - logx.Error(response) - return err - } - // Data Filling - ruleDuration := v1.Duration(req.Duration) - rule := &v1.PrometheusRule{ - TypeMeta: v12.TypeMeta{Kind: "PrometheusRule", - APIVersion: "monitoring.coreos.com/v1"}, - ObjectMeta: v12.ObjectMeta{ - Name: req.Name, - Namespace: ruleSelectorResp.Prometheus.ObjectMeta.Namespace, - Labels: ruleSelectorResp.Prometheus.Spec.RuleSelector.MatchLabels, - }, - Spec: v1.PrometheusRuleSpec{ - Groups: []v1.RuleGroup{ - { - Name: "example-group", - Rules: []v1.Rule{ - { - Alert: req.Name, - Expr: intstr.FromString(req.PromQL), - For: &ruleDuration, - Labels: map[string]string{ - "severity": req.AlertLevel, - }, - Annotations: map[string]string{"description": req.Annotations}, - }, - }, - }, - }, - }, - } - - ruleBytes, err := json.Marshal(rule) - if err != nil { - return err - } - - // create prometheus rule - response, err = l.svcCtx.HttpClient.R(). - SetBody(&OperateStruct{ - ClusterName: req.ClusterName, - YamlString: string(ruleBytes), - }). - ForceContentType("application/json"). - Post(server + "/api/v1/operate/apply") - if err != nil || response.IsError() { - return err - } - - return nil -} - -type OperateStruct struct { - ClusterName string `json:"clusterName"` - YamlString string `json:"yamlString"` -} diff --git a/api/internal/logic/monitoring/deletealertrulelogic.go b/api/internal/logic/monitoring/deletealertrulelogic.go deleted file mode 100644 index aa718829..00000000 --- a/api/internal/logic/monitoring/deletealertrulelogic.go +++ /dev/null @@ -1,66 +0,0 @@ -package monitoring - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteAlertRuleLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteAlertRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlertRuleLogic { - return &DeleteAlertRuleLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteAlertRuleLogic) DeleteAlertRule(req *types.DeleteAlertRuleReq) error { - // Delete data from the database - l.svcCtx.DbEngin.Delete(&types.AlertRule{}, "id = ?", req.Id) - - // query cluster http url. - var server string - l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) - - // create prometheus rule - response, err := l.svcCtx.HttpClient.R(). - SetBody(&CrdStruct{ - ClusterName: req.ClusterName, - Name: req.Name, - Grv: Grv{ - Group: "monitoring.coreos.com", - Version: "v1", - Resource: "prometheusrules", - }, - }). - ForceContentType("application/json"). - Delete(server + "/api/v1/crd") - if err != nil { - return err - } - if err != nil || response.IsError() { - return err - } - return nil -} - -type Grv struct { - Group string `json:"group"` - Version string `json:"version"` - Resource string `json:"resource"` -} - -type CrdStruct struct { - ClusterName string `json:"clusterName"` - Grv Grv `json:"grv"` - Name string `json:"name"` -} diff --git a/api/internal/logic/monitoring/nodesloadtoplogic.go b/api/internal/logic/monitoring/nodesloadtoplogic.go deleted file mode 100644 index 5a1fd7e2..00000000 --- a/api/internal/logic/monitoring/nodesloadtoplogic.go +++ /dev/null @@ -1,44 +0,0 @@ -package monitoring - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type NodesLoadTopLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewNodesLoadTopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NodesLoadTopLogic { - return &NodesLoadTopLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *NodesLoadTopLogic) NodesLoadTop(req *types.NodesLoadTopReq) (resp *types.NodesLoadTopResp, err error) { - - resp = &types.NodesLoadTopResp{} - - var server string - l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) - response, err := l.svcCtx.HttpClient.R(). - SetQueryParams(map[string]string{ - "clusterName": req.ClusterName, - "metrics": req.Metrics, - }). - SetResult(&resp). - ForceContentType("application/json"). - Get(server + "/api/v1/monitoring/node") - if err != nil || response.IsError() { - return nil, err - } - return resp, nil -} diff --git a/api/internal/logic/monitoring/schedulesituationlogic.go b/api/internal/logic/monitoring/schedulesituationlogic.go deleted file mode 100644 index d2b41697..00000000 --- a/api/internal/logic/monitoring/schedulesituationlogic.go +++ /dev/null @@ -1,82 +0,0 @@ -package monitoring - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "strings" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleSituationLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleSituationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleSituationLogic { - return &ScheduleSituationLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleSituationLogic) ScheduleSituation() (resp *types.ScheduleSituationResp, err error) { - resp = &types.ScheduleSituationResp{} - // node region - tx := l.svcCtx.DbEngin.Raw("SELECT c.id, c.name, tdi.id AS category, count(DISTINCT ta.id)+count(DISTINCT tc.id)+COUNT(DISTINCT th.id)+COUNT(tv.id) as value FROM t_cluster c LEFT JOIN t_dict_item tdi ON c.region_dict = tdi.id left JOIN task_ai ta ON ta.cluster_id = c.id left JOIN task_cloud tc ON tc.cluster_id = c.id left JOIN task_hpc th ON th.cluster_id = c.id left JOIN task_vm tv ON tv.cluster_id = c.id WHERE tc.deleted_at IS NULL GROUP BY c.id").Scan(&resp.Nodes) - if tx.Error != nil { - return nil, tx.Error - } - - // hpc - var hpcLinks []string - tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT( distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_hpc WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&hpcLinks) - if tx.Error != nil { - return nil, tx.Error - } - LinksHandler(hpcLinks, resp) - // cloud - var cloudLinks []string - tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT(distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_cloud WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&cloudLinks) - if tx.Error != nil { - return nil, tx.Error - } - LinksHandler(cloudLinks, resp) - // ai - var aiLinks []string - tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT(distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_ai WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&aiLinks) - if tx.Error != nil { - return nil, tx.Error - } - LinksHandler(aiLinks, resp) - // vm - var vmLinks []string - tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT(distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_vm WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&vmLinks) - if tx.Error != nil { - return nil, tx.Error - } - LinksHandler(vmLinks, resp) - - // categories - tx = l.svcCtx.DbEngin.Raw("select tdi.item_text as name from t_dict_item tdi,t_dict td where td.dict_code = 'cluster_region_dict' and tdi.dict_id = td.id").Scan(&resp.Categories) - if tx.Error != nil { - return nil, tx.Error - } - return resp, nil -} - -func LinksHandler(sources []string, resp *types.ScheduleSituationResp) { - for _, source := range sources { - links := strings.Split(source, ",") - - for i := 1; i < len(links); i++ { - if links[i] != links[i-1] { - resp.Links = append(resp.Links, types.Link{Source: links[i], Target: links[i-1]}) - } - } - } - -} diff --git a/api/internal/logic/monitoring/syncclusteralertlogic.go b/api/internal/logic/monitoring/syncclusteralertlogic.go deleted file mode 100644 index 11e8eef3..00000000 --- a/api/internal/logic/monitoring/syncclusteralertlogic.go +++ /dev/null @@ -1,44 +0,0 @@ -package monitoring - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "k8s.io/apimachinery/pkg/util/json" - "time" - - "github.com/zeromicro/go-zero/core/logx" -) - -type SyncClusterAlertLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewSyncClusterAlertLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncClusterAlertLogic { - return &SyncClusterAlertLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *SyncClusterAlertLogic) SyncClusterAlert(req *types.SyncClusterAlertReq) error { - - if len(req.AlertRecordsMap) != 0 { - for k, v := range req.AlertRecordsMap { - bytes, err := json.Marshal(v) - if err != nil { - return err - } - setCmd := l.svcCtx.RedisClient.Set(l.ctx, k, bytes, 1*time.Minute) - if setCmd.Err() != nil { - logx.Error(setCmd.Err()) - } - - } - } - - return nil -} diff --git a/api/internal/logic/monitoring/tasknumlogic.go b/api/internal/logic/monitoring/tasknumlogic.go deleted file mode 100644 index 0b7f1659..00000000 --- a/api/internal/logic/monitoring/tasknumlogic.go +++ /dev/null @@ -1,33 +0,0 @@ -package monitoring - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type TaskNumLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewTaskNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskNumLogic { - return &TaskNumLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *TaskNumLogic) TaskNum(req *types.TaskNumReq) (resp *types.TaskNumResp, err error) { - resp = &types.TaskNumResp{} - l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ? and status = 'running'", req.ClusterId).Scan(resp.Current) - l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = '' and DATE(start_time) = CURDATE()", req.ClusterId).Scan(resp.Today) - l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ?", req.ClusterId).Scan(resp.History) - l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ? and status = 'failed'", req.ClusterId).Scan(resp.Failed) - return resp, nil -} diff --git a/api/internal/logic/schedule/downloadalgothmcodelogic.go b/api/internal/logic/schedule/downloadalgothmcodelogic.go deleted file mode 100644 index 03800fe7..00000000 --- a/api/internal/logic/schedule/downloadalgothmcodelogic.go +++ /dev/null @@ -1,37 +0,0 @@ -package schedule - -import ( - "context" - "strings" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DownloadAlgothmCodeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDownloadAlgothmCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadAlgothmCodeLogic { - return &DownloadAlgothmCodeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DownloadAlgothmCodeLogic) DownloadAlgorithmCode(req *types.DownloadAlgorithmCodeReq) (resp *types.DownloadAlgorithmCodeResp, err error) { - resp = &types.DownloadAlgorithmCodeResp{} - code, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].DownloadAlgorithmCode(l.ctx, - req.ResourceType, strings.ToLower(req.Card), req.TaskType, req.Dataset, req.Algorithm) - if err != nil { - return nil, err - } - resp.Code = code - - return resp, nil -} diff --git a/api/internal/logic/schedule/getclusterbalancebyidlogic.go b/api/internal/logic/schedule/getclusterbalancebyidlogic.go deleted file mode 100644 index 09f70b2c..00000000 --- a/api/internal/logic/schedule/getclusterbalancebyidlogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package schedule - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetClusterBalanceByIdLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetClusterBalanceByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterBalanceByIdLogic { - return &GetClusterBalanceByIdLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetClusterBalanceByIdLogic) GetClusterBalanceById(req *types.GetClusterBalanceByIdReq) (resp *types.GetClusterBalanceByIdResp, err error) { - resp = &types.GetClusterBalanceByIdResp{} - balance, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].GetUserBalance(l.ctx) - if err != nil { - return nil, err - } - resp.Balance = balance - - return resp, nil -} diff --git a/api/internal/logic/schedule/getcomputecardsbyclusterlogic.go b/api/internal/logic/schedule/getcomputecardsbyclusterlogic.go deleted file mode 100644 index 4cb94f91..00000000 --- a/api/internal/logic/schedule/getcomputecardsbyclusterlogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package schedule - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetComputeCardsByClusterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetComputeCardsByClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputeCardsByClusterLogic { - return &GetComputeCardsByClusterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetComputeCardsByClusterLogic) GetComputeCardsByCluster(req *types.GetComputeCardsByClusterReq) (resp *types.GetComputeCardsByClusterResp, err error) { - resp = &types.GetComputeCardsByClusterResp{} - cards, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].GetComputeCards(l.ctx) - if err != nil { - return nil, err - } - resp.Cards = cards - - return resp, nil -} diff --git a/api/internal/logic/schedule/schedulegetaijoblogloglogic.go b/api/internal/logic/schedule/schedulegetaijoblogloglogic.go deleted file mode 100644 index e0f304de..00000000 --- a/api/internal/logic/schedule/schedulegetaijoblogloglogic.go +++ /dev/null @@ -1,40 +0,0 @@ -package schedule - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleGetAiJobLogLogLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleGetAiJobLogLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAiJobLogLogLogic { - return &ScheduleGetAiJobLogLogLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleGetAiJobLogLogLogic) ScheduleGetAiJobLogLog(req *types.AiJobLogReq) (resp *types.AiJobLogResp, err error) { - resp = &types.AiJobLogResp{} - - id, err := l.svcCtx.Scheduler.AiStorages.GetAiTaskIdByClusterIdAndTaskId(req.ClusterId, req.TaskId) - if err != nil { - return nil, err - } - log, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].GetTrainingTaskLog(l.ctx, id, req.InstanceNum) - if err != nil { - return nil, err - } - - resp.Log = log - return resp, nil -} diff --git a/api/internal/logic/schedule/schedulegetairesourcetypeslogic.go b/api/internal/logic/schedule/schedulegetairesourcetypeslogic.go deleted file mode 100644 index 0b0ff2d2..00000000 --- a/api/internal/logic/schedule/schedulegetairesourcetypeslogic.go +++ /dev/null @@ -1,33 +0,0 @@ -package schedule - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleGetAiResourceTypesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleGetAiResourceTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAiResourceTypesLogic { - return &ScheduleGetAiResourceTypesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleGetAiResourceTypesLogic) ScheduleGetAiResourceTypes() (resp *types.AiResourceTypesResp, err error) { - resp = &types.AiResourceTypesResp{} - resourceTypes := storeLink.GetResourceTypes() - resp.ResourceTypes = resourceTypes - - return resp, nil -} diff --git a/api/internal/logic/schedule/schedulegetaitasktypeslogic.go b/api/internal/logic/schedule/schedulegetaitasktypeslogic.go deleted file mode 100644 index 4f34944b..00000000 --- a/api/internal/logic/schedule/schedulegetaitasktypeslogic.go +++ /dev/null @@ -1,33 +0,0 @@ -package schedule - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleGetAiTaskTypesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleGetAiTaskTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAiTaskTypesLogic { - return &ScheduleGetAiTaskTypesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleGetAiTaskTypesLogic) ScheduleGetAiTaskTypes() (resp *types.AiTaskTypesResp, err error) { - resp = &types.AiTaskTypesResp{} - taskTypes := storeLink.GetTaskTypes() - resp.TaskTypes = taskTypes - - return resp, nil -} diff --git a/api/internal/logic/schedule/schedulegetalgorithmslogic.go b/api/internal/logic/schedule/schedulegetalgorithmslogic.go deleted file mode 100644 index 009c44e0..00000000 --- a/api/internal/logic/schedule/schedulegetalgorithmslogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package schedule - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleGetAlgorithmsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleGetAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAlgorithmsLogic { - return &ScheduleGetAlgorithmsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleGetAlgorithmsLogic) ScheduleGetAlgorithms(req *types.AiAlgorithmsReq) (resp *types.AiAlgorithmsResp, err error) { - resp = &types.AiAlgorithmsResp{} - algorithms, err := storeLink.GetAlgorithms(l.ctx, l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId], req.ResourceType, req.TaskType, req.Dataset) - if err != nil { - return nil, err - } - resp.Algorithms = algorithms - return resp, nil -} diff --git a/api/internal/logic/schedule/schedulegetdatasetslogic.go b/api/internal/logic/schedule/schedulegetdatasetslogic.go deleted file mode 100644 index af3a0857..00000000 --- a/api/internal/logic/schedule/schedulegetdatasetslogic.go +++ /dev/null @@ -1,37 +0,0 @@ -package schedule - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleGetDatasetsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleGetDatasetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetDatasetsLogic { - return &ScheduleGetDatasetsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleGetDatasetsLogic) ScheduleGetDatasets(req *types.AiDatasetsReq) (resp *types.AiDatasetsResp, err error) { - resp = &types.AiDatasetsResp{} - names, err := storeLink.GetDatasetsNames(l.ctx, l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId]) - if err != nil { - logx.Errorf("GetDatasetsNames err: %v", err) - return nil, errors.New("网络异常,请稍后重试.") - } - resp.Datasets = names - return resp, nil -} diff --git a/api/internal/logic/schedule/schedulegetoverviewlogic.go b/api/internal/logic/schedule/schedulegetoverviewlogic.go deleted file mode 100644 index f3ab02af..00000000 --- a/api/internal/logic/schedule/schedulegetoverviewlogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package schedule - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleGetOverviewLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleGetOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetOverviewLogic { - return &ScheduleGetOverviewLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleGetOverviewLogic) ScheduleGetOverview() (resp *types.ScheduleOverviewResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/api/internal/logic/schedule/schedulegetstrategylogic.go b/api/internal/logic/schedule/schedulegetstrategylogic.go deleted file mode 100644 index d9d2c950..00000000 --- a/api/internal/logic/schedule/schedulegetstrategylogic.go +++ /dev/null @@ -1,32 +0,0 @@ -package schedule - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleGetStrategyLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleGetStrategyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetStrategyLogic { - return &ScheduleGetStrategyLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleGetStrategyLogic) ScheduleGetStrategy() (resp *types.AiStrategyResp, err error) { - resp = &types.AiStrategyResp{} - names := strategy.GetStrategyNames() - resp.Strategies = names - - return resp, nil -} diff --git a/api/internal/logic/schedule/schedulesubmitlogic.go b/api/internal/logic/schedule/schedulesubmitlogic.go deleted file mode 100644 index fdcd4f2f..00000000 --- a/api/internal/logic/schedule/schedulesubmitlogic.go +++ /dev/null @@ -1,106 +0,0 @@ -package schedule - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "strconv" - "strings" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScheduleSubmitLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScheduleSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleSubmitLogic { - return &ScheduleSubmitLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *types.ScheduleResp, err error) { - resp = &types.ScheduleResp{} - opt := &option.AiOption{ - AdapterId: req.AiOption.AdapterId, - ClusterIds: req.AiOption.AiClusterIds, - TaskName: req.AiOption.TaskName, - ResourceType: req.AiOption.ResourceType, - Replica: req.AiOption.Replica, - ComputeCard: req.AiOption.ComputeCard, - Tops: req.AiOption.Tops, - TaskType: req.AiOption.TaskType, - DatasetsName: req.AiOption.Datasets, - AlgorithmName: req.AiOption.Algorithm, - StrategyName: req.AiOption.Strategy, - ClusterToStaticWeight: req.AiOption.StaticWeightMap, - Params: req.AiOption.Params, - Envs: req.AiOption.Envs, - Cmd: req.AiOption.Cmd, - } - aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt) - if err != nil { - return nil, err - } - - results, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl) - if err != nil { - return nil, err - } - - switch opt.GetOptionType() { - case option.AI: - rs := (results).([]*schedulers.AiResult) - var synergystatus int64 - if len(rs) > 1 { - synergystatus = 1 - } - strategyCode, err := l.svcCtx.Scheduler.AiStorages.GetStrategyCode(req.AiOption.Strategy) - if err != nil { - return nil, err - } - adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(rs[0].AdapterId) - if err != nil { - return nil, err - } - id, err := l.svcCtx.Scheduler.AiStorages.SaveTask(req.AiOption.TaskName, strategyCode, synergystatus, "10") - if err != nil { - return nil, err - } - - for _, r := range rs { - scheResult := &types.ScheduleResult{} - scheResult.ClusterId = r.ClusterId - scheResult.TaskId = strconv.FormatInt(id, 10) - scheResult.JobId = r.JobId - scheResult.Strategy = r.Strategy - scheResult.Card = strings.ToUpper(r.Card) - scheResult.Replica = r.Replica - scheResult.Msg = r.Msg - - opt.ComputeCard = strings.ToUpper(r.Card) - - clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(r.ClusterId) - - err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, r.ClusterId, clusterName, r.JobId, constants.Saved, r.Msg) - if err != nil { - return nil, err - } - - l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(r.AdapterId, adapterName, r.ClusterId, clusterName, r.TaskName, "create", "任务创建中") - - resp.Results = append(resp.Results, scheResult) - } - - } - - return resp, nil -} diff --git a/api/internal/logic/schedule/uploadalgothmcodelogic.go b/api/internal/logic/schedule/uploadalgothmcodelogic.go deleted file mode 100644 index 052412c4..00000000 --- a/api/internal/logic/schedule/uploadalgothmcodelogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package schedule - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UploadAlgothmCodeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUploadAlgothmCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadAlgothmCodeLogic { - return &UploadAlgothmCodeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UploadAlgothmCodeLogic) UploadAlgorithmCode(req *types.UploadAlgorithmCodeReq) (resp *types.UploadAlgorithmCodeResp, err error) { - resp = &types.UploadAlgorithmCodeResp{} - err = l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].UploadAlgorithmCode(l.ctx, - req.ResourceType, req.Card, req.TaskType, req.Dataset, req.Algorithm, req.Code) - if err != nil { - return nil, err - } - - return resp, nil -} diff --git a/api/internal/logic/storage/dailypowerscreenlogic.go b/api/internal/logic/storage/dailypowerscreenlogic.go deleted file mode 100644 index 804b6b21..00000000 --- a/api/internal/logic/storage/dailypowerscreenlogic.go +++ /dev/null @@ -1,40 +0,0 @@ -package storage - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" - "k8s.io/apimachinery/pkg/util/json" - "strings" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DailyPowerScreenLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DailyPowerScreenLogic { - return &DailyPowerScreenLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DailyPowerScreenLogic) DailyPowerScreen() (resp *types.DailyPowerScreenResp, err error) { - resp = &types.DailyPowerScreenResp{} - statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/dailytrend", strings.NewReader(``)) - - if statusCode == 200 { - json.Unmarshal(body, &resp.Chart) - println(resp) - } else if statusCode != 200 { - return nil, err - } - return resp, nil -} diff --git a/api/internal/logic/storage/percentercomputerpowerslogic.go b/api/internal/logic/storage/percentercomputerpowerslogic.go deleted file mode 100644 index 4813fbb1..00000000 --- a/api/internal/logic/storage/percentercomputerpowerslogic.go +++ /dev/null @@ -1,39 +0,0 @@ -package storage - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" - "k8s.io/apimachinery/pkg/util/json" - "strings" - - "github.com/zeromicro/go-zero/core/logx" -) - -type PerCenterComputerPowersLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPerCenterComputerPowersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerCenterComputerPowersLogic { - return &PerCenterComputerPowersLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers() (resp *types.PerCenterComputerPowersResp, err error) { - resp = &types.PerCenterComputerPowersResp{} - statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/percenter", strings.NewReader(``)) - - if statusCode == 200 { - json.Unmarshal(body, &resp.Chart) - println(resp) - } else if statusCode != 200 { - return nil, err - } - return resp, nil -} diff --git a/api/internal/logic/storage/screenstoragelogic.go b/api/internal/logic/storage/screenstoragelogic.go deleted file mode 100644 index 468a6369..00000000 --- a/api/internal/logic/storage/screenstoragelogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storage - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/jcce-pcm/pcm-participant-ceph/ceph" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ScreenStorageLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewScreenStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScreenStorageLogic { - return &ScreenStorageLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ScreenStorageLogic) ScreenStorage(req *types.StorageScreenReq) (resp *types.StorageScreenResp, err error) { - // todo: add your logic here and delete this line - storageScreenReq := &ceph.StorageScreenReq{} - err = copier.CopyWithOption(storageScreenReq, req, copier.Option{Converters: utils.Converters}) - StorageScreenResp, err := l.svcCtx.CephRpc.StorageScreen(l.ctx, storageScreenReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db storage list"), "Failed to get db storage list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&StorageScreenResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &StorageScreenResp, copier.Option{Converters: utils.Converters}) - return resp, nil -} diff --git a/api/internal/logic/storelink/deletelinkimagelogic.go b/api/internal/logic/storelink/deletelinkimagelogic.go deleted file mode 100644 index 6b2f91e5..00000000 --- a/api/internal/logic/storelink/deletelinkimagelogic.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteLinkImageLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkImageLogic { - return &DeleteLinkImageLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteLinkImageLogic) DeleteLinkImage(req *types.DeleteLinkImageReq) (resp *types.DeleteLinkImageResp, err error) { - participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) - if *participant == (models.StorelinkCenter{}) { - resp = &types.DeleteLinkImageResp{} - resp.Success = false - resp.ErrorMsg = "partId不存在" - return resp, nil - } - - storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) - if storelink == nil { - return nil, nil - } - - img, err := storelink.ILinkage.DeleteImage(l.ctx, req.ImageId) - if err != nil { - return nil, err - } - if img == nil { - return nil, storeLink.ERROR_RESP_EMPTY - } - - resp = &types.DeleteLinkImageResp{} - //转换成统一返回类型 - imgResp, err := storeLink.ConvertType(img, resp, participant) - if err != nil { - return nil, err - } - if imgResp == nil { - return nil, storeLink.ERROR_CONVERT_EMPTY - } - - return imgResp.(*types.DeleteLinkImageResp), nil -} diff --git a/api/internal/logic/storelink/deletelinktasklogic.go b/api/internal/logic/storelink/deletelinktasklogic.go deleted file mode 100644 index 1321f983..00000000 --- a/api/internal/logic/storelink/deletelinktasklogic.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteLinkTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkTaskLogic { - return &DeleteLinkTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteLinkTaskLogic) DeleteLinkTask(req *types.DeleteLinkTaskReq) (resp *types.DeleteLinkTaskResp, err error) { - participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) - if *participant == (models.StorelinkCenter{}) { - resp = &types.DeleteLinkTaskResp{} - resp.Success = false - resp.ErrorMsg = "partId不存在" - return resp, nil - } - - storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) - if storelink == nil { - return nil, nil - } - - task, err := storelink.ILinkage.DeleteTask(l.ctx, req.TaskId) - if err != nil { - return nil, err - } - if task == nil { - return nil, storeLink.ERROR_RESP_EMPTY - } - - resp = &types.DeleteLinkTaskResp{} - //转换成统一返回类型 - taskResp, err := storeLink.ConvertType(task, resp, participant) - if err != nil { - return nil, err - } - if taskResp == nil { - return nil, storeLink.ERROR_CONVERT_EMPTY - } - - return taskResp.(*types.DeleteLinkTaskResp), nil -} diff --git a/api/internal/logic/storelink/getaispecslogic.go b/api/internal/logic/storelink/getaispecslogic.go deleted file mode 100644 index 2ba8ee38..00000000 --- a/api/internal/logic/storelink/getaispecslogic.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" -) - -type GetAISpecsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetAISpecsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAISpecsLogic { - return &GetAISpecsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetAISpecsLogic) GetAISpecs(req *types.GetResourceSpecsReq) (resp *types.GetResourceSpecsResp, err error) { - participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) - if *participant == (models.StorelinkCenter{}) { - resp = &types.GetResourceSpecsResp{} - resp.Success = false - resp.ResourceSpecs = nil - resp.ErrorMsg = "partId不存在" - return resp, nil - } - - storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) - if storelink == nil { - return nil, nil - } - - specs, err := storelink.ILinkage.QuerySpecs(l.ctx) - if err != nil { - return nil, err - } - if specs == nil { - return nil, storeLink.ERROR_RESP_EMPTY - } - - resp = &types.GetResourceSpecsResp{} - //转换成统一返回类型 - specsResp, err := storeLink.ConvertType(specs, resp, participant) - if err != nil { - return nil, err - } - if specsResp == nil { - return nil, storeLink.ERROR_CONVERT_EMPTY - } - - return specsResp.(*types.GetResourceSpecsResp), nil -} diff --git a/api/internal/logic/storelink/getlinkimagelistlogic.go b/api/internal/logic/storelink/getlinkimagelistlogic.go deleted file mode 100644 index 9e811da8..00000000 --- a/api/internal/logic/storelink/getlinkimagelistlogic.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" -) - -type GetLinkImageListLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetLinkImageListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLinkImageListLogic { - return &GetLinkImageListLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetLinkImageListLogic) GetLinkImageList(req *types.GetLinkImageListReq) (resp *types.GetLinkImageListResp, err error) { - participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) - if *participant == (models.StorelinkCenter{}) { - resp = &types.GetLinkImageListResp{} - resp.Success = false - resp.Images = nil - resp.ErrorMsg = "partId不存在" - return resp, nil - } - - storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) - if storelink == nil { - return nil, nil - } - - list, err := storelink.ILinkage.QueryImageList(l.ctx) - if err != nil { - return nil, err - } - if list == nil { - return nil, storeLink.ERROR_RESP_EMPTY - } - - resp = &types.GetLinkImageListResp{} - //转换成统一返回类型 - listResp, err := storeLink.ConvertType(list, resp, participant) - if err != nil { - return nil, err - } - if listResp == nil { - return nil, storeLink.ERROR_CONVERT_EMPTY - } - - return listResp.(*types.GetLinkImageListResp), nil -} diff --git a/api/internal/logic/storelink/getlinktasklogic.go b/api/internal/logic/storelink/getlinktasklogic.go deleted file mode 100644 index 97aab7af..00000000 --- a/api/internal/logic/storelink/getlinktasklogic.go +++ /dev/null @@ -1,75 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetLinkTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLinkTaskLogic { - return &GetLinkTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetLinkTaskLogic) GetLinkTask(req *types.GetLinkTaskReq) (resp *types.GetLinkTaskResp, err error) { - participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) - if *participant == (models.StorelinkCenter{}) { - resp = &types.GetLinkTaskResp{} - resp.Success = false - resp.Task = nil - resp.ErrorMsg = "partId不存在" - return resp, nil - } - - storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) - if storelink == nil { - return nil, nil - } - - task, err := storelink.ILinkage.QueryTask(l.ctx, req.TaskId) - if err != nil { - return nil, err - } - if task == nil { - return nil, storeLink.ERROR_RESP_EMPTY - } - - resp = &types.GetLinkTaskResp{} - //转换成统一返回类型 - taskResp, err := storeLink.ConvertType(task, resp, participant) - if err != nil { - return nil, err - } - if taskResp == nil { - return nil, storeLink.ERROR_CONVERT_EMPTY - } - - return taskResp.(*types.GetLinkTaskResp), nil -} diff --git a/api/internal/logic/storelink/getparticipantslogic.go b/api/internal/logic/storelink/getparticipantslogic.go deleted file mode 100644 index b71f7bee..00000000 --- a/api/internal/logic/storelink/getparticipantslogic.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -type GetParticipantsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetParticipantsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetParticipantsLogic { - return &GetParticipantsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetParticipantsLogic) GetParticipants(req *types.GetParticipantsReq) (resp *types.GetParticipantsResp, err error) { - participants := storeLink.GetParticipants(l.svcCtx.DbEngin) - resp = &types.GetParticipantsResp{} - - if participants == nil { - resp.Success = false - resp.Participants = nil - return resp, nil - } - - for _, participant := range participants { - var p types.ParticipantSl - p.ParticipantId = participant.Id - p.ParticipantType = storeLink.AITYPE[participant.Type] - p.ParticipantName = participant.Name - resp.Participants = append(resp.Participants, &p) - } - - resp.Success = true - return resp, nil - -} diff --git a/api/internal/logic/storelink/submitlinktasklogic.go b/api/internal/logic/storelink/submitlinktasklogic.go deleted file mode 100644 index 5e8f9d14..00000000 --- a/api/internal/logic/storelink/submitlinktasklogic.go +++ /dev/null @@ -1,86 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "github.com/zeromicro/go-zero/core/logx" -) - -type SubmitLinkTaskLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitLinkTaskLogic { - return &SubmitLinkTaskLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) { - participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) - if *participant == (models.StorelinkCenter{}) { - resp = &types.SubmitLinkTaskResp{} - resp.Success = false - resp.TaskId = "" - resp.ErrorMsg = "partId不存在" - return resp, nil - } - - storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) - if storelink == nil { - return nil, nil - } - - var params []string - if len(req.Params) != 0 { - for _, v := range req.Params { - param := v.Key + storeLink.COMMA + v.Val - params = append(params, param) - } - } - var envs []string - if len(req.Envs) != 0 { - for _, v := range req.Envs { - env := v.Key + storeLink.COMMA + v.Val - envs = append(envs, env) - } - } - task, err := storelink.ILinkage.SubmitTask(l.ctx, req.ImageId, req.Cmd, envs, params, req.ResourceId, "", "", "pytorch") - if err != nil { - return nil, err - } - - resp = &types.SubmitLinkTaskResp{} - //转换成统一返回类型 - taskResp, err := storeLink.ConvertType(task, resp, participant) - if err != nil { - return nil, err - } - if taskResp == nil { - return nil, storeLink.ERROR_CONVERT_EMPTY - } - - return taskResp.(*types.SubmitLinkTaskResp), nil -} diff --git a/api/internal/logic/storelink/uploadlinkimagelogic.go b/api/internal/logic/storelink/uploadlinkimagelogic.go deleted file mode 100644 index 60beade5..00000000 --- a/api/internal/logic/storelink/uploadlinkimagelogic.go +++ /dev/null @@ -1,75 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storelink - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UploadLinkImageLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUploadLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLinkImageLogic { - return &UploadLinkImageLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UploadLinkImageLogic) UploadLinkImage(req *types.UploadLinkImageReq) (resp *types.UploadLinkImageResp, err error) { - participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) - if *participant == (models.StorelinkCenter{}) { - resp = &types.UploadLinkImageResp{} - resp.Success = false - resp.Image = nil - resp.ErrorMsg = "partId不存在" - return resp, nil - } - - storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) - if storelink == nil { - return nil, nil - } - - img, err := storelink.ILinkage.UploadImage(l.ctx, req.FilePath) - if err != nil { - return nil, err - } - if img == nil { - return nil, storeLink.ERROR_RESP_EMPTY - } - - resp = &types.UploadLinkImageResp{} - //转换成统一返回类型 - imgResp, err := storeLink.ConvertType(img, resp, participant) - if err != nil { - return nil, err - } - if imgResp == nil { - return nil, storeLink.ERROR_CONVERT_EMPTY - } - - return imgResp.(*types.UploadLinkImageResp), nil -} diff --git a/api/internal/logic/vm/addsecuritygrouptoserverlogic.go b/api/internal/logic/vm/addsecuritygrouptoserverlogic.go deleted file mode 100644 index 6723703f..00000000 --- a/api/internal/logic/vm/addsecuritygrouptoserverlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type AddSecurityGroupToServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAddSecurityGroupToServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddSecurityGroupToServerLogic { - return &AddSecurityGroupToServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AddSecurityGroupToServerLogic) AddSecurityGroupToServer(req *types.AddSecurityGroupToServerReq) (resp *types.AddSecurityGroupToServerResp, err error) { - // todo: add your logic here and delete this line - AddSecurityGroupToServerReq := &openstack.AddSecurityGroupToServerReq{} - err = copier.CopyWithOption(AddSecurityGroupToServerReq, req, copier.Option{Converters: utils.Converters}) - AddSecurityGroupToServerResp, err := l.svcCtx.OpenstackRpc.AddSecurityGroupToServer(l.ctx, AddSecurityGroupToServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&AddSecurityGroupToServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &AddSecurityGroupToServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/bulkcreatenetworkslogic.go b/api/internal/logic/vm/bulkcreatenetworkslogic.go deleted file mode 100644 index a23c55e7..00000000 --- a/api/internal/logic/vm/bulkcreatenetworkslogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type BulkCreateNetworksLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewBulkCreateNetworksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BulkCreateNetworksLogic { - return &BulkCreateNetworksLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *BulkCreateNetworksLogic) BulkCreateNetworks(req *types.BulkCreateNetworksReq) (resp *types.BulkCreateNetworksResp, err error) { - // todo: add your logic here and delete this line - BulkCreateNetworksReq := &openstack.BulkCreateNetworksReq{} - err = copier.CopyWithOption(BulkCreateNetworksReq, req, copier.Option{Converters: tool.Converters}) - BulkCreateNetworksResp, err := l.svcCtx.OpenstackRpc.BulkCreateNetworks(l.ctx, BulkCreateNetworksReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&BulkCreateNetworksResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &BulkCreateNetworksResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/changeadministrativepasswordlogic.go b/api/internal/logic/vm/changeadministrativepasswordlogic.go deleted file mode 100644 index a87dba17..00000000 --- a/api/internal/logic/vm/changeadministrativepasswordlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ChangeAdministrativePasswordLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewChangeAdministrativePasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChangeAdministrativePasswordLogic { - return &ChangeAdministrativePasswordLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ChangeAdministrativePasswordLogic) ChangeAdministrativePassword(req *types.ChangeAdministrativePasswordReq) (resp *types.ChangeAdministrativePasswordResp, err error) { - // todo: add your logic here and delete this line - ChangeAdministrativePasswordReq := &openstack.ChangeAdministrativePasswordReq{} - err = copier.CopyWithOption(ChangeAdministrativePasswordReq, req, copier.Option{Converters: utils.Converters}) - ChangeAdministrativePasswordResp, err := l.svcCtx.OpenstackRpc.ChangeAdministrativePassword(l.ctx, ChangeAdministrativePasswordReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ChangeAdministrativePasswordResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ChangeAdministrativePasswordResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createfirewallgrouplogic.go b/api/internal/logic/vm/createfirewallgrouplogic.go deleted file mode 100644 index 1a4fafa0..00000000 --- a/api/internal/logic/vm/createfirewallgrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateFirewallGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateFirewallGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFirewallGroupLogic { - return &CreateFirewallGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateFirewallGroupLogic) CreateFirewallGroup(req *types.CreateFirewallGroupReq) (resp *types.CreateFirewallGroupResp, err error) { - // todo: add your logic here and delete this line - CreateFirewallGroupReq := &openstack.CreateFirewallGroupReq{} - err = copier.CopyWithOption(CreateFirewallGroupReq, req, copier.Option{Converters: utils.Converters}) - CreateFirewallGroupResp, err := l.svcCtx.OpenstackRpc.CreateFirewallGroup(l.ctx, CreateFirewallGroupReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateFirewallGroupResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateFirewallGroupResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createfirewallpolicylogic.go b/api/internal/logic/vm/createfirewallpolicylogic.go deleted file mode 100644 index ea58bfdd..00000000 --- a/api/internal/logic/vm/createfirewallpolicylogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateFirewallPolicyLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateFirewallPolicyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFirewallPolicyLogic { - return &CreateFirewallPolicyLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateFirewallPolicyLogic) CreateFirewallPolicy(req *types.CreateFirewallPolicyReq) (resp *types.CreateFirewallPolicyResp, err error) { - // todo: add your logic here and delete this line - CreateFirewallPolicyReq := &openstack.CreateFirewallPolicyReq{} - err = copier.CopyWithOption(CreateFirewallPolicyReq, req, copier.Option{Converters: utils.Converters}) - CreateFirewallPolicyResp, err := l.svcCtx.OpenstackRpc.CreateFirewallPolicy(l.ctx, CreateFirewallPolicyReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateFirewallPolicyResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateFirewallPolicyResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createfirewallrulelogic.go b/api/internal/logic/vm/createfirewallrulelogic.go deleted file mode 100644 index 2ecf318a..00000000 --- a/api/internal/logic/vm/createfirewallrulelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateFirewallRuleLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateFirewallRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFirewallRuleLogic { - return &CreateFirewallRuleLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateFirewallRuleLogic) CreateFirewallRule(req *types.CreateFirewallRuleReq) (resp *types.CreateFirewallRuleResp, err error) { - // todo: add your logic here and delete this line - CreateFirewallRuleReq := &openstack.CreateFirewallRuleReq{} - err = copier.CopyWithOption(CreateFirewallRuleReq, req, copier.Option{Converters: utils.Converters}) - CreateFirewallRuleResp, err := l.svcCtx.OpenstackRpc.CreateFirewallRule(l.ctx, CreateFirewallRuleReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateFirewallRuleResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateFirewallRuleResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createflavorlogic.go b/api/internal/logic/vm/createflavorlogic.go deleted file mode 100644 index 3d414ed0..00000000 --- a/api/internal/logic/vm/createflavorlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateFlavorLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateFlavorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFlavorLogic { - return &CreateFlavorLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateFlavorLogic) CreateFlavor(req *types.CreateFlavorReq) (resp *types.CreateFlavorResp, err error) { - // todo: add your logic here and delete this line - CreateFlavorReq := &openstack.CreateFlavorReq{} - err = copier.CopyWithOption(CreateFlavorReq, req, copier.Option{Converters: utils.Converters}) - CreateFlavorResp, err := l.svcCtx.OpenstackRpc.CreateFlavor(l.ctx, CreateFlavorReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateFlavorResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateFlavorResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createfloatingiplogic.go b/api/internal/logic/vm/createfloatingiplogic.go deleted file mode 100644 index de300dc8..00000000 --- a/api/internal/logic/vm/createfloatingiplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateFloatingIPLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateFloatingIPLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFloatingIPLogic { - return &CreateFloatingIPLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateFloatingIPLogic) CreateFloatingIP(req *types.CreateFloatingIPReq) (resp *types.CreateFloatingIPResp, err error) { - // todo: add your logic here and delete this line - CreateFloatingIPReq := &openstack.CreateFloatingIPReq{} - err = copier.CopyWithOption(CreateFloatingIPReq, req, copier.Option{Converters: utils.Converters}) - CreateFloatingIPResp, err := l.svcCtx.OpenstackRpc.CreateFloatingIP(l.ctx, CreateFloatingIPReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateFloatingIPResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateFloatingIPResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createimagelogic.go b/api/internal/logic/vm/createimagelogic.go deleted file mode 100644 index 264e9341..00000000 --- a/api/internal/logic/vm/createimagelogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "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: utils.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: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createmulserverlogic.go b/api/internal/logic/vm/createmulserverlogic.go deleted file mode 100644 index b59f575c..00000000 --- a/api/internal/logic/vm/createmulserverlogic.go +++ /dev/null @@ -1,82 +0,0 @@ -package vm - -import ( - "context" - "fmt" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateMulServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateMulServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMulServerLogic { - return &CreateMulServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -// ServerLinks 表示服务器链接的结构体 -type ServerLinks struct { - Href string `json:"href"` // 注意:在JSON中,"href "有一个额外的空格,需要移除 - Rel string `json:"rel"` -} - -// SecurityGroup 表示安全组的结构体 -type SecurityGroup struct { - Name string `json:"name"` -} - -// Server 表示服务器的结构体 -type Server struct { - ID string `json:"id"` - Links []ServerLinks `json:"links"` - OSDCFDiskConfig string `json:"OS_DCF_diskConfig"` - SecurityGroups []SecurityGroup `json:"security_groups"` - AdminPass string `json:"adminPass"` -} - -// Response 表示整个响应的结构体 -type Response struct { - Server Server `json:"server"` -} - -func (l *CreateMulServerLogic) CreateMulServer(req *types.CreateMulServerReq) (resp *types.CreateMulServerResp, err error) { - // todo: add your logic here and delete this line - CreateServerReq := &openstack.CreateServerReq{} - var response Response - fmt.Println("请求入参:", req) - for _, server := range req.CreateMulServer { - fmt.Println("入参参数:", server) - err = copier.CopyWithOption(CreateServerReq, server, copier.Option{Converters: utils.Converters}) - CreateServerResp, err := l.svcCtx.OpenstackRpc.CreateServer(l.ctx, CreateServerReq) - fmt.Println("返回结果:", CreateServerResp) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to create Server list"), "Failed to get db Server list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateServerResp) - fmt.Println("返回结果b:", marshal) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &response) - } - err = copier.CopyWithOption(&resp, &response, copier.Option{Converters: utils.Converters}) - fmt.Println("返回结果c:", resp) - return resp, err -} diff --git a/api/internal/logic/vm/createnetworklogic.go b/api/internal/logic/vm/createnetworklogic.go deleted file mode 100644 index 8c2a26b2..00000000 --- a/api/internal/logic/vm/createnetworklogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateNetworkLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNetworkLogic { - return &CreateNetworkLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateNetworkLogic) CreateNetwork(req *types.CreateNetworkReq) (resp *types.CreateNetworkResp, err error) { - // todo: add your logic here and delete this line - CreateNetworkReq := &openstack.CreateNetworkReq{} - err = copier.CopyWithOption(CreateNetworkReq, req, copier.Option{Converters: utils.Converters}) - CreateNetworkResp, err := l.svcCtx.OpenstackRpc.CreateNetwork(l.ctx, CreateNetworkReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateNetworkResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateNetworkResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createnetworksegmentrangelogic.go b/api/internal/logic/vm/createnetworksegmentrangelogic.go deleted file mode 100644 index b9ae3b57..00000000 --- a/api/internal/logic/vm/createnetworksegmentrangelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateNetworkSegmentRangeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateNetworkSegmentRangeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNetworkSegmentRangeLogic { - return &CreateNetworkSegmentRangeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateNetworkSegmentRangeLogic) CreateNetworkSegmentRange(req *types.CreateNetworkSegmentRangeReq) (resp *types.CreateNetworkSegmentRangeResp, err error) { - // todo: add your logic here and delete this line - CreateNetworkSegmentRangeReq := &openstack.CreateNetworkSegmentRangeReq{} - err = copier.CopyWithOption(CreateNetworkSegmentRangeReq, req, copier.Option{Converters: utils.Converters}) - CreateNetworkSegmentRangeResp, err := l.svcCtx.OpenstackRpc.CreateNetworkSegmentRange(l.ctx, CreateNetworkSegmentRangeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateNetworkSegmentRangeResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateNetworkSegmentRangeResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createnodelogic.go b/api/internal/logic/vm/createnodelogic.go deleted file mode 100644 index ee34c790..00000000 --- a/api/internal/logic/vm/createnodelogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateNodeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateNodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNodeLogic { - return &CreateNodeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateNodeLogic) CreateNode(req *types.CreateNodeReq) (resp *types.CreateNodeResp, err error) { - // todo: add your logic here and delete this line - CreateNodeReq := &openstack.CreateNodeReq{} - err = copier.CopyWithOption(CreateNodeReq, req, copier.Option{Converters: tool.Converters}) - CreateNodeResp, err := l.svcCtx.OpenstackRpc.CreateNode(l.ctx, CreateNodeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateNodeResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateNodeResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createportlogic.go b/api/internal/logic/vm/createportlogic.go deleted file mode 100644 index c305da4e..00000000 --- a/api/internal/logic/vm/createportlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreatePortLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreatePortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePortLogic { - return &CreatePortLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreatePortLogic) CreatePort(req *types.CreatePortReq) (resp *types.CreatePortResp, err error) { - // todo: add your logic here and delete this line - CreatePortReq := &openstack.CreatePortReq{} - err = copier.CopyWithOption(CreatePortReq, req, copier.Option{Converters: utils.Converters}) - CreatePortResp, err := l.svcCtx.OpenstackRpc.CreatePort(l.ctx, CreatePortReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreatePortResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreatePortResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createrouterlogic.go b/api/internal/logic/vm/createrouterlogic.go deleted file mode 100644 index aa325a63..00000000 --- a/api/internal/logic/vm/createrouterlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateRouterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateRouterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRouterLogic { - return &CreateRouterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateRouterLogic) CreateRouter(req *types.CreateRouterReq) (resp *types.CreateRouterResp, err error) { - // todo: add your logic here and delete this line - CreateRouterReq := &openstack.CreateRouterReq{} - err = copier.CopyWithOption(CreateRouterReq, req, copier.Option{Converters: utils.Converters}) - CreateRouterResp, err := l.svcCtx.OpenstackRpc.CreateRouter(l.ctx, CreateRouterReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateRouterResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateRouterResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createsecuritygrouplogic.go b/api/internal/logic/vm/createsecuritygrouplogic.go deleted file mode 100644 index ae512392..00000000 --- a/api/internal/logic/vm/createsecuritygrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateSecurityGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSecurityGroupLogic { - return &CreateSecurityGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateSecurityGroupLogic) CreateSecurityGroup(req *types.CreateSecurityGroupReq) (resp *types.CreateSecurityGroupResp, err error) { - // todo: add your logic here and delete this line - CreateSecurityGroupReq := &openstack.CreateSecurityGroupReq{} - err = copier.CopyWithOption(CreateSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) - CreateSecurityGroupResp, err := l.svcCtx.OpenstackRpc.CreateSecurityGroup(l.ctx, CreateSecurityGroupReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateSecurityGroupResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateSecurityGroupResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createsecuritygrouprulelogic.go b/api/internal/logic/vm/createsecuritygrouprulelogic.go deleted file mode 100644 index 00b18cf0..00000000 --- a/api/internal/logic/vm/createsecuritygrouprulelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateSecurityGroupRuleLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateSecurityGroupRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSecurityGroupRuleLogic { - return &CreateSecurityGroupRuleLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateSecurityGroupRuleLogic) CreateSecurityGroupRule(req *types.CreateSecurityGroupRuleReq) (resp *types.CreateSecurityGroupRuleResp, err error) { - // todo: add your logic here and delete this line - CreateSecurityGroupRuleReq := &openstack.CreateSecurityGroupRuleReq{} - err = copier.CopyWithOption(CreateSecurityGroupRuleReq, req, copier.Option{Converters: utils.Converters}) - CreateSecurityGroupRuleResp, err := l.svcCtx.OpenstackRpc.CreateSecurityGroupRule(l.ctx, CreateSecurityGroupRuleReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateSecurityGroupRuleResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateSecurityGroupRuleResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createserverlogic.go b/api/internal/logic/vm/createserverlogic.go deleted file mode 100644 index fec78356..00000000 --- a/api/internal/logic/vm/createserverlogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServerLogic { - return &CreateServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateServerLogic) CreateServer(req *types.CreateServerReq) (resp *types.CreateServerResp, err error) { - // todo: add your logic here and delete this line - CreateServerReq := &openstack.CreateServerReq{} - err = copier.CopyWithOption(CreateServerReq, req, copier.Option{Converters: utils.Converters}) - CreateServerResp, err := l.svcCtx.OpenstackRpc.CreateServer(l.ctx, CreateServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createsubnetlogic.go b/api/internal/logic/vm/createsubnetlogic.go deleted file mode 100644 index 23767979..00000000 --- a/api/internal/logic/vm/createsubnetlogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateSubnetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateSubnetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSubnetLogic { - return &CreateSubnetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateSubnetLogic) CreateSubnet(req *types.CreateSubnetReq) (resp *types.CreateSubnetResp, err error) { - // todo: add your logic here and delete this line - CreateSubnetReq := &openstack.CreateSubnetReq{} - err = copier.CopyWithOption(CreateSubnetReq, req, copier.Option{Converters: utils.Converters}) - CreateSubnetResp, err := l.svcCtx.OpenstackRpc.CreateSubnet(l.ctx, CreateSubnetReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateSubnetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateSubnetResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createvolumelogic.go b/api/internal/logic/vm/createvolumelogic.go deleted file mode 100644 index ce5710ee..00000000 --- a/api/internal/logic/vm/createvolumelogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateVolumeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVolumeLogic { - return &CreateVolumeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateVolumeLogic) CreateVolume(req *types.CreateVolumeReq) (resp *types.CreateVolumeResp, err error) { - // todo: add your logic here and delete this line - CreateVolumeReq := &openstack.CreateVolumeReq{} - err = copier.CopyWithOption(CreateVolumeReq, req, copier.Option{Converters: utils.Converters}) - CreateVolumeResp, err := l.svcCtx.OpenstackRpc.CreateVolume(l.ctx, CreateVolumeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateVolumeResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateVolumeResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/createvolumetypeslogic.go b/api/internal/logic/vm/createvolumetypeslogic.go deleted file mode 100644 index 763e11c7..00000000 --- a/api/internal/logic/vm/createvolumetypeslogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type CreateVolumeTypesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCreateVolumeTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVolumeTypesLogic { - return &CreateVolumeTypesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CreateVolumeTypesLogic) CreateVolumeTypes(req *types.CreateVolumeTypeReq) (resp *types.CreateVolumeTypeResp, err error) { - // todo: add your logic here and delete this line - CreateVolumeTypeReq := &openstack.CreateVolumeTypeReq{} - err = copier.CopyWithOption(CreateVolumeTypeReq, req, copier.Option{Converters: tool.Converters}) - CreateVolumeTypeResp, err := l.svcCtx.OpenstackRpc.CreateVolumeTypes(l.ctx, CreateVolumeTypeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&CreateVolumeTypeResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateVolumeTypeResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletefirewallgrouplogic.go b/api/internal/logic/vm/deletefirewallgrouplogic.go deleted file mode 100644 index ca0d6637..00000000 --- a/api/internal/logic/vm/deletefirewallgrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteFirewallGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteFirewallGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFirewallGroupLogic { - return &DeleteFirewallGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteFirewallGroupLogic) DeleteFirewallGroup(req *types.DeleteFirewallGroupReq) (resp *types.DeleteFirewallGroupResp, err error) { - // todo: add your logic here and delete this line - DeleteFirewallGroupReq := &openstack.DeleteFirewallGroupReq{} - err = copier.CopyWithOption(DeleteFirewallGroupReq, req, copier.Option{Converters: utils.Converters}) - DeleteFirewallGroupResp, err := l.svcCtx.OpenstackRpc.DeleteFirewallGroup(l.ctx, DeleteFirewallGroupReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteFirewallGroupResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteFirewallGroupResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletefirewallpolicylogic.go b/api/internal/logic/vm/deletefirewallpolicylogic.go deleted file mode 100644 index 4fd40561..00000000 --- a/api/internal/logic/vm/deletefirewallpolicylogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteFirewallPolicyLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteFirewallPolicyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFirewallPolicyLogic { - return &DeleteFirewallPolicyLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteFirewallPolicyLogic) DeleteFirewallPolicy(req *types.DeleteFirewallPolicyReq) (resp *types.DeleteFirewallPolicyResp, err error) { - // todo: add your logic here and delete this line - DeleteFirewallPolicyReq := &openstack.DeleteFirewallPolicyReq{} - err = copier.CopyWithOption(DeleteFirewallPolicyReq, req, copier.Option{Converters: utils.Converters}) - DeleteFirewallPolicyResp, err := l.svcCtx.OpenstackRpc.DeleteFirewallPolicy(l.ctx, DeleteFirewallPolicyReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteFirewallPolicyResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteFirewallPolicyResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletefirewallrulelogic.go b/api/internal/logic/vm/deletefirewallrulelogic.go deleted file mode 100644 index 5fd81587..00000000 --- a/api/internal/logic/vm/deletefirewallrulelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteFirewallRuleLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteFirewallRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFirewallRuleLogic { - return &DeleteFirewallRuleLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteFirewallRuleLogic) DeleteFirewallRule(req *types.DeleteFirewallRuleReq) (resp *types.DeleteFirewallRuleResp, err error) { - // todo: add your logic here and delete this line - DeleteFirewallRuleReq := &openstack.DeleteFirewallPolicyReq{} - err = copier.CopyWithOption(DeleteFirewallRuleReq, req, copier.Option{Converters: utils.Converters}) - DeleteFirewallRuleResp, err := l.svcCtx.OpenstackRpc.DeleteFirewallPolicy(l.ctx, DeleteFirewallRuleReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteFirewallRuleResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteFirewallRuleResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deleteflavorlogic.go b/api/internal/logic/vm/deleteflavorlogic.go deleted file mode 100644 index c4e66fa8..00000000 --- a/api/internal/logic/vm/deleteflavorlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteFlavorLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteFlavorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFlavorLogic { - return &DeleteFlavorLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteFlavorLogic) DeleteFlavor(req *types.DeleteFlavorReq) (resp *types.DeleteFlavorResp, err error) { - // todo: add your logic here and delete this line - DeleteFlavorReq := &openstack.DeleteFlavorReq{} - err = copier.CopyWithOption(DeleteFlavorReq, req, copier.Option{Converters: utils.Converters}) - DeleteFlavorResp, err := l.svcCtx.OpenstackRpc.DeleteFlavor(l.ctx, DeleteFlavorReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteFlavorResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteFlavorResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletefloatingiplogic.go b/api/internal/logic/vm/deletefloatingiplogic.go deleted file mode 100644 index e0355b66..00000000 --- a/api/internal/logic/vm/deletefloatingiplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteFloatingIPLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteFloatingIPLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFloatingIPLogic { - return &DeleteFloatingIPLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteFloatingIPLogic) DeleteFloatingIP(req *types.DeleteFloatingIPReq) (resp *types.DeleteFloatingIPResp, err error) { - // todo: add your logic here and delete this line - DeleteFloatingIPReq := &openstack.DeleteFloatingIPReq{} - err = copier.CopyWithOption(DeleteFloatingIPReq, req, copier.Option{Converters: utils.Converters}) - DeleteFloatingIPResp, err := l.svcCtx.OpenstackRpc.DeleteFloatingIP(l.ctx, DeleteFloatingIPReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteFloatingIPResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteFloatingIPResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deleteimagelogic.go b/api/internal/logic/vm/deleteimagelogic.go deleted file mode 100644 index ead0a488..00000000 --- a/api/internal/logic/vm/deleteimagelogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteImageLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteImageLogic { - return &DeleteImageLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteImageLogic) DeleteImage(req *types.DeleteImageReq) (resp *types.DeleteImageResp, err error) { - // todo: add your logic here and delete this line - DeleteImageReq := &openstack.DeleteImageReq{} - err = copier.CopyWithOption(DeleteImageReq, req, copier.Option{Converters: utils.Converters}) - DeleteImageResp, err := l.svcCtx.OpenstackRpc.DeleteImage(l.ctx, DeleteImageReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteImageResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteImageResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletenetworklogic.go b/api/internal/logic/vm/deletenetworklogic.go deleted file mode 100644 index e3a36fe0..00000000 --- a/api/internal/logic/vm/deletenetworklogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteNetworkLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNetworkLogic { - return &DeleteNetworkLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteNetworkLogic) DeleteNetwork(req *types.DeleteNetworkReq) (resp *types.DeleteNetworkResp, err error) { - // todo: add your logic here and delete this line - DeleteNetworkReq := &openstack.DeleteNetworkReq{} - err = copier.CopyWithOption(DeleteNetworkReq, req, copier.Option{Converters: utils.Converters}) - DeleteNetworkResp, err := l.svcCtx.OpenstackRpc.DeleteNetwork(l.ctx, DeleteNetworkReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to delete network "), "Failed to delete network err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteNetworkResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteNetworkResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletenetworksegmentrangeslogic.go b/api/internal/logic/vm/deletenetworksegmentrangeslogic.go deleted file mode 100644 index 2a533b07..00000000 --- a/api/internal/logic/vm/deletenetworksegmentrangeslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteNetworkSegmentRangesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteNetworkSegmentRangesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNetworkSegmentRangesLogic { - return &DeleteNetworkSegmentRangesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteNetworkSegmentRangesLogic) DeleteNetworkSegmentRanges(req *types.DeleteNetworkSegmentRangesReq) (resp *types.DeleteNetworkSegmentRangesResp, err error) { - // todo: add your logic here and delete this line - DeleteNetworkSegmentRangesReq := &openstack.DeleteNetworkSegmentRangesReq{} - err = copier.CopyWithOption(DeleteNetworkSegmentRangesReq, req, copier.Option{Converters: utils.Converters}) - DeleteNetworkSegmentRangesResp, err := l.svcCtx.OpenstackRpc.DeleteNetworkSegmentRanges(l.ctx, DeleteNetworkSegmentRangesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteNetworkSegmentRangesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteNetworkSegmentRangesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletenodelogic.go b/api/internal/logic/vm/deletenodelogic.go deleted file mode 100644 index c23cd5c6..00000000 --- a/api/internal/logic/vm/deletenodelogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteNodeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteNodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNodeLogic { - return &DeleteNodeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteNodeLogic) DeleteNode(req *types.DeleteNodeReq) (resp *types.DeleteNodeResp, err error) { - // todo: add your logic here and delete this line - DeleteNodeReq := &openstack.DeleteNodeReq{} - err = copier.CopyWithOption(DeleteNodeReq, req, copier.Option{Converters: tool.Converters}) - DeleteNodeResp, err := l.svcCtx.OpenstackRpc.DeleteNode(l.ctx, DeleteNodeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteNodeResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteNodeResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deleteportlogic.go b/api/internal/logic/vm/deleteportlogic.go deleted file mode 100644 index 892440f1..00000000 --- a/api/internal/logic/vm/deleteportlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeletePortLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeletePortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePortLogic { - return &DeletePortLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeletePortLogic) DeletePort(req *types.DeletePortReq) (resp *types.DeletePortResp, err error) { - // todo: add your logic here and delete this line - DeletePortReq := &openstack.DeletePortReq{} - err = copier.CopyWithOption(DeletePortReq, req, copier.Option{Converters: utils.Converters}) - DeletePortResp, err := l.svcCtx.OpenstackRpc.DeletePort(l.ctx, DeletePortReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeletePortResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeletePortResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deleterouterlogic.go b/api/internal/logic/vm/deleterouterlogic.go deleted file mode 100644 index 7e39dfdb..00000000 --- a/api/internal/logic/vm/deleterouterlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteRouterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteRouterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRouterLogic { - return &DeleteRouterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteRouterLogic) DeleteRouter(req *types.DeleteRouterReq) (resp *types.DeleteRouterResp, err error) { - // todo: add your logic here and delete this line - DeleteRouterReq := &openstack.DeleteRouterReq{} - err = copier.CopyWithOption(DeleteRouterReq, req, copier.Option{Converters: utils.Converters}) - DeleteRouterResp, err := l.svcCtx.OpenstackRpc.DeleteRouter(l.ctx, DeleteRouterReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteRouterResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteRouterResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletesecuritygrouplogic.go b/api/internal/logic/vm/deletesecuritygrouplogic.go deleted file mode 100644 index a5f72343..00000000 --- a/api/internal/logic/vm/deletesecuritygrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteSecurityGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSecurityGroupLogic { - return &DeleteSecurityGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteSecurityGroupLogic) DeleteSecurityGroup(req *types.DeleteSecurityGroupReq) (resp *types.DeleteSecurityGroupResp, err error) { - // todo: add your logic here and delete this line - DeleteSecurityGroupReq := &openstack.DeleteSecurityGroupReq{} - err = copier.CopyWithOption(DeleteSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) - DeleteSecurityGroupResp, err := l.svcCtx.OpenstackRpc.DeleteSecurityGroup(l.ctx, DeleteSecurityGroupReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteSecurityGroupResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteSecurityGroupResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletesecuritygrouprulelogic.go b/api/internal/logic/vm/deletesecuritygrouprulelogic.go deleted file mode 100644 index 369be8d1..00000000 --- a/api/internal/logic/vm/deletesecuritygrouprulelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteSecurityGroupRuleLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteSecurityGroupRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSecurityGroupRuleLogic { - return &DeleteSecurityGroupRuleLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteSecurityGroupRuleLogic) DeleteSecurityGroupRule(req *types.DeleteSecurityGroupRuleReq) (resp *types.DeleteSecurityGroupRuleResp, err error) { - // todo: add your logic here and delete this line - DeleteSecurityGroupRuleReq := &openstack.DeleteSecurityGroupRuleReq{} - err = copier.CopyWithOption(DeleteSecurityGroupRuleReq, req, copier.Option{Converters: utils.Converters}) - DeleteSecurityGroupRuleResp, err := l.svcCtx.OpenstackRpc.DeleteSecurityGroupRule(l.ctx, DeleteSecurityGroupRuleReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteSecurityGroupRuleResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteSecurityGroupRuleResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deleteserverlogic.go b/api/internal/logic/vm/deleteserverlogic.go deleted file mode 100644 index a953e6f1..00000000 --- a/api/internal/logic/vm/deleteserverlogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServerLogic { - return &DeleteServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteServerLogic) DeleteServer(req *types.DeleteServerReq) (resp *types.DeleteServerResp, err error) { - // todo: add your logic here and delete this line - DeleteServerReq := &openstack.DeleteServerReq{} - err = copier.CopyWithOption(DeleteServerReq, req, copier.Option{Converters: utils.Converters}) - DeleteServerResp, err := l.svcCtx.OpenstackRpc.DeleteServer(l.ctx, DeleteServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletesubnetlogic.go b/api/internal/logic/vm/deletesubnetlogic.go deleted file mode 100644 index 794537cb..00000000 --- a/api/internal/logic/vm/deletesubnetlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteSubnetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteSubnetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSubnetLogic { - return &DeleteSubnetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteSubnetLogic) DeleteSubnet(req *types.DeleteSubnetReq) (resp *types.DeleteSubnetResp, err error) { - // todo: add your logic here and delete this line - DeleteSubnetReq := &openstack.DeleteSubnetReq{} - err = copier.CopyWithOption(DeleteSubnetReq, req, copier.Option{Converters: utils.Converters}) - DeleteSubnetResp, err := l.svcCtx.OpenstackRpc.DeleteSubnet(l.ctx, DeleteSubnetReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteSubnetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteSubnetResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletevolumelogic.go b/api/internal/logic/vm/deletevolumelogic.go deleted file mode 100644 index c4b0aab7..00000000 --- a/api/internal/logic/vm/deletevolumelogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteVolumeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteVolumeLogic { - return &DeleteVolumeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteVolumeLogic) DeleteVolume(req *types.DeleteVolumeReq) (resp *types.DeleteVolumeResp, err error) { - // todo: add your logic here and delete this line - DeleteVolumeReq := &openstack.DeleteVolumeReq{} - err = copier.CopyWithOption(DeleteVolumeReq, req, copier.Option{Converters: utils.Converters}) - DeleteVolumeResp, err := l.svcCtx.OpenstackRpc.DeleteVolume(l.ctx, DeleteVolumeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteVolumeResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteVolumeResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/deletevolumetypelogic.go b/api/internal/logic/vm/deletevolumetypelogic.go deleted file mode 100644 index f6b60dd4..00000000 --- a/api/internal/logic/vm/deletevolumetypelogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteVolumeTypeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewDeleteVolumeTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteVolumeTypeLogic { - return &DeleteVolumeTypeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *DeleteVolumeTypeLogic) DeleteVolumeType(req *types.DeleteVolumeTypeReq) (resp *types.DeleteVolumeTypeResp, err error) { - // todo: add your logic here and delete this line - DeleteVolumeTypeReq := &openstack.DeleteVolumeTypeReq{} - err = copier.CopyWithOption(DeleteVolumeTypeReq, req, copier.Option{Converters: tool.Converters}) - DeleteVolumeTypeResp, err := l.svcCtx.OpenstackRpc.DeleteVolumeTypes(l.ctx, DeleteVolumeTypeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DeleteVolumeTypeResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DeleteVolumeTypeResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/getcomputelimitslogic.go b/api/internal/logic/vm/getcomputelimitslogic.go deleted file mode 100644 index 8da14faa..00000000 --- a/api/internal/logic/vm/getcomputelimitslogic.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "encoding/json" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetComputeLimitsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetComputeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputeLimitsLogic { - return &GetComputeLimitsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetComputeLimitsLogic) GetComputeLimits(req *types.GetComputeLimitsReq) (resp *types.GetComputeLimitsResp, err error) { - GetComputeLimitsReq := &openstack.GetComputeLimitsReq{} - err = copier.CopyWithOption(GetComputeLimitsReq, req, copier.Option{Converters: utils.Converters}) - GetComputeLimitsResp, err := l.svcCtx.OpenstackRpc.GetComputeLimits(l.ctx, GetComputeLimitsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&GetComputeLimitsResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &GetComputeLimitsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/getimagenumlogic.go b/api/internal/logic/vm/getimagenumlogic.go deleted file mode 100644 index 24f763d2..00000000 --- a/api/internal/logic/vm/getimagenumlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "fmt" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetImageNumLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetImageNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImageNumLogic { - return &GetImageNumLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetImageNumLogic) GetImageNum(req *types.ListImagesReq) (resp *types.ImageNum, err error) { - // todo: add your logic here and delete this line - resp = &types.ImageNum{} - listImagesReq := &openstack.ListImagesReq{} - listImagesReq.Platform = req.Platform - //err = copier.CopyWithOption(ListImagesReq, req, copier.Option{Converters: utils.Converters}) - ListImagesResp, err := l.svcCtx.OpenstackRpc.ListImages(l.ctx, listImagesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Networks list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - var count int = len(ListImagesResp.Images) - resp.ImageNum = int32(count) - fmt.Println(count) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - return resp, err -} diff --git a/api/internal/logic/vm/getnetworknumlogic.go b/api/internal/logic/vm/getnetworknumlogic.go deleted file mode 100644 index 0d785b1c..00000000 --- a/api/internal/logic/vm/getnetworknumlogic.go +++ /dev/null @@ -1,47 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetNetworkNumLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetNetworkNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNetworkNumLogic { - return &GetNetworkNumLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetNetworkNumLogic) GetNetworkNum(req *types.ListNetworksReq) (resp *types.NetworkNum, err error) { - // todo: add your logic here and delete this line - resp = &types.NetworkNum{} - ListNetworksReq := &openstack.ListNetworksReq{} - err = copier.CopyWithOption(ListNetworksReq, req, copier.Option{Converters: utils.Converters}) - ListNetworksResp, err := l.svcCtx.OpenstackRpc.ListNetworks(l.ctx, ListNetworksReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Networks list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - var count int = len(ListNetworksResp.Networks) - resp.NetworkNum = int32(count) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - return resp, err -} diff --git a/api/internal/logic/vm/getopenstackoverviewlogic.go b/api/internal/logic/vm/getopenstackoverviewlogic.go deleted file mode 100644 index 39155fc8..00000000 --- a/api/internal/logic/vm/getopenstackoverviewlogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package vm - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" -) - -type GetOpenstackOverviewLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetOpenstackOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOpenstackOverviewLogic { - return &GetOpenstackOverviewLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetOpenstackOverviewLogic) GetOpenstackOverview(req *types.OpenstackOverviewReq) (resp *types.OpenstackOverviewResp, err error) { - // todo: add your logic here and delete this line - var openstackOverview types.OpenstackOverview - sqlStr := "SELECT t.max_total_cores,t.max_total_ram_size,t.max_total_volumes FROM `vm_openstack_overview` t left join t_cluster tc on t.cluster_id=tc.id where tc.`name` = ?" - l.svcCtx.DbEngin.Raw(sqlStr, req.Platform).Scan(&openstackOverview) - resp = &types.OpenstackOverviewResp{ - Code: 200, - Msg: "success", - Data: openstackOverview, - } - return resp, err -} diff --git a/api/internal/logic/vm/getserversdetailedbyidlogic.go b/api/internal/logic/vm/getserversdetailedbyidlogic.go deleted file mode 100644 index 22bec7c1..00000000 --- a/api/internal/logic/vm/getserversdetailedbyidlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetServersDetailedByIdLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetServersDetailedByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetServersDetailedByIdLogic { - return &GetServersDetailedByIdLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetServersDetailedByIdLogic) GetServersDetailedById(req *types.GetServersDetailedByIdReq) (resp *types.GetServersDetailedByIdResp, err error) { - // todo: add your logic here and delete this line - GetServersDetailedByIdReq := &openstack.GetServersDetailedByIdReq{} - err = copier.CopyWithOption(GetServersDetailedByIdReq, req, copier.Option{Converters: tool.Converters}) - GetServersDetailedByIdResp, err := l.svcCtx.OpenstackRpc.GetServersDetailedById(l.ctx, GetServersDetailedByIdReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&GetServersDetailedByIdResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &GetServersDetailedByIdResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/getvolumedetailedbyidlogic.go b/api/internal/logic/vm/getvolumedetailedbyidlogic.go deleted file mode 100644 index 0729728b..00000000 --- a/api/internal/logic/vm/getvolumedetailedbyidlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetVolumeDetailedByIdLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetVolumeDetailedByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVolumeDetailedByIdLogic { - return &GetVolumeDetailedByIdLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetVolumeDetailedByIdLogic) GetVolumeDetailedById(req *types.GetVolumeDetailedByIdReq) (resp *types.GetVolumeDetailedByIdResp, err error) { - // todo: add your logic here and delete this line - GetVolumeDetailedByIdReq := &openstack.GetVolumeDetailedByIdReq{} - err = copier.CopyWithOption(GetVolumeDetailedByIdReq, req, copier.Option{Converters: tool.Converters}) - GetVolumeDetailedByIdResp, err := l.svcCtx.OpenstackRpc.GetVolumeDetailedById(l.ctx, GetVolumeDetailedByIdReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&GetVolumeDetailedByIdResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &GetVolumeDetailedByIdResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/getvolumelimitslogic.go b/api/internal/logic/vm/getvolumelimitslogic.go deleted file mode 100644 index 4f267f23..00000000 --- a/api/internal/logic/vm/getvolumelimitslogic.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "encoding/json" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetVolumeLimitsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetVolumeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVolumeLimitsLogic { - return &GetVolumeLimitsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetVolumeLimitsLogic) GetVolumeLimits(req *types.GetVolumeLimitsReq) (resp *types.GetVolumeLimitsResp, err error) { - GetVolumeLimitsReq := &openstack.GetVolumeLimitsReq{} - err = copier.CopyWithOption(GetVolumeLimitsReq, req, copier.Option{Converters: utils.Converters}) - GetVolumeLimitsResp, err := l.svcCtx.OpenstackRpc.GetVolumeLimits(l.ctx, GetVolumeLimitsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&GetVolumeLimitsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &GetVolumeLimitsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listfirewallgroupslogic.go b/api/internal/logic/vm/listfirewallgroupslogic.go deleted file mode 100644 index ae8676e7..00000000 --- a/api/internal/logic/vm/listfirewallgroupslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListFirewallGroupsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListFirewallGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFirewallGroupsLogic { - return &ListFirewallGroupsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListFirewallGroupsLogic) ListFirewallGroups(req *types.ListFirewallGroupsReq) (resp *types.ListFirewallGroupsResp, err error) { - // todo: add your logic here and delete this line - ListFirewallGroupsReq := &openstack.ListFirewallGroupsReq{} - err = copier.CopyWithOption(ListFirewallGroupsReq, req, copier.Option{Converters: utils.Converters}) - ListFirewallGroupsResp, err := l.svcCtx.OpenstackRpc.ListFirewallGroups(l.ctx, ListFirewallGroupsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListFirewallGroupsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListFirewallGroupsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listfirewallpolicieslogic.go b/api/internal/logic/vm/listfirewallpolicieslogic.go deleted file mode 100644 index 9a716b56..00000000 --- a/api/internal/logic/vm/listfirewallpolicieslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListFirewallPoliciesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListFirewallPoliciesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFirewallPoliciesLogic { - return &ListFirewallPoliciesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListFirewallPoliciesLogic) ListFirewallPolicies(req *types.ListFirewallPoliciesReq) (resp *types.ListFirewallPoliciesResp, err error) { - // todo: add your logic here and delete this line - ListFirewallPoliciesReq := &openstack.ListFirewallPoliciesReq{} - err = copier.CopyWithOption(ListFirewallPoliciesReq, req, copier.Option{Converters: utils.Converters}) - ListFirewallPoliciesResp, err := l.svcCtx.OpenstackRpc.ListFirewallPolicies(l.ctx, ListFirewallPoliciesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListFirewallPoliciesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListFirewallPoliciesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listfirewallruleslogic.go b/api/internal/logic/vm/listfirewallruleslogic.go deleted file mode 100644 index de2c5fd1..00000000 --- a/api/internal/logic/vm/listfirewallruleslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListFirewallRulesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListFirewallRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFirewallRulesLogic { - return &ListFirewallRulesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListFirewallRulesLogic) ListFirewallRules(req *types.ListFirewallRulesReq) (resp *types.ListFirewallRulesResp, err error) { - // todo: add your logic here and delete this line - ListFirewallRulesReq := &openstack.ListFirewallRulesReq{} - err = copier.CopyWithOption(ListFirewallRulesReq, req, copier.Option{Converters: utils.Converters}) - ListFirewallRulesResp, err := l.svcCtx.OpenstackRpc.ListFirewallRules(l.ctx, ListFirewallRulesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListFirewallRulesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListFirewallRulesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listflavorsdetaillogic.go b/api/internal/logic/vm/listflavorsdetaillogic.go deleted file mode 100644 index 1f0d842c..00000000 --- a/api/internal/logic/vm/listflavorsdetaillogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListFlavorsDetailLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListFlavorsDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFlavorsDetailLogic { - return &ListFlavorsDetailLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListFlavorsDetailLogic) ListFlavorsDetail(req *types.ListFlavorsDetailReq) (resp *types.ListFlavorsDetailResp, err error) { - // todo: add your logic here and delete this line - ListFlavorsDetailReq := &openstack.ListFlavorsDetailReq{} - err = copier.CopyWithOption(ListFlavorsDetailReq, req, copier.Option{Converters: utils.Converters}) - ListFlavorsDetailResp, err := l.svcCtx.OpenstackRpc.ListFlavorsDetail(l.ctx, ListFlavorsDetailReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListFlavorsDetailResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListFlavorsDetailResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listfloatingipslogic.go b/api/internal/logic/vm/listfloatingipslogic.go deleted file mode 100644 index c3dea113..00000000 --- a/api/internal/logic/vm/listfloatingipslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListFloatingIPsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListFloatingIPsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFloatingIPsLogic { - return &ListFloatingIPsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListFloatingIPsLogic) ListFloatingIPs(req *types.ListFloatingIPsReq) (resp *types.ListFloatingIPsResp, err error) { - // todo: add your logic here and delete this line - ListFloatingIPsReq := &openstack.ListFloatingIPsReq{} - err = copier.CopyWithOption(ListFloatingIPsReq, req, copier.Option{Converters: utils.Converters}) - ListFloatingIPsResp, err := l.svcCtx.OpenstackRpc.ListFloatingIPs(l.ctx, ListFloatingIPsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListFloatingIPsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListFloatingIPsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listimageslogic.go b/api/internal/logic/vm/listimageslogic.go deleted file mode 100644 index 9665a2d1..00000000 --- a/api/internal/logic/vm/listimageslogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListImagesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListImagesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListImagesLogic { - return &ListImagesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListImagesLogic) ListImages(req *types.ListImagesReq) (resp *types.ListImagesResp, err error) { - // todo: add your logic here and delete this line - ListImagesReq := &openstack.ListImagesReq{} - err = copier.CopyWithOption(ListImagesReq, req, copier.Option{Converters: utils.Converters}) - ListImagesResp, err := l.svcCtx.OpenstackRpc.ListImages(l.ctx, ListImagesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListImagesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListImagesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listnetworksegmentrangesrangelogic.go b/api/internal/logic/vm/listnetworksegmentrangesrangelogic.go deleted file mode 100644 index 263659a4..00000000 --- a/api/internal/logic/vm/listnetworksegmentrangesrangelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListNetworkSegmentRangesRangeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListNetworkSegmentRangesRangeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNetworkSegmentRangesRangeLogic { - return &ListNetworkSegmentRangesRangeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListNetworkSegmentRangesRangeLogic) ListNetworkSegmentRangesRange(req *types.ListNetworkSegmentRangesReq) (resp *types.ListNetworkSegmentRangesResp, err error) { - // todo: add your logic here and delete this line - ListNetworkSegmentRangesReq := &openstack.ListNetworkSegmentRangesReq{} - err = copier.CopyWithOption(ListNetworkSegmentRangesReq, req, copier.Option{Converters: utils.Converters}) - ListNetworkSegmentRangesResp, err := l.svcCtx.OpenstackRpc.ListNetworkSegmentRanges(l.ctx, ListNetworkSegmentRangesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListNetworkSegmentRangesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListNetworkSegmentRangesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listnetworkslogic.go b/api/internal/logic/vm/listnetworkslogic.go deleted file mode 100644 index 2433324d..00000000 --- a/api/internal/logic/vm/listnetworkslogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListNetworksLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListNetworksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNetworksLogic { - return &ListNetworksLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListNetworksLogic) ListNetworks(req *types.ListNetworksReq) (resp *types.ListNetworksResp, err error) { - // todo: add your logic here and delete this line - ListNetworksReq := &openstack.ListNetworksReq{} - err = copier.CopyWithOption(ListNetworksReq, req, copier.Option{Converters: utils.Converters}) - ListNetworksResp, err := l.svcCtx.OpenstackRpc.ListNetworks(l.ctx, ListNetworksReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Networks list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListNetworksResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListNetworksResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listnodeslogic.go b/api/internal/logic/vm/listnodeslogic.go deleted file mode 100644 index 01fcfa65..00000000 --- a/api/internal/logic/vm/listnodeslogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListNodesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListNodesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNodesLogic { - return &ListNodesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListNodesLogic) ListNodes(req *types.ListNodesReq) (resp *types.ListNodesResp, err error) { - // todo: add your logic here and delete this line - ListNodesReq := &openstack.ListNodesReq{} - err = copier.CopyWithOption(ListNodesReq, req, copier.Option{Converters: tool.Converters}) - ListNodesResp, err := l.svcCtx.OpenstackRpc.ListNodes(l.ctx, ListNodesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListNodesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListNodesResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listportslogic.go b/api/internal/logic/vm/listportslogic.go deleted file mode 100644 index 91f28123..00000000 --- a/api/internal/logic/vm/listportslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListPortsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListPortsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPortsLogic { - return &ListPortsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListPortsLogic) ListPorts(req *types.ListPortsReq) (resp *types.ListPortsResp, err error) { - // todo: add your logic here and delete this line - ListPortsReq := &openstack.ListPortsReq{} - err = copier.CopyWithOption(ListPortsReq, req, copier.Option{Converters: utils.Converters}) - ListPortsResp, err := l.svcCtx.OpenstackRpc.ListPorts(l.ctx, ListPortsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListPortsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListPortsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listrouterslogic.go b/api/internal/logic/vm/listrouterslogic.go deleted file mode 100644 index 66a74a40..00000000 --- a/api/internal/logic/vm/listrouterslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListRoutersLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListRoutersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListRoutersLogic { - return &ListRoutersLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListRoutersLogic) ListRouters(req *types.ListRoutersReq) (resp *types.ListRoutersResp, err error) { - // todo: add your logic here and delete this line - ListRoutersReq := &openstack.ListRoutersReq{} - err = copier.CopyWithOption(ListRoutersReq, req, copier.Option{Converters: utils.Converters}) - ListRoutersResp, err := l.svcCtx.OpenstackRpc.ListRouters(l.ctx, ListRoutersReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListRoutersResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListRoutersResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listsecuritygroupruleslogic.go b/api/internal/logic/vm/listsecuritygroupruleslogic.go deleted file mode 100644 index aeffcd26..00000000 --- a/api/internal/logic/vm/listsecuritygroupruleslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListSecurityGroupRulesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListSecurityGroupRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSecurityGroupRulesLogic { - return &ListSecurityGroupRulesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListSecurityGroupRulesLogic) ListSecurityGroupRules(req *types.ListSecurityGroupRulesReq) (resp *types.ListSecurityGroupRulesResp, err error) { - // todo: add your logic here and delete this line - ListSecurityGroupRulesReq := &openstack.ListSecurityGroupRulesReq{} - err = copier.CopyWithOption(ListSecurityGroupRulesReq, req, copier.Option{Converters: utils.Converters}) - ListSecurityGroupRulesResp, err := l.svcCtx.OpenstackRpc.ListSecurityGroupRules(l.ctx, ListSecurityGroupRulesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListSecurityGroupRulesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListSecurityGroupRulesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listsecuritygroupslogic.go b/api/internal/logic/vm/listsecuritygroupslogic.go deleted file mode 100644 index f4f713a5..00000000 --- a/api/internal/logic/vm/listsecuritygroupslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListSecurityGroupsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListSecurityGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSecurityGroupsLogic { - return &ListSecurityGroupsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListSecurityGroupsLogic) ListSecurityGroups(req *types.ListSecurityGroupsReq) (resp *types.ListSecurityGroupsResp, err error) { - // todo: add your logic here and delete this line - ListSecurityGroupsReq := &openstack.ListSecurityGroupsReq{} - err = copier.CopyWithOption(ListSecurityGroupsReq, req, copier.Option{Converters: utils.Converters}) - ListSecurityGroupsResp, err := l.svcCtx.OpenstackRpc.ListSecurityGroups(l.ctx, ListSecurityGroupsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListSecurityGroupsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListSecurityGroupsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listserverlogic.go b/api/internal/logic/vm/listserverlogic.go deleted file mode 100644 index 5fb8a4fb..00000000 --- a/api/internal/logic/vm/listserverlogic.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" -) - -type ListServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServerLogic { - return &ListServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListServerLogic) ListServer(req *types.ListServersReq) (resp *types.ListServersResp, err error) { - // todo: add your logic here and delete this line - ListServersReq := &openstack.ListServersReq{} - err = copier.CopyWithOption(ListServersReq, req, copier.Option{Converters: utils.Converters}) - ListServersResp, err := l.svcCtx.OpenstackRpc.ListServers(l.ctx, ListServersReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListServersResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListServersResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listserversdetailedlogic.go b/api/internal/logic/vm/listserversdetailedlogic.go deleted file mode 100644 index 79b217e5..00000000 --- a/api/internal/logic/vm/listserversdetailedlogic.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" -) - -type ListServersDetailedLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListServersDetailedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServersDetailedLogic { - return &ListServersDetailedLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListServersDetailedLogic) ListServersDetailed(req *types.ListServersDetailedReq) (resp *types.ListServersDetailedResp, err error) { - resp = &types.ListServersDetailedResp{} - ListServersDetailedReq := &openstack.ListServersDetailedReq{} - err = copier.CopyWithOption(ListServersDetailedReq, req, copier.Option{Converters: utils.Converters}) - ListServersDetailedResp, err := l.svcCtx.OpenstackRpc.ListServersDetailed(l.ctx, ListServersDetailedReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - utils.Convert(&ListServersDetailedResp.Servers, &resp.ServersDetailed) - err = copier.CopyWithOption(&resp, &ListServersDetailedResp, copier.Option{Converters: utils.Converters}) - return resp, err - -} diff --git a/api/internal/logic/vm/listsubnetslogic.go b/api/internal/logic/vm/listsubnetslogic.go deleted file mode 100644 index 2497089e..00000000 --- a/api/internal/logic/vm/listsubnetslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListSubnetsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListSubnetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSubnetsLogic { - return &ListSubnetsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListSubnetsLogic) ListSubnets(req *types.ListSubnetsReq) (resp *types.ListSubnetsResp, err error) { - // todo: add your logic here and delete this line - ListSubnetsReq := &openstack.ListSubnetsReq{} - err = copier.CopyWithOption(ListSubnetsReq, req, copier.Option{Converters: utils.Converters}) - ListSubnetsResp, err := l.svcCtx.OpenstackRpc.ListSubnets(l.ctx, ListSubnetsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ListSubnetsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListSubnetsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listvolumesdetaillogic.go b/api/internal/logic/vm/listvolumesdetaillogic.go deleted file mode 100644 index aca25a5c..00000000 --- a/api/internal/logic/vm/listvolumesdetaillogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListVolumesDetailLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListVolumesDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVolumesDetailLogic { - return &ListVolumesDetailLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListVolumesDetailLogic) ListVolumesDetail(req *types.ListVolumesDetailReq) (resp *types.ListVolumesDetailResp, err error) { - // todo: add your logic here and delete this line - ListVolumesDetailReq := &openstack.ListVolumesDetailReq{} - err = copier.CopyWithOption(ListVolumesDetailReq, req, copier.Option{Converters: utils.Converters}) - ListVolumesDetailResp, err := l.svcCtx.OpenstackRpc.ListVolumesDetail(l.ctx, ListVolumesDetailReq) - 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(&ListVolumesDetailResp) - if err != nil { - return nil, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListVolumesDetailResp, copier.Option{Converters: utils.Converters}) - return resp, err - -} diff --git a/api/internal/logic/vm/listvolumeslogic.go b/api/internal/logic/vm/listvolumeslogic.go deleted file mode 100644 index 92dd2ae1..00000000 --- a/api/internal/logic/vm/listvolumeslogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListVolumesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewListVolumesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVolumesLogic { - return &ListVolumesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ListVolumesLogic) ListVolumes(req *types.ListVolumesReq) (resp *types.ListVolumesResp, err error) { - // todo: add your logic here and delete this line - ListVolumesReq := &openstack.ListVolumesReq{} - err = copier.CopyWithOption(ListVolumesReq, req, copier.Option{Converters: tool.Converters}) - ListVolumesResp, err := l.svcCtx.OpenstackRpc.ListVolumes(l.ctx, ListVolumesReq) - 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(&ListVolumesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListVolumesResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/listvolumetypeslogic.go b/api/internal/logic/vm/listvolumetypeslogic.go deleted file mode 100644 index 9af04764..00000000 --- a/api/internal/logic/vm/listvolumetypeslogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "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: utils.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, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ListVolumeTypesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/migrateserverlogic.go b/api/internal/logic/vm/migrateserverlogic.go deleted file mode 100644 index 69169bb4..00000000 --- a/api/internal/logic/vm/migrateserverlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type MigrateServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewMigrateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MigrateServerLogic { - return &MigrateServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *MigrateServerLogic) MigrateServer(req *types.MigrateServerReq) (resp *types.MigrateServerResp, err error) { - // todo: add your logic here and delete this line - MigrateServerReq := &openstack.MigrateServerReq{} - err = copier.CopyWithOption(MigrateServerReq, req, copier.Option{Converters: utils.Converters}) - MigrateServerResp, err := l.svcCtx.OpenstackRpc.MigrateServer(l.ctx, MigrateServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&MigrateServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &MigrateServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/pauseserverlogic.go b/api/internal/logic/vm/pauseserverlogic.go deleted file mode 100644 index 4675dfc0..00000000 --- a/api/internal/logic/vm/pauseserverlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type PauseServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewPauseServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PauseServerLogic { - return &PauseServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *PauseServerLogic) PauseServer(req *types.PauseServerReq) (resp *types.PauseServerResp, err error) { - // todo: add your logic here and delete this line - PauseServerReq := &openstack.PauseServerReq{} - err = copier.CopyWithOption(PauseServerReq, req, copier.Option{Converters: tool.Converters}) - PauseServerResp, err := l.svcCtx.OpenstackRpc.PauseServer(l.ctx, PauseServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&PauseServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &PauseServerResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/rebootserverlogic.go b/api/internal/logic/vm/rebootserverlogic.go deleted file mode 100644 index 7f41a3ff..00000000 --- a/api/internal/logic/vm/rebootserverlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type RebootServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewRebootServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RebootServerLogic { - return &RebootServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *RebootServerLogic) RebootServer(req *types.RebootServerReq) (resp *types.RebootServerResp, err error) { - // todo: add your logic here and delete this line - RebootServerReq := &openstack.RebootServerReq{} - err = copier.CopyWithOption(RebootServerReq, req, copier.Option{Converters: tool.Converters}) - RebootServerResp, err := l.svcCtx.OpenstackRpc.RebootServer(l.ctx, RebootServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&RebootServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &RebootServerResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/removesecuritygrouplogic.go b/api/internal/logic/vm/removesecuritygrouplogic.go deleted file mode 100644 index 71ea50b2..00000000 --- a/api/internal/logic/vm/removesecuritygrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type RemoveSecurityGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewRemoveSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveSecurityGroupLogic { - return &RemoveSecurityGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *RemoveSecurityGroupLogic) RemoveSecurityGroup(req *types.RemoveSecurityGroupReq) (resp *types.RemoveSecurityGroupResp, err error) { - // todo: add your logic here and delete this line - CreateImageReq := &openstack.CreateImageReq{} - err = copier.CopyWithOption(CreateImageReq, req, copier.Option{Converters: utils.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: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/rescueserverlogic.go b/api/internal/logic/vm/rescueserverlogic.go deleted file mode 100644 index 49931fad..00000000 --- a/api/internal/logic/vm/rescueserverlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type RescueServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewRescueServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RescueServerLogic { - return &RescueServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *RescueServerLogic) RescueServer(req *types.RescueServerReq) (resp *types.RescueServerResp, err error) { - // todo: add your logic here and delete this line - RescueServerReq := &openstack.RescueServerReq{} - err = copier.CopyWithOption(RescueServerReq, req, copier.Option{Converters: utils.Converters}) - RescueServerResp, err := l.svcCtx.OpenstackRpc.RescueServer(l.ctx, RescueServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&RescueServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &RescueServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/resizeserverlogic.go b/api/internal/logic/vm/resizeserverlogic.go deleted file mode 100644 index 87c6c430..00000000 --- a/api/internal/logic/vm/resizeserverlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ResizeServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewResizeServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResizeServerLogic { - return &ResizeServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ResizeServerLogic) ResizeServer(req *types.ResizeServerReq) (resp *types.ResizeServerResp, err error) { - // todo: add your logic here and delete this line - ResizeServerReq := &openstack.ResizeServerReq{} - err = copier.CopyWithOption(ResizeServerReq, req, copier.Option{Converters: utils.Converters}) - ResizeServerResp, err := l.svcCtx.OpenstackRpc.ResizeServer(l.ctx, ResizeServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ResizeServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ResizeServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/shelveserverlogic.go b/api/internal/logic/vm/shelveserverlogic.go deleted file mode 100644 index 0fd6c10f..00000000 --- a/api/internal/logic/vm/shelveserverlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShelveServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShelveServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShelveServerLogic { - return &ShelveServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShelveServerLogic) ShelveServer(req *types.ShelveServerReq) (resp *types.ShelveServerResp, err error) { - // todo: add your logic here and delete this line - ShelveServerReq := &openstack.ShelveServerReq{} - err = copier.CopyWithOption(ShelveServerReq, req, copier.Option{Converters: utils.Converters}) - ShelveServerResp, err := l.svcCtx.OpenstackRpc.ShelveServer(l.ctx, ShelveServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShelveServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShelveServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showfirewallgroupdetailslogic.go b/api/internal/logic/vm/showfirewallgroupdetailslogic.go deleted file mode 100644 index 89813126..00000000 --- a/api/internal/logic/vm/showfirewallgroupdetailslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowFirewallGroupDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowFirewallGroupDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFirewallGroupDetailsLogic { - return &ShowFirewallGroupDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowFirewallGroupDetailsLogic) ShowFirewallGroupDetails(req *types.ShowFirewallGroupDetailsReq) (resp *types.ShowFirewallGroupDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowFirewallGroupDetailsReq := &openstack.ShowFirewallGroupDetailsReq{} - err = copier.CopyWithOption(ShowFirewallGroupDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowFirewallGroupDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFirewallGroupDetails(l.ctx, ShowFirewallGroupDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowFirewallGroupDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowFirewallGroupDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showfirewallpolicydetailslogic.go b/api/internal/logic/vm/showfirewallpolicydetailslogic.go deleted file mode 100644 index dce3b065..00000000 --- a/api/internal/logic/vm/showfirewallpolicydetailslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowFirewallPolicyDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowFirewallPolicyDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFirewallPolicyDetailsLogic { - return &ShowFirewallPolicyDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowFirewallPolicyDetailsLogic) ShowFirewallPolicyDetails(req *types.ShowFirewallPolicyDetailsReq) (resp *types.ShowFirewallPolicyDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowFirewallPolicyDetailsReq := &openstack.ShowFirewallPolicyDetailsReq{} - err = copier.CopyWithOption(ShowFirewallPolicyDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowFirewallPolicyDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFirewallPolicyDetails(l.ctx, ShowFirewallPolicyDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowFirewallPolicyDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowFirewallPolicyDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showfirewallruledetailslogic.go b/api/internal/logic/vm/showfirewallruledetailslogic.go deleted file mode 100644 index 1b60c02a..00000000 --- a/api/internal/logic/vm/showfirewallruledetailslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowFirewallRuleDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowFirewallRuleDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFirewallRuleDetailsLogic { - return &ShowFirewallRuleDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowFirewallRuleDetailsLogic) ShowFirewallRuleDetails(req *types.ShowFirewallRuleDetailsReq) (resp *types.ShowFirewallRuleDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowFirewallRuleDetailsReq := &openstack.ShowFirewallRuleDetailsReq{} - err = copier.CopyWithOption(ShowFirewallRuleDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowFirewallRuleDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFirewallRuleDetails(l.ctx, ShowFirewallRuleDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowFirewallRuleDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowFirewallRuleDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showfloatingipdetailslogic.go b/api/internal/logic/vm/showfloatingipdetailslogic.go deleted file mode 100644 index 38ee82c8..00000000 --- a/api/internal/logic/vm/showfloatingipdetailslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowFloatingIPDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowFloatingIPDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFloatingIPDetailsLogic { - return &ShowFloatingIPDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowFloatingIPDetailsLogic) ShowFloatingIPDetails(req *types.ShowFloatingIPDetailsReq) (resp *types.ShowFloatingIPDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowFloatingIPDetailsReq := &openstack.ShowFloatingIPDetailsReq{} - err = copier.CopyWithOption(ShowFloatingIPDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowFloatingIPDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFloatingIPDetails(l.ctx, ShowFloatingIPDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowFloatingIPDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowFloatingIPDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/shownetworkdetailslogic.go b/api/internal/logic/vm/shownetworkdetailslogic.go deleted file mode 100644 index 60e563fa..00000000 --- a/api/internal/logic/vm/shownetworkdetailslogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowNetworkDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowNetworkDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNetworkDetailsLogic { - return &ShowNetworkDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowNetworkDetailsLogic) ShowNetworkDetails(req *types.ShowNetworkDetailsReq) (resp *types.ShowNetworkDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowNetworkDetailsReq := &openstack.ShowNetworkDetailsReq{} - err = copier.CopyWithOption(ShowNetworkDetailsReq, req, copier.Option{Converters: tool.Converters}) - ShowNetworkDetailsResp, err := l.svcCtx.OpenstackRpc.ShowNetworkDetails(l.ctx, ShowNetworkDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowNetworkDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowNetworkDetailsResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/shownetworksegmentrangedetailslogic.go b/api/internal/logic/vm/shownetworksegmentrangedetailslogic.go deleted file mode 100644 index 68e69c39..00000000 --- a/api/internal/logic/vm/shownetworksegmentrangedetailslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowNetworkSegmentRangeDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowNetworkSegmentRangeDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNetworkSegmentRangeDetailsLogic { - return &ShowNetworkSegmentRangeDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowNetworkSegmentRangeDetailsLogic) ShowNetworkSegmentRangeDetails(req *types.ShowNetworkSegmentRangeDetailsReq) (resp *types.ShowNetworkSegmentRangeDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowNetworkSegmentRangeDetailsReq := &openstack.ShowNetworkSegmentRangeDetailsReq{} - err = copier.CopyWithOption(ShowNetworkSegmentRangeDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowNetworkSegmentRangeDetailsResp, err := l.svcCtx.OpenstackRpc.ShowNetworkSegmentRangeDetails(l.ctx, ShowNetworkSegmentRangeDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowNetworkSegmentRangeDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowNetworkSegmentRangeDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/shownodedetailslogic.go b/api/internal/logic/vm/shownodedetailslogic.go deleted file mode 100644 index 6b29d9e1..00000000 --- a/api/internal/logic/vm/shownodedetailslogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowNodeDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowNodeDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNodeDetailsLogic { - return &ShowNodeDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowNodeDetailsLogic) ShowNodeDetails(req *types.ShowNodeDetailsReq) (resp *types.ShowNodeDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowNodeDetailsReq := &openstack.ShowNodeDetailsReq{} - err = copier.CopyWithOption(ShowNodeDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowNodeDetailsResp, err := l.svcCtx.OpenstackRpc.ShowNodeDetails(l.ctx, ShowNodeDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowNodeDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowNodeDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showportdetailslogic.go b/api/internal/logic/vm/showportdetailslogic.go deleted file mode 100644 index 6e7ae8c9..00000000 --- a/api/internal/logic/vm/showportdetailslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowPortDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowPortDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowPortDetailsLogic { - return &ShowPortDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowPortDetailsLogic) ShowPortDetails(req *types.ShowPortDetailsReq) (resp *types.ShowPortDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowPortDetailsReq := &openstack.ShowPortDetailsReq{} - err = copier.CopyWithOption(ShowPortDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowPortDetailsResp, err := l.svcCtx.OpenstackRpc.ShowPortDetails(l.ctx, ShowPortDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowPortDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowPortDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showrouterdetailslogic.go b/api/internal/logic/vm/showrouterdetailslogic.go deleted file mode 100644 index ebc53ad1..00000000 --- a/api/internal/logic/vm/showrouterdetailslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowRouterDetailsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowRouterDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowRouterDetailsLogic { - return &ShowRouterDetailsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowRouterDetailsLogic) ShowRouterDetails(req *types.ShowRouterDetailsReq) (resp *types.ShowRouterDetailsResp, err error) { - // todo: add your logic here and delete this line - ShowRouterDetailsReq := &openstack.ShowRouterDetailsReq{} - err = copier.CopyWithOption(ShowRouterDetailsReq, req, copier.Option{Converters: utils.Converters}) - ShowRouterDetailsResp, err := l.svcCtx.OpenstackRpc.ShowRouterDetails(l.ctx, ShowRouterDetailsReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowRouterDetailsResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowRouterDetailsResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showsecuritygrouplogic.go b/api/internal/logic/vm/showsecuritygrouplogic.go deleted file mode 100644 index 4eb4aa16..00000000 --- a/api/internal/logic/vm/showsecuritygrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowSecurityGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowSecurityGroupLogic { - return &ShowSecurityGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowSecurityGroupLogic) ShowSecurityGroup(req *types.ShowSecurityGroupReq) (resp *types.ShowSecurityGroupResp, err error) { - // todo: add your logic here and delete this line - ShowSecurityGroupReq := &openstack.ShowSecurityGroupReq{} - err = copier.CopyWithOption(ShowSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) - ShowSecurityGroupResp, err := l.svcCtx.OpenstackRpc.ShowSecurityGroup(l.ctx, ShowSecurityGroupReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowSecurityGroupResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowSecurityGroupResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/showsecuritygrouprulelogic.go b/api/internal/logic/vm/showsecuritygrouprulelogic.go deleted file mode 100644 index 3edf3a4c..00000000 --- a/api/internal/logic/vm/showsecuritygrouprulelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ShowSecurityGroupRuleLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewShowSecurityGroupRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowSecurityGroupRuleLogic { - return &ShowSecurityGroupRuleLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ShowSecurityGroupRuleLogic) ShowSecurityGroupRule(req *types.ShowSecurityGroupRuleReq) (resp *types.ShowSecurityGroupRuleResp, err error) { - // todo: add your logic here and delete this line - ShowSecurityGroupRuleReq := &openstack.ShowSecurityGroupRuleReq{} - err = copier.CopyWithOption(ShowSecurityGroupRuleReq, req, copier.Option{Converters: utils.Converters}) - ShowSecurityGroupRuleResp, err := l.svcCtx.OpenstackRpc.ShowSecurityGroupRule(l.ctx, ShowSecurityGroupRuleReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&ShowSecurityGroupRuleResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &ShowSecurityGroupRuleResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/startserverlogic.go b/api/internal/logic/vm/startserverlogic.go deleted file mode 100644 index 846944f0..00000000 --- a/api/internal/logic/vm/startserverlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type StartServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewStartServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartServerLogic { - return &StartServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *StartServerLogic) StartServer(req *types.StartServerReq) (resp *types.StartServerResp, err error) { - // todo: add your logic here and delete this line - StartServerReq := &openstack.StartServerReq{} - err = copier.CopyWithOption(StartServerReq, req, copier.Option{Converters: tool.Converters}) - StartServerResp, err := l.svcCtx.OpenstackRpc.StartServer(l.ctx, StartServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&StartServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &StartServerResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/stopserverlogic.go b/api/internal/logic/vm/stopserverlogic.go deleted file mode 100644 index 530fd165..00000000 --- a/api/internal/logic/vm/stopserverlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type StopServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewStopServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopServerLogic { - return &StopServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *StopServerLogic) StopServer(req *types.StopServerReq) (resp *types.StopServerResp, err error) { - // todo: add your logic here and delete this line - StopServerReq := &openstack.StopServerReq{} - err = copier.CopyWithOption(StopServerReq, req, copier.Option{Converters: tool.Converters}) - StopServerResp, err := l.svcCtx.OpenstackRpc.StopServer(l.ctx, StopServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&StopServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &StopServerResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/suspendserverlogic.go b/api/internal/logic/vm/suspendserverlogic.go deleted file mode 100644 index 5e246920..00000000 --- a/api/internal/logic/vm/suspendserverlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type SuspendServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewSuspendServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SuspendServerLogic { - return &SuspendServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *SuspendServerLogic) SuspendServer(req *types.SuspendServerReq) (resp *types.SuspendServerResp, err error) { - // todo: add your logic here and delete this line - SuspendServerReq := &openstack.SuspendServerReq{} - err = copier.CopyWithOption(SuspendServerReq, req, copier.Option{Converters: utils.Converters}) - SuspendServerResp, err := l.svcCtx.OpenstackRpc.SuspendServer(l.ctx, SuspendServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&SuspendServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &SuspendServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/unpauseserverlogic.go b/api/internal/logic/vm/unpauseserverlogic.go deleted file mode 100644 index f01651ca..00000000 --- a/api/internal/logic/vm/unpauseserverlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UnpauseServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUnpauseServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnpauseServerLogic { - return &UnpauseServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UnpauseServerLogic) UnpauseServer(req *types.UnpauseServerReq) (resp *types.UnpauseServerResp, err error) { - // todo: add your logic here and delete this line - UnpauseServerReq := &openstack.UnpauseServerReq{} - err = copier.CopyWithOption(UnpauseServerReq, req, copier.Option{Converters: utils.Converters}) - UnpauseServerResp, err := l.svcCtx.OpenstackRpc.UnpauseServer(l.ctx, UnpauseServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UnpauseServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UnpauseServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/unrescuelogic.go b/api/internal/logic/vm/unrescuelogic.go deleted file mode 100644 index 9cde0bc7..00000000 --- a/api/internal/logic/vm/unrescuelogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UnRescueLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUnRescueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnRescueLogic { - return &UnRescueLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UnRescueLogic) UnRescue(req *types.UnRescueServerReq) (resp *types.UnRescueServerResp, err error) { - // todo: add your logic here and delete this line - UnRescueServerReq := &openstack.UnRescueServerReq{} - err = copier.CopyWithOption(UnRescueServerReq, req, copier.Option{Converters: utils.Converters}) - UnRescueServerResp, err := l.svcCtx.OpenstackRpc.UnRescue(l.ctx, UnRescueServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UnRescueServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UnRescueServerResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updatefirewallgrouplogic.go b/api/internal/logic/vm/updatefirewallgrouplogic.go deleted file mode 100644 index c7ea460c..00000000 --- a/api/internal/logic/vm/updatefirewallgrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateFirewallGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateFirewallGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateFirewallGroupLogic { - return &UpdateFirewallGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateFirewallGroupLogic) UpdateFirewallGroup(req *types.UpdateFirewallGroupReq) (resp *types.UpdateFirewallGroupResp, err error) { - // todo: add your logic here and delete this line - UpdateFirewallGroupReq := &openstack.UpdateFirewallGroupReq{} - err = copier.CopyWithOption(UpdateFirewallGroupReq, req, copier.Option{Converters: utils.Converters}) - UpdateFirewallGroupResp, err := l.svcCtx.OpenstackRpc.UpdateFirewallGroup(l.ctx, UpdateFirewallGroupReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateFirewallGroupResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateFirewallGroupResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updatefloatingiplogic.go b/api/internal/logic/vm/updatefloatingiplogic.go deleted file mode 100644 index 7af49686..00000000 --- a/api/internal/logic/vm/updatefloatingiplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateFloatingIPLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateFloatingIPLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateFloatingIPLogic { - return &UpdateFloatingIPLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateFloatingIPLogic) UpdateFloatingIP(req *types.UpdateFloatingIPReq) (resp *types.UpdateFloatingIPResp, err error) { - // todo: add your logic here and delete this line - UpdateFloatingIPReq := &openstack.UpdateFloatingIPReq{} - err = copier.CopyWithOption(UpdateFloatingIPReq, req, copier.Option{Converters: utils.Converters}) - UpdateFloatingIPResp, err := l.svcCtx.OpenstackRpc.UpdateFloatingIP(l.ctx, UpdateFloatingIPReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateFloatingIPResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateFloatingIPResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updatenetworklogic.go b/api/internal/logic/vm/updatenetworklogic.go deleted file mode 100644 index 48edfef1..00000000 --- a/api/internal/logic/vm/updatenetworklogic.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateNetworkLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateNetworkLogic { - return &UpdateNetworkLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateNetworkLogic) UpdateNetwork(req *types.UpdateNetworkReq) (resp *types.UpdateNetworkResp, err error) { - // todo: add your logic here and delete this line - UpdateNetworkReq := &openstack.UpdateNetworkReq{} - err = copier.CopyWithOption(UpdateNetworkReq, req, copier.Option{Converters: utils.Converters}) - UpdateNetworkResp, err := l.svcCtx.OpenstackRpc.UpdateNetwork(l.ctx, UpdateNetworkReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端更新失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateNetworkResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateNetworkResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updatenetworksegmentrangeslogic.go b/api/internal/logic/vm/updatenetworksegmentrangeslogic.go deleted file mode 100644 index 5d8cfbe8..00000000 --- a/api/internal/logic/vm/updatenetworksegmentrangeslogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateNetworkSegmentRangesLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateNetworkSegmentRangesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateNetworkSegmentRangesLogic { - return &UpdateNetworkSegmentRangesLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateNetworkSegmentRangesLogic) UpdateNetworkSegmentRanges(req *types.UpdateNetworkSegmentRangesReq) (resp *types.UpdateNetworkSegmentRangesResp, err error) { - // todo: add your logic here and delete this line - UpdateNetworkSegmentRangesReq := &openstack.UpdateNetworkSegmentRangesReq{} - err = copier.CopyWithOption(UpdateNetworkSegmentRangesReq, req, copier.Option{Converters: utils.Converters}) - UpdateNetworkSegmentRangesResp, err := l.svcCtx.OpenstackRpc.UpdateNetworkSegmentRanges(l.ctx, UpdateNetworkSegmentRangesReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateNetworkSegmentRangesResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateNetworkSegmentRangesResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updateportlogic.go b/api/internal/logic/vm/updateportlogic.go deleted file mode 100644 index fae09088..00000000 --- a/api/internal/logic/vm/updateportlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdatePortLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdatePortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdatePortLogic { - return &UpdatePortLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdatePortLogic) UpdatePort(req *types.UpdatePortReq) (resp *types.UpdatePortResp, err error) { - // todo: add your logic here and delete this line - UpdatePortReq := &openstack.UpdatePortReq{} - err = copier.CopyWithOption(UpdatePortReq, req, copier.Option{Converters: utils.Converters}) - UpdatePortResp, err := l.svcCtx.OpenstackRpc.UpdatePort(l.ctx, UpdatePortReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdatePortResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdatePortResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updaterouterlogic.go b/api/internal/logic/vm/updaterouterlogic.go deleted file mode 100644 index 17b4c03c..00000000 --- a/api/internal/logic/vm/updaterouterlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateRouterLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateRouterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRouterLogic { - return &UpdateRouterLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateRouterLogic) UpdateRouter(req *types.UpdateRouterReq) (resp *types.UpdateRouterResp, err error) { - // todo: add your logic here and delete this line - UpdateRouterReq := &openstack.UpdateRouterReq{} - err = copier.CopyWithOption(UpdateRouterReq, req, copier.Option{Converters: utils.Converters}) - UpdateRouterResp, err := l.svcCtx.OpenstackRpc.UpdateRouter(l.ctx, UpdateRouterReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateRouterResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateRouterResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updatesecuritygrouplogic.go b/api/internal/logic/vm/updatesecuritygrouplogic.go deleted file mode 100644 index 79713476..00000000 --- a/api/internal/logic/vm/updatesecuritygrouplogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateSecurityGroupLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSecurityGroupLogic { - return &UpdateSecurityGroupLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateSecurityGroupLogic) UpdateSecurityGroup(req *types.UpdateSecurityGroupReq) (resp *types.UpdateSecurityGroupResp, err error) { - // todo: add your logic here and delete this line - UpdateSecurityGroupReq := &openstack.UpdateSecurityGroupReq{} - err = copier.CopyWithOption(UpdateSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) - UpdateSecurityGroupResp, err := l.svcCtx.OpenstackRpc.UpdateSecurityGroup(l.ctx, UpdateSecurityGroupReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateSecurityGroupResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateSecurityGroupResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updateserverlogic.go b/api/internal/logic/vm/updateserverlogic.go deleted file mode 100644 index 2750e31f..00000000 --- a/api/internal/logic/vm/updateserverlogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateServerLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateServerLogic { - return &UpdateServerLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateServerLogic) UpdateServer(req *types.UpdateServerReq) (resp *types.UpdateServerResp, err error) { - // todo: add your logic here and delete this line - UpdateServerReq := &openstack.UpdateServerReq{} - err = copier.CopyWithOption(UpdateServerReq, req, copier.Option{Converters: tool.Converters}) - UpdateServerResp, err := l.svcCtx.OpenstackRpc.UpdateServer(l.ctx, UpdateServerReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateServerResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updatesubnetlogic.go b/api/internal/logic/vm/updatesubnetlogic.go deleted file mode 100644 index af757571..00000000 --- a/api/internal/logic/vm/updatesubnetlogic.go +++ /dev/null @@ -1,48 +0,0 @@ -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateSubnetLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateSubnetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSubnetLogic { - return &UpdateSubnetLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateSubnetLogic) UpdateSubnet(req *types.UpdateSubnetReq) (resp *types.UpdateSubnetResp, err error) { - // todo: add your logic here and delete this line - UpdateSubnetReq := &openstack.UpdateSubnetReq{} - err = copier.CopyWithOption(UpdateSubnetReq, req, copier.Option{Converters: utils.Converters}) - UpdateSubnetResp, err := l.svcCtx.OpenstackRpc.UpdateSubnet(l.ctx, UpdateSubnetReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateSubnetResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateSubnetResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/updatevolumelogic.go b/api/internal/logic/vm/updatevolumelogic.go deleted file mode 100644 index 67c0c9c6..00000000 --- a/api/internal/logic/vm/updatevolumelogic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UpdateVolumeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUpdateVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateVolumeLogic { - return &UpdateVolumeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UpdateVolumeLogic) UpdateVolume(req *types.UpdateVolumeReq) (resp *types.UpdateVolumeResp, err error) { - // todo: add your logic here and delete this line - UpdateVolumeReq := &openstack.UpdateVolumeReq{} - err = copier.CopyWithOption(UpdateVolumeReq, req, copier.Option{Converters: tool.Converters}) - UpdateServerResp, err := l.svcCtx.OpenstackRpc.UpdateVolume(l.ctx, UpdateVolumeReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&UpdateServerResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &UpdateServerResp, copier.Option{Converters: tool.Converters}) - return resp, err -} diff --git a/api/internal/logic/vm/uploadimagelogic.go b/api/internal/logic/vm/uploadimagelogic.go deleted file mode 100644 index 7bf881d7..00000000 --- a/api/internal/logic/vm/uploadimagelogic.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package vm - -import ( - "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-openstack/openstack" - "k8s.io/apimachinery/pkg/util/json" - - "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: utils.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, error2.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &CreateImageResp, copier.Option{Converters: utils.Converters}) - return resp, err -} diff --git a/api/internal/mqs/ScheduleAi.go b/api/internal/mqs/ScheduleAi.go deleted file mode 100644 index 2e47695a..00000000 --- a/api/internal/mqs/ScheduleAi.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package mqs - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -/* -* -Listening to the payment flow status change notification message queue -*/ -type AiQueue struct { - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewAiMq(ctx context.Context, svcCtx *svc.ServiceContext) *AiQueue { - return &AiQueue{ - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *AiQueue) Consume(val string) error { - aiSchdl, _ := schedulers.NewAiScheduler(l.ctx, val, l.svcCtx.Scheduler, nil) - - // 调度算法 - _, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl) - if err != nil { - return err - } - - return nil -} diff --git a/api/internal/mqs/ScheduleCloud.go b/api/internal/mqs/ScheduleCloud.go deleted file mode 100644 index a74056ff..00000000 --- a/api/internal/mqs/ScheduleCloud.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package mqs - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -/* -* - */ -type CloudMq struct { - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewCloudMq(ctx context.Context, svcCtx *svc.ServiceContext) *CloudMq { - return &CloudMq{ - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *CloudMq) Consume(val string) error { - // 接受消息, 根据标签筛选过滤 - //cloudScheduler := schedulers.NewCloudScheduler() - //schdl, err := scheduler.NewScheduler(cloudScheduler, val, l.svcCtx.DbEngin, l.svcCtx.ParticipantRpc) - //if err != nil { - // return err - //} - // - ////检测是否指定了集群列表 - //schdl.SpecifyClusters() - // - ////检测是否指定了nsID - //schdl.SpecifyNsID() - // - ////通过标签匹配筛选出集群范围 - //schdl.MatchLabels() - // - ////todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度 - //schdl.TempAssign() - // - //// 存储数据 - //err = schdl.SaveToDb() - //if err != nil { - // return err - //} - return nil -} diff --git a/api/internal/mqs/ScheduleHpc.go b/api/internal/mqs/ScheduleHpc.go deleted file mode 100644 index 5132c56e..00000000 --- a/api/internal/mqs/ScheduleHpc.go +++ /dev/null @@ -1,40 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package mqs - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -/* -* -Listening to the payment flow status change notification message queue -*/ -type HpcMq struct { - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewHpcMq(ctx context.Context, svcCtx *svc.ServiceContext) *HpcMq { - return &HpcMq{ - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *HpcMq) Consume(val string) error { - return nil -} diff --git a/api/internal/mqs/ScheduleVm.go b/api/internal/mqs/ScheduleVm.go deleted file mode 100644 index 6c362807..00000000 --- a/api/internal/mqs/ScheduleVm.go +++ /dev/null @@ -1,49 +0,0 @@ -package mqs - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -/* -* - */ -type VmMq struct { - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewVmMq(ctx context.Context, svcCtx *svc.ServiceContext) *VmMq { - return &VmMq{ - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *VmMq) Consume(val string) error { - // 接受消息, 根据标签筛选过滤 - //vmScheduler := schedulers.NewVmScheduler() - //schdl, err := scheduler.NewScheduler(vmScheduler, val, l.svcCtx.DbEngin, l.svcCtx.ParticipantRpc) - //if err != nil { - // return err - //} - // - ////检测是否指定了集群列表 - //schdl.SpecifyClusters() - // - ////检测是否指定了nsID - //schdl.SpecifyNsID() - // - ////通过标签匹配筛选出集群范围 - //schdl.MatchLabels() - // - ////todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度 - //schdl.TempAssign() - // - //// 存储数据 - //err = schdl.SaveToDb() - //if err != nil { - // return err - //} - return nil -} diff --git a/api/internal/scheduler/database/aiStorage.go b/api/internal/scheduler/database/aiStorage.go deleted file mode 100644 index 6db3cdac..00000000 --- a/api/internal/scheduler/database/aiStorage.go +++ /dev/null @@ -1,368 +0,0 @@ -package database - -import ( - "github.com/zeromicro/go-zero/core/logx" - clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - "gorm.io/gorm" - "strconv" - "time" -) - -type AiStorage struct { - DbEngin *gorm.DB -} - -func (s *AiStorage) GetParticipants() (*types.ClusterListResp, error) { - var resp types.ClusterListResp - tx := s.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL ORDER BY create_time Desc").Scan(&resp.List) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return nil, tx.Error - } - return &resp, nil -} - -func (s *AiStorage) GetClustersByAdapterId(id string) (*types.ClusterListResp, error) { - var resp types.ClusterListResp - tx := s.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL and `adapter_id` = ? ORDER BY create_time Desc", id).Scan(&resp.List) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return nil, tx.Error - } - return &resp, nil -} - -func (s *AiStorage) GetClusterNameById(id string) (string, error) { - var name string - tx := s.DbEngin.Raw("select `description` from t_cluster where `id` = ?", id).Scan(&name) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return "", tx.Error - } - return name, nil -} - -func (s *AiStorage) GetAdapterNameById(id string) (string, error) { - var name string - tx := s.DbEngin.Raw("select `name` from t_adapter where `id` = ?", id).Scan(&name) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return "", tx.Error - } - return name, nil -} - -func (s *AiStorage) GetAdapterIdsByType(adapterType string) ([]string, error) { - var list []types.AdapterInfo - var ids []string - db := s.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") - db = db.Where("type = ?", adapterType) - err := db.Order("create_time desc").Find(&list).Error - if err != nil { - return nil, err - } - for _, info := range list { - ids = append(ids, info.Id) - } - return ids, nil -} - -func (s *AiStorage) GetAdaptersByType(adapterType string) ([]*types.AdapterInfo, error) { - var list []*types.AdapterInfo - db := s.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") - db = db.Where("type = ?", adapterType) - err := db.Order("create_time desc").Find(&list).Error - if err != nil { - return nil, err - } - return list, nil -} - -func (s *AiStorage) GetAiTasksByAdapterId(adapterId string) ([]*models.TaskAi, error) { - var resp []*models.TaskAi - db := s.DbEngin.Model(&models.TaskAi{}).Table("task_ai") - db = db.Where("adapter_id = ?", adapterId) - err := db.Order("commit_time desc").Find(&resp).Error - if err != nil { - return nil, err - } - return resp, nil -} - -func (s *AiStorage) GetAiTaskListById(id int64) ([]*models.TaskAi, error) { - var aiTaskList []*models.TaskAi - tx := s.DbEngin.Raw("select * from task_ai where `task_id` = ? ", id).Scan(&aiTaskList) - if tx.Error != nil { - return nil, tx.Error - } - return aiTaskList, nil -} - -func (s *AiStorage) SaveTask(name string, strategyCode int64, synergyStatus int64, aiType string) (int64, error) { - startTime := time.Now() - // 构建主任务结构体 - taskModel := models.Task{ - Status: constants.Saved, - Description: "ai task", - Name: name, - SynergyStatus: synergyStatus, - Strategy: strategyCode, - AdapterTypeDict: "1", - TaskTypeDict: aiType, - StartTime: &startTime, - CommitTime: time.Now(), - } - // 保存任务数据到数据库 - tx := s.DbEngin.Create(&taskModel) - if tx.Error != nil { - return 0, tx.Error - } - return taskModel.Id, nil -} - -func (s *AiStorage) UpdateTask(task *types.TaskModel) error { - task.UpdatedTime = time.Now().Format(constants.Layout) - tx := s.DbEngin.Table("task").Model(task).Updates(task) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return tx.Error - } - return nil -} - -func (s *AiStorage) SaveAiTask(taskId int64, opt option.Option, adapterName string, clusterId string, clusterName string, jobId string, status string, msg string) error { - var aiOpt *option.AiOption - switch (opt).(type) { - case *option.AiOption: - aiOpt = (opt).(*option.AiOption) - case *option.InferOption: - inferOpt := (opt).(*option.InferOption) - aiOpt = &option.AiOption{} - aiOpt.TaskName = inferOpt.TaskName - aiOpt.Replica = inferOpt.Replica - aiOpt.AdapterId = inferOpt.AdapterId - aiOpt.TaskType = inferOpt.ModelType - aiOpt.StrategyName = inferOpt.Strategy - } - // 构建主任务结构体 - aId, err := strconv.ParseInt(aiOpt.AdapterId, 10, 64) - if err != nil { - return err - } - cId, err := strconv.ParseInt(clusterId, 10, 64) - if err != nil { - return err - } - - aiTaskModel := models.TaskAi{ - TaskId: taskId, - AdapterId: aId, - AdapterName: adapterName, - ClusterId: cId, - ClusterName: clusterName, - Name: aiOpt.TaskName, - Replica: int64(aiOpt.Replica), - JobId: jobId, - TaskType: aiOpt.TaskType, - Strategy: aiOpt.StrategyName, - Status: status, - Msg: msg, - Card: aiOpt.ComputeCard, - StartTime: time.Now().Format(time.RFC3339), - CommitTime: time.Now(), - } - // 保存任务数据到数据库 - tx := s.DbEngin.Create(&aiTaskModel) - if tx.Error != nil { - return tx.Error - } - return nil -} - -func (s *AiStorage) SaveAiTaskImageSubTask(ta *models.TaskAiSub) error { - tx := s.DbEngin.Table("task_ai_sub").Create(ta) - if tx.Error != nil { - return tx.Error - } - return nil -} - -func (s *AiStorage) SaveClusterTaskQueue(adapterId string, clusterId string, queueNum int64) error { - aId, err := strconv.ParseInt(adapterId, 10, 64) - if err != nil { - return err - } - cId, err := strconv.ParseInt(clusterId, 10, 64) - if err != nil { - return err - } - taskQueue := models.TClusterTaskQueue{ - AdapterId: aId, - ClusterId: cId, - QueueNum: queueNum, - } - tx := s.DbEngin.Create(&taskQueue) - if tx.Error != nil { - return tx.Error - } - return nil -} - -func (s *AiStorage) GetClusterTaskQueues(adapterId string, clusterId string) ([]*models.TClusterTaskQueue, error) { - var taskQueues []*models.TClusterTaskQueue - tx := s.DbEngin.Raw("select * from t_cluster_task_queue where `adapter_id` = ? and `cluster_id` = ?", adapterId, clusterId).Scan(&taskQueues) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return nil, tx.Error - } - return taskQueues, nil -} - -func (s *AiStorage) GetAiTaskIdByClusterIdAndTaskId(clusterId string, taskId string) (string, error) { - var aiTask models.TaskAi - tx := s.DbEngin.Raw("select * from task_ai where `cluster_id` = ? and `task_id` = ?", clusterId, taskId).Scan(&aiTask) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return "", tx.Error - } - return aiTask.JobId, nil -} - -func (s *AiStorage) GetClusterResourcesById(clusterId string) (*models.TClusterResource, error) { - var clusterResource models.TClusterResource - tx := s.DbEngin.Raw("select * from t_cluster_resource where `cluster_id` = ?", clusterId).Scan(&clusterResource) - if tx.Error != nil { - logx.Errorf(tx.Error.Error()) - return nil, tx.Error - } - return &clusterResource, nil -} - -func (s *AiStorage) SaveClusterResources(adapterId string, clusterId string, clusterName string, clusterType int64, cpuAvail float64, cpuTotal float64, - memAvail float64, memTotal float64, diskAvail float64, diskTotal float64, gpuAvail float64, gpuTotal float64, cardTotal int64, topsTotal float64) error { - cId, err := strconv.ParseInt(clusterId, 10, 64) - if err != nil { - return err - } - aId, err := strconv.ParseInt(adapterId, 10, 64) - if err != nil { - return err - } - clusterResource := models.TClusterResource{ - AdapterId: aId, - ClusterId: cId, - ClusterName: clusterName, - ClusterType: clusterType, - CpuAvail: cpuAvail, - CpuTotal: cpuTotal, - MemAvail: memAvail, - MemTotal: memTotal, - DiskAvail: diskAvail, - DiskTotal: diskTotal, - GpuAvail: gpuAvail, - GpuTotal: gpuTotal, - CardTotal: cardTotal, - CardTopsTotal: topsTotal, - } - tx := s.DbEngin.Create(&clusterResource) - if tx.Error != nil { - return tx.Error - } - // prometheus - param := tracker.ClusterLoadRecord{ - AdapterId: aId, - ClusterName: clusterName, - CpuAvail: cpuAvail, - CpuTotal: cpuTotal, - CpuUtilisation: clusterResource.CpuAvail / clusterResource.CpuTotal, - MemoryAvail: memAvail, - MemoryTotal: memTotal, - MemoryUtilisation: clusterResource.MemAvail / clusterResource.MemTotal, - DiskAvail: diskAvail, - DiskTotal: diskTotal, - DiskUtilisation: clusterResource.DiskAvail / clusterResource.DiskTotal, - } - tracker.SyncClusterLoad(param) - return nil -} - -func (s *AiStorage) UpdateClusterResources(clusterResource *models.TClusterResource) error { - tx := s.DbEngin.Where("cluster_id = ?", clusterResource.ClusterId).Updates(clusterResource) - - if tx.Error != nil { - return tx.Error - } - // prometheus - param := tracker.ClusterLoadRecord{ - AdapterId: clusterResource.AdapterId, - ClusterName: clusterResource.ClusterName, - CpuAvail: clusterResource.CpuAvail, - CpuTotal: clusterResource.CpuTotal, - CpuUtilisation: clusterResource.CpuAvail / clusterResource.CpuTotal, - MemoryAvail: clusterResource.MemAvail, - MemoryTotal: clusterResource.MemTotal, - MemoryUtilisation: clusterResource.MemAvail / clusterResource.MemTotal, - DiskAvail: clusterResource.DiskAvail, - DiskTotal: clusterResource.DiskTotal, - DiskUtilisation: clusterResource.DiskAvail / clusterResource.DiskTotal, - } - tracker.SyncClusterLoad(param) - return nil -} - -func (s *AiStorage) UpdateAiTask(task *models.TaskAi) error { - tx := s.DbEngin.Updates(task) - if tx.Error != nil { - return tx.Error - } - return nil -} - -func (s *AiStorage) GetStrategyCode(name string) (int64, error) { - var strategy int64 - sqlStr := `select t_dict_item.item_value - from t_dict - left join t_dict_item on t_dict.id = t_dict_item.dict_id - where item_text = ? - and t_dict.dict_code = 'schedule_Strategy'` - //查询调度策略 - err := s.DbEngin.Raw(sqlStr, name).Scan(&strategy).Error - if err != nil { - return strategy, nil - } - return strategy, nil -} - -func (s *AiStorage) AddNoticeInfo(adapterId string, adapterName string, clusterId string, clusterName string, taskName string, noticeType string, incident string) { - aId, err := strconv.ParseInt(adapterId, 10, 64) - if err != nil { - logx.Errorf("adapterId convert failure, err: %v", err) - } - var cId int64 - if clusterId != "" { - cId, err = strconv.ParseInt(clusterId, 10, 64) - if err != nil { - logx.Errorf("clusterId convert failure, err: %v", err) - } - } - - noticeInfo := clientCore.NoticeInfo{ - AdapterId: aId, - AdapterName: adapterName, - ClusterId: cId, - ClusterName: clusterName, - NoticeType: noticeType, - TaskName: taskName, - Incident: incident, - CreatedTime: time.Now(), - } - result := s.DbEngin.Table("t_notice").Create(¬iceInfo) - if result.Error != nil { - logx.Errorf("Task creation failure, err: %v", result.Error) - } -} diff --git a/api/internal/scheduler/database/cloudStorage.go b/api/internal/scheduler/database/cloudStorage.go deleted file mode 100644 index f9c3a341..00000000 --- a/api/internal/scheduler/database/cloudStorage.go +++ /dev/null @@ -1,34 +0,0 @@ -package database - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/entity" - "gorm.io/gorm" -) - -type CloudStorage struct { - dbEngin *gorm.DB -} - -func NewCloudStorage(dbEngin *gorm.DB) *CloudStorage { - return &CloudStorage{dbEngin: dbEngin} -} - -func (c *CloudStorage) GetProviderParams() ([]entity.ProviderParams, error) { - var proParams []entity.ProviderParams - sqlstr := "SELECT SUM(a.disk_avail) as disk_avail,SUM(a.mem_avail) as mem_avail,SUM(a.cpu_total * a.cpu_usable) as cpu_avail,participant_id from (SELECT * from sc_node_avail_info where created_time in (SELECT MAX(created_time) as time from sc_node_avail_info where deleted_flag = 0 GROUP BY participant_id,node_name)) a GROUP BY a.participant_id" - c.dbEngin.Raw(sqlstr).Scan(&proParams) - if len(proParams) == 0 { - return nil, nil - } - return proParams, nil -} - -func (c *CloudStorage) FindAvailableParticipants() ([]entity.Participant, error) { - var parts []entity.Participant - sqlstr := "select id as participant_id, name as name from sc_participant_phy_info" - c.dbEngin.Raw(sqlstr).Scan(&parts) - if len(parts) == 0 { - return nil, nil - } - return parts, nil -} diff --git a/api/internal/scheduler/database/storage.go b/api/internal/scheduler/database/storage.go deleted file mode 100644 index 3202b22a..00000000 --- a/api/internal/scheduler/database/storage.go +++ /dev/null @@ -1,13 +0,0 @@ -package database - -import "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/entity" - -type Storage interface { - GetProviderParams() ([]entity.ProviderParams, error) - FindAvailableParticipants() ([]entity.Participant, error) -} - -type NSIDSpecified interface { - Storage - NSID() error -} diff --git a/api/internal/scheduler/scheduler.go b/api/internal/scheduler/scheduler.go deleted file mode 100644 index bbdb1f23..00000000 --- a/api/internal/scheduler/scheduler.go +++ /dev/null @@ -1,172 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package scheduler - -import ( - "encoding/json" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/client/participantservice" - "gorm.io/gorm" - "sigs.k8s.io/yaml" - "strings" - "sync" -) - -type Scheduler struct { - task *response.TaskInfo - participantIds []int64 - subSchedule SubSchedule - dbEngin *gorm.DB - result []string //pID:子任务yamlstring 键值对 - participantRpc participantservice.ParticipantService - AiStorages *database.AiStorage - AiService *service.AiService - mu sync.RWMutex -} - -type SubSchedule interface { - GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) - PickOptimalStrategy() (strategy.Strategy, error) - AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) -} - -func NewScheduler(subSchedule SubSchedule, val string, dbEngin *gorm.DB, participantRpc participantservice.ParticipantService) (*Scheduler, error) { - var task *response.TaskInfo - err := json.Unmarshal([]byte(val), &task) - if err != nil { - return nil, errors.New("create scheduler failed : " + err.Error()) - } - return &Scheduler{task: task, subSchedule: subSchedule, dbEngin: dbEngin, participantRpc: participantRpc}, nil -} - -func NewSchdlr(aiService *service.AiService, storages *database.AiStorage) *Scheduler { - return &Scheduler{AiService: aiService, AiStorages: storages} -} - -func (s *Scheduler) SpecifyClusters() { - // 如果已指定集群名,通过数据库查询后返回p端ip列表 - if len(s.task.Clusters) != 0 { - s.dbEngin.Raw("select id from sc_participant_phy_info where `name` in (?)", s.task.Clusters).Scan(&s.participantIds) - return - } -} - -func (s *Scheduler) SpecifyNsID() { - // 未指定集群名,只指定nsID - if len(s.task.Clusters) == 0 { - if len(s.task.NsID) != 0 { - var clusters string - s.dbEngin.Raw("select clusters from sc_tenant_info where `tenant_name` = ?", s.task.NsID).Scan(&clusters) - - clusterArr := strings.Split(clusters, ",") - - s.dbEngin.Raw("select id from sc_participant_phy_info where `name` in (?)", clusterArr).Scan(&s.participantIds) - } - } else { - return - } -} - -func (s *Scheduler) MatchLabels() { - - var ids []int64 - count := 0 - // 集群和nsID都未指定,则通过标签匹配 - if len(s.task.Clusters) == 0 && len(s.task.NsID) == 0 { - //如果集群列表或nsID均未指定 - for key := range s.task.MatchLabels { - var participantIds []int64 - s.dbEngin.Raw("select participant_id from sc_participant_label_info where `key` = ? and value = ?", key, s.task.MatchLabels[key]).Scan(&participantIds) - if count == 0 { - ids = participantIds - } - ids = common.Intersect(ids, participantIds) - count++ - } - s.participantIds = ids - } else { - return - } -} - -// TempAssign todo 屏蔽原调度算法 -func (s *Scheduler) TempAssign() error { - - //需要判断task中的资源类型,针对metadata中的多个kind做不同处理 - //输入副本数和集群列表,最终结果输出为pID对应副本数量列表,针对多个kind需要做拆分和重新拼接组合 - var meData []string - for _, yamlString := range s.task.Metadata { - var data map[string]interface{} - err := yaml.Unmarshal([]byte(yamlString), &data) - if err != nil { - } - - jsonData, err := json.Marshal(data) - if err != nil { - } - meData = append(meData, string(jsonData)) - } - s.task.Metadata = meData - return nil -} - -func (s *Scheduler) AssignAndSchedule(ss SubSchedule) (interface{}, error) { - //choose strategy - strategy, err := ss.PickOptimalStrategy() - if err != nil { - return nil, err - } - - //schedule - clusters, err := strategy.Schedule() - if err != nil { - return nil, err - } - - //assign tasks to clusters - resp, err := ss.AssignTask(clusters) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (s *Scheduler) SaveToDb() error { - - for _, participantId := range s.participantIds { - - for _, resource := range s.task.Metadata { - structForDb, err := s.subSchedule.GetNewStructForDb(s.task, resource, participantId) - if err != nil { - return err - } - - tx := s.dbEngin.Create(structForDb) - if tx.Error != nil { - logx.Error(tx.Error) - return tx.Error - } - } - - } - return nil -} diff --git a/api/internal/scheduler/schedulers/aiScheduler.go b/api/internal/scheduler/schedulers/aiScheduler.go deleted file mode 100644 index 8be805d6..00000000 --- a/api/internal/scheduler/schedulers/aiScheduler.go +++ /dev/null @@ -1,388 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package schedulers - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy/param" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" - "gitlink.org.cn/JointCloud/pcm-octopus/octopus" - "sync" -) - -type AiScheduler struct { - yamlString string - task *response.TaskInfo - *scheduler.Scheduler - option *option.AiOption - ctx context.Context -} - -type AiResult struct { - AdapterId string - TaskName string - JobId string - ClusterId string - Strategy string - Replica int32 - Card string - Msg string -} - -func NewAiScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.AiOption) (*AiScheduler, error) { - return &AiScheduler{ctx: ctx, yamlString: val, Scheduler: scheduler, option: option}, nil -} - -func (as *AiScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { - ai := models.Ai{ - AdapterId: participantId, - TaskId: task.TaskId, - Status: "Saved", - YamlString: as.yamlString, - } - utils.Convert(task.Metadata, &ai) - return ai, nil -} - -func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) { - if as.option.ComputeCard != "" { - m, ok := as.AiService.AiCollectorAdapterMap[as.option.AdapterId] - if ok { - for _, id := range as.option.ClusterIds { - cm, ok := m[id] - if ok { - cards, err := cm.GetComputeCards(as.ctx) - if err != nil { - return nil, err - } - if common.Contains(cards, as.option.ComputeCard) { - return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: id, Replicas: 1}}, nil - } - } - } - } - } - - if len(as.option.ClusterIds) == 1 { - return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: as.option.ClusterIds[0], Replicas: 1}}, nil - } - - resources, err := as.findClustersWithResources() - - if err != nil { - return nil, err - } - if len(resources) == 0 { - return nil, errors.New("no cluster has resources") - } - - if len(resources) == 1 { - var cluster strategy.AssignedCluster - cluster.ClusterId = resources[0].ClusterId - cluster.Replicas = 1 - return &strategy.SingleAssignment{Cluster: &cluster}, nil - } - - params := ¶m.Params{Resources: resources} - - switch as.option.StrategyName { - case strategy.REPLICATION: - var clusterIds []string - for _, resource := range resources { - if resource == nil { - continue - } - clusterIds = append(clusterIds, resource.ClusterId) - } - strategy := strategy.NewReplicationStrategy(clusterIds, 1) - return strategy, nil - case strategy.RESOURCES_PRICING: - strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: 1}) - return strategy, nil - case strategy.DYNAMIC_RESOURCES: - strategy := strategy.NewDynamicResourcesStrategy(params.Resources, as.option, 1) - return strategy, nil - case strategy.STATIC_WEIGHT: - //todo resources should match cluster StaticWeightMap - strategy := strategy.NewStaticWeightStrategy(as.option.ClusterToStaticWeight, as.option.Replica) - return strategy, nil - case strategy.RANDOM: - strategy := strategy.NewRandomStrategy(as.option.ClusterIds, as.option.Replica) - return strategy, nil - } - - return nil, errors.New("no strategy has been chosen") -} - -func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { - if clusters == nil { - return nil, errors.New("clusters is nil") - } - - for i := len(clusters) - 1; i >= 0; i-- { - if clusters[i].Replicas == 0 { - clusters = append(clusters[:i], clusters[i+1:]...) - } - } - - if len(clusters) == 0 { - return nil, errors.New("clusters is nil") - } - - var wg sync.WaitGroup - var results []*AiResult - var mu sync.Mutex - var errs []interface{} - var taskNum int32 - for _, cluster := range clusters { - taskNum += cluster.Replicas - } - var ch = make(chan *AiResult, taskNum) - var errCh = make(chan interface{}, taskNum) - - executorMap := as.AiService.AiExecutorAdapterMap[as.option.AdapterId] - for _, cluster := range clusters { - c := cluster - for i := 0; i < int(c.Replicas); i++ { - wg.Add(1) - go func() { - opt, _ := cloneAiOption(as.option) - resp, err := executorMap[c.ClusterId].Execute(as.ctx, opt) - if err != nil { - e := struct { - err error - clusterId string - }{ - err: err, - clusterId: c.ClusterId, - } - errCh <- e - wg.Done() - return - } - - result := &AiResult{} - mu.Lock() - result, _ = convertType(resp) - mu.Unlock() - - result.AdapterId = opt.AdapterId - result.TaskName = opt.TaskName - result.Replica = c.Replicas - result.ClusterId = c.ClusterId - result.Strategy = as.option.StrategyName - result.Card = opt.ComputeCard - - ch <- result - wg.Done() - }() - } - } - wg.Wait() - close(ch) - close(errCh) - - for e := range errCh { - errs = append(errs, e) - } - - for s := range ch { - results = append(results, s) - } - - if len(errs) != 0 { - var synergystatus int64 - if len(clusters) > 1 { - synergystatus = 1 - } - strategyCode, err := as.AiStorages.GetStrategyCode(as.option.StrategyName) - taskId, err := as.AiStorages.SaveTask(as.option.TaskName, strategyCode, synergystatus, "10") - if err != nil { - return nil, errors.New("database add failed: " + err.Error()) - } - adapterName, err := as.AiStorages.GetAdapterNameById(as.option.AdapterId) - if err != nil { - return nil, err - } - - var errmsg string - for _, err := range errs { - e := (err).(struct { - err error - clusterId string - }) - msg := fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) - errmsg += msg - - clusterName, _ := as.AiStorages.GetClusterNameById(e.clusterId) - - err := as.AiStorages.SaveAiTask(taskId, as.option, adapterName, e.clusterId, clusterName, "", constants.Failed, msg) - if err != nil { - return nil, errors.New("database add failed: " + err.Error()) - } - } - for _, s := range results { - as.option.ComputeCard = s.Card //execute card - clusterName, _ := as.AiStorages.GetClusterNameById(s.ClusterId) - - if s.Msg != "" { - msg := fmt.Sprintf("clusterId: %v , error: %v \n", s.ClusterId, s.Msg) - errmsg += msg - err := as.AiStorages.SaveAiTask(taskId, as.option, adapterName, s.ClusterId, clusterName, "", constants.Failed, msg) - if err != nil { - return nil, errors.New("database add failed: " + err.Error()) - } - } else { - msg := fmt.Sprintf("clusterId: %v , submitted successfully, jobId: %v \n", s.ClusterId, s.JobId) - errmsg += msg - err := as.AiStorages.SaveAiTask(taskId, as.option, adapterName, s.ClusterId, clusterName, s.JobId, constants.Saved, msg) - if err != nil { - return nil, errors.New("database add failed: " + err.Error()) - } - } - } - logx.Errorf(errors.New(errmsg).Error()) - return nil, errors.New(errmsg) - } - - return results, nil -} - -func (as *AiScheduler) findClustersWithResources() ([]*collector.ResourceStats, error) { - var wg sync.WaitGroup - var clustersNum = len(as.AiService.AiCollectorAdapterMap[as.option.AdapterId]) - var ch = make(chan *collector.ResourceStats, clustersNum) - var errCh = make(chan interface{}, clustersNum) - - var resourceSpecs []*collector.ResourceStats - var errs []interface{} - - for s, resourceCollector := range as.AiService.AiCollectorAdapterMap[as.option.AdapterId] { - wg.Add(1) - rc := resourceCollector - id := s - go func() { - spec, err := rc.GetResourceStats(as.ctx) - if err != nil { - e := struct { - err error - clusterId string - }{ - err: err, - clusterId: id, - } - errCh <- e - wg.Done() - return - } - ch <- spec - wg.Done() - }() - } - wg.Wait() - close(ch) - close(errCh) - - for s := range ch { - resourceSpecs = append(resourceSpecs, s) - } - - for e := range errCh { - errs = append(errs, e) - } - - if len(errs) == clustersNum { - return nil, errors.New("get resources failed") - } - - if len(errs) != 0 { - var msg string - for _, err := range errs { - e := (err).(struct { - err error - clusterId string - }) - msg += fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) - } - return nil, errors.New(msg) - } - - return resourceSpecs, nil -} - -func convertType(in interface{}) (*AiResult, error) { - var result AiResult - switch (in).(type) { - case *hpcAC.SubmitTaskAiResp: - resp := (in).(*hpcAC.SubmitTaskAiResp) - if resp.Code == "0" { - result.JobId = resp.Data - } else { - result.Msg = resp.Msg - } - return &result, nil - case *octopus.CreateTrainJobResp: - resp := (in).(*octopus.CreateTrainJobResp) - - if resp.Success { - result.JobId = resp.Payload.JobId - } else { - result.Msg = resp.Error.Message - } - - return &result, nil - case *modelartsservice.CreateTrainingJobResp: - resp := (in).(*modelartsservice.CreateTrainingJobResp) - - if resp.ErrorMsg != "" { - result.Msg = resp.ErrorMsg - } else { - - result.JobId = resp.Metadata.Id - } - - return &result, nil - default: - return nil, errors.New("ai task response failed") - } -} - -func cloneAiOption(opt *option.AiOption) (*option.AiOption, error) { - origJSON, err := json.Marshal(opt) - if err != nil { - return nil, err - } - - clone := option.AiOption{} - if err = json.Unmarshal(origJSON, &clone); err != nil { - return nil, err - } - - return &clone, nil -} diff --git a/api/internal/scheduler/schedulers/cloudScheduler.go b/api/internal/scheduler/schedulers/cloudScheduler.go deleted file mode 100644 index f14db395..00000000 --- a/api/internal/scheduler/schedulers/cloudScheduler.go +++ /dev/null @@ -1,190 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package schedulers - -import ( - "context" - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy/param" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - "math" - "time" -) - -type CloudScheduler struct { - yamlString string - task *response.TaskInfo - *scheduler.Scheduler - option *option.CloudOption - ctx context.Context - dbEngin *gorm.DB - promClient tracker.Prometheus - svcCtx *svc.ServiceContext -} - -type CloudResult struct { - TaskId string - ClusterId string - ClusterName string - Strategy string - Replica int32 - Msg string -} - -func NewCloudScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.CloudOption, dbEngin *gorm.DB, promClient tracker.Prometheus) (*CloudScheduler, error) { - return &CloudScheduler{ctx: ctx, yamlString: val, Scheduler: scheduler, option: option, dbEngin: dbEngin, promClient: promClient}, nil -} - -func (as *CloudScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { - c := cloud.TaskCloudModel{ - AdapterId: uint(participantId), - TaskId: uint(task.TaskId), - Status: constants.Saved, - YamlString: as.yamlString, - } - utils.Convert(task.Metadata, &c) - return c, nil -} - -func (as *CloudScheduler) PickOptimalStrategy() (strategy.Strategy, error) { - if len(as.option.ClusterIds) == 1 { - return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: as.option.ClusterIds[0], Replicas: 1}}, nil - } - - resources, err := as.findClustersWithResources() - - if err != nil { - return nil, err - } - if len(resources) == 0 { - return nil, errors.New("no cluster has resources") - } - - if len(resources) == 1 { - var cluster strategy.AssignedCluster - cluster.ClusterId = resources[0].ClusterId - cluster.Replicas = 1 - return &strategy.SingleAssignment{Cluster: &cluster}, nil - } - - params := ¶m.Params{Resources: resources} - - switch as.option.Strategy { - case strategy.REPLICATION: - var clusterIds []string - for _, resource := range resources { - clusterIds = append(clusterIds, resource.ClusterId) - } - strategy := strategy.NewReplicationStrategy(clusterIds, as.option.Replica) - return strategy, nil - case strategy.RESOURCES_PRICING: - strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: as.option.Replica}) - return strategy, nil - case strategy.DYNAMIC_RESOURCES: - strategy := strategy.NewDynamicResourcesStrategy(params.Resources, as.option, 1) - return strategy, nil - case strategy.STATIC_WEIGHT: - //todo resources should match cluster StaticWeightMap - strategy := strategy.NewStaticWeightStrategy(as.option.StaticWeightMap, as.option.Replica) - return strategy, nil - } - - return nil, errors.New("no strategy has been chosen") -} - -func (as *CloudScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { - if clusters == nil { - return nil, errors.New("clusters is nil") - } - - for i := len(clusters) - 1; i >= 0; i-- { - if clusters[i].Replicas == 0 { - clusters = append(clusters[:i], clusters[i+1:]...) - } - } - - if len(clusters) == 0 { - return nil, errors.New("clusters is nil") - } - - var results []*CloudResult - - for _, cluster := range clusters { - cName := "" - as.dbEngin.Table("t_cluster").Select("name").Where("id=?", cluster.ClusterId).Find(&cName) - cr := CloudResult{ - ClusterId: cluster.ClusterId, - ClusterName: cName, - Replica: cluster.Replicas, - } - cr.ClusterId = cluster.ClusterId - cr.Replica = cluster.Replicas - - cr.ClusterName = cName - results = append(results, &cr) - } - - return results, nil -} - -func (as *CloudScheduler) findClustersWithResources() ([]*collector.ResourceStats, error) { - resp := []*collector.ResourceStats{} - //查询集群资源信息 - var rMetrics []tracker.Metric - metrics := []string{"cluster_cpu_utilisation", "cluster_cpu_avail", "cluster_cpu_total", "cluster_memory_total", "cluster_memory_avail", "cluster_memory_utilisation", "cluster_disk_utilisation", "cluster_disk_avail", "cluster_disk_total", "cluster_pod_utilisation"} - var clusterNames []string - as.dbEngin.Table("t_cluster").Select("name").Where("id in ?", as.option.ClusterIds).Find(&clusterNames) - for _, c := range clusterNames { - rMetrics = as.promClient.GetNamedMetrics(metrics, time.Now(), tracker.ClusterOption{ClusterName: c}) - r := collector.ResourceStats{} - var cid string - as.dbEngin.Table("t_cluster").Select("id").Where("name = ?", c).Find(&cid) - r.ClusterId = cid - r.Name = c - for _, metric := range rMetrics { - if metric.MetricName == "cluster_cpu_total" { - r.CpuCoreTotal = int64(metric.MetricData.MetricValues[0].Sample.Value()) - } - if metric.MetricName == "cluster_cpu_avail" { - cpuAvail := metric.MetricData.MetricValues[0].Sample.Value() - r.CpuCoreAvail = int64(math.Round(cpuAvail)) - } - if metric.MetricName == "cluster_memory_total" { - r.MemTotal = metric.MetricData.MetricValues[0].Sample.Value() - } - if metric.MetricName == "cluster_memory_avail" { - r.MemAvail = metric.MetricData.MetricValues[0].Sample.Value() - } - if metric.MetricName == "cluster_disk_total" { - r.DiskTotal = metric.MetricData.MetricValues[0].Sample.Value() - } - if metric.MetricName == "cluster_disk_avail" { - r.DiskAvail = metric.MetricData.MetricValues[0].Sample.Value() - } - } - resp = append(resp, &r) - } - return resp, nil -} diff --git a/api/internal/scheduler/schedulers/hpcScheduler.go b/api/internal/scheduler/schedulers/hpcScheduler.go deleted file mode 100644 index 6d84eaef..00000000 --- a/api/internal/scheduler/schedulers/hpcScheduler.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package schedulers - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/algorithm/providerPricing" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" -) - -type HpcScheduler struct { - yamlString string -} - -func NewHpcScheduler(val string) *HpcScheduler { - return &HpcScheduler{yamlString: val} -} - -func (h *HpcScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { - hpc := models.Hpc{} - utils.Convert(task.Metadata, &hpc) - hpc.Id = utils.GenSnowflakeID() - hpc.TaskId = task.TaskId - hpc.Status = constants.Saved - hpc.ParticipantId = participantId - hpc.YamlString = h.yamlString - return hpc, nil -} - -func (h *HpcScheduler) PickOptimalStrategy() (strategy.Strategy, error) { - return nil, nil -} - -func (h *HpcScheduler) genTaskAndProviders(task *response.TaskInfo) (*providerPricing.Task, []*providerPricing.Provider) { - return nil, nil -} - -func (h *HpcScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { - return nil, nil -} diff --git a/api/internal/scheduler/schedulers/vmScheduler.go b/api/internal/scheduler/schedulers/vmScheduler.go deleted file mode 100644 index 3d8e4750..00000000 --- a/api/internal/scheduler/schedulers/vmScheduler.go +++ /dev/null @@ -1,151 +0,0 @@ -package schedulers - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/algorithm/providerPricing" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/pkg/response" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" -) - -type VmScheduler struct { - yamlString string - storage database.Storage - task *response.TaskInfo - *scheduler.Scheduler - option *option.VmOption - ctx context.Context - promClient tracker.Prometheus - dbEngin *gorm.DB - svcCtx *svc.ServiceContext -} - -type VmResult struct { - TaskId string - ClusterId string - ClusterName string - Strategy string - Replica int32 - Msg string -} - -func NewVmScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.VmOption, dbEngin *gorm.DB, promClient tracker.Prometheus) (*VmScheduler, error) { - return &VmScheduler{ctx: ctx, yamlString: val, Scheduler: scheduler, option: option, dbEngin: dbEngin, promClient: promClient}, nil -} - -func (vm *VmScheduler) PickOptimalStrategy() (strategy.Strategy, error) { - if len(vm.option.ClusterIds) == 1 { - // TODO database operation Find - return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: vm.option.ClusterIds[0], Replicas: 1}}, nil - } - //resources, err := vm.findClustersWithResources() - - /* if err != nil { - return nil, err - }*/ - - //if len(resources) == 1 { - // var cluster strategy.AssignedCluster - // cluster.ClusterId = resources[0].ClusterId - // cluster.Replicas = 1 - // return &strategy.SingleAssignment{Cluster: &cluster}, nil - //} - //params := ¶m.Params{Resources: resources} - - switch vm.option.Strategy { - /* case strategy.REPLICATION: - var clusterIds []string - for _, resource := range resources { - clusterIds = append(clusterIds, resource.ClusterId) - } - strategy := strategy.NewReplicationStrategy(clusterIds, 1) - return strategy, nil - case strategy.RESOURCES_PRICING: - strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: 1}) - return strategy, nil*/ - /* case strategy.DYNAMIC_RESOURCES: - strategy := strategy.NewDynamicResourcesStrategy(params.Resources, vm.option, 1) - return strategy, nil*/ - case strategy.STATIC_WEIGHT: - //todo resources should match cluster StaticWeightMap - strategy := strategy.NewStaticWeightStrategy(vm.option.StaticWeightMap, 1) - return strategy, nil - case strategy.RANDOM: - strategy := strategy.NewRandomStrategy(vm.option.ClusterIds, vm.option.Replicas) - return strategy, nil - } - return nil, errors.New("no strategy has been chosen") -} - -func (v *VmScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { - //TODO implement me - vm := models.Vm{} - utils.Convert(task.Metadata, &vm) - vm.Id = utils.GenSnowflakeID() - vm.TaskId = vm.TaskId - vm.Status = constants.Saved - vm.ParticipantId = participantId - return vm, nil -} - -func (vm *VmScheduler) genTaskAndProviders() (*providerPricing.Task, []*providerPricing.Provider, error) { - proParams, err := vm.storage.GetProviderParams() - if err != nil { - return nil, nil, nil - } - var providerList []*providerPricing.Provider - for _, p := range proParams { - provider := providerPricing.NewProvider(p.Participant_id, p.Cpu_avail, p.Mem_avail, p.Disk_avail, 0.0, 0.0, 0.0) - providerList = append(providerList, provider) - } - - //replicas := task.Metadata.(map[string]interface{})["spec"].(map[string]interface{})["replicas"].(float64) - //t := algorithm.NewTask(0, int(replicas), 2, 75120000, 301214500, 1200, 2, 6, 2000) - - return nil, providerList, nil -} - -func (as *VmScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { - //TODO implement me - if clusters == nil { - return nil, errors.New("clusters is nil") - } - - for i := len(clusters) - 1; i >= 0; i-- { - if clusters[i].Replicas == 0 { - clusters = append(clusters[:i], clusters[i+1:]...) - } - } - - if len(clusters) == 0 { - return nil, errors.New("clusters is nil") - } - - var results []*VmResult - - for _, cluster := range clusters { - cName := "" - as.dbEngin.Table("t_cluster").Select("name").Where("id=?", cluster.ClusterId).Find(&cName) - cr := VmResult{ - ClusterId: cluster.ClusterId, - ClusterName: cName, - Replica: cluster.Replicas, - } - cr.ClusterId = cluster.ClusterId - cr.Replica = cluster.Replicas - - cr.ClusterName = cName - results = append(results, &cr) - } - - return results, nil -} diff --git a/api/internal/scheduler/service/aiService.go b/api/internal/scheduler/service/aiService.go deleted file mode 100644 index 6d07a8e7..00000000 --- a/api/internal/scheduler/service/aiService.go +++ /dev/null @@ -1,110 +0,0 @@ -package service - -import ( - "github.com/zeromicro/go-zero/core/logx" - "github.com/zeromicro/go-zero/zrpc" - hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/executor" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/inference" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" - "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" - "net/http" - "strconv" - "sync" -) - -const ( - OCTOPUS = "octopus" - MODELARTS = "modelarts" - SHUGUANGAI = "shuguangAi" -) - -type AiService struct { - AiExecutorAdapterMap map[string]map[string]executor.AiExecutor - AiCollectorAdapterMap map[string]map[string]collector.AiCollector - Storage *database.AiStorage - mu sync.Mutex -} - -func NewAiService(conf *config.Config, storages *database.AiStorage) (*AiService, error) { - var aiType = "1" - adapterIds, err := storages.GetAdapterIdsByType(aiType) - if err != nil { - return nil, err - } - aiService := &AiService{ - AiExecutorAdapterMap: make(map[string]map[string]executor.AiExecutor), - AiCollectorAdapterMap: make(map[string]map[string]collector.AiCollector), - Storage: storages, - } - for _, id := range adapterIds { - clusters, err := storages.GetClustersByAdapterId(id) - if err != nil { - return nil, err - } - if len(clusters.List) == 0 { - continue - } - exeClusterMap, colClusterMap := InitAiClusterMap(conf, clusters.List) - aiService.AiExecutorAdapterMap[id] = exeClusterMap - aiService.AiCollectorAdapterMap[id] = colClusterMap - } - - return aiService, nil -} - -func InitAiClusterMap(conf *config.Config, clusters []types.ClusterInfo) (map[string]executor.AiExecutor, map[string]collector.AiCollector) { - executorMap := make(map[string]executor.AiExecutor) - collectorMap := make(map[string]collector.AiCollector) - for _, c := range clusters { - switch c.Name { - case OCTOPUS: - id, _ := strconv.ParseInt(c.Id, 10, 64) - octopusRpc := octopusclient.NewOctopus(zrpc.MustNewClient(conf.OctopusRpcConf)) - octopus := storeLink.NewOctopusLink(octopusRpc, c.Nickname, id) - collectorMap[c.Id] = octopus - executorMap[c.Id] = octopus - case MODELARTS: - id, _ := strconv.ParseInt(c.Id, 10, 64) - modelArtsRpc := modelartsservice.NewModelArtsService(zrpc.MustNewClient(conf.ModelArtsRpcConf)) - modelArtsImgRpc := imagesservice.NewImagesService(zrpc.MustNewClient(conf.ModelArtsImgRpcConf)) - modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, c.Name, id, c.Nickname) - collectorMap[c.Id] = modelarts - executorMap[c.Id] = modelarts - case SHUGUANGAI: - id, _ := strconv.ParseInt(c.Id, 10, 64) - aCRpc := hpcacclient.NewHpcAC(zrpc.MustNewClient(conf.ACRpcConf)) - sgai := storeLink.NewShuguangAi(aCRpc, c.Nickname, id) - collectorMap[c.Id] = sgai - executorMap[c.Id] = sgai - } - } - - return executorMap, collectorMap -} - -func (as *AiService) ImageInfer(opt *option.InferOption, id int64, adapterName string, clusters []*strategy.AssignedCluster, ts []*inference.ImageFile) { - - r := http.Request{} - _, err := inference.Infer(opt, id, adapterName, clusters, ts, as.AiCollectorAdapterMap, as.Storage, r.Context()) - if err != nil { - logx.Errorf(err.Error()) - return - } -} - -//func (a *AiService) AddCluster() error { -// -//} -// -//func (a *AiService) AddAdapter() error { -// -//} diff --git a/api/internal/scheduler/service/collector/collector.go b/api/internal/scheduler/service/collector/collector.go deleted file mode 100644 index 4c978628..00000000 --- a/api/internal/scheduler/service/collector/collector.go +++ /dev/null @@ -1,67 +0,0 @@ -package collector - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" -) - -type AiCollector interface { - GetResourceStats(ctx context.Context) (*ResourceStats, error) - GetDatasetsSpecs(ctx context.Context) ([]*DatasetsSpecs, error) - GetAlgorithms(ctx context.Context) ([]*Algorithm, error) - GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) - GetTrainingTask(ctx context.Context, taskId string) (*Task, error) - DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) - UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error - GetComputeCards(ctx context.Context) ([]string, error) - GetUserBalance(ctx context.Context) (float64, error) - GetInferUrl(ctx context.Context, option *option.InferOption) ([]*InferUrl, error) -} - -type InferUrl struct { - Url string - Card string -} - -type ResourceStats struct { - ClusterId string - Name string - CpuCoreAvail int64 - CpuCoreTotal int64 - MemAvail float64 - MemTotal float64 - DiskAvail float64 - DiskTotal float64 - GpuAvail int64 - GpuTotal int64 - CardsAvail []*Card - CpuCoreHours float64 - Balance float64 -} - -type Card struct { - Platform string - Type string - Name string - TOpsAtFp16 float64 - CardHours float64 - CardNum int32 -} - -type DatasetsSpecs struct { - Name string - Size string -} - -type Algorithm struct { - Name string - Platform string - TaskType string -} - -type Task struct { - Id string - Start string - End string - Status string -} diff --git a/api/internal/scheduler/service/executor/aiExecutor.go b/api/internal/scheduler/service/executor/aiExecutor.go deleted file mode 100644 index de3e49da..00000000 --- a/api/internal/scheduler/service/executor/aiExecutor.go +++ /dev/null @@ -1,10 +0,0 @@ -package executor - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" -) - -type AiExecutor interface { - Execute(ctx context.Context, option *option.AiOption) (interface{}, error) -} diff --git a/api/internal/scheduler/service/inference/imageInfer.go b/api/internal/scheduler/service/inference/imageInfer.go deleted file mode 100644 index 1085f919..00000000 --- a/api/internal/scheduler/service/inference/imageInfer.go +++ /dev/null @@ -1,396 +0,0 @@ -package inference - -import ( - "context" - "encoding/json" - "errors" - "github.com/go-resty/resty/v2" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/storeLink" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "log" - "math/rand" - "mime/multipart" - "sort" - "strconv" - "sync" - "time" -) - -type ImageFile struct { - ImageResult *types.ImageResult - File multipart.File -} - -func Infer(opt *option.InferOption, id int64, adapterName string, clusters []*strategy.AssignedCluster, ts []*ImageFile, aiCollectorAdapterMap map[string]map[string]collector.AiCollector, storage *database.AiStorage, ctx context.Context) ([]*types.ImageResult, error) { - - //for i := len(clusters) - 1; i >= 0; i-- { - // if clusters[i].Replicas == 0 { - // clusters = append(clusters[:i], clusters[i+1:]...) - // } - //} - - var wg sync.WaitGroup - var cluster_ch = make(chan struct { - urls []*collector.InferUrl - clusterId string - clusterName string - imageNum int32 - }, len(clusters)) - - var cs []struct { - urls []*collector.InferUrl - clusterId string - clusterName string - imageNum int32 - } - collectorMap := aiCollectorAdapterMap[opt.AdapterId] - - ////save taskai - //for _, c := range clusters { - // clusterName, _ := storage.GetClusterNameById(c.ClusterId) - // opt.Replica = c.Replicas - // err := storage.SaveAiTask(id, opt, adapterName, c.ClusterId, clusterName, "", constants.Saved, "") - // if err != nil { - // return nil, err - // } - //} - - var mutex sync.Mutex - errMap := make(map[string]string) - for _, cluster := range clusters { - wg.Add(1) - c := cluster - go func() { - imageUrls, err := collectorMap[c.ClusterId].GetInferUrl(ctx, opt) - if err != nil { - mutex.Lock() - errMap[c.ClusterId] = err.Error() - mutex.Unlock() - wg.Done() - return - } - for i, _ := range imageUrls { - imageUrls[i].Url = imageUrls[i].Url + storeLink.FORWARD_SLASH + "image" - } - clusterName, _ := storage.GetClusterNameById(c.ClusterId) - - s := struct { - urls []*collector.InferUrl - clusterId string - clusterName string - imageNum int32 - }{ - urls: imageUrls, - clusterId: c.ClusterId, - clusterName: clusterName, - imageNum: c.Replicas, - } - - cluster_ch <- s - wg.Done() - return - }() - } - wg.Wait() - close(cluster_ch) - - for s := range cluster_ch { - cs = append(cs, s) - } - - aiTaskList, err := storage.GetAiTaskListById(id) - if err != nil { - return nil, err - } - - //no cluster available - if len(cs) == 0 { - for _, t := range aiTaskList { - t.Status = constants.Failed - t.EndTime = time.Now().Format(time.RFC3339) - if _, ok := errMap[strconv.Itoa(int(t.ClusterId))]; ok { - t.Msg = errMap[strconv.Itoa(int(t.ClusterId))] - } - err := storage.UpdateAiTask(t) - if err != nil { - logx.Errorf(err.Error()) - } - } - storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") - return nil, errors.New("image infer task failed") - } - - //change cluster status - if len(clusters) != len(cs) { - var acs []*strategy.AssignedCluster - var rcs []*strategy.AssignedCluster - for _, cluster := range clusters { - if contains(cs, cluster.ClusterId) { - var ac *strategy.AssignedCluster - ac = cluster - rcs = append(rcs, ac) - } else { - var ac *strategy.AssignedCluster - ac = cluster - acs = append(acs, ac) - } - } - - // update failed cluster status - for _, ac := range acs { - for _, t := range aiTaskList { - if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) { - t.Status = constants.Failed - t.EndTime = time.Now().Format(time.RFC3339) - if _, ok := errMap[strconv.Itoa(int(t.ClusterId))]; ok { - t.Msg = errMap[strconv.Itoa(int(t.ClusterId))] - } - err := storage.UpdateAiTask(t) - if err != nil { - logx.Errorf(err.Error()) - } - } - } - } - - // update running cluster status - for _, ac := range rcs { - for _, t := range aiTaskList { - if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) { - t.Status = constants.Running - err := storage.UpdateAiTask(t) - if err != nil { - logx.Errorf(err.Error()) - } - } - } - } - storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") - } else { - for _, t := range aiTaskList { - t.Status = constants.Running - err := storage.UpdateAiTask(t) - if err != nil { - logx.Errorf(err.Error()) - } - } - storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "running", "任务运行中") - } - - var result_ch = make(chan *types.ImageResult, len(ts)) - var results []*types.ImageResult - limit := make(chan bool, 7) - - var imageNumIdx int32 = 0 - var imageNumIdxEnd int32 = 0 - for _, c := range cs { - new_images := make([]*ImageFile, len(ts)) - copy(new_images, ts) - - imageNumIdxEnd = imageNumIdxEnd + c.imageNum - new_images = new_images[imageNumIdx:imageNumIdxEnd] - imageNumIdx = imageNumIdx + c.imageNum - - wg.Add(len(new_images)) - go sendInferReq(new_images, c, &wg, result_ch, limit) - } - wg.Wait() - close(result_ch) - - for s := range result_ch { - results = append(results, s) - } - - sort.Slice(results, func(p, q int) bool { - return results[p].ClusterName < results[q].ClusterName - }) - - //save ai sub tasks - for _, r := range results { - for _, task := range aiTaskList { - if r.ClusterId == strconv.Itoa(int(task.ClusterId)) { - taskAiSub := models.TaskAiSub{ - TaskId: id, - TaskName: task.Name, - TaskAiId: task.TaskId, - TaskAiName: task.Name, - ImageName: r.ImageName, - Result: r.ImageResult, - Card: r.Card, - ClusterId: task.ClusterId, - ClusterName: r.ClusterName, - } - err := storage.SaveAiTaskImageSubTask(&taskAiSub) - if err != nil { - panic(err) - } - } - } - } - - // update succeeded cluster status - var successStatusCount int - for _, c := range cs { - for _, t := range aiTaskList { - if c.clusterId == strconv.Itoa(int(t.ClusterId)) { - t.Status = constants.Completed - t.EndTime = time.Now().Format(time.RFC3339) - err := storage.UpdateAiTask(t) - if err != nil { - logx.Errorf(err.Error()) - } - successStatusCount++ - } else { - continue - } - } - } - - if len(cs) == successStatusCount { - storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "completed", "任务完成") - } else { - storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") - } - - return results, nil -} - -func sendInferReq(images []*ImageFile, cluster struct { - urls []*collector.InferUrl - clusterId string - clusterName string - imageNum int32 -}, wg *sync.WaitGroup, ch chan<- *types.ImageResult, limit chan bool) { - for _, image := range images { - limit <- true - go func(t *ImageFile, c struct { - urls []*collector.InferUrl - clusterId string - clusterName string - imageNum int32 - }) { - if len(c.urls) == 1 { - r, err := getInferResult(c.urls[0].Url, t.File, t.ImageResult.ImageName, c.clusterName) - if err != nil { - t.ImageResult.ImageResult = err.Error() - t.ImageResult.ClusterId = c.clusterId - t.ImageResult.ClusterName = c.clusterName - t.ImageResult.Card = c.urls[0].Card - ch <- t.ImageResult - wg.Done() - <-limit - return - } - t.ImageResult.ImageResult = r - t.ImageResult.ClusterId = c.clusterId - t.ImageResult.ClusterName = c.clusterName - t.ImageResult.Card = c.urls[0].Card - - ch <- t.ImageResult - wg.Done() - <-limit - return - } else { - idx := rand.Intn(len(c.urls)) - r, err := getInferResult(c.urls[idx].Url, t.File, t.ImageResult.ImageName, c.clusterName) - if err != nil { - t.ImageResult.ImageResult = err.Error() - t.ImageResult.ClusterId = c.clusterId - t.ImageResult.ClusterName = c.clusterName - t.ImageResult.Card = c.urls[idx].Card - ch <- t.ImageResult - wg.Done() - <-limit - return - } - t.ImageResult.ImageResult = r - t.ImageResult.ClusterId = c.clusterId - t.ImageResult.ClusterName = c.clusterName - t.ImageResult.Card = c.urls[idx].Card - - ch <- t.ImageResult - wg.Done() - <-limit - return - } - }(image, cluster) - <-limit - } -} - -func getInferResult(url string, file multipart.File, fileName string, clusterName string) (string, error) { - if clusterName == "鹏城云脑II-modelarts" { - r, err := getInferResultModelarts(url, file, fileName) - if err != nil { - return "", err - } - return r, nil - } - var res Res - req := GetRestyRequest(20) - _, err := req. - SetFileReader("file", fileName, file). - SetResult(&res). - Post(url) - if err != nil { - return "", err - } - return res.Result, nil -} - -func getInferResultModelarts(url string, file multipart.File, fileName string) (string, error) { - var res Res - /* req := GetRestyRequest(20) - _, err := req. - SetFileReader("file", fileName, file). - SetHeaders(map[string]string{ - "ak": "UNEHPHO4Z7YSNPKRXFE4", - "sk": "JWXCE9qcYbc7RjpSRIWt4WgG3ZKF6Q4lPzkJReX9", - }). - SetResult(&res). - Post(url) - if err != nil { - return "", err - }*/ - body, err := utils.SendRequest("POST", url, file, fileName) - if err != nil { - return "", err - } - errjson := json.Unmarshal([]byte(body), &res) - if errjson != nil { - log.Fatalf("Error parsing JSON: %s", errjson) - } - return res.Result, nil -} - -func GetRestyRequest(timeoutSeconds int64) *resty.Request { - client := resty.New().SetTimeout(time.Duration(timeoutSeconds) * time.Second) - request := client.R() - return request -} - -type Res struct { - Result string `json:"result"` -} - -func contains(cs []struct { - urls []*collector.InferUrl - clusterId string - clusterName string - imageNum int32 -}, e string) bool { - for _, c := range cs { - if c.clusterId == e { - return true - } - } - return false -} diff --git a/api/internal/scheduler/service/status/taskStatusSync.go b/api/internal/scheduler/service/status/taskStatusSync.go deleted file mode 100644 index 52bfe922..00000000 --- a/api/internal/scheduler/service/status/taskStatusSync.go +++ /dev/null @@ -1,337 +0,0 @@ -package status - -import ( - "errors" - "fmt" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "net/http" - "strconv" - "sync" - "time" -) - -func UpdateTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { - list := make([]*types.TaskModel, len(tasklist)) - copy(list, tasklist) - for i := len(list) - 1; i >= 0; i-- { - if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed { - list = append(list[:i], list[i+1:]...) - } - } - - if len(list) == 0 { - return - } - - task := list[0] - for i := range list { - earliest, _ := time.Parse(time.RFC3339, task.UpdatedTime) - latest, _ := time.Parse(time.RFC3339, list[i].UpdatedTime) - if latest.Before(earliest) { - task = list[i] - } - } - - // Update Infer Task Status - if task.TaskTypeDict == "11" || task.TaskTypeDict == "12" { - updateInferTaskStatus(svc, *task) - return - } - - aiTask, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) - if err != nil { - logx.Errorf(err.Error()) - return - } - - if len(aiTask) == 0 { - err := svc.Scheduler.AiStorages.UpdateTask(task) - if err != nil { - return - } - return - } - - if len(aiTask) == 1 { - if aiTask[0].Status == constants.Completed { - task.Status = constants.Succeeded - } else { - task.Status = aiTask[0].Status - } - task.StartTime = aiTask[0].StartTime - task.EndTime = aiTask[0].EndTime - err := svc.Scheduler.AiStorages.UpdateTask(task) - if err != nil { - return - } - return - } - - for i := len(aiTask) - 1; i >= 0; i-- { - if aiTask[i].StartTime == "" { - task.Status = aiTask[i].Status - aiTask = append(aiTask[:i], aiTask[i+1:]...) - } - } - - if len(aiTask) == 0 { - err := svc.Scheduler.AiStorages.UpdateTask(task) - if err != nil { - return - } - return - } - - start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local) - end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local) - - var status string - var count int - for _, a := range aiTask { - s, _ := time.ParseInLocation(constants.Layout, a.StartTime, time.Local) - e, _ := time.ParseInLocation(constants.Layout, a.EndTime, time.Local) - - if s.Before(start) { - start = s - } - - if e.After(end) { - end = e - } - - if a.Status == constants.Failed { - status = a.Status - break - } - - if a.Status == constants.Pending { - status = a.Status - continue - } - - if a.Status == constants.Running { - status = a.Status - continue - } - - if a.Status == constants.Completed { - count++ - continue - } - } - - if count == len(aiTask) { - status = constants.Succeeded - } - - if status != "" { - task.Status = status - task.StartTime = start.Format(constants.Layout) - task.EndTime = end.Format(constants.Layout) - } - - err = svc.Scheduler.AiStorages.UpdateTask(task) - if err != nil { - return - } -} - -func updateInferTaskStatus(svc *svc.ServiceContext, task types.TaskModel) { - aiTask, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) - if err != nil { - logx.Errorf(err.Error()) - return - } - - if len(aiTask) == 0 { - task.Status = constants.Failed - err = svc.Scheduler.AiStorages.UpdateTask(&task) - if err != nil { - return - } - return - } - - if len(aiTask) == 1 { - if aiTask[0].Status == constants.Completed { - task.StartTime = aiTask[0].StartTime - task.EndTime = aiTask[0].EndTime - task.Status = constants.Succeeded - } else { - task.StartTime = aiTask[0].StartTime - task.Status = aiTask[0].Status - } - - err = svc.Scheduler.AiStorages.UpdateTask(&task) - if err != nil { - return - } - return - } - - //for i := len(aiTask) - 1; i >= 0; i-- { - // if aiTask[i].StartTime == "" { - // task.Status = aiTask[i].Status - // aiTask = append(aiTask[:i], aiTask[i+1:]...) - // } - //} - // - //if len(aiTask) == 0 { - // task.UpdatedTime = time.Now().Format(constants.Layout) - // tx = svc.DbEngin.Table("task").Model(task).Updates(task) - // if tx.Error != nil { - // logx.Errorf(tx.Error.Error()) - // return - // } - // return - //} - - if aiTask[0].StartTime == "" { - return - } - - start, _ := time.ParseInLocation(time.RFC3339, aiTask[0].StartTime, time.Local) - end, _ := time.ParseInLocation(time.RFC3339, aiTask[0].EndTime, time.Local) - var status string - var count int - for _, a := range aiTask { - if a.Status == constants.Failed { - status = a.Status - break - } - - if a.Status == constants.Pending { - status = a.Status - continue - } - - if a.Status == constants.Running { - status = a.Status - continue - } - - if a.Status == constants.Completed { - count++ - continue - } - } - - if count == len(aiTask) { - status = constants.Succeeded - } - - if status == constants.Succeeded { - task.Status = status - task.StartTime = start.Format(time.RFC3339) - task.EndTime = end.Format(time.RFC3339) - } else { - task.Status = status - task.StartTime = start.Format(time.RFC3339) - } - - err = svc.Scheduler.AiStorages.UpdateTask(&task) - if err != nil { - return - } -} - -func UpdateAiTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { - list := make([]*types.TaskModel, len(tasklist)) - copy(list, tasklist) - for i := len(list) - 1; i >= 0; i-- { - if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed { - list = append(list[:i], list[i+1:]...) - } - } - - if len(list) == 0 { - return - } - - task := list[0] - for i := range list { - earliest, _ := time.Parse(constants.Layout, task.UpdatedTime) - latest, _ := time.Parse(constants.Layout, list[i].UpdatedTime) - if latest.Before(earliest) { - task = list[i] - } - } - - aiTaskList, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) - if err != nil { - logx.Errorf(err.Error()) - return - } - - if len(aiTaskList) == 0 { - return - } - - var wg sync.WaitGroup - for _, aitask := range aiTaskList { - t := aitask - if t.Status == constants.Completed || t.Status == constants.Failed || t.JobId == "" { - continue - } - wg.Add(1) - go func() { - h := http.Request{} - trainingTask, err := svc.Scheduler.AiService.AiCollectorAdapterMap[strconv.FormatInt(t.AdapterId, 10)][strconv.FormatInt(t.ClusterId, 10)].GetTrainingTask(h.Context(), t.JobId) - if err != nil { - if status.Code(err) == codes.DeadlineExceeded { - msg := fmt.Sprintf("###UpdateAiTaskStatus###, AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) - logx.Errorf(errors.New(msg).Error()) - wg.Done() - return - } - - msg := fmt.Sprintf("###UpdateAiTaskStatus###, AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) - logx.Errorf(errors.New(msg).Error()) - wg.Done() - return - } - if trainingTask == nil { - wg.Done() - return - } - switch trainingTask.Status { - case constants.Running: - if t.Status != trainingTask.Status { - svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "running", "任务运行中") - t.Status = trainingTask.Status - } - case constants.Failed: - if t.Status != trainingTask.Status { - svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "failed", "任务失败") - t.Status = trainingTask.Status - } - case constants.Completed: - if t.Status != trainingTask.Status { - svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "completed", "任务完成") - t.Status = trainingTask.Status - } - default: - if t.Status != trainingTask.Status { - svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "pending", "任务pending") - t.Status = trainingTask.Status - } - } - t.StartTime = trainingTask.Start - t.EndTime = trainingTask.End - err = svc.Scheduler.AiStorages.UpdateAiTask(t) - if err != nil { - msg := fmt.Sprintf("###UpdateAiTaskStatus###, AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) - logx.Errorf(errors.New(msg).Error()) - wg.Done() - return - } - wg.Done() - }() - } - wg.Wait() -} diff --git a/api/internal/scheduler/strategy/dynamicResources.go b/api/internal/scheduler/strategy/dynamicResources.go deleted file mode 100644 index 913ea0b8..00000000 --- a/api/internal/scheduler/strategy/dynamicResources.go +++ /dev/null @@ -1,75 +0,0 @@ -package strategy - -import ( - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" -) - -type DynamicResourcesStrategy struct { - replicas int32 - resources []*collector.ResourceStats - opt option.Option -} - -func NewDynamicResourcesStrategy(resources []*collector.ResourceStats, opt option.Option, replica int32) *DynamicResourcesStrategy { - return &DynamicResourcesStrategy{resources: resources, opt: opt, replicas: replica} -} - -func (ps *DynamicResourcesStrategy) Schedule() ([]*AssignedCluster, error) { - if ps.replicas < 1 { - return nil, errors.New("replicas must be greater than 0") - } - - switch ps.opt.GetOptionType() { - case option.AI: - opt := (interface{})(ps.opt).(*option.AiOption) - - var maxCardHoursAvailable float64 - var maxCpuCoreHoursAvailable float64 - var assignedCluster AssignedCluster - var results []*AssignedCluster - for _, res := range ps.resources { - - if res == nil { - continue - } - - if opt.ResourceType == "cpu" { - if res.CpuCoreHours <= 0 { - cluster := &AssignedCluster{ClusterId: res.ClusterId, Replicas: ps.replicas} - results = append(results, cluster) - return results, nil - } - - if res.CpuCoreHours > maxCpuCoreHoursAvailable { - maxCpuCoreHoursAvailable = res.CpuCoreHours - assignedCluster.ClusterId = res.ClusterId - assignedCluster.Replicas = ps.replicas - } - } - - if opt.ResourceType == "computeCard" { - var maxCurrentCardHours float64 - for _, card := range res.CardsAvail { - cardHours := common.RoundFloat( /*card.TOpsAtFp16**/ card.CardHours, 3) - if cardHours > maxCurrentCardHours { - maxCurrentCardHours = cardHours - } - } - if maxCurrentCardHours > maxCardHoursAvailable { - maxCardHoursAvailable = maxCurrentCardHours - assignedCluster.ClusterId = res.ClusterId - assignedCluster.Replicas = ps.replicas - } - } - } - results = append(results, &assignedCluster) - return results, nil - case option.CLOUD: - - } - - return nil, errors.New("failed to apply DynamicResourcesStrategy") -} diff --git a/api/internal/scheduler/strategy/param/params.go b/api/internal/scheduler/strategy/param/params.go deleted file mode 100644 index 558cfef1..00000000 --- a/api/internal/scheduler/strategy/param/params.go +++ /dev/null @@ -1,9 +0,0 @@ -package param - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" -) - -type Params struct { - Resources []*collector.ResourceStats -} diff --git a/api/internal/scheduler/strategy/param/resourcePricing.go b/api/internal/scheduler/strategy/param/resourcePricing.go deleted file mode 100644 index 4c47e7cc..00000000 --- a/api/internal/scheduler/strategy/param/resourcePricing.go +++ /dev/null @@ -1,34 +0,0 @@ -package param - -import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/algorithm/providerPricing" - "strconv" -) - -type ResourcePricingParams struct { - Replicas int32 - task *providerPricing.Task - *Params -} - -func (r *ResourcePricingParams) GetReplicas() int32 { - return r.Replicas -} - -func (r *ResourcePricingParams) GetTask() *providerPricing.Task { - return r.task -} - -func (r *ResourcePricingParams) GetProviders() []*providerPricing.Provider { - var providerList []*providerPricing.Provider - for _, resource := range r.Resources { - id, _ := strconv.ParseInt(resource.ClusterId, 10, 64) - provider := providerPricing.NewProvider( - id, - float64(resource.CpuCoreAvail), - resource.MemAvail, - resource.DiskAvail, 0.0, 0.0, 0.0) - providerList = append(providerList, provider) - } - return providerList -} diff --git a/api/internal/scheduler/strategy/resourcePricing.go b/api/internal/scheduler/strategy/resourcePricing.go deleted file mode 100644 index 32d3de6b..00000000 --- a/api/internal/scheduler/strategy/resourcePricing.go +++ /dev/null @@ -1,167 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package strategy - -import ( - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/algorithm/providerPricing" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy/param" - "strconv" -) - -type PricingStrategy struct { - ProviderList []*providerPricing.Provider - Task *providerPricing.Task - StrategyList []*providerPricing.Strategy -} - -func NewPricingStrategy(params *param.ResourcePricingParams) *PricingStrategy { - providers := params.GetProviders() - task := params.GetTask() - var providerList []*providerPricing.Provider - var res [][]int - - for _, p := range providers { - p.GenMaxResourceNum(task) - providerList = append(providerList, p) - } - - providerPricing.Back_trace_task(task.Replicas, 0, providerList, 0, &res, 0) - - var strategyList []*providerPricing.Strategy - for _, r := range res { - var path []int - var pathlist [][]int - - var resourcePerProvider []int - for j, p := range providerList { - if r[j] > p.MaxReplicas { - resourcePerProvider = append(resourcePerProvider, p.MaxReplicas) - } else { - resourcePerProvider = append(resourcePerProvider, r[j]) - } - } - providerPricing.Back_trace_resource(resourcePerProvider, 0, path, &pathlist) - strategy := providerPricing.NewStrategy() - strategy.Tasksolution = r - strategy.Resourcesolution = pathlist - strategyList = append(strategyList, strategy) - } - - return &PricingStrategy{ProviderList: providerList, Task: task, StrategyList: strategyList} -} - -func (ps *PricingStrategy) computeMaxScore() (*providerPricing.Task, error) { - maxStrategy := providerPricing.NewStrategy() - var maxprofit float64 - - //先计算出最大的利润值 - for _, strategy := range ps.StrategyList { - for _, resourceSolu := range strategy.Resourcesolution { - profit := providerPricing.ComputeProfit(ps.Task, strategy.Tasksolution, resourceSolu, ps.ProviderList) - if profit > maxprofit { - maxprofit = profit - } - } - } - - for _, strategy := range ps.StrategyList { - for _, resourceSolu := range strategy.Resourcesolution { - profit := providerPricing.ComputeProfit(ps.Task, strategy.Tasksolution, resourceSolu, ps.ProviderList) - highDegree := providerPricing.ComputeHighDegree(ps.Task, resourceSolu, ps.ProviderList) - - valueSum := profit/maxprofit + highDegree - - //将每个确定任务分配策略的最高的策略得分存储到里面 - if valueSum > maxStrategy.ValueSum { - strategy.Profit = profit - strategy.HighDegree = highDegree - } - - if valueSum > maxStrategy.ValueSum { - maxStrategy.ValueSum = valueSum - maxStrategy.Tasksolution = strategy.Tasksolution - newResourceSolu := [][]int{} - newResourceSolu = append(newResourceSolu, resourceSolu) - maxStrategy.Resourcesolution = newResourceSolu - maxStrategy.Profit = profit - maxStrategy.HighDegree = highDegree - } - } - } - - if len(ps.ProviderList) == 0 { - return nil, errors.New("empty providers") - } - - ps.Task.MaxscoreStrategy = maxStrategy // 记录该任务的最终分配策略 - return ps.Task, nil -} - -func (ps *PricingStrategy) produceMaxScoreStrategy() (*providerPricing.Strategy, error) { - task, err := ps.computeMaxScore() - if err != nil { - return nil, err - } - - //计算任务i的resourcePerTask属性 - for i, _ := range ps.ProviderList { - tasksolu := task.MaxscoreStrategy.Tasksolution[i] // 第j个提供商分到的任务数 - resourcesolu := task.MaxscoreStrategy.Resourcesolution[0][i] // 第j个提供商分到的资源数 - - // 在第j个云提供商处声明一个长度为资源数的链表 - resourcePerTaskPerProviders := make([]int, resourcesolu) - if tasksolu > 0 { - for tasksolu > 0 { - for j := 0; j < resourcesolu; j++ { - resourcePerTaskPerProviders[j] += 1 - tasksolu -= 1 - } - } - } else if tasksolu == 0 { - resourcePerTaskPerProviders = []int{0} - } - - task.ResourcePerTask = append(task.ResourcePerTask, resourcePerTaskPerProviders) - } - - return task.MaxscoreStrategy, nil -} - -func (ps *PricingStrategy) Schedule() ([]*AssignedCluster, error) { - strategy, err := ps.produceMaxScoreStrategy() - if err != nil { - return nil, err - } - - if len(strategy.Tasksolution) == 0 { - return nil, errors.New("调度失败, 未能获取调度结果") - } - - var results []*AssignedCluster - for i, e := range strategy.Tasksolution { - if e == 0 { - continue - } - cluster := &AssignedCluster{ClusterId: strconv.FormatInt(ps.ProviderList[i].Pid, 10), Replicas: int32(e)} - results = append(results, cluster) - } - - if len(results) == 0 { - return nil, errors.New("可用集群为空") - } - - return results, nil -} diff --git a/api/internal/scheduler/strategy/staticWeight.go b/api/internal/scheduler/strategy/staticWeight.go deleted file mode 100644 index f106b608..00000000 --- a/api/internal/scheduler/strategy/staticWeight.go +++ /dev/null @@ -1,50 +0,0 @@ -package strategy - -import ( - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/algorithm/weightDistributing" -) - -type StaticWeightStrategy struct { - staticWeightMap map[string]int32 - replicas int32 -} - -func NewStaticWeightStrategy(staticWeightMap map[string]int32, replicas int32) *StaticWeightStrategy { - return &StaticWeightStrategy{staticWeightMap: staticWeightMap, - replicas: replicas, - } -} - -func (s *StaticWeightStrategy) Schedule() ([]*AssignedCluster, error) { - - if s.replicas < 1 { - return nil, errors.New("replicas must be greater than 0") - } - - if len(s.staticWeightMap) == 0 || s.staticWeightMap == nil { - return nil, errors.New("weight must be set") - } - - weights := make([]*weightDistributing.Weight, 0) - for k, v := range s.staticWeightMap { - weight := &weightDistributing.Weight{ - Id: k, - Weight: v, - } - weights = append(weights, weight) - } - - err := weightDistributing.DistributeReplicas(weights, s.replicas) - if err != nil { - return nil, err - } - - var results []*AssignedCluster - for _, weight := range weights { - cluster := &AssignedCluster{ClusterId: weight.Id, Replicas: weight.Replica} - results = append(results, cluster) - } - - return results, nil -} diff --git a/api/internal/scheduler/strategy/test/strategy_test.go b/api/internal/scheduler/strategy/test/strategy_test.go deleted file mode 100644 index de36b7be..00000000 --- a/api/internal/scheduler/strategy/test/strategy_test.go +++ /dev/null @@ -1,251 +0,0 @@ -package test - -import ( - "fmt" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/entity" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/strategy" - "math/rand" - "testing" - "time" -) - -func TestReplication(t *testing.T) { - parts := []entity.Participant{ - {Name: "test1", Participant_id: 1}, - {Name: "test2", Participant_id: 2}, - {Name: "test3", Participant_id: 3}, - } - rsc := []*collector.ResourceStats{ - { - ClusterId: "1", - Name: "test1", - }, - { - ClusterId: "2", - Name: "test2"}, - { - ClusterId: "3", - Name: "test3"}, - } - tests := []struct { - name string - replica int32 - ps []entity.Participant - res []*collector.ResourceStats - }{ - { - name: "test1", - replica: 1, - ps: parts, - }, - { - name: "test2", - replica: 2, - ps: parts, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var clusterIds []string - for _, stats := range rsc { - clusterIds = append(clusterIds, stats.ClusterId) - } - repl := strategy.NewReplicationStrategy(clusterIds, 0) - schedule, err := repl.Schedule() - if err != nil { - return - } - for _, cluster := range schedule { - fmt.Println(cluster) - } - - }) - } - -} - -func TestStaticWeight(t *testing.T) { - parts := map[string]int32{ - "test1": 6, - "test2": 5, - "test3": 2, - } - tests := []struct { - name string - replica int32 - ps map[string]int32 - }{ - { - name: "test1", - replica: 1, - ps: parts, - }, - { - name: "test2", - replica: 5, - ps: parts, - }, - { - name: "test2", - replica: 6, - ps: parts, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - repl := strategy.NewStaticWeightStrategy(tt.ps, tt.replica) - schedule, err := repl.Schedule() - if err != nil { - return - } - for _, cluster := range schedule { - fmt.Println(cluster) - } - - }) - } -} - -func TestRandom(t *testing.T) { - // 使用当前时间作为随机数种子,确保每次程序运行产生的随机数序列都不同 - rand.Seed(time.Now().UnixNano()) - - /*randomNum := randInt(1, 100) - fmt.Println("Random number:", randomNum)*/ - total := 5 // 假设总数是5 - first, second := splitIntoTwoRandomParts(total) - fmt.Printf("第一部分的数量: %d, 第二部分的数量: %d\n", first, second) -} - -// randInt 生成一个指定范围内的随机整数,包括min但不包括max -func randInt(min, max int) int { - return min + rand.Intn(max-min) -} - -func splitIntoTwoRandomParts(total int) (int, int) { - if total < 2 { - // 如果总数小于2,则无法分成两部分 - return 0, 0 - } - // 生成一个随机数作为第一部分的数量(范围在[1, total-1]之间) - firstPart := rand.Intn(total-1) + 1 - // 第二部分的数量就是总数减去第一部分的数量 - secondPart := total - firstPart - return firstPart, secondPart -} - -func splitIntoRandomParts(total int) (int, int) { - if total < 2 { - // 如果总数小于2,则无法分成两部分 - return 0, 0 - } - // 生成一个随机数作为第一部分的数量(范围在[1, total-1]之间) - firstPart := rand.Intn(total-1) + 1 - // 第二部分的数量就是总数减去第一部分的数量 - secondPart := total - firstPart - return firstPart, secondPart -} - -func TestRandoms(t *testing.T) { - // 使用当前时间作为随机数种子,确保每次程序运行产生的随机数序列都不同 - rand.Seed(time.Now().UnixNano()) - - /*randomNum := randInt(1, 100) - fmt.Println("Random number:", randomNum)*/ - total := 10 // 假设总数是5 - parts := splitRandomParts(total) - fmt.Println("分配结果:", parts) -} - -// splitIntoRandomParts 将总数total随机分成多个部分,并返回这些部分的切片 -func splitRandomParts(total int) []int { - if total < 2 { - // 如果总数小于2,则无法分成多个部分 - return []int{total} - } - - // 创建一个切片来保存每个部分的数量 - var parts []int - - // 剩余要分配的副本数 - remaining := total - - // 随机决定要分成的部分数量(至少2个部分) - numParts := rand.Intn(total-1) + 2 - - // 确保每个部分至少获得1个副本 - for i := 0; i < numParts-1; i++ { - // 生成一个随机数(1到剩余副本数之间) - // 为了避免最后一个部分太小,我们可能需要调整随机数范围 - minPartSize := 1 - if remaining <= numParts-i { - // 如果剩余副本数不足以让每个部分都至少获得1个,则调整最小部分大小 - minPartSize = remaining / (numParts - i) - if remaining%(numParts-i) > 0 { - minPartSize++ - } - } - // 生成一个大于等于minPartSize且小于等于remaining的随机数 - partSize := minPartSize + rand.Intn(remaining-minPartSize+1) - parts = append(parts, partSize) - remaining -= partSize - } - - // 最后一个部分的数量就是剩余的副本数 - parts = append(parts, remaining) - - return parts -} - -func TestNumRandom(t *testing.T) { - total := 10 // 假设副本数是10 - numParts := 2 // 假设要分成5个集群 - - parts, err := splitIntoParts(total, numParts) - if err != nil { - fmt.Println("Error:", err) - return - } - fmt.Println("分配结果:", parts) -} - -// splitIntoParts 将总数total随机分成numParts个部分,并返回这些部分的切片 -func splitIntoParts(total int, numParts int) ([]int, error) { - if total < 1 || numParts < 1 { - // 总数或部分数量不能小于1 - return nil, fmt.Errorf("total and numParts must be greater than 0") - } - if numParts > total { - // 部分数量不能大于总数 - return nil, fmt.Errorf("numParts cannot be greater than total") - } - - // 创建一个切片来保存每个部分的数量 - parts := make([]int, numParts) - - // 首先将每个部分都分配至少一个副本 - for i := range parts { - parts[i] = 1 - total-- - } - - // 剩余要分配的副本数 - remaining := total - - // 随机分配剩余的副本 - for remaining > 0 { - // 随机选择一个部分(索引从0到numParts-1) - partIndex := rand.Intn(numParts) - - // 如果该部分加上一个副本后不会超过总数,则分配一个副本 - if parts[partIndex]+1 <= total { - parts[partIndex]++ - remaining-- - } - } - - return parts, nil -} diff --git a/api/internal/storeLink/modelarts.go b/api/internal/storeLink/modelarts.go deleted file mode 100644 index 331becb1..00000000 --- a/api/internal/storeLink/modelarts.go +++ /dev/null @@ -1,399 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storeLink - -import ( - "context" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - modelartsclient "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "strconv" - "strings" - "time" -) - -const ( - Ascend = "Ascend" -) - -type ModelArtsLink struct { - modelArtsRpc modelartsservice.ModelArtsService - modelArtsImgRpc imagesservice.ImagesService - platform string - participantId int64 - pageIndex int32 - pageSize int32 -} - -func NewModelArtsLink(modelArtsRpc modelartsservice.ModelArtsService, modelArtsImgRpc imagesservice.ImagesService, name string, id int64, nickname string) *ModelArtsLink { - return &ModelArtsLink{modelArtsRpc: modelArtsRpc, modelArtsImgRpc: modelArtsImgRpc, platform: nickname, participantId: id, pageIndex: 0, pageSize: 50} -} - -func (m *ModelArtsLink) UploadImage(ctx context.Context, path string) (interface{}, error) { - //TODO modelArts上传镜像 - return nil, nil -} - -func (m *ModelArtsLink) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { - // TODO modelArts删除镜像 - return nil, nil -} - -func (m *ModelArtsLink) QueryImageList(ctx context.Context) (interface{}, error) { - // modelArts获取镜像列表 - req := &modelarts.ListRepoReq{ - Offset: "0", - Limit: strconv.Itoa(int(m.pageSize)), - Platform: m.platform, - } - resp, err := m.modelArtsImgRpc.ListReposDetails(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (m *ModelArtsLink) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { - // modelArts提交任务 - environments := make(map[string]string) - parameters := make([]*modelarts.ParametersTrainJob, 0) - for _, env := range envs { - s := strings.Split(env, COMMA) - environments[s[0]] = s[1] - } - for _, param := range params { - s := strings.Split(param, COMMA) - parameters = append(parameters, &modelarts.ParametersTrainJob{ - Name: s[0], - Value: s[1], - }) - } - req := &modelarts.CreateTrainingJobReq{ - Kind: "job", - Metadata: &modelarts.MetadataS{ - Name: TASK_NAME_PREFIX + utils.RandomString(10), - WorkspaceId: "0", - }, - Algorithm: &modelarts.Algorithms{ - Id: algorithmId, - Engine: &modelarts.EngineCreateTraining{ - ImageUrl: imageId, - }, - Command: cmd, - Environments: environments, - Parameters: parameters, - }, - Spec: &modelarts.SpecsC{ - Resource: &modelarts.ResourceCreateTraining{ - FlavorId: resourceId, - NodeCount: 1, - }, - }, - Platform: m.platform, - } - resp, err := m.modelArtsRpc.CreateTrainingJob(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (m *ModelArtsLink) QueryTask(ctx context.Context, taskId string) (interface{}, error) { - // 获取任务 - req := &modelarts.DetailTrainingJobsReq{ - TrainingJobId: taskId, - Platform: m.platform, - } - resp, err := m.modelArtsRpc.GetTrainingJobs(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (m *ModelArtsLink) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { - // 删除任务 - req := &modelarts.DeleteTrainingJobReq{ - TrainingJobId: taskId, - Platform: m.platform, - } - resp, err := m.modelArtsRpc.DeleteTrainingJob(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (m *ModelArtsLink) QuerySpecs(ctx context.Context) (interface{}, error) { - // octopus查询资源规格 - req := &modelarts.TrainingJobFlavorsReq{ - Platform: m.platform, - } - resp, err := m.modelArtsRpc.GetTrainingJobFlavors(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (m *ModelArtsLink) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { - return nil, nil -} - -func (m *ModelArtsLink) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) { - return nil, nil -} - -func (m *ModelArtsLink) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) { - var algorithms []*collector.Algorithm - - req := &modelarts.ListAlgorithmsReq{ - Platform: m.platform, - Offset: m.pageIndex, - Limit: m.pageSize, - } - resp, err := m.modelArtsRpc.ListAlgorithms(ctx, req) - if err != nil { - return nil, err - } - if resp.ErrorMsg != "" { - return nil, errors.New("failed to get algorithms") - } - - for _, a := range resp.Items { - //TODO The value of taskType is temporarily fixed to "pytorch" - algorithm := &collector.Algorithm{Name: a.Metadata.Name, Platform: MODELARTS, TaskType: "pytorch"} - algorithms = append(algorithms, algorithm) - } - return algorithms, nil -} - -func (m *ModelArtsLink) GetComputeCards(ctx context.Context) ([]string, error) { - var cards []string - cards = append(cards, Ascend) - return cards, nil -} - -func (m *ModelArtsLink) GetUserBalance(ctx context.Context) (float64, error) { - return 0, nil -} - -func (m *ModelArtsLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) { - return "", nil -} - -func (m *ModelArtsLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error { - return nil -} - -func (m *ModelArtsLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { - req := &modelartsservice.GetTrainingJobLogsPreviewReq{ - Platform: m.platform, - TaskId: "worker-0", - TrainingJobId: taskId, - } - resp, err := m.modelArtsRpc.GetTrainingJobLogsPreview(ctx, req) - if err != nil { - return "", err - } - - if strings.Contains(resp.Content, "404 Not Found") { - resp.Content = "waiting for logs..." - } - return resp.Content, nil -} - -func (m *ModelArtsLink) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { - resp, err := m.QueryTask(ctx, taskId) - if err != nil { - return nil, err - } - jobresp, ok := (resp).(*modelartsservice.JobResponse) - if jobresp.ErrorMsg != "" || !ok { - if jobresp.ErrorMsg != "" { - return nil, errors.New(jobresp.ErrorMsg) - } else { - return nil, errors.New("get training task failed, empty error returned") - } - } - var task collector.Task - task.Id = jobresp.Metadata.Id - - switch strings.ToLower(jobresp.Status.Phase) { - case "completed": - milliTimestamp := int64(jobresp.Status.StartTime) - task.Start = timeutils.MillisecondsToUTCString(milliTimestamp, time.DateTime) - duration := int64(jobresp.Status.Duration) - task.End = timeutils.MillisecondsToAddDurationToUTCString(milliTimestamp, duration, time.DateTime) - task.Status = constants.Completed - case "failed": - milliTimestamp := int64(jobresp.Status.StartTime) - task.Start = timeutils.MillisecondsToUTCString(milliTimestamp, time.DateTime) - duration := int64(jobresp.Status.Duration) - task.End = timeutils.MillisecondsToAddDurationToUTCString(milliTimestamp, duration, time.DateTime) - task.Status = constants.Failed - case "running": - milliTimestamp := int64(jobresp.Status.StartTime) - task.Start = timeutils.MillisecondsToUTCString(milliTimestamp, time.DateTime) - task.Status = constants.Running - case "stopped": - task.Status = constants.Stopped - case "pending": - task.Status = constants.Pending - case "terminated": - //TODO Failed - task.Status = constants.Failed - default: - task.Status = "undefined" - } - - return &task, nil -} - -func (m *ModelArtsLink) Execute(ctx context.Context, option *option.AiOption) (interface{}, error) { - err := m.GenerateSubmitParams(ctx, option) - if err != nil { - return nil, err - } - task, err := m.SubmitTask(ctx, option.ImageId, option.Cmd, option.Envs, option.Params, option.ResourceId, option.DatasetsId, option.AlgorithmId, option.TaskType) - if err != nil { - return nil, err - } - return task, nil -} - -func (m *ModelArtsLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error { - err := m.generateResourceId(ctx, option) - if err != nil { - return err - } - err = m.generateAlgorithmId(ctx, option) - if err != nil { - return err - } - err = m.generateImageId(option) - if err != nil { - return err - } - err = m.generateCmd(option) - if err != nil { - return err - } - err = m.generateEnv(option) - if err != nil { - return err - } - err = m.generateParams(option) - if err != nil { - return err - } - return nil -} - -func (m *ModelArtsLink) generateResourceId(ctx context.Context, option *option.AiOption) error { - option.ResourceId = "modelarts.kat1.xlarge" - return nil -} - -func (m *ModelArtsLink) generateImageId(option *option.AiOption) error { - - return nil -} - -func (m *ModelArtsLink) generateCmd(option *option.AiOption) error { - - return nil -} - -func (m *ModelArtsLink) generateEnv(option *option.AiOption) error { - - return nil -} - -func (m *ModelArtsLink) generateParams(option *option.AiOption) error { - - return nil -} - -func (m *ModelArtsLink) generateAlgorithmId(ctx context.Context, option *option.AiOption) error { - req := &modelarts.ListAlgorithmsReq{ - Platform: m.platform, - Offset: m.pageIndex, - Limit: m.pageSize, - } - resp, err := m.modelArtsRpc.ListAlgorithms(ctx, req) - if err != nil { - return err - } - if resp.ErrorMsg != "" { - return errors.New("failed to get algorithmId") - } - - for _, algorithm := range resp.Items { - engVersion := algorithm.JobConfig.Engine.EngineVersion - if strings.Contains(engVersion, option.TaskType) { - ns := strings.Split(algorithm.Metadata.Name, DASH) - if ns[0] != option.TaskType { - continue - } - if ns[1] != option.DatasetsName { - continue - } - if ns[2] != option.AlgorithmName { - continue - } - option.AlgorithmId = algorithm.Metadata.Id - return nil - } - } - - if option.AlgorithmId == "" { - return errors.New("Algorithm does not exist") - } - - return errors.New("failed to get AlgorithmId") -} - -func (m *ModelArtsLink) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*collector.InferUrl, error) { - var imageUrls []*collector.InferUrl - urlReq := &modelartsclient.ImageReasoningUrlReq{ - ModelName: option.ModelName, - Type: option.ModelType, - Card: "npu", - } - urlResp, err := m.modelArtsRpc.ImageReasoningUrl(ctx, urlReq) - if err != nil { - return nil, err - } - imageUrl := &collector.InferUrl{ - Url: urlResp.Url, - Card: "npu", - } - imageUrls = append(imageUrls, imageUrl) - - return imageUrls, nil -} diff --git a/api/internal/storeLink/octopus.go b/api/internal/storeLink/octopus.go deleted file mode 100644 index ed706c0a..00000000 --- a/api/internal/storeLink/octopus.go +++ /dev/null @@ -1,904 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storeLink - -import ( - "context" - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-octopus/octopus" - "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" - "math" - "strconv" - "strings" - "time" -) - -type OctopusLink struct { - octopusRpc octopusclient.Octopus - pageIndex int32 - pageSize int32 - platform string - participantId int64 -} - -const ( - IMG_NAME_PREFIX = "oct_" - IMG_VERSION_PREFIX = "version_" - TASK_NAME_PREFIX = "trainJob" - RESOURCE_POOL = "common-pool" - HANWUJI = "hanwuji" - SUIYUAN = "suiyuan" - SAILINGSI = "sailingsi" - MLU = "MLU" - BIV100 = "BI-V100" - CAMBRICONMLU290 = 256 - GCU = "GCU" - ENFLAME = "enflame" - EnflameT20 = 128 - BASE_TOPS = 128 - CAMBRICON = "cambricon" - ILUVATAR = "iluvatar" - TRAIN_CMD = "cd /code; python train.py" - VERSION = "V1" - DOMAIN = "http://192.168.242.41:8001/" - CAMBRICON_CN = "寒武纪290" - ENFLAME_CN = "燧原T20" - ILUVATAR_CN = "天数BI-V100" -) - -var ( - cardAliasMap = map[string]string{ - MLU: CAMBRICON, - GCU: ENFLAME, - BIV100: ILUVATAR, - } - cardCnMap = map[string]string{ - MLU: CAMBRICON_CN, - GCU: ENFLAME_CN, - BIV100: ILUVATAR_CN, - } - cardTopsMap = map[string]float64{ - MLU: CAMBRICONMLU290, - GCU: EnflameT20, - } -) - -func NewOctopusLink(octopusRpc octopusclient.Octopus, name string, id int64) *OctopusLink { - return &OctopusLink{octopusRpc: octopusRpc, platform: name, participantId: id, pageIndex: 1, pageSize: 100} -} - -func (o *OctopusLink) UploadImage(ctx context.Context, path string) (interface{}, error) { - // octopus创建镜像 - createReq := &octopus.CreateImageReq{ - Platform: o.platform, - CreateImage: &octopus.CreateImage{ - SourceType: 1, - ImageName: IMG_NAME_PREFIX + utils.RandomString(7), - ImageVersion: IMG_VERSION_PREFIX + utils.RandomString(7), - }, - } - createResp, err := o.octopusRpc.CreateImage(ctx, createReq) - if err != nil { - return nil, err - } - - // octopus上传镜像 - uploadReq := &octopus.UploadImageReq{ - Platform: o.platform, - ImageId: createResp.Payload.ImageId, - Params: &octopus.UploadImageParam{ - Domain: "", - FileName: "", - }, - } - uploadResp, err := o.octopusRpc.UploadImage(ctx, uploadReq) - if err != nil { - return nil, err - } - - // Todo 实际上传 - - return uploadResp, nil -} - -func (o *OctopusLink) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { - // octopus删除镜像 - req := &octopus.DeleteImageReq{ - Platform: o.platform, - ImageId: imageId, - } - resp, err := o.octopusRpc.DeleteImage(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OctopusLink) QueryImageList(ctx context.Context) (interface{}, error) { - // octopus获取镜像列表 - req := &octopus.GetUserImageListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - resp, err := o.octopusRpc.GetUserImageList(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OctopusLink) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { - // octopus提交任务 - - // python参数 - var prms []*octopus.Parameters - for _, param := range params { - var p octopus.Parameters - s := strings.Split(param, COMMA) - p.Key = s[0] - p.Value = s[1] - prms = append(prms, &p) - } - - //环境变量 - envMap := make(map[string]string) - for _, env := range envs { - s := strings.Split(env, COMMA) - envMap[s[0]] = s[1] - } - - req := &octopus.CreateTrainJobReq{ - Platform: o.platform, - Params: &octopus.CreateTrainJobParam{ - ImageId: imageId, - Name: TASK_NAME_PREFIX + UNDERSCORE + utils.RandomString(10), - ResourcePool: RESOURCE_POOL, - Config: []*octopus.Config{ - { - Command: cmd, - ResourceSpecId: resourceId, - MinFailedTaskCount: 1, - MinSucceededTaskCount: 1, - TaskNumber: 1, - Parameters: prms, - Envs: envMap, - }, - }, - DataSetId: datasetsId, - DataSetVersion: VERSION, - AlgorithmId: algorithmId, - AlgorithmVersion: VERSION, - }, - } - resp, err := o.octopusRpc.CreateTrainJob(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OctopusLink) QueryTask(ctx context.Context, taskId string) (interface{}, error) { - // octopus获取任务 - req := &octopus.GetTrainJobReq{ - Platform: o.platform, - Id: taskId, - } - resp, err := o.octopusRpc.GetTrainJob(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OctopusLink) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { - // octopus删除任务 - req := &octopus.DeleteTrainJobReq{ - Platform: o.platform, - JobIds: []string{taskId}, - } - resp, err := o.octopusRpc.DeleteTrainJob(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OctopusLink) QuerySpecs(ctx context.Context) (interface{}, error) { - // octopus查询资源规格 - req := &octopus.GetResourceSpecsReq{ - Platform: o.platform, - ResourcePool: RESOURCE_POOL, - } - resp, err := o.octopusRpc.GetResourceSpecs(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OctopusLink) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { - req := &octopus.GetResourceSpecsReq{ - Platform: o.platform, - ResourcePool: RESOURCE_POOL, - } - specResp, err := o.octopusRpc.GetResourceSpecs(ctx, req) - if err != nil { - return nil, err - } - if !specResp.Success { - return nil, errors.New(specResp.Error.Message) - } - balanceReq := &octopus.GetUserBalanceReq{ - Platform: o.platform, - } - balanceResp, err := o.octopusRpc.GetUserBalance(ctx, balanceReq) - if err != nil { - return nil, err - } - if !balanceResp.Success { - return nil, errors.New(balanceResp.Error.Message) - } - - var cards []*collector.Card - balance := float64(balanceResp.Payload.BillingUser.Amount) - var cpuHours float64 - for _, spec := range specResp.TrainResourceSpecs { - if spec.Price == 0 { - ns := strings.Split(spec.Name, COMMA) - if len(ns) == 2 { - nss := strings.Split(ns[0], COLON) - if nss[0] == CPU { - cpuHours = -1 - } - } - } - - if spec.Price == 1 { - ns := strings.Split(spec.Name, COMMA) - cardSpecs := strings.Split(ns[0], STAR) - - cardTops, isMapContainsKey := cardTopsMap[cardSpecs[1]] - if !isMapContainsKey { - continue - } - - card := &collector.Card{ - Platform: OCTOPUS, - Type: CARD, - Name: cardSpecs[1], - TOpsAtFp16: cardTops, - CardHours: balance / spec.Price, - } - cards = append(cards, card) - } - } - - resourceStats := &collector.ResourceStats{ - ClusterId: strconv.FormatInt(o.participantId, 10), - Name: o.platform, - Balance: balance, - CardsAvail: cards, - CpuCoreHours: cpuHours, - } - - return resourceStats, nil -} - -func (o *OctopusLink) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) { - req := &octopus.GetMyDatasetListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - resp, err := o.octopusRpc.GetMyDatasetList(ctx, req) - if err != nil { - return nil, err - } - if !resp.Success { - return nil, errors.New(resp.Error.Message) - } - specs := []*collector.DatasetsSpecs{} - for _, dataset := range resp.Payload.Datasets { - spec := &collector.DatasetsSpecs{Name: dataset.Name} - specs = append(specs, spec) - } - return specs, nil -} - -func (o *OctopusLink) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) { - var algorithms []*collector.Algorithm - - req := &octopus.GetMyAlgorithmListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - resp, err := o.octopusRpc.GetMyAlgorithmList(ctx, req) - if err != nil { - return nil, err - } - if !resp.Success { - return nil, errors.New("failed to get algorithms") - } - - for _, a := range resp.Payload.Algorithms { - algorithm := &collector.Algorithm{Name: a.AlgorithmName, Platform: OCTOPUS, TaskType: strings.ToLower(a.FrameworkName)} - algorithms = append(algorithms, algorithm) - } - return algorithms, nil -} - -func (o *OctopusLink) GetComputeCards(ctx context.Context) ([]string, error) { - var cards []string - for s, _ := range cardAliasMap { - cards = append(cards, s) - } - return cards, nil -} - -func (o *OctopusLink) GetUserBalance(ctx context.Context) (float64, error) { - balanceReq := &octopus.GetUserBalanceReq{ - Platform: o.platform, - } - balanceResp, err := o.octopusRpc.GetUserBalance(ctx, balanceReq) - if err != nil { - return 0, err - } - if !balanceResp.Success { - if balanceResp.Error != nil { - return 0, errors.New(balanceResp.Error.Message) - } else { - return 0, errors.New("failed to get user balance") - } - } - balance := float64(balanceResp.Payload.BillingUser.Amount) - return balance, nil -} - -func (o *OctopusLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) { - var name string - if resourceType == CARD { - name = dataset + UNDERSCORE + algorithm + UNDERSCORE + card - } else { - name = dataset + UNDERSCORE + algorithm + UNDERSCORE + CPU - } - - req := &octopus.GetMyAlgorithmListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - resp, err := o.octopusRpc.GetMyAlgorithmList(ctx, req) - if err != nil { - return "", err - } - if !resp.Success { - return "", errors.New("failed to get algorithmList") - } - - var algorithmId string - var algorithms []*octopus.Algorithms - for _, a := range resp.Payload.Algorithms { - if strings.ToLower(a.FrameworkName) != taskType { - continue - } - - if a.AlgorithmDescript == name { - algorithms = append(algorithms, a) - } - } - - if len(algorithms) == 0 { - return "", errors.New("algorithmId not found") - } - - if len(algorithms) == 1 { - algorithmId = algorithms[0].AlgorithmId - } - - aLatest := &octopus.Algorithms{} - for i, _ := range algorithms { - if time.Unix(algorithms[i].CreatedAt, 0).After(time.Unix(aLatest.CreatedAt, 0)) { - aLatest = algorithms[i] - } - } - if aLatest.AlgorithmId == "" { - return "", errors.New("algorithmId not found") - } - - algorithmId = aLatest.AlgorithmId - - dcReq := &octopus.DownloadCompressReq{ - Platform: o.platform, - Version: VERSION, - AlgorithmId: algorithmId, - } - dcResp, err := o.octopusRpc.DownloadCompress(ctx, dcReq) - if err != nil { - return "", err - } - - if !dcResp.Success { - return "", errors.New(dcResp.Error.Message) - } - - daReq := &octopus.DownloadAlgorithmReq{ - Platform: o.platform, - Version: VERSION, - AlgorithmId: algorithmId, - CompressAt: dcResp.Payload.CompressAt, - Domain: DOMAIN, - } - daResp, err := o.octopusRpc.DownloadAlgorithm(ctx, daReq) - if err != nil { - return "", err - } - if !daResp.Success { - return "", errors.New(dcResp.Error.Message) - } - urlReq := &octopus.AlgorithmUrlReq{ - Platform: o.platform, - Url: daResp.Payload.DownloadUrl, - } - urlResp, err := o.octopusRpc.DownloadAlgorithmUrl(ctx, urlReq) - if err != nil { - return "", err - } - - return urlResp.Algorithm, nil -} - -func (o *OctopusLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error { - //var name string - //if resourceType == CARD { - // name = dataset + UNDERSCORE + algorithm + UNDERSCORE + card - //} else { - // name = dataset + UNDERSCORE + algorithm + UNDERSCORE + CPU - //} - //uploadReq := &octopus.UploadAlgorithmReq{} - return nil -} - -func (o *OctopusLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { - instance, err := strconv.ParseInt(instanceNum, 10, 32) - if err != nil { - return "", err - } - req := &octopus.GetTrainJobLogReq{ - Platform: o.platform, - TaskId: taskId, - TaskNum: "task0", - Num: int32(instance), - } - resp, err := o.octopusRpc.GetTrainJobLog(ctx, req) - if err != nil { - return "", err - } - - if strings.Contains(resp.Content, "404 Not Found") { - resp.Content = "waiting for logs..." - } - - return resp.Content, nil -} - -func (o *OctopusLink) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { - resp, err := o.QueryTask(ctx, taskId) - if err != nil { - return nil, err - } - jobresp, ok := (resp).(*octopus.GetTrainJobResp) - if !jobresp.Success || !ok { - if jobresp.Error != nil { - return nil, errors.New(jobresp.Error.Message) - } else { - return nil, errors.New("get training task failed, empty error returned") - } - } - var task collector.Task - task.Id = jobresp.Payload.TrainJob.Id - if jobresp.Payload.TrainJob.StartedAt != 0 { - task.Start = time.Unix(jobresp.Payload.TrainJob.StartedAt, 0).Format(constants.Layout) - } - if jobresp.Payload.TrainJob.CompletedAt != 0 { - task.End = time.Unix(jobresp.Payload.TrainJob.CompletedAt, 0).Format(constants.Layout) - } - switch jobresp.Payload.TrainJob.Status { - case "succeeded": - task.Status = constants.Completed - case "failed": - task.Status = constants.Failed - case "running": - task.Status = constants.Running - case "stopped": - task.Status = constants.Stopped - case "pending": - task.Status = constants.Pending - default: - task.Status = "undefined" - } - - return &task, nil -} - -func (o *OctopusLink) Execute(ctx context.Context, option *option.AiOption) (interface{}, error) { - err := o.GenerateSubmitParams(ctx, option) - if err != nil { - return nil, err - } - task, err := o.SubmitTask(ctx, option.ImageId, option.Cmd, option.Envs, option.Params, option.ResourceId, option.DatasetsId, option.AlgorithmId, option.TaskType) - if err != nil { - return nil, err - } - return task, nil -} - -func (o *OctopusLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error { - err := o.generateResourceId(ctx, option) - if err != nil { - return err - } - err = o.generateDatasetsId(ctx, option) - if err != nil { - return err - } - err = o.generateImageId(ctx, option) - if err != nil { - return err - } - err = o.generateAlgorithmId(ctx, option) - if err != nil { - return err - } - err = o.generateCmd(option) - if err != nil { - return err - } - err = o.generateEnv(option) - if err != nil { - return err - } - err = o.generateParams(option) - if err != nil { - return err - } - return nil -} - -func (o *OctopusLink) generateResourceId(ctx context.Context, option *option.AiOption) error { - if option.ResourceType == "" { - return errors.New("ResourceType not set") - } - req := &octopus.GetResourceSpecsReq{ - Platform: o.platform, - ResourcePool: RESOURCE_POOL, - } - specResp, err := o.octopusRpc.GetResourceSpecs(ctx, req) - if err != nil { - return err - } - if !specResp.Success { - return errors.New(specResp.Error.Message) - } - - if option.ResourceType == CPU { - for _, spec := range specResp.TrainResourceSpecs { - if spec.Price == 0 { - option.ResourceId = spec.Id - return nil - } - } - } - - if option.ResourceType == CARD { - if option.ComputeCard == "" { - option.ComputeCard = GCU - } - err = setResourceIdByCard(option, specResp, option.ComputeCard) - if err != nil { - return err - } - return nil - } - - return errors.New("failed to get ResourceId") -} - -func (o *OctopusLink) generateDatasetsId(ctx context.Context, option *option.AiOption) error { - if option.DatasetsName == "" { - return errors.New("DatasetsName not set") - } - req := &octopus.GetMyDatasetListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - resp, err := o.octopusRpc.GetMyDatasetList(ctx, req) - if err != nil { - return err - } - if !resp.Success { - return errors.New("failed to get DatasetsId") - } - for _, dataset := range resp.Payload.Datasets { - if dataset.Name == option.DatasetsName { - option.DatasetsId = dataset.Id - return nil - } - } - return errors.New("failed to get DatasetsId") -} - -func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOption) error { - if option.TaskType == "" { - return errors.New("TaskType not set") - } - - req := &octopus.GetUserImageListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - resp, err := o.octopusRpc.GetUserImageList(ctx, req) - if err != nil { - return err - } - if !resp.Success { - return errors.New("failed to get imageId") - } - - if option.ResourceType == CPU { - for _, img := range resp.Payload.Images { - if img.Image.ImageName == "test-image" { - option.ImageId = img.Image.Id - return nil - } - } - } - - preImgReq := &octopus.GetPresetImageListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - preImgResp, err := o.octopusRpc.GetPresetImageList(ctx, preImgReq) - if err != nil { - return err - } - if !preImgResp.Success { - return errors.New("failed to get PresetImages") - } - - if option.ResourceType == CARD { - for _, image := range preImgResp.Payload.Images { - if strings.Contains(image.ImageName, cardAliasMap[strings.ToUpper(option.ComputeCard)]) { - switch strings.ToUpper(option.ComputeCard) { - case GCU: - if strings.HasPrefix(image.ImageVersion, "t20_") { - option.ImageId = image.Id - return nil - } - case BIV100: - if strings.HasPrefix(image.ImageVersion, "bi_") { - option.ImageId = image.Id - return nil - } - case MLU: - option.ImageId = image.Id - return nil - } - } - } - } - - return errors.New("failed to get ImageId") -} - -func (o *OctopusLink) generateAlgorithmId(ctx context.Context, option *option.AiOption) error { - req := &octopus.GetMyAlgorithmListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - resp, err := o.octopusRpc.GetMyAlgorithmList(ctx, req) - if err != nil { - return err - } - if !resp.Success { - return errors.New("failed to get algorithmId") - } - - for _, algorithm := range resp.Payload.Algorithms { - if algorithm.FrameworkName == strings.Title(option.TaskType) { - ns := strings.Split(algorithm.AlgorithmName, UNDERSCORE) - if ns[0] != option.DatasetsName { - continue - } - if ns[1] != option.AlgorithmName { - continue - } - switch option.ResourceType { - case CPU: - if ns[2] != CPU { - continue - } - case CARD: - if ns[2] != strings.ToLower(option.ComputeCard) { - continue - } - } - - option.AlgorithmId = algorithm.AlgorithmId - return nil - } - } - - if option.AlgorithmId == "" { - return errors.New("Algorithm does not exist") - } - - return errors.New("failed to get AlgorithmId") -} - -func (o *OctopusLink) generateCmd(option *option.AiOption) error { - if option.Cmd == "" { - switch option.ComputeCard { - case GCU: - option.Cmd = "cd /code; python3 train.py" - case MLU: - option.Cmd = ". /torch/venv3/pytorch/bin/activate; cd /code; python train.py" - default: - option.Cmd = TRAIN_CMD - } - } - - return nil -} - -func (o *OctopusLink) generateEnv(option *option.AiOption) error { - - return nil -} - -func (o *OctopusLink) generateParams(option *option.AiOption) error { - if len(option.Params) == 0 { - epoch := "epoch" + COMMA + "1" - option.Params = append(option.Params, epoch) - } - return nil -} - -func setResourceIdByCard(option *option.AiOption, specs *octopus.GetResourceSpecsResp, computeCard string) error { - if option.Tops == 0 { - for _, spec := range specs.TrainResourceSpecs { - if spec.Price == 1 { - ns := strings.Split(spec.Name, COMMA) - cardSpecs := strings.Split(ns[0], STAR) - if cardSpecs[1] == cardCnMap[strings.ToUpper(computeCard)] { - option.ResourceId = spec.Id - option.ComputeCard = computeCard - return nil - } - } else { - continue - } - } - } else { - cardNum := math.Ceil(option.Tops / float64(BASE_TOPS)) - for _, spec := range specs.TrainResourceSpecs { - if option.Tops < BASE_TOPS { - if spec.Price == 1 { - ns := strings.Split(spec.Name, COMMA) - cardSpecs := strings.Split(ns[0], STAR) - if cardSpecs[1] == cardCnMap[strings.ToUpper(computeCard)] { - option.ResourceId = spec.Id - option.ComputeCard = computeCard - return nil - } - } else { - continue - } - } else { - ns := strings.Split(spec.Name, COMMA) - if len(ns) != 4 { - continue - } - cardSpecs := strings.Split(ns[0], STAR) - if cardSpecs[1] != cardCnMap[strings.ToUpper(computeCard)] { - continue - } - s, err := strconv.ParseFloat(cardSpecs[0], 64) - if err != nil { - return err - } - switch computeCard { - case GCU: - option.ComputeCard = computeCard - if cardNum == s { // 1, 4, 8 - option.ResourceId = spec.Id - return nil - } - if 1 < cardNum && cardNum <= 4 && s == 4 { - option.ResourceId = spec.Id - return nil - } - if 4 < cardNum && s == 8 { - option.ResourceId = spec.Id - return nil - } - - case MLU: // 1, 2, 4 - option.ComputeCard = computeCard - if cardNum/2 == s { - option.ResourceId = spec.Id - return nil - } - if 1 < cardNum/2 && cardNum/2 <= 2 && s == 2 { - option.ResourceId = spec.Id - return nil - } - if 2 < cardNum/2 && s == 4 { - option.ResourceId = spec.Id - return nil - } - } - } - } - } - return errors.New("set ResourceId error") -} - -func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*collector.InferUrl, error) { - req := &octopus.GetNotebookListReq{ - Platform: o.platform, - PageIndex: o.pageIndex, - PageSize: o.pageSize, - } - list, err := o.octopusRpc.GetNotebookList(ctx, req) - if err != nil { - return nil, err - } - - var imageUrls []*collector.InferUrl - for _, notebook := range list.Payload.GetNotebooks() { - if strings.Contains(notebook.AlgorithmName, option.ModelName) && notebook.Status == "running" { - url := strings.Replace(notebook.Tasks[0].Url, FORWARD_SLASH, "", -1) - names := strings.Split(notebook.AlgorithmName, UNDERSCORE) - imageUrl := &collector.InferUrl{ - Url: DOMAIN + url, - Card: names[2], - } - imageUrls = append(imageUrls, imageUrl) - } else { - continue - } - } - - if len(imageUrls) == 0 { - return nil, errors.New("no infer url available") - } - return imageUrls, nil -} diff --git a/api/internal/storeLink/shuguangHpc.go b/api/internal/storeLink/shuguangHpc.go deleted file mode 100644 index afb1fdd5..00000000 --- a/api/internal/storeLink/shuguangHpc.go +++ /dev/null @@ -1,268 +0,0 @@ -package storeLink - -import ( - "context" - "errors" - "fmt" - "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" - hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "strconv" - "strings" -) - -type ShuguangHpc struct { - aCRpc hpcacclient.HpcAC - platform string - participantId int64 -} - -const ( - GAP_WALL_TIME_24H = "24:00:00" - TASK_SHUGUANG_PREFIX = "ShuguangHPC" - NEWLINE = "\n" - JOBNAME = "JOBNAME" - GAP_CMD_FILE = "cmd" - GAP_NNODE = "1" // 节点个数 - GAP_NODE_STRING = "" - GAP_APPNAME = "BASE" - GAP_QUEUE = "wzhdtest" - GAP_WORK_DIR = "/work/home/acgnnmfbwo/BASE/JOBNAME" - GAP_STD_OUT_FILE = "/work/home/acgnnmfbwo/BASE/JOBNAME/std.out.%j" - GAP_STD_ERR_FILE = "/work/home/acgnnmfbwo/BASE/JOBNAME/std.err.%j" - StrJobManagerID = 1637920656 - Apptype = "BASIC" - EXPORT = "export" - GAP_NPROC = "1" - GAP_NDCU = "1" - GAP_EXCLUSIVE = "" - GAP_PPN = "" - GAP_NGPU = "" - GAP_MULTI_SUB = "" - StrJobInfoMap = "%d,%s:%s:" - Username = "acgnnmfbwo" -) - -var RESOURCEMAP = map[string]ResourceSpecHpc{ - "FPOqD5Cx8iNYqawEgDrAxLdrszp4Tmhl": { - GAP_NNODE: "1", - GAP_NPROC: "1", - GAP_NDCU: "1", - }, - "Nd99eGNoBFC2ZTycKDlqD37heWTOmrMS": { - GAP_NNODE: "1", - GAP_NPROC: "2", - GAP_NDCU: "1", - }, - "uAmLkz6jgSZkC6o8JywG7Yo2aiFPPOBO": { - GAP_NNODE: "1", - GAP_NPROC: "4", - GAP_NDCU: "2", - }, - "D71OZQYrRabJc2nfL2GDWOdLEfbiMzYH": { - GAP_NNODE: "1", - GAP_NPROC: "8", - GAP_NDCU: "4", - }, - "sXUMrGmgMDFJaLi6dPiB9LkHjFb3lvL5": { - GAP_NNODE: "1", - GAP_NPROC: "16", - GAP_NDCU: "4", - }, - "ZfCKQKbNbQl9RPwlSyWLah1Gf7Ti7uJA": { - GAP_NNODE: "1", - GAP_NPROC: "32", - GAP_NDCU: "4", - }, - "cfEI4ulTNo2gYUozzdG59URByUjwLl3x": { - GAP_NNODE: "2", - GAP_NPROC: "4", - GAP_NDCU: "2", - }, - "vtbkaks8bErhpLRkUDiPDUHq6ssotFpD": { - GAP_NNODE: "2", - GAP_NPROC: "8", - GAP_NDCU: "4", - }, - "QJXZFJSReVWWQfkvQjGyEq1JpDHN55Oh": { - GAP_NNODE: "2", - GAP_NPROC: "16", - GAP_NDCU: "4", - }, - "79xSdy48yLbVLl9DqEV6tQ2J6jaHe5KO": { - GAP_NNODE: "2", - GAP_NPROC: "32", - GAP_NDCU: "8", - }, -} - -var RESOURCESPECSHPC = map[string]string{ - "FPOqD5Cx8iNYqawEgDrAxLdrszp4Tmhl": "1*NODE, CPU:1, 1*DCU", - "Nd99eGNoBFC2ZTycKDlqD37heWTOmrMS": "1*NODE, CPU:2, 1*DCU", - "uAmLkz6jgSZkC6o8JywG7Yo2aiFPPOBO": "1*NODE, CPU:4, 2*DCU", - "D71OZQYrRabJc2nfL2GDWOdLEfbiMzYH": "1*NODE, CPU:8, 4*DCU", - "sXUMrGmgMDFJaLi6dPiB9LkHjFb3lvL5": "1*NODE, CPU:16, 4*DCU", - "ZfCKQKbNbQl9RPwlSyWLah1Gf7Ti7uJA": "1*NODE, CPU:32, 4*DCU", - "cfEI4ulTNo2gYUozzdG59URByUjwLl3x": "2*NODE, CPU:4, 2*DCU", - "vtbkaks8bErhpLRkUDiPDUHq6ssotFpD": "2*NODE, CPU:8, 4*DCU", - "QJXZFJSReVWWQfkvQjGyEq1JpDHN55Oh": "2*NODE, CPU:16, 4*DCU", - "79xSdy48yLbVLl9DqEV6tQ2J6jaHe5KO": "2*NODE, CPU:32, 8*DCU", -} - -var AcStatus = map[string]string{ - "statQ": "Pending", - "statR": "Running", - "statE": "Pending", - "statC": "Completed", - "statH": "Pending", - "statS": "Pending", - "statW": "Pending", - "statX": "Other", -} - -type ResourceSpecHpc struct { - GAP_NNODE string - GAP_NPROC string - GAP_NDCU string -} - -func NewShuguangHpc(aCRpc hpcacclient.HpcAC, name string, id int64) *ShuguangHpc { - return &ShuguangHpc{aCRpc: aCRpc, platform: name, participantId: id} -} - -func (s ShuguangHpc) UploadImage(ctx context.Context, path string) (interface{}, error) { - return nil, nil -} - -func (s ShuguangHpc) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { - return nil, nil -} - -func (s ShuguangHpc) QueryImageList(ctx context.Context) (interface{}, error) { - return nil, nil -} - -func (s ShuguangHpc) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { - // shuguangHpc提交任务 - - //判断是否resourceId匹配自定义资源Id - _, isMapContainsKey := RESOURCESPECSHPC[resourceId] - if !isMapContainsKey { - return nil, errors.New("shuguangHpc资源Id不存在") - } - - //环境变量 - var env string - for _, e := range envs { - s := strings.Split(e, COMMA) - env += EXPORT + SPACE + s[0] + EQUAL + s[1] + NEWLINE - } - - //请求 - taskName := TASK_SHUGUANG_PREFIX + UNDERSCORE + utils.RandomString(10) - GAP_WORK_DIR := strings.Replace(GAP_WORK_DIR, JOBNAME, taskName, -1) - GAP_STD_OUT_FILE := strings.Replace(GAP_STD_OUT_FILE, JOBNAME, taskName, -1) - GAP_STD_ERR_FILE := strings.Replace(GAP_STD_ERR_FILE, JOBNAME, taskName, -1) - - req := &hpcAC.SubmitJobReq{ - Apptype: Apptype, - Appname: GAP_APPNAME, - StrJobManagerID: StrJobManagerID, - MapAppJobInfo: &hpcAC.MapAppJobInfo{ - GAP_CMD_FILE: cmd, - GAP_NNODE: GAP_NNODE, - GAP_NODE_STRING: GAP_NODE_STRING, - GAP_SUBMIT_TYPE: GAP_CMD_FILE, - GAP_JOB_NAME: taskName, - GAP_WORK_DIR: GAP_WORK_DIR, - GAP_QUEUE: GAP_QUEUE, - GAP_NPROC: GAP_NPROC, - GAP_PPN: GAP_PPN, - GAP_NGPU: GAP_NGPU, - GAP_NDCU: GAP_NDCU, - GAP_WALL_TIME: GAP_WALL_TIME_24H, - GAP_EXCLUSIVE: GAP_EXCLUSIVE, - GAP_APPNAME: GAP_APPNAME, - GAP_MULTI_SUB: GAP_MULTI_SUB, - GAP_STD_OUT_FILE: GAP_STD_OUT_FILE, - GAP_STD_ERR_FILE: GAP_STD_ERR_FILE, - GAP_SCHEDULER_OPT_WEB: env, - }, - } - - updateSGHpcRequestByResourceId(resourceId, req) - - resp, err := s.aCRpc.SubmitJob(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil - -} - -func (s ShuguangHpc) QueryTask(ctx context.Context, taskId string) (interface{}, error) { - //实时作业 - reqC := &hpcAC.JobDetailReq{ - JobId: taskId, - } - respC, err := s.aCRpc.GetJobDetail(ctx, reqC) - if err != nil { - return nil, err - } - - //实时作业检查是否成功 - if respC.Data != nil && respC.Data.JobEndTime != "" { - return respC, nil - } else { - //历史作业 - reqH := &hpcAC.HistoryJobDetailReq{ - JobId: taskId, - JobmanagerId: strconv.Itoa(StrJobManagerID), - } - - respH, err := s.aCRpc.HistoryJobDetail(ctx, reqH) - if err != nil { - return nil, err - } - - return respH, nil - } -} - -func (s ShuguangHpc) QuerySpecs(ctx context.Context) (interface{}, error) { - resp := &types.GetResourceSpecsResp{} - - for k, v := range RESOURCESPECSHPC { - var respec types.ResourceSpecSl - respec.SpecId = k - respec.SpecName = v - respec.ParticipantId = s.participantId - respec.ParticipantName = s.platform - resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) - } - - resp.Success = true - return resp, nil -} - -func (s ShuguangHpc) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { - strJobInfoMap := fmt.Sprintf(StrJobInfoMap, StrJobManagerID, Username, taskId) - req := &hpcAC.DeleteJobReq{ - StrJobInfoMap: strJobInfoMap, - } - resp, err := s.aCRpc.DeleteJob(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func updateSGHpcRequestByResourceId(resourceId string, req *hpcAC.SubmitJobReq) { - spec := RESOURCEMAP[resourceId] - req.MapAppJobInfo.GAP_NNODE = spec.GAP_NNODE - req.MapAppJobInfo.GAP_NPROC = spec.GAP_NPROC - req.MapAppJobInfo.GAP_NDCU = spec.GAP_NDCU -} diff --git a/api/internal/storeLink/shuguangai.go b/api/internal/storeLink/shuguangai.go deleted file mode 100644 index 2a634a4c..00000000 --- a/api/internal/storeLink/shuguangai.go +++ /dev/null @@ -1,753 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storeLink - -import ( - "context" - "errors" - "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" - hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "strconv" - "strings" - "sync" - "time" -) - -const ( - RAM_SIZE_1G = 1024 // 1G - WORKER_NUMBER = 1 - DCU = "DCU" - DCU_TOPS = 24.5 - PYTORCH = "Pytorch" - TASK_PYTORCH_PREFIX = "PytorchTask" - TENSORFLOW = "Tensorflow" - RESOURCE_GROUP = "wzhdtest" - WorkPath = "/work/home/acgnnmfbwo/pcmv1/" - TimeoutLimit = "10:00:00" - PythonCodePath = "/work/home/acgnnmfbwo/111111/py/test.py" - DATASETS_DIR = "/work/home/acgnnmfbwo/pcmv1/dataset" - ALGORITHM_DIR = "/work/home/acgnnmfbwo/pcmv1/algorithm" - TRAIN_FILE = "train.py" - CPUCOREPRICEPERHOUR = 0.09 - DCUPRICEPERHOUR = 2.0 - KB = 1024 -) - -var RESOURCESGAIMAP = map[string]ResourceSpecSGAI{ - "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": { - CPU: 1, - GPU: 1, - RAM: 2 * RAM_SIZE_1G, - }, - "6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": { - CPU: 1, - GPU: 2, - RAM: 2 * RAM_SIZE_1G, - }, - "OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": { - CPU: 2, - GPU: 3, - RAM: 4 * RAM_SIZE_1G, - }, - "sBWfpkntUzsWYly11kdwEHZOYYIsFmve": { - CPU: 4, - GPU: 4, - RAM: 8 * RAM_SIZE_1G, - }, - "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": { - CPU: 5, - GPU: 5, - RAM: 10 * RAM_SIZE_1G, - }, -} - -var RESOURCESPECSAI = map[string]string{ - "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": "CPU:1, DCU:1, RAM:2G", - "6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": "CPU:1, DCU:2, RAM:2G", - "OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": "CPU:2, DCU:3, RAM:4G", - "sBWfpkntUzsWYly11kdwEHZOYYIsFmve": "CPU:4, DCU:4, RAM:8G", - "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": "CPU:5, DCU:5, RAM:10G", -} - -type ResourceSpecSGAI struct { - CPU int64 - GPU int64 - RAM int64 -} - -type ShuguangAi struct { - aCRpc hpcacclient.HpcAC - platform string - participantId int64 -} - -func NewShuguangAi(aCRpc hpcAC.HpcACClient, name string, id int64) *ShuguangAi { - return &ShuguangAi{aCRpc: aCRpc, platform: name, participantId: id} -} - -func (s *ShuguangAi) UploadImage(ctx context.Context, path string) (interface{}, error) { - return nil, nil -} - -func (s *ShuguangAi) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { - return nil, nil -} - -func (s *ShuguangAi) QueryImageList(ctx context.Context) (interface{}, error) { - // shuguangAi获取镜像列表 - req := &hpcAC.GetImageListAiReq{ - AcceleratorType: DCU, - TaskType: PYTORCH, - } - resp, err := s.aCRpc.GetImageListAi(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (s *ShuguangAi) SubmitPytorchTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string) (interface{}, error) { - //判断是否resourceId匹配自定义资源Id - _, isMapContainsKey := RESOURCESPECSAI[resourceId] - if !isMapContainsKey { - return nil, errors.New("shuguangAi资源Id不存在") - } - - //根据imageId获取imagePath, version - imageReq := &hpcAC.GetImageAiByIdReq{ImageId: imageId} - imageResp, err := s.aCRpc.GetImageAiById(ctx, imageReq) - if err != nil { - return nil, err - } - - //python参数 - var pythonArg string - for _, param := range params { - s := strings.Split(param, COMMA) - pythonArg += PY_PARAM_PREFIX + s[0] + "=" + s[1] + SPACE - } - - //环境变量 - var env string - for _, e := range envs { - s := strings.Split(e, COMMA) - env += s[0] + "=" + s[1] + SPACE - } - - //set paths - paths := strings.Split(algorithmId, DASH) - workPath := ALGORITHM_DIR + FORWARD_SLASH + paths[0] + FORWARD_SLASH + paths[1] + DASH + paths[2] - codePath := workPath + FORWARD_SLASH + TRAIN_FILE - - req := &hpcAC.SubmitPytorchTaskReq{ - Params: &hpcAC.SubmitPytorchTaskParams{ - TaskName: TASK_PYTORCH_PREFIX + UNDERSCORE + utils.RandomString(10), - WorkPath: workPath, - IsDistributed: false, - IsHvd: false, - Env: env, - AcceleratorType: DCU, - Version: imageResp.Image.Version, - ImagePath: imageResp.Image.Path, - WorkerNumber: WORKER_NUMBER, - ResourceGroup: RESOURCE_GROUP, - TimeoutLimit: TimeoutLimit, - PythonCodePath: codePath, - PythonArg: pythonArg, - }, - } - - updateSGAIRequestByResourceId(resourceId, req) - - resp, err := s.aCRpc.SubmitPytorchTask(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func updateSGAIRequestByResourceId(resourceId string, req *hpcAC.SubmitPytorchTaskReq) { - spec := RESOURCESGAIMAP[resourceId] - req.Params.WorkerCpuNumber = spec.CPU - req.Params.WorkerGpuNumber = spec.GPU - req.Params.WorkerRamSize = spec.RAM -} - -func (s *ShuguangAi) SubmitTensorflowTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string) (interface{}, error) { - //req := &hpcAC.SubmitTensorflowTaskReq{ - // Params: &hpcAC.SubmitTensorflowTaskParams{ - // - // } - //} - return nil, nil -} - -func (s *ShuguangAi) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { - // set algorithmId temporarily for storelink submit - if algorithmId == "" { - algorithmId = "pytorch-mnist-fcn" - } - - // shuguangAi提交任务 - switch aiType { - case PYTORCH_TASK: - task, err := s.SubmitPytorchTask(ctx, imageId, cmd, envs, params, resourceId, datasetsId, algorithmId) - if err != nil { - return nil, err - } - return task, nil - case TENSORFLOW_TASK: - task, err := s.SubmitTensorflowTask(ctx, imageId, cmd, envs, params, resourceId, datasetsId, algorithmId) - if err != nil { - return nil, err - } - return task, nil - } - return nil, errors.New("shuguangAi不支持的任务类型") -} - -func (s *ShuguangAi) QueryTask(ctx context.Context, taskId string) (interface{}, error) { - // shuguangAi获取任务 - req := &hpcAC.GetPytorchTaskReq{ - Id: taskId, - } - resp, err := s.aCRpc.GetPytorchTask(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (s *ShuguangAi) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { - // shuguangAi删除任务 - req := &hpcAC.DeleteTaskAiReq{ - Ids: taskId, - } - resp, err := s.aCRpc.DeleteTaskAi(ctx, req) - if err != nil { - return nil, err - } - - return resp, nil -} - -func (s *ShuguangAi) QuerySpecs(ctx context.Context) (interface{}, error) { - resp := &types.GetResourceSpecsResp{} - - for k, v := range RESOURCESPECSAI { - var respec types.ResourceSpecSl - respec.SpecId = k - respec.SpecName = v - respec.ParticipantId = s.participantId - respec.ParticipantName = s.platform - resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) - } - - resp.Success = true - return resp, nil -} - -func (s *ShuguangAi) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { - var wg sync.WaitGroup - wg.Add(4) - var cBalance = make(chan float64) - var cMemTotal = make(chan float64) - var cTotalCpu = make(chan int64) - - resourceStats := &collector.ResourceStats{ - ClusterId: strconv.FormatInt(s.participantId, 10), - Name: s.platform, - } - - dcu := &collector.Card{ - Platform: SHUGUANGAI, - Type: CARD, - Name: DCU, - TOpsAtFp16: DCU_TOPS, - } - - //balance - go func() { - userReq := &hpcAC.GetUserInfoReq{} - userinfo, err := s.aCRpc.GetUserInfo(ctx, userReq) - if err != nil { - return - } - balance, _ := strconv.ParseFloat(userinfo.Data.AccountBalance, 64) - resourceStats.Balance = balance - - cBalance <- balance - }() - - //resource limit - go func() { - limitReq := &hpcAC.QueueReq{} - limitResp, err := s.aCRpc.QueryUserQuotasLimit(ctx, limitReq) - if err != nil { - wg.Done() - return - } - totalCpu := limitResp.Data.AccountMaxCpu - totalDcu := limitResp.Data.AccountMaxDcu - - dcu.CardNum = int32(totalDcu) - resourceStats.CpuCoreTotal = totalCpu - - cTotalCpu <- totalCpu - wg.Done() - }() - - //disk - go func() { - diskReq := &hpcAC.ParaStorQuotaReq{} - diskResp, err := s.aCRpc.ParaStorQuota(ctx, diskReq) - if err != nil { - wg.Done() - return - } - - totalDisk := common.RoundFloat(diskResp.Data[0].Threshold*KB*KB*KB, 3) - availDisk := common.RoundFloat((diskResp.Data[0].Threshold-diskResp.Data[0].Usage)*KB*KB*KB, 3) - - resourceStats.DiskTotal = totalDisk - resourceStats.DiskAvail = availDisk - wg.Done() - }() - - //memory - go func() { - nodeResp, err := s.aCRpc.GetNodeResources(ctx, nil) - if err != nil { - wg.Done() - return - } - memSize := common.RoundFloat(float64(nodeResp.Data.MemorySize)*KB*KB, 3) // MB to BYTES - - resourceStats.MemTotal = memSize - cMemTotal <- memSize - wg.Done() - }() - - //resources being occupied - go func() { - memSize := <-cMemTotal - totalCpu := <-cTotalCpu - memberJobResp, err := s.aCRpc.GetMemberJobs(ctx, nil) - if err != nil { - wg.Done() - return - } - var cpuCoreAvail int64 - var memAvail float64 - if len(memberJobResp.Data) != 0 { - cpuCoreAvail = totalCpu - memAvail = memSize - } else { - var cpuCoreUsed int64 - var memUsed float64 - for _, datum := range memberJobResp.Data { - cpuCoreUsed += datum.CpuCore - } - memUsed = float64(cpuCoreUsed * 2 * KB * KB * KB) // 2 GB per cpu core - if cpuCoreUsed > totalCpu { - cpuCoreAvail = 0 - } else { - cpuCoreAvail = totalCpu - cpuCoreUsed - } - if memUsed > memSize { - memAvail = 0 - } else { - memAvail = memSize - memUsed - } - } - resourceStats.CpuCoreAvail = cpuCoreAvail - resourceStats.MemAvail = memAvail - wg.Done() - }() - - //usable hours - var balance float64 - - select { - case v := <-cBalance: - balance = v - case <-time.After(2 * time.Second): - return nil, errors.New("get balance rpc call failed") - } - - var cards []*collector.Card - cardHours := common.RoundFloat(balance/DCUPRICEPERHOUR, 3) - cpuHours := common.RoundFloat(balance/CPUCOREPRICEPERHOUR, 3) - - dcu.CardHours = cardHours - resourceStats.CpuCoreHours = cpuHours - - wg.Wait() - - cards = append(cards, dcu) - resourceStats.CardsAvail = cards - - return resourceStats, nil -} - -func (s *ShuguangAi) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) { - req := &hpcAC.GetFileListReq{Limit: 100, Path: DATASETS_DIR, Start: 0} - list, err := s.aCRpc.GetFileList(ctx, req) - if err != nil { - return nil, err - } - if list.Code != "0" { - return nil, errors.New(list.Msg) - } - specs := []*collector.DatasetsSpecs{} - for _, file := range list.Data.FileList { - spec := &collector.DatasetsSpecs{Name: file.Name, Size: strconv.FormatInt(file.Size, 10)} - specs = append(specs, spec) - } - return specs, nil -} - -func (s *ShuguangAi) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) { - var algorithms []*collector.Algorithm - for _, t := range GetTaskTypes() { - taskType := t - req := &hpcAC.GetFileListReq{Limit: 100, Path: ALGORITHM_DIR + FORWARD_SLASH + taskType, Start: 0, Order: "asc", OrderBy: "name", KeyWord: ""} - list, err := s.aCRpc.GetFileList(ctx, req) - if err != nil { - return nil, err - } - if list.Code != "0" { - return nil, errors.New(list.Msg) - } - for _, file := range list.Data.FileList { - algorithm := &collector.Algorithm{Name: file.Name, Platform: SHUGUANGAI, TaskType: taskType} - algorithms = append(algorithms, algorithm) - } - } - return algorithms, nil -} - -func (s *ShuguangAi) GetComputeCards(ctx context.Context) ([]string, error) { - var cards []string - cards = append(cards, DCU) - return cards, nil -} - -func (s *ShuguangAi) GetUserBalance(ctx context.Context) (float64, error) { - userReq := &hpcAC.GetUserInfoReq{} - userinfo, err := s.aCRpc.GetUserInfo(ctx, userReq) - if err != nil { - return 0, err - } - balance, _ := strconv.ParseFloat(userinfo.Data.AccountBalance, 64) - return balance, nil -} - -func (s *ShuguangAi) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) { - algoName := dataset + DASH + algorithm - req := &hpcAC.GetFileReq{ - Path: ALGORITHM_DIR + FORWARD_SLASH + taskType + FORWARD_SLASH + algoName + FORWARD_SLASH + TRAIN_FILE, - } - resp, err := s.aCRpc.GetFile(ctx, req) - if err != nil { - return "", err - } - - return resp.Content, nil -} - -func (s *ShuguangAi) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error { - algoName := dataset + DASH + algorithm - req := &hpcAC.UploadFileReq{ - Path: ALGORITHM_DIR + FORWARD_SLASH + taskType + FORWARD_SLASH + algoName + FORWARD_SLASH, - Cover: "cover", - File: code, - } - - _, err := s.aCRpc.UploadFile(ctx, req) - if err != nil { - return err - } - - return nil -} - -func (s *ShuguangAi) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { - req := &hpcAC.GetInstanceLogReq{ - TaskId: taskId, - InstanceNum: instanceNum, - LineCount: 1000, - StartLineNum: -1, - } - resp, err := s.aCRpc.GetInstanceLog(ctx, req) - if err != nil { - return "", err - } - - if resp.Code != "0" { - resp.Data.Content = "waiting for logs..." - } - - return resp.Data.Content, nil -} - -func (s *ShuguangAi) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { - resp, err := s.QueryTask(ctx, taskId) - if err != nil { - return nil, err - } - jobresp := (resp).(*hpcAC.GetPytorchTaskResp) - if jobresp.Code != "0" { - return nil, errors.New(jobresp.Msg) - } - var task collector.Task - task.Id = jobresp.Data.Id - if jobresp.Data.StartTime != "" { - task.Start = jobresp.Data.StartTime - } - if jobresp.Data.EndTime != "" { - task.End = jobresp.Data.EndTime - } - task.Status = jobresp.Data.Status - - return &task, nil -} - -func (s *ShuguangAi) Execute(ctx context.Context, option *option.AiOption) (interface{}, error) { - err := s.GenerateSubmitParams(ctx, option) - if err != nil { - return nil, err - } - task, err := s.SubmitTask(ctx, option.ImageId, option.Cmd, option.Envs, option.Params, option.ResourceId, option.DatasetsId, option.AlgorithmId, option.TaskType) - if err != nil { - return nil, err - } - return task, nil -} - -func (s *ShuguangAi) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error { - err := s.generateResourceId(option) - if err != nil { - return err - } - err = s.generateImageId(ctx, option) - if err != nil { - return err - } - err = s.generateAlgorithmId(ctx, option) - if err != nil { - return err - } - err = s.generateCmd(option) - if err != nil { - return err - } - err = s.generateEnv(option) - if err != nil { - return err - } - err = s.generateParams(option) - if err != nil { - return err - } - return nil -} - -func (s *ShuguangAi) generateResourceId(option *option.AiOption) error { - if option.ResourceType == "" { - return errors.New("ResourceType not set") - } - - if option.ResourceType == CPU { - option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi" - option.ComputeCard = CPU - return nil - } - - if option.ResourceType == CARD { - if option.ComputeCard == "" { - option.ComputeCard = DCU - } - - if strings.ToUpper(option.ComputeCard) != DCU { - return errors.New("computeCard not found") - } - option.ComputeCard = DCU - - if 0 <= option.Tops && option.Tops <= DCU_TOPS { - option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi" - return nil - } - - cardNum := 5 - for k, v := range RESOURCESGAIMAP { - for i := 1; i <= cardNum; i++ { - if float64(i)*DCU_TOPS <= option.Tops && option.Tops <= float64(v.GPU)*DCU_TOPS { - option.ResourceId = k - return nil - } - } - } - - if option.Tops > float64(cardNum)*DCU_TOPS { - option.ResourceId = "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2" - return nil - } - } - - return errors.New("failed to get ResourceId") -} - -func (s *ShuguangAi) generateImageId(ctx context.Context, option *option.AiOption) error { - if option.TaskType == "" { - return errors.New("TaskType not set") - } - taskType := strings.Title(option.TaskType) - req := &hpcAC.GetImageListAiReq{ - AcceleratorType: DCU, - TaskType: taskType, - } - resp, err := s.aCRpc.GetImageListAi(ctx, req) - if err != nil { - return err - } - if resp.Code != "0" { - return errors.New("failed to get imageId") - } - - for _, datum := range resp.Data { - ns := strings.Split(datum.Version, COLON) - if ns[0] == "jupyterlab-pytorch" { - option.ImageId = datum.ImageId - return nil - } - - } - - return errors.New("failed to get ImageId") -} - -func (s *ShuguangAi) generateAlgorithmId(ctx context.Context, option *option.AiOption) error { - if option.DatasetsName == "" { - return errors.New("DatasetsName not set") - } - - req := &hpcAC.GetFileListReq{Limit: 100, Path: ALGORITHM_DIR + FORWARD_SLASH + option.TaskType, Start: 0} - list, err := s.aCRpc.GetFileList(ctx, req) - if err != nil { - return err - } - if list.Code != "0" { - return errors.New(list.Msg) - } - - var algorithmId string - for _, file := range list.Data.FileList { - ns := strings.Split(file.Name, DASH) - if ns[0] == option.DatasetsName { - algoName := ns[1] - if option.AlgorithmName == "" { - switch option.DatasetsName { - case "cifar10": - algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + "cnn" - option.AlgorithmId = algorithmId - option.AlgorithmName = algoName - return nil - case "mnist": - algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + "fcn" - option.AlgorithmId = algorithmId - option.AlgorithmName = algoName - return nil - } - } else { - if algoName == option.AlgorithmName { - algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + algoName - option.AlgorithmId = algorithmId - return nil - } - } - } - } - - if algorithmId == "" { - return errors.New("Algorithm does not exist") - } - - return errors.New("failed to get AlgorithmId") -} - -func (s *ShuguangAi) generateCmd(option *option.AiOption) error { - - return nil -} - -func (s *ShuguangAi) generateEnv(option *option.AiOption) error { - - return nil -} - -func (s *ShuguangAi) generateParams(option *option.AiOption) error { - if option.ResourceType == "" { - return errors.New("ResourceType not set") - } - - if len(option.Params) == 0 { - epoch := "epoch" + COMMA + "1" - option.Params = append(option.Params, epoch) - } - - switch option.ResourceType { - case CPU: - card := "card" + COMMA + CPU - option.Params = append(option.Params, card) - return nil - case CARD: - card := "card" + COMMA + "cuda:0" - option.Params = append(option.Params, card) - return nil - } - - return errors.New("failed to set params") -} - -func (s *ShuguangAi) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*collector.InferUrl, error) { - var imageUrls []*collector.InferUrl - - urlReq := &hpcAC.GetInferUrlReq{ - ModelName: option.ModelName, - Type: option.ModelType, - Card: "dcu", - } - - urlResp, err := s.aCRpc.GetInferUrl(ctx, urlReq) - if err != nil { - return nil, err - } - imageUrl := &collector.InferUrl{ - Url: urlResp.Url, - Card: "dcu", - } - imageUrls = append(imageUrls, imageUrl) - - return imageUrls, nil -} diff --git a/api/internal/storeLink/storeLink.go b/api/internal/storeLink/storeLink.go deleted file mode 100644 index 69cfc02d..00000000 --- a/api/internal/storeLink/storeLink.go +++ /dev/null @@ -1,1035 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package storeLink - -import ( - "context" - "fmt" - "github.com/pkg/errors" - "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" - hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" - "gitlink.org.cn/JointCloud/pcm-octopus/octopus" - "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" - "gorm.io/gorm" - "strings" - "sync" -) - -type Linkage interface { - UploadImage(ctx context.Context, path string) (interface{}, error) - DeleteImage(ctx context.Context, imageId string) (interface{}, error) - QueryImageList(ctx context.Context) (interface{}, error) - SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) - QueryTask(ctx context.Context, taskId string) (interface{}, error) - QuerySpecs(ctx context.Context) (interface{}, error) - DeleteTask(ctx context.Context, taskId string) (interface{}, error) -} - -const ( - COLON = ":" - PY_PARAM_PREFIX = "--" - SPACE = " " - UNDERSCORE = "_" - EQUAL = "=" - DASH = "-" - FORWARD_SLASH = "/" - COMMA = "," - STAR = "*" - TYPE_OCTOPUS = "1" - TYPE_MODELARTS = "2" - TYPE_SHUGUANGAI = "3" - TYPE_SHUGUANGHPC = "4" - OCTOPUS = "Octopus" - MODELARTS = "Modelarts" - SHUGUANGAI = "ShuguangAi" - SHUGUANGHPC = "ShuguangHpc" - CPU = "cpu" - GPU = "gpu" - CARD = "computeCard" - PYTORCH_TASK = "pytorch" - TENSORFLOW_TASK = "tensorflow" -) - -var ( - OctImgStatus = map[int32]string{ - 1: "未上传", - 3: "制作完成", - 4: "制作失败", - } - ModelTypeMap = map[string][]string{ - "image_recognition": {"imagenet_resnet50"}, - "text_to_text": {"chatGLM_6B"}, - } - AITYPE = map[string]string{ - "1": OCTOPUS, - "2": MODELARTS, - "3": SHUGUANGAI, - "4": SHUGUANGHPC, - } - resourceTypes = []string{CARD} - taskTypes = []string{PYTORCH_TASK} - - ERROR_RESP_EMPTY = errors.New("resp empty error") - ERROR_CONVERT_EMPTY = errors.New("convert empty error") -) - -type StoreLink struct { - ILinkage Linkage -} - -func NewStoreLink(octopusRpc octopusclient.Octopus, modelArtsRpc modelartsservice.ModelArtsService, modelArtsImgRpc imagesservice.ImagesService, aCRpc hpcacclient.HpcAC, participant *models.StorelinkCenter) *StoreLink { - switch participant.Type { - case TYPE_OCTOPUS: - linkStruct := NewOctopusLink(octopusRpc, participant.Name, participant.Id) - return &StoreLink{ILinkage: linkStruct} - case TYPE_MODELARTS: - linkStruct := NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, participant.Name, participant.Id, "") - return &StoreLink{ILinkage: linkStruct} - case TYPE_SHUGUANGAI: - linkStruct := NewShuguangAi(aCRpc, participant.Name, participant.Id) - return &StoreLink{ILinkage: linkStruct} - case TYPE_SHUGUANGHPC: - linkStruct := NewShuguangHpc(aCRpc, participant.Name, participant.Id) - return &StoreLink{ILinkage: linkStruct} - default: - return nil - } -} - -func GetParticipants(dbEngin *gorm.DB) []*models.StorelinkCenter { - var participants []*models.StorelinkCenter - dbEngin.Raw("select * from storelink_center").Scan(&participants) - return participants -} - -func GetParticipantById(partId int64, dbEngin *gorm.DB) *models.StorelinkCenter { - var participant models.StorelinkCenter - dbEngin.Raw("select * from storelink_center where id = ?", partId).Scan(&participant) - return &participant -} - -func GetResourceTypes() []string { - return resourceTypes -} - -func GetModelTypes() []string { - var mTypes []string - for k, _ := range ModelTypeMap { - mTypes = append(mTypes, k) - } - return mTypes -} - -func GetModelNamesByType(t string) ([]string, error) { - _, ok := ModelTypeMap[t] - if !ok { - return nil, errors.New("model type does not exist") - } - return ModelTypeMap[t], nil -} - -func GetDatasetsNames(ctx context.Context, collectorMap map[string]collector.AiCollector) ([]string, error) { - var wg sync.WaitGroup - var errCh = make(chan interface{}, len(collectorMap)) - var errs []interface{} - var names []string - var mu sync.Mutex - colMap := collectorMap - for s, col := range colMap { - wg.Add(1) - c := col - id := s - go func() { - var ns []string - specs, err := c.GetDatasetsSpecs(ctx) - if err != nil { - e := struct { - err error - clusterId string - }{ - err: err, - clusterId: id, - } - errCh <- e - wg.Done() - return - } - for _, spec := range specs { - ns = append(ns, spec.Name) - } - if len(ns) == 0 { - wg.Done() - return - } - mu.Lock() - if len(names) == 0 { - names = ns - wg.Done() - mu.Unlock() - return - } - names = common.IntersectString(names, ns) - wg.Done() - mu.Unlock() - }() - } - wg.Wait() - close(errCh) - - if len(errs) == len(colMap) { - return nil, errors.New("get DatasetsNames failed") - } - - for e := range errCh { - errs = append(errs, e) - } - - if len(errs) != 0 { - var msg string - for _, err := range errs { - e := (err).(struct { - err error - clusterId string - }) - msg += fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) - } - return nil, errors.New(msg) - } - - names = common.RemoveDuplicates(names) - return names, nil -} - -func GetAlgorithms(ctx context.Context, collectorMap map[string]collector.AiCollector, resourceType string, taskType string, dataset string) ([]string, error) { - var names []string - var wg sync.WaitGroup - var errCh = make(chan interface{}, len(collectorMap)) - var errs []interface{} - var mu sync.Mutex - - colMap := collectorMap - for s, col := range colMap { - wg.Add(1) - c := col - id := s - go func() { - var ns []string - algorithms, err := c.GetAlgorithms(ctx) - if err != nil { - e := struct { - err error - clusterId string - }{ - err: err, - clusterId: id, - } - errCh <- e - wg.Done() - return - } - for _, algorithm := range algorithms { - if algorithm.TaskType != taskType { - continue - } - switch algorithm.Platform { - case OCTOPUS: - splitns := strings.Split(algorithm.Name, UNDERSCORE) - if dataset != splitns[0] || len(splitns) == 1 { - continue - } - ns = append(ns, splitns[1]) - case SHUGUANGAI: - splitns := strings.Split(algorithm.Name, DASH) - if dataset != splitns[0] || len(splitns) == 1 { - continue - } - ns = append(ns, splitns[1]) - } - } - if len(ns) == 0 { - wg.Done() - return - } - mu.Lock() - if len(names) == 0 { - names = ns - wg.Done() - mu.Unlock() - return - } - names = common.IntersectString(names, ns) - wg.Done() - mu.Unlock() - }() - } - wg.Wait() - close(errCh) - - for e := range errCh { - errs = append(errs, e) - } - - if len(errs) == len(colMap) { - return nil, errors.New("get Algorithms failed") - } - - if len(errs) != 0 { - var msg string - for _, err := range errs { - e := (err).(struct { - err error - clusterId string - }) - msg += fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) - } - return nil, errors.New(msg) - } - - names = common.RemoveDuplicates(names) - return names, nil -} - -func GetTaskTypes() []string { - return taskTypes -} - -func ConvertType(in interface{}, out interface{}, participant *models.StorelinkCenter) (interface{}, error) { - - switch (interface{})(in).(type) { - case *types.GetResourceSpecsResp: - return in, nil - case *octopus.UploadImageResp: - inresp := (interface{})(in).(*octopus.UploadImageResp) - switch (interface{})(out).(type) { - case *types.UploadLinkImageResp: - resp := (interface{})(out).(*types.UploadLinkImageResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - return resp, nil - } - return nil, nil - - case *octopus.DeleteImageResp: - inresp := (interface{})(in).(*octopus.DeleteImageResp) - switch (interface{})(out).(type) { - case *types.DeleteLinkImageResp: - resp := (interface{})(out).(*types.DeleteLinkImageResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - return resp, nil - } - return nil, nil - - case *octopus.GetUserImageListResp: - inresp := (interface{})(in).(*octopus.GetUserImageListResp) - switch (interface{})(out).(type) { - case *types.GetLinkImageListResp: - resp := (interface{})(out).(*types.GetLinkImageListResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - resp.Images = nil - return resp, nil - } - - for _, v := range inresp.Payload.Images { - var image types.ImageSl - image.ImageId = v.Image.Id - image.ImageName = v.Image.ImageName - image.ImageStatus = OctImgStatus[v.Image.ImageStatus] - resp.Images = append(resp.Images, &image) - } - return resp, nil - } - return nil, nil - - case *modelarts.ListReposDetailsResp: - inresp := (interface{})(in).(*modelarts.ListReposDetailsResp) - switch (interface{})(out).(type) { - case *types.GetLinkImageListResp: - resp := (interface{})(out).(*types.GetLinkImageListResp) - if inresp.Errors != nil { - resp.Success = false - resp.ErrorMsg = inresp.Errors[0].ErrorMessage - resp.Images = nil - return resp, nil - } - - resp.Success = true - for _, v := range inresp.Items { - for _, r := range v.Tags { - var image types.ImageSl - image.ImageId = v.Namespace + "/" + v.Name + ":" + r - image.ImageName = v.Name - image.ImageStatus = "created" - resp.Images = append(resp.Images, &image) - } - } - return resp, nil - } - return nil, nil - - case *hpcAC.GetImageListAiResp: - inresp := (interface{})(in).(*hpcAC.GetImageListAiResp) - switch (interface{})(out).(type) { - case *types.GetLinkImageListResp: - resp := (interface{})(out).(*types.GetLinkImageListResp) - if inresp.Code == "0" { - resp.Success = true - for _, img := range inresp.Data { - var image types.ImageSl - image.ImageId = img.ImageId - image.ImageName = img.Version - image.ImageStatus = "created" - resp.Images = append(resp.Images, &image) - } - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Images = nil - } - return resp, nil - } - return nil, nil - - case *octopus.CreateTrainJobResp: - inresp := (interface{})(in).(*octopus.CreateTrainJobResp) - switch (interface{})(out).(type) { - case *types.SubmitLinkTaskResp: - resp := (interface{})(out).(*types.SubmitLinkTaskResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - resp.TaskId = inresp.Payload.JobId - - return resp, nil - case *types.ScheduleResp: - resp := (interface{})(out).(*types.ScheduleResp) - return resp, nil - } - return nil, nil - - case *modelarts.CreateTrainingJobResp: - inresp := (interface{})(in).(*modelarts.CreateTrainingJobResp) - switch (interface{})(out).(type) { - case *types.SubmitLinkTaskResp: - resp := (interface{})(out).(*types.SubmitLinkTaskResp) - if inresp.ErrorMsg != "" { - resp.ErrorMsg = inresp.ErrorMsg - resp.Success = false - return resp, nil - } - resp.Success = true - resp.TaskId = inresp.Metadata.Id - - return resp, nil - } - return nil, nil - - case *hpcAC.SubmitTaskAiResp: - inresp := (interface{})(in).(*hpcAC.SubmitTaskAiResp) - switch (interface{})(out).(type) { - case *types.SubmitLinkTaskResp: - resp := (interface{})(out).(*types.SubmitLinkTaskResp) - if inresp.Code == "0" { - resp.Success = true - resp.TaskId = inresp.Data - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - case *types.ScheduleResp: - resp := (interface{})(out).(*types.ScheduleResp) - return resp, nil - } - return nil, nil - - case *hpcAC.SubmitJobResp: - inresp := (interface{})(in).(*hpcAC.SubmitJobResp) - switch (interface{})(out).(type) { - case *types.SubmitLinkTaskResp: - resp := (interface{})(out).(*types.SubmitLinkTaskResp) - if inresp.Code == "0" { - resp.Success = true - resp.TaskId = inresp.Data - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - } - return nil, nil - - case *octopus.GetTrainJobResp: - inresp := (interface{})(in).(*octopus.GetTrainJobResp) - switch (interface{})(out).(type) { - case *types.GetLinkTaskResp: - resp := (interface{})(out).(*types.GetLinkTaskResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - var task types.TaskSl - task.TaskId = inresp.Payload.TrainJob.Id - task.TaskName = inresp.Payload.TrainJob.Name - task.StartedAt = inresp.Payload.TrainJob.StartedAt - task.CompletedAt = inresp.Payload.TrainJob.CompletedAt - task.TaskStatus = inresp.Payload.TrainJob.Status - - resp.Task = &task - return resp, nil - } - return nil, nil - - case *modelarts.JobResponse: - inresp := (interface{})(in).(*modelarts.JobResponse) - switch (interface{})(out).(type) { - case *types.GetLinkTaskResp: - resp := (interface{})(out).(*types.GetLinkTaskResp) - if inresp.ErrorMsg != "" { - resp.ErrorMsg = inresp.ErrorMsg - resp.Success = false - return resp, nil - } - resp.Success = true - resp.Task = &types.TaskSl{} - resp.Task.TaskId = inresp.Metadata.Id - resp.Task.TaskName = inresp.Metadata.Name - resp.Task.StartedAt = int64(inresp.Status.StartTime) - resp.Task.CompletedAt = int64(inresp.Status.Duration) - resp.Task.TaskStatus = inresp.Status.Phase - - return resp, nil - } - return nil, nil - - case *hpcAC.GetPytorchTaskResp: - inresp := (interface{})(in).(*hpcAC.GetPytorchTaskResp) - switch (interface{})(out).(type) { - case *types.GetLinkTaskResp: - resp := (interface{})(out).(*types.GetLinkTaskResp) - if inresp.Code == "0" { - resp.Success = true - var task types.TaskSl - task.TaskId = inresp.Data.Id - task.TaskName = inresp.Data.TaskName - task.TaskStatus = inresp.Data.Status - task.StartedAt = timeutils.StringToUnixTime(inresp.Data.StartTime) - task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.EndTime) - resp.Task = &task - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Task = nil - } - - return resp, nil - } - return nil, nil - - case *hpcAC.GetJobDetailResp: - inresp := (interface{})(in).(*hpcAC.GetJobDetailResp) - switch (interface{})(out).(type) { - case *types.GetLinkTaskResp: - resp := (interface{})(out).(*types.GetLinkTaskResp) - if inresp.Code == "0" { - resp.Success = true - var task types.TaskSl - task.TaskId = inresp.Data.JobId - task.TaskName = inresp.Data.JobName - task.TaskStatus = AcStatus[inresp.Data.JobStatus] - task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) - task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) - resp.Task = &task - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Task = nil - } - - return resp, nil - } - return nil, nil - - case *hpcAC.HistoryJobDetailResp: - inresp := (interface{})(in).(*hpcAC.HistoryJobDetailResp) - switch (interface{})(out).(type) { - case *types.GetLinkTaskResp: - resp := (interface{})(out).(*types.GetLinkTaskResp) - if inresp.Code == "0" { - resp.Success = true - var task types.TaskSl - task.TaskId = inresp.Data.JobId - task.TaskName = inresp.Data.JobName - task.TaskStatus = AcStatus[inresp.Data.JobState] - task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) - task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) - resp.Task = &task - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Task = nil - } - - return resp, nil - } - return nil, nil - - case *octopus.DeleteTrainJobResp: - inresp := (interface{})(in).(*octopus.DeleteTrainJobResp) - switch (interface{})(out).(type) { - case *types.DeleteLinkTaskResp: - resp := (interface{})(out).(*types.DeleteLinkTaskResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - return resp, nil - } - return nil, nil - - case *modelarts.DeleteTrainingJobResp: - inresp := (interface{})(in).(*modelarts.DeleteTrainingJobResp) - switch (interface{})(out).(type) { - case *types.DeleteLinkTaskResp: - resp := (interface{})(out).(*types.DeleteLinkTaskResp) - if inresp.ErrorMsg != "" { - resp.ErrorMsg = inresp.ErrorMsg - resp.Success = false - return resp, nil - } - resp.Success = true - return resp, nil - } - return nil, nil - - case *hpcAC.DeleteTaskAiResp: - inresp := (interface{})(in).(*hpcAC.DeleteTaskAiResp) - switch (interface{})(out).(type) { - case *types.DeleteLinkTaskResp: - resp := (interface{})(out).(*types.DeleteLinkTaskResp) - if inresp.Code == "0" { - resp.Success = true - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - } - return nil, nil - - case *hpcAC.DeleteJobResp: - inresp := (interface{})(in).(*hpcAC.DeleteJobResp) - switch (interface{})(out).(type) { - case *types.DeleteLinkTaskResp: - resp := (interface{})(out).(*types.DeleteLinkTaskResp) - if inresp.Code == "0" { - resp.Success = true - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - } - return nil, nil - - case *octopus.GetResourceSpecsResp: - inresp := (interface{})(in).(*octopus.GetResourceSpecsResp) - switch (interface{})(out).(type) { - case *types.GetResourceSpecsResp: - resp := (interface{})(out).(*types.GetResourceSpecsResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ResourceSpecs = nil - return resp, nil - } - - for _, spec := range inresp.TrainResourceSpecs { - var respec types.ResourceSpecSl - respec.SpecId = spec.Id - respec.SpecName = spec.Name - respec.ParticipantId = participant.Id - respec.ParticipantName = participant.Name - respec.SpecPrice = spec.Price - resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) - } - - return resp, nil - } - return nil, nil - - case *modelarts.TrainingJobFlavorsResp: - inresp := (interface{})(in).(*modelarts.TrainingJobFlavorsResp) - switch (interface{})(out).(type) { - case *types.GetResourceSpecsResp: - resp := (interface{})(out).(*types.GetResourceSpecsResp) - resp.Success = true - - if inresp.Flavors == nil { - resp.Success = false - resp.ResourceSpecs = nil - return resp, nil - } - - for _, spec := range inresp.Flavors { - var respec types.ResourceSpecSl - respec.SpecId = spec.FlavorId - respec.SpecName = spec.FlavorName - respec.ParticipantId = participant.Id - respec.ParticipantName = participant.Name - respec.SpecPrice = 0 - resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) - } - - return resp, nil - } - return nil, nil - - default: - return nil, errors.New("type convert fail") - } -} - -func ConvertTypeOld[T any](in *T, participant *models.StorelinkCenter) (interface{}, error) { - - switch (interface{})(in).(type) { - case *octopus.UploadImageResp: - var resp types.UploadLinkImageResp - inresp := (interface{})(in).(*octopus.UploadImageResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - return resp, nil - case *octopus.DeleteImageResp: - var resp types.DeleteLinkImageResp - inresp := (interface{})(in).(*octopus.DeleteImageResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - return resp, nil - - case *octopus.GetUserImageListResp: - var resp types.GetLinkImageListResp - inresp := (interface{})(in).(*octopus.GetUserImageListResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - resp.Images = nil - return resp, nil - } - - for _, v := range inresp.Payload.Images { - var image types.ImageSl - image.ImageId = v.Image.Id - image.ImageName = v.Image.ImageName - image.ImageStatus = OctImgStatus[v.Image.ImageStatus] - resp.Images = append(resp.Images, &image) - } - return resp, nil - case *modelarts.ListReposDetailsResp: - var resp types.GetLinkImageListResp - inresp := (interface{})(in).(*modelarts.ListReposDetailsResp) - - if inresp.Errors != nil { - resp.Success = false - resp.ErrorMsg = inresp.Errors[0].ErrorMessage - resp.Images = nil - return resp, nil - } - - resp.Success = true - for _, v := range inresp.Items { - for _, r := range v.Tags { - var image types.ImageSl - image.ImageId = v.Namespace + "/" + v.Name + ":" + r - image.ImageName = v.Name - image.ImageStatus = "created" - resp.Images = append(resp.Images, &image) - } - } - return resp, nil - case *hpcAC.GetImageListAiResp: - var resp types.GetLinkImageListResp - inresp := (interface{})(in).(*hpcAC.GetImageListAiResp) - - if inresp.Code == "0" { - resp.Success = true - for _, img := range inresp.Data { - var image types.ImageSl - image.ImageId = img.ImageId - image.ImageName = img.Version - image.ImageStatus = "created" - resp.Images = append(resp.Images, &image) - } - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Images = nil - } - return resp, nil - - case *octopus.CreateTrainJobResp: - var resp types.SubmitLinkTaskResp - inresp := (interface{})(in).(*octopus.CreateTrainJobResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - resp.TaskId = inresp.Payload.JobId - - return resp, nil - case *modelarts.CreateTrainingJobResp: - var resp types.SubmitLinkTaskResp - inresp := (interface{})(in).(*modelarts.CreateTrainingJobResp) - - if inresp.ErrorMsg != "" { - resp.ErrorMsg = inresp.ErrorMsg - resp.Success = false - return resp, nil - } - resp.Success = true - resp.TaskId = inresp.Metadata.Id - - return resp, nil - case *hpcAC.SubmitTaskAiResp: - var resp types.SubmitLinkTaskResp - inresp := (interface{})(in).(*hpcAC.SubmitTaskAiResp) - - if inresp.Code == "0" { - resp.Success = true - resp.TaskId = inresp.Data - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - case *hpcAC.SubmitJobResp: - var resp types.SubmitLinkTaskResp - inresp := (interface{})(in).(*hpcAC.SubmitJobResp) - if inresp.Code == "0" { - resp.Success = true - resp.TaskId = inresp.Data - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - case *octopus.GetTrainJobResp: - var resp types.GetLinkTaskResp - inresp := (interface{})(in).(*octopus.GetTrainJobResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - var task types.TaskSl - task.TaskId = inresp.Payload.TrainJob.Id - task.TaskName = inresp.Payload.TrainJob.Name - task.StartedAt = inresp.Payload.TrainJob.StartedAt - task.CompletedAt = inresp.Payload.TrainJob.CompletedAt - task.TaskStatus = inresp.Payload.TrainJob.Status - - resp.Task = &task - return resp, nil - case *modelarts.JobResponse: - var resp types.GetLinkTaskResp - inresp := (interface{})(in).(*modelarts.JobResponse) - if inresp.ErrorMsg != "" { - resp.ErrorMsg = inresp.ErrorMsg - resp.Success = false - return resp, nil - } - resp.Success = true - resp.Task = &types.TaskSl{} - resp.Task.TaskId = inresp.Metadata.Id - resp.Task.TaskName = inresp.Metadata.Name - resp.Task.StartedAt = int64(inresp.Status.StartTime) - resp.Task.CompletedAt = int64(inresp.Status.Duration) - resp.Task.TaskStatus = inresp.Status.Phase - - return resp, nil - case *hpcAC.GetPytorchTaskResp: - var resp types.GetLinkTaskResp - inresp := (interface{})(in).(*hpcAC.GetPytorchTaskResp) - if inresp.Code == "0" { - resp.Success = true - var task types.TaskSl - task.TaskId = inresp.Data.Id - task.TaskName = inresp.Data.TaskName - task.TaskStatus = inresp.Data.Status - task.StartedAt = timeutils.StringToUnixTime(inresp.Data.StartTime) - task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.EndTime) - resp.Task = &task - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Task = nil - } - - return resp, nil - case *hpcAC.GetJobDetailResp: - var resp types.GetLinkTaskResp - inresp := (interface{})(in).(*hpcAC.GetJobDetailResp) - if inresp.Code == "0" { - resp.Success = true - var task types.TaskSl - task.TaskId = inresp.Data.JobId - task.TaskName = inresp.Data.JobName - task.TaskStatus = AcStatus[inresp.Data.JobStatus] - task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) - task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) - resp.Task = &task - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Task = nil - } - - return resp, nil - case *hpcAC.HistoryJobDetailResp: - var resp types.GetLinkTaskResp - inresp := (interface{})(in).(*hpcAC.HistoryJobDetailResp) - if inresp.Code == "0" { - resp.Success = true - var task types.TaskSl - task.TaskId = inresp.Data.JobId - task.TaskName = inresp.Data.JobName - task.TaskStatus = AcStatus[inresp.Data.JobState] - task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) - task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) - resp.Task = &task - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - resp.Task = nil - } - - return resp, nil - case *octopus.DeleteTrainJobResp: - var resp types.DeleteLinkTaskResp - inresp := (interface{})(in).(*octopus.DeleteTrainJobResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ErrorMsg = inresp.Error.Message - return resp, nil - } - - return resp, nil - case *modelarts.DeleteTrainingJobResp: - var resp types.DeleteLinkTaskResp - inresp := (interface{})(in).(*modelarts.DeleteTrainingJobResp) - if inresp.ErrorMsg != "" { - resp.ErrorMsg = inresp.ErrorMsg - resp.Success = false - return resp, nil - } - resp.Success = true - return resp, nil - case *hpcAC.DeleteTaskAiResp: - var resp types.DeleteLinkTaskResp - inresp := (interface{})(in).(*hpcAC.DeleteTaskAiResp) - if inresp.Code == "0" { - resp.Success = true - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - case *hpcAC.DeleteJobResp: - var resp types.DeleteLinkTaskResp - inresp := (interface{})(in).(*hpcAC.DeleteJobResp) - if inresp.Code == "0" { - resp.Success = true - } else { - resp.Success = false - resp.ErrorMsg = inresp.Msg - } - return resp, nil - case *octopus.GetResourceSpecsResp: - var resp types.GetResourceSpecsResp - inresp := (interface{})(in).(*octopus.GetResourceSpecsResp) - resp.Success = inresp.Success - if !resp.Success { - resp.ResourceSpecs = nil - return resp, nil - } - - for _, spec := range inresp.TrainResourceSpecs { - var respec types.ResourceSpecSl - respec.SpecId = spec.Id - respec.SpecName = spec.Name - respec.ParticipantId = participant.Id - respec.ParticipantName = participant.Name - respec.SpecPrice = spec.Price - resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) - } - - return resp, nil - case *modelarts.TrainingJobFlavorsResp: - var resp types.GetResourceSpecsResp - resp.Success = true - inresp := (interface{})(in).(*modelarts.TrainingJobFlavorsResp) - if inresp.Flavors == nil { - resp.Success = false - resp.ResourceSpecs = nil - return resp, nil - } - - for _, spec := range inresp.Flavors { - var respec types.ResourceSpecSl - respec.SpecId = spec.FlavorId - respec.SpecName = spec.FlavorName - respec.ParticipantId = participant.Id - respec.ParticipantName = participant.Name - respec.SpecPrice = 0 - resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) - } - - return resp, nil - default: - return nil, errors.New("type convert fail") - } -} diff --git a/api/internal/svc/servicecontext.go b/api/internal/svc/servicecontext.go deleted file mode 100644 index a2ee4aed..00000000 --- a/api/internal/svc/servicecontext.go +++ /dev/null @@ -1,144 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package svc - -import ( - "github.com/go-redis/redis/v8" - "github.com/go-resty/resty/v2" - alert "github.com/prometheus/alertmanager/api/v2/client" - "github.com/robfig/cron/v3" - "github.com/zeromicro/go-zero/core/logx" - "github.com/zeromicro/go-zero/zrpc" - hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/client/participantservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" - "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" - "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" - "gitlink.org.cn/JointCloud/pcm-openstack/openstackclient" - slurmClient "gitlink.org.cn/JointCloud/pcm-slurm/slurmclient" - "gitlink.org.cn/jcce-pcm/pcm-participant-ceph/cephclient" - "gorm.io/driver/mysql" - "gorm.io/gorm" - "gorm.io/gorm/logger" - "gorm.io/gorm/schema" - "time" -) - -type ServiceContext struct { - Config config.Config - RedisClient *redis.Client - Cron *cron.Cron - ModelArtsRpc modelartsservice.ModelArtsService - ModelArtsImgRpc imagesservice.ImagesService - DbEngin *gorm.DB - ACRpc hpcacclient.HpcAC - THRpc slurmClient.Slurm - OctopusRpc octopusclient.Octopus - CephRpc cephclient.Ceph - OpenstackRpc openstackclient.Openstack - MonitorClient map[int64]tracker.Prometheus - ParticipantRpc participantservice.ParticipantService - PromClient tracker.Prometheus - AlertClient *alert.AlertmanagerAPI - HttpClient *resty.Client - Scheduler *scheduler.Scheduler -} - -func NewServiceContext(c config.Config) *ServiceContext { - promClient, err := tracker.NewPrometheus(c.Monitoring.PromUrl) - - if err != nil { - logx.Errorf("InitPrometheus err: %v", err) - panic("InitSnowflake err") - } - httpClient := resty.New() - httpClient.SetTimeout(1 * time.Second) - alertClient := tracker.NewAlertClient(c.Monitoring.AlertUrl) - if err != nil { - logx.Errorf("InitPrometheus err: %v", err) - panic("InitSnowflake err") - } - - //添加snowflake支持 - err = utils.InitSnowflake(c.SnowflakeConf.MachineId) - if err != nil { - logx.Errorf("InitSnowflake err: %v", err) - panic("InitSnowflake err") - } - - //启动Gorm支持 - dbEngin, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{ - NamingStrategy: schema.NamingStrategy{ - SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user` - }, - Logger: logger.Default.LogMode(logger.Warn), - }) - if err != nil { - logx.Errorf("数据库连接失败, err%v", err) - panic(err) - } - sqlDB, err := dbEngin.DB() - // SetMaxIdleConns 设置空闲连接池中连接的最大数量 - sqlDB.SetMaxIdleConns(10) - - // SetMaxOpenConns 设置打开数据库连接的最大数量。 - sqlDB.SetMaxOpenConns(50) - - // SetConnMaxLifetime 设置了连接可复用的最大时间。 - sqlDB.SetConnMaxLifetime(time.Hour) - - if err != nil { - logx.Error(err.Error()) - return nil - } - redisClient := redis.NewClient(&redis.Options{ - Addr: c.Redis.Host, - Password: c.Redis.Pass, - }) - - // scheduler - storage := &database.AiStorage{DbEngin: dbEngin} - aiService, err := service.NewAiService(&c, storage) - if err != nil { - logx.Error(err.Error()) - return nil - } - scheduler := scheduler.NewSchdlr(aiService, storage) - - return &ServiceContext{ - DbEngin: dbEngin, - Cron: cron.New(cron.WithSeconds()), - Config: c, - RedisClient: redisClient, - ModelArtsRpc: modelartsservice.NewModelArtsService(zrpc.MustNewClient(c.ModelArtsRpcConf)), - ModelArtsImgRpc: imagesservice.NewImagesService(zrpc.MustNewClient(c.ModelArtsImgRpcConf)), - CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)), - ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)), - OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)), - OpenstackRpc: openstackclient.NewOpenstack(zrpc.MustNewClient(c.OpenstackRpcConf)), - MonitorClient: make(map[int64]tracker.Prometheus), - ParticipantRpc: participantservice.NewParticipantService(zrpc.MustNewClient(c.PcmCoreRpcConf)), - PromClient: promClient, - AlertClient: alertClient, - HttpClient: httpClient, - Scheduler: scheduler, - } -} diff --git a/api/pcm.go b/api/pcm.go deleted file mode 100644 index dc46d1ba..00000000 --- a/api/pcm.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package main - -import ( - "context" - "flag" - "github.com/zeromicro/go-zero/core/conf" - "github.com/zeromicro/go-zero/core/logx" - "github.com/zeromicro/go-zero/core/service" - "github.com/zeromicro/go-zero/rest" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/cron" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/mqs" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" -) - -var configFile = flag.String("f", "api/etc/pcm.yaml", "the config file") - -func main() { - flag.Parse() - - var c config.Config - conf.MustLoad(*configFile, &c) - - serviceGroup := service.NewServiceGroup() - defer serviceGroup.Stop() - - server := rest.MustNewServer(c.RestConf, rest.WithCors()) - - ctx := svc.NewServiceContext(c) - // start log component - logx.MustSetup(c.LogConf) - ctx.Cron.Start() - cron.AddCronGroup(ctx) - handler.RegisterHandlers(server, ctx) - - serviceGroup.Add(server) - services := []service.Service{ - //mqs.MustNewQueue("ai", mqs.NewAiMq(context.Background(), ctx)), - mqs.MustNewQueue("cloud", mqs.NewCloudMq(context.Background(), ctx)), - //mqs.MustNewQueue("hpc", mqs.NewHpcMq(context.Background(), ctx)), - } - for _, mq := range services { - serviceGroup.Add(mq) - } - logx.Infof("Starting server at %s:%d...\n", c.Host, c.Port) - serviceGroup.Start() - -} diff --git a/api/client/client.go b/client/client.go similarity index 100% rename from api/client/client.go rename to client/client.go diff --git a/api/client/client_impl.go b/client/client_impl.go similarity index 100% rename from api/client/client_impl.go rename to client/client_impl.go diff --git a/api/client/notice.go b/client/notice.go similarity index 100% rename from api/client/notice.go rename to client/notice.go diff --git a/api/client/notice_impl.go b/client/notice_impl.go similarity index 100% rename from api/client/notice_impl.go rename to client/notice_impl.go diff --git a/api/client/task.go b/client/task.go similarity index 100% rename from api/client/task.go rename to client/task.go diff --git a/api/client/task_impl.go b/client/task_impl.go similarity index 100% rename from api/client/task_impl.go rename to client/task_impl.go diff --git a/api/client/types.go b/client/types.go similarity index 100% rename from api/client/types.go rename to client/types.go diff --git a/api/pcm-coordinator-api.yaml b/deploy/pcm-coordinator-api.yaml similarity index 100% rename from api/pcm-coordinator-api.yaml rename to deploy/pcm-coordinator-api.yaml diff --git a/api/desc/ai/pcm-ai.api b/desc/ai/pcm-ai.api similarity index 100% rename from api/desc/ai/pcm-ai.api rename to desc/ai/pcm-ai.api diff --git a/api/desc/cloud/pcm-cloud.api b/desc/cloud/pcm-cloud.api similarity index 100% rename from api/desc/cloud/pcm-cloud.api rename to desc/cloud/pcm-cloud.api diff --git a/api/desc/core/pcm-core.api b/desc/core/pcm-core.api similarity index 100% rename from api/desc/core/pcm-core.api rename to desc/core/pcm-core.api diff --git a/api/desc/hpc/pcm-hpc.api b/desc/hpc/pcm-hpc.api similarity index 100% rename from api/desc/hpc/pcm-hpc.api rename to desc/hpc/pcm-hpc.api diff --git a/api/desc/inference/inference.api b/desc/inference/inference.api similarity index 100% rename from api/desc/inference/inference.api rename to desc/inference/inference.api diff --git a/api/desc/monitoring/pcm-monitoring.api b/desc/monitoring/pcm-monitoring.api similarity index 100% rename from api/desc/monitoring/pcm-monitoring.api rename to desc/monitoring/pcm-monitoring.api diff --git a/api/desc/pcm.api b/desc/pcm.api similarity index 100% rename from api/desc/pcm.api rename to desc/pcm.api diff --git a/api/desc/pcm.json b/desc/pcm.json similarity index 100% rename from api/desc/pcm.json rename to desc/pcm.json diff --git a/api/desc/schedule/pcm-schedule.api b/desc/schedule/pcm-schedule.api similarity index 100% rename from api/desc/schedule/pcm-schedule.api rename to desc/schedule/pcm-schedule.api diff --git a/api/desc/storage/pcm-storage.api b/desc/storage/pcm-storage.api similarity index 100% rename from api/desc/storage/pcm-storage.api rename to desc/storage/pcm-storage.api diff --git a/api/desc/storelink/pcm-storelink.api b/desc/storelink/pcm-storelink.api similarity index 100% rename from api/desc/storelink/pcm-storelink.api rename to desc/storelink/pcm-storelink.api diff --git a/api/desc/vm/pcm-vm.api b/desc/vm/pcm-vm.api similarity index 100% rename from api/desc/vm/pcm-vm.api rename to desc/vm/pcm-vm.api diff --git a/etc/pcm.yaml b/etc/pcm.yaml new file mode 100644 index 00000000..e2e14f99 --- /dev/null +++ b/etc/pcm.yaml @@ -0,0 +1,85 @@ +Name: pcm.core.api +Host: 0.0.0.0 +Port: 8999 +MaxBytes: 524288000 + +Timeout: 50000 + +DB: +# DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local + DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local +Redis: + Host: 10.206.0.12:6379 + Pass: redisPW123 + +Monitoring: + PromUrl: http://47.92.39.128:30877 + AlertUrl: 47.92.39.128:32243 + +#rpc +THRpcConf: + target: nacos://10.206.0.12:8848/pcm.th.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + # Endpoints: + # - 127.0.0.1:8888 + NonBlock: true + +#rpc +ModelArtsRpcConf: + # target: nacos://10.206.0.12:8848/pcm.modelarts.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + Endpoints: + - 127.0.0.1:2002 + NonBlock: true + Timeout: 20000 + +#rpc +ModelArtsImgRpcConf: + target: nacos://10.206.0.12:8848/pcm.modelarts.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + # Endpoints: + # - 127.0.0.1:2002 + NonBlock: true + +#rpc +ACRpcConf: + target: nacos://10.206.0.12:8848/pcm.ac.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + # Endpoints: + # - 127.0.0.1:8888 + NonBlock: true + Timeout: 50000 + +#rpc +CephRpcConf: + # target: nacos://10.206.0.12:8848/pcm.ceph.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + Endpoints: + - pcm-participant-ceph-service:2008 + NonBlock: true + Timeout: 50000 + +OctopusRpcConf: + target: nacos://10.206.0.12:8848/pcm.octopus.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + # Endpoints: + # - 127.0.0.1:8888 + NonBlock: true + Timeout: 20000 + +OpenstackRpcConf: + # target: nacos://10.206.0.12:8848/pcm.openstack.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + Endpoints: + - 127.0.0.1:2010 + NonBlock: true + Timeout: 20000 + +# core rpc +PcmCoreRpcConf: + # target: nacos://10.206.0.12:8848/pcm.core.rpc?timeout=30s&namespaceid=test&groupname=DEFAULT_GROUP&appName=pcm.core.api + Endpoints: + - pcm-core-rpc:2004 + NonBlock: true + Timeout: 20000 + +MinioConf: + Secret: minio_xnu122@_ + AccessKey: minioadmin + Endpoint: http://121.89.220.60:9000 + +SnowflakeConf: + MachineId: 1 \ No newline at end of file diff --git a/examples/ai/modelArts.yaml b/examples/ai/modelArts.yaml deleted file mode 100644 index c724191c..00000000 --- a/examples/ai/modelArts.yaml +++ /dev/null @@ -1,10 +0,0 @@ -description: modelArts -name: modelArts -tasks: - - serviceName: modelArts - metadata: - projectId: 0a62ffb0d48026c12fbfc011b8d23f0b - name: demo3 - command: echo hello;sleep 100;echo hello;sleep 100;echo hello - flavorId: modelarts.p3.large.public.free - imageUrl: jcce/nginx:v1 \ No newline at end of file diff --git a/examples/cloud/nginx.yaml b/examples/cloud/nginx.yaml deleted file mode 100644 index 22a0fee3..00000000 --- a/examples/cloud/nginx.yaml +++ /dev/null @@ -1,72 +0,0 @@ -description: sealos-task-zw3 -name: sealos-task-zw3 -nsID: ns-admin -tasks: - - taskType: cloud - replicas: 2 - matchLabels: - cloud: sealos - metadata: - - apiVersion: v1 - kind: Service - metadata: - namespace: ns-admin - name: hello-world-3 - labels: - cloud.sealos.io/app-deploy-manager: hello-world-3 - spec: - ports: - - port: 80 - targetPort: 80 - name: rcszabasszit - selector: - app: hello-world-3 - - - apiVersion: apps/v1 - kind: Deployment - metadata: - namespace: ns-admin - name: hello-world-3 - annotations: - originImageName: nginx - deploy.cloud.sealos.io/minReplicas: '1' - deploy.cloud.sealos.io/maxReplicas: '1' - labels: - cloud.sealos.io/app-deploy-manager: hello-world-3 - app: hello-world-3 - spec: - replicas: 1 - revisionHistoryLimit: 1 - selector: - matchLabels: - app: hello-world-3 - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 0 - maxSurge: 1 - template: - metadata: - labels: - app: hello-world-3 - restartTime: '20231129185132' - spec: - containers: - - name: hello-world-3 - image: nginx - env: [] - resources: - requests: - cpu: 10m - memory: 6Mi - limits: - cpu: 100m - memory: 64Mi - ports: - - containerPort: 80 - name: rcszabasszit - imagePullPolicy: Always - volumeMounts: [] - volumes: [] - - diff --git a/examples/hpc/ac.yaml b/examples/hpc/ac.yaml deleted file mode 100644 index 69713d25..00000000 --- a/examples/hpc/ac.yaml +++ /dev/null @@ -1,19 +0,0 @@ -description: ac_01 -name: ac_01 -tasks: - - taskType: hpc - matchLabels: - hpc: shuguang - metadata: - cardCount: 1 - name: ac_01 - workDir: /public/home/zhijiang/test/testjob1 - wallTime: 00:10:00 - cmdScript: sleep 300 - appType: BASIC - appName: BASE - queue: debug2 - nNode: "1" - submitType: cmd - stdOutFile: /public/home/zhijiang/test/testjob1/std.out.%j - stdErrFile: /public/home/zhijiang/test/testjob1/std.err.%j \ No newline at end of file diff --git a/examples/hpc/th.yaml b/examples/hpc/th.yaml deleted file mode 100644 index 4da1fd0b..00000000 --- a/examples/hpc/th.yaml +++ /dev/null @@ -1,8 +0,0 @@ -description: th1 task -name: th1 demo -tasks: - - serviceName: th - metadata: - cardCount: 1 - name: tianhe1 demo - cmdScript: srun sleep 500 diff --git a/go.mod b/go.mod index 8899453d..34ae8613 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/go-redis/redis/v8 v8.11.5 github.com/go-resty/resty/v2 v2.12.0 - github.com/go-sql-driver/mysql v1.8.1 github.com/jinzhu/copier v0.4.0 github.com/json-iterator/go v1.1.12 github.com/pkg/errors v0.9.1 @@ -32,7 +31,6 @@ require ( go.opentelemetry.io/otel/trace v1.27.0 gonum.org/v1/gonum v0.11.0 google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.34.2 gorm.io/datatypes v1.2.0 gorm.io/driver/mysql v1.5.2 gorm.io/gorm v1.25.5 @@ -73,6 +71,7 @@ require ( github.com/go-openapi/strfmt v0.22.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-openapi/validate v0.23.0 // indirect + github.com/go-sql-driver/mysql v1.8.1 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect @@ -155,6 +154,7 @@ require ( golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/api/internal/config/config.go b/internal/config/config.go similarity index 100% rename from api/internal/config/config.go rename to internal/config/config.go diff --git a/internal/cron/aiCronTask.go b/internal/cron/aiCronTask.go new file mode 100644 index 00000000..60511835 --- /dev/null +++ b/internal/cron/aiCronTask.go @@ -0,0 +1,250 @@ +package cron + +import ( + "errors" + "fmt" + "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/zrpc" + hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/config" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/executor" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" + "net/http" + "strconv" + "sync" +) + +const ( + OCTOPUS = "octopus" + MODELARTS = "modelarts" + SHUGUANGAI = "shuguangAi" +) + +func GetTaskList(svc *svc.ServiceContext) ([]*types.TaskModel, error) { + limit := 10 + offset := 0 + var list []*types.TaskModel + db := svc.DbEngin.Model(&types.TaskModel{}).Table("task") + + db = db.Where("deleted_at is null") + + //count total + var total int64 + err := db.Count(&total).Error + db.Limit(limit).Offset(offset) + + if err != nil { + return nil, err + } + err = db.Order("created_time desc").Find(&list).Error + if err != nil { + return nil, err + } + return list, nil +} + +func UpdateAiAdapterMaps(svc *svc.ServiceContext) { + var aiType = "1" + adapterIds, err := svc.Scheduler.AiStorages.GetAdapterIdsByType(aiType) + if err != nil { + msg := fmt.Sprintf("###UpdateAiAdapterMaps###, error: %v \n", err.Error()) + logx.Errorf(errors.New(msg).Error()) + return + } + if len(adapterIds) == 0 { + return + } + + for _, id := range adapterIds { + clusters, err := svc.Scheduler.AiStorages.GetClustersByAdapterId(id) + if err != nil { + msg := fmt.Sprintf("###UpdateAiAdapterMaps###, error: %v \n", err.Error()) + logx.Errorf(errors.New(msg).Error()) + return + } + if len(clusters.List) == 0 { + continue + } + if isAdapterExist(svc, id, len(clusters.List)) { + continue + } else { + if isAdapterEmpty(svc, id) { + exeClusterMap, colClusterMap := InitAiClusterMap(&svc.Config, clusters.List) + svc.Scheduler.AiService.AiExecutorAdapterMap[id] = exeClusterMap + svc.Scheduler.AiService.AiCollectorAdapterMap[id] = colClusterMap + } else { + UpdateClusterMaps(svc, id, clusters.List) + } + } + } +} + +func UpdateClusterMaps(svc *svc.ServiceContext, adapterId string, clusters []types.ClusterInfo) { + for _, c := range clusters { + _, ok := svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] + _, ok2 := svc.Scheduler.AiService.AiCollectorAdapterMap[adapterId][c.Id] + if !ok && !ok2 { + switch c.Name { + case OCTOPUS: + id, _ := strconv.ParseInt(c.Id, 10, 64) + octopusRpc := octopusclient.NewOctopus(zrpc.MustNewClient(svc.Config.OctopusRpcConf)) + octopus := storeLink.NewOctopusLink(octopusRpc, c.Nickname, id) + svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = octopus + svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = octopus + case MODELARTS: + id, _ := strconv.ParseInt(c.Id, 10, 64) + modelArtsRpc := modelartsservice.NewModelArtsService(zrpc.MustNewClient(svc.Config.ModelArtsRpcConf)) + modelArtsImgRpc := imagesservice.NewImagesService(zrpc.MustNewClient(svc.Config.ModelArtsImgRpcConf)) + modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, c.Name, id, c.Nickname) + svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = modelarts + svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = modelarts + case SHUGUANGAI: + id, _ := strconv.ParseInt(c.Id, 10, 64) + aCRpc := hpcacclient.NewHpcAC(zrpc.MustNewClient(svc.Config.ACRpcConf)) + sgai := storeLink.NewShuguangAi(aCRpc, c.Nickname, id) + svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = sgai + svc.Scheduler.AiService.AiExecutorAdapterMap[adapterId][c.Id] = sgai + } + } else { + continue + } + } + +} + +func isAdapterExist(svc *svc.ServiceContext, id string, clusterNum int) bool { + emap, ok := svc.Scheduler.AiService.AiExecutorAdapterMap[id] + cmap, ok2 := svc.Scheduler.AiService.AiCollectorAdapterMap[id] + if ok && ok2 { + if len(emap) == clusterNum && len(cmap) == clusterNum { + return true + } + } + return false +} + +func isAdapterEmpty(svc *svc.ServiceContext, id string) bool { + _, ok := svc.Scheduler.AiService.AiExecutorAdapterMap[id] + _, ok2 := svc.Scheduler.AiService.AiCollectorAdapterMap[id] + if !ok && !ok2 { + return true + } + return false +} + +func InitAiClusterMap(conf *config.Config, clusters []types.ClusterInfo) (map[string]executor.AiExecutor, map[string]collector.AiCollector) { + executorMap := make(map[string]executor.AiExecutor) + collectorMap := make(map[string]collector.AiCollector) + for _, c := range clusters { + switch c.Name { + case OCTOPUS: + id, _ := strconv.ParseInt(c.Id, 10, 64) + octopusRpc := octopusclient.NewOctopus(zrpc.MustNewClient(conf.OctopusRpcConf)) + octopus := storeLink.NewOctopusLink(octopusRpc, c.Nickname, id) + collectorMap[c.Id] = octopus + executorMap[c.Id] = octopus + case MODELARTS: + id, _ := strconv.ParseInt(c.Id, 10, 64) + modelArtsRpc := modelartsservice.NewModelArtsService(zrpc.MustNewClient(conf.ModelArtsRpcConf)) + modelArtsImgRpc := imagesservice.NewImagesService(zrpc.MustNewClient(conf.ModelArtsImgRpcConf)) + modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, c.Name, id, c.Nickname) + collectorMap[c.Id] = modelarts + executorMap[c.Id] = modelarts + case SHUGUANGAI: + id, _ := strconv.ParseInt(c.Id, 10, 64) + aCRpc := hpcacclient.NewHpcAC(zrpc.MustNewClient(conf.ACRpcConf)) + sgai := storeLink.NewShuguangAi(aCRpc, c.Nickname, id) + collectorMap[c.Id] = sgai + executorMap[c.Id] = sgai + } + } + + return executorMap, collectorMap +} + +func UpdateClusterResource(svc *svc.ServiceContext) { + list, err := svc.Scheduler.AiStorages.GetAdaptersByType("1") + if err != nil { + return + } + var wg sync.WaitGroup + for _, adapter := range list { + clusters, err := svc.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) + if err != nil { + continue + } + for _, cluster := range clusters.List { + c := cluster + clusterResource, err := svc.Scheduler.AiStorages.GetClusterResourcesById(c.Id) + if err != nil { + continue + } + wg.Add(1) + go func() { + _, ok := svc.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id] + if !ok { + wg.Done() + return + } + h := http.Request{} + stat, err := svc.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id].GetResourceStats(h.Context()) + if err != nil { + wg.Done() + return + } + if stat == nil { + wg.Done() + return + } + clusterType, err := strconv.ParseInt(adapter.Type, 10, 64) + if err != nil { + wg.Done() + return + } + var cardTotal int64 + var topsTotal float64 + for _, card := range stat.CardsAvail { + cardTotal += int64(card.CardNum) + topsTotal += card.TOpsAtFp16 * float64(card.CardNum) + } + + if (models.TClusterResource{} == *clusterResource) { + err = svc.Scheduler.AiStorages.SaveClusterResources(adapter.Id, c.Id, c.Name, clusterType, float64(stat.CpuCoreAvail), float64(stat.CpuCoreTotal), + stat.MemAvail, stat.MemTotal, stat.DiskAvail, stat.DiskTotal, float64(stat.GpuAvail), float64(stat.GpuTotal), cardTotal, topsTotal) + if err != nil { + wg.Done() + return + } + } else { + if stat.CpuCoreTotal == 0 || stat.MemTotal == 0 || stat.DiskTotal == 0 { + wg.Done() + return + } + clusterResource.CardTotal = cardTotal + clusterResource.CardTopsTotal = topsTotal + clusterResource.CpuAvail = float64(stat.CpuCoreAvail) + clusterResource.CpuTotal = float64(stat.CpuCoreTotal) + clusterResource.MemAvail = stat.MemAvail + clusterResource.MemTotal = stat.MemTotal + clusterResource.DiskAvail = stat.DiskAvail + clusterResource.DiskTotal = stat.DiskTotal + + err := svc.Scheduler.AiStorages.UpdateClusterResources(clusterResource) + if err != nil { + wg.Done() + return + } + } + wg.Done() + }() + } + } + wg.Wait() +} diff --git a/internal/cron/cron.go b/internal/cron/cron.go new file mode 100644 index 00000000..342b9b34 --- /dev/null +++ b/internal/cron/cron.go @@ -0,0 +1,42 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package cron + +import ( + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/status" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func AddCronGroup(svc *svc.ServiceContext) { + + svc.Cron.AddFunc("*/5 * * * * ?", func() { + list, err := GetTaskList(svc) + if err != nil { + logx.Errorf(err.Error()) + return + } + status.UpdateTaskStatus(svc, list) + status.UpdateAiTaskStatus(svc, list) + }) + + svc.Cron.AddFunc("*/5 * * * * ?", func() { + UpdateAiAdapterMaps(svc) + }) + + svc.Cron.AddFunc("*/59 * * * * ?", func() { + UpdateClusterResource(svc) + }) +} diff --git a/internal/handler/adapters/adapterslisthandler.go b/internal/handler/adapters/adapterslisthandler.go new file mode 100644 index 00000000..a5052362 --- /dev/null +++ b/internal/handler/adapters/adapterslisthandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func AdaptersListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdapterQueryReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewAdaptersListLogic(r.Context(), svcCtx) + resp, err := l.AdaptersList(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/clusterlisthandler.go b/internal/handler/adapters/clusterlisthandler.go new file mode 100644 index 00000000..6c8a7b7f --- /dev/null +++ b/internal/handler/adapters/clusterlisthandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ClusterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ClusterReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewClusterListLogic(r.Context(), svcCtx) + resp, err := l.ClusterList(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/createadapterhandler.go b/internal/handler/adapters/createadapterhandler.go new file mode 100644 index 00000000..01739e2e --- /dev/null +++ b/internal/handler/adapters/createadapterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdapterCreateReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewCreateAdapterLogic(r.Context(), svcCtx) + resp, err := l.CreateAdapter(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/createclusterhandler.go b/internal/handler/adapters/createclusterhandler.go new file mode 100644 index 00000000..b5299d87 --- /dev/null +++ b/internal/handler/adapters/createclusterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ClusterCreateReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewCreateClusterLogic(r.Context(), svcCtx) + resp, err := l.CreateCluster(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/deleteadapterhandler.go b/internal/handler/adapters/deleteadapterhandler.go new file mode 100644 index 00000000..e1607214 --- /dev/null +++ b/internal/handler/adapters/deleteadapterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdapterDelReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewDeleteAdapterLogic(r.Context(), svcCtx) + resp, err := l.DeleteAdapter(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/deleteclusterhandler.go b/internal/handler/adapters/deleteclusterhandler.go new file mode 100644 index 00000000..7bf7aa7f --- /dev/null +++ b/internal/handler/adapters/deleteclusterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.FId + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewDeleteClusterLogic(r.Context(), svcCtx) + resp, err := l.DeleteCluster(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/getadapterhandler.go b/internal/handler/adapters/getadapterhandler.go new file mode 100644 index 00000000..221bb1cf --- /dev/null +++ b/internal/handler/adapters/getadapterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdapterDelReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewGetAdapterLogic(r.Context(), svcCtx) + resp, err := l.GetAdapter(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/getadapterrelationhandler.go b/internal/handler/adapters/getadapterrelationhandler.go new file mode 100644 index 00000000..16c6b591 --- /dev/null +++ b/internal/handler/adapters/getadapterrelationhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetAdapterRelationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdapterRelationQueryReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewGetAdapterRelationLogic(r.Context(), svcCtx) + resp, err := l.GetAdapterRelation(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/getclusterhandler.go b/internal/handler/adapters/getclusterhandler.go new file mode 100644 index 00000000..4d072fb3 --- /dev/null +++ b/internal/handler/adapters/getclusterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.FId + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewGetClusterLogic(r.Context(), svcCtx) + resp, err := l.GetCluster(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/getclustersumhandler.go b/internal/handler/adapters/getclustersumhandler.go new file mode 100644 index 00000000..992cd6d7 --- /dev/null +++ b/internal/handler/adapters/getclustersumhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetClusterSumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ClusterSumReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewGetClusterSumLogic(r.Context(), svcCtx) + resp, err := l.GetClusterSum(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/updateadapterhandler.go b/internal/handler/adapters/updateadapterhandler.go new file mode 100644 index 00000000..759eef81 --- /dev/null +++ b/internal/handler/adapters/updateadapterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func UpdateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdapterReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewUpdateAdapterLogic(r.Context(), svcCtx) + resp, err := l.UpdateAdapter(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/adapters/updateclusterhandler.go b/internal/handler/adapters/updateclusterhandler.go new file mode 100644 index 00000000..191a8683 --- /dev/null +++ b/internal/handler/adapters/updateclusterhandler.go @@ -0,0 +1,24 @@ +package adapters + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/adapters" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func UpdateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ClusterCreateReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := adapters.NewUpdateClusterLogic(r.Context(), svcCtx) + resp, err := l.UpdateCluster(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createalgorithmhandler.go b/internal/handler/ai/createalgorithmhandler.go new file mode 100644 index 00000000..92b074d4 --- /dev/null +++ b/internal/handler/ai/createalgorithmhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateAlgorithmHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateAlgorithmReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateAlgorithmLogic(r.Context(), svcCtx) + resp, err := l.CreateAlgorithm(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createdatasethandler.go b/internal/handler/ai/createdatasethandler.go new file mode 100644 index 00000000..9661a729 --- /dev/null +++ b/internal/handler/ai/createdatasethandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateDataSetReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateDataSetLogic(r.Context(), svcCtx) + resp, err := l.CreateDataSet(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createexporttaskhandler.go b/internal/handler/ai/createexporttaskhandler.go new file mode 100644 index 00000000..32594dfe --- /dev/null +++ b/internal/handler/ai/createexporttaskhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateExportTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateExportTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateExportTaskLogic(r.Context(), svcCtx) + resp, err := l.CreateExportTask(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createnotebookhandler.go b/internal/handler/ai/createnotebookhandler.go new file mode 100644 index 00000000..7c9bcf68 --- /dev/null +++ b/internal/handler/ai/createnotebookhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateNotebookReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateNotebookLogic(r.Context(), svcCtx) + resp, err := l.CreateNotebook(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createprocessortaskhandler.go b/internal/handler/ai/createprocessortaskhandler.go new file mode 100644 index 00000000..82bfc688 --- /dev/null +++ b/internal/handler/ai/createprocessortaskhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateProcessorTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateProcessorTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateProcessorTaskLogic(r.Context(), svcCtx) + resp, err := l.CreateProcessorTask(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createservicehandler.go b/internal/handler/ai/createservicehandler.go new file mode 100644 index 00000000..afef0e78 --- /dev/null +++ b/internal/handler/ai/createservicehandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateServiceReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateServiceLogic(r.Context(), svcCtx) + resp, err := l.CreateService(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createtaskhandler.go b/internal/handler/ai/createtaskhandler.go new file mode 100644 index 00000000..5f83d772 --- /dev/null +++ b/internal/handler/ai/createtaskhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ImportTaskDataReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateTaskLogic(r.Context(), svcCtx) + resp, err := l.CreateTask(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createtrainingjobhandler.go b/internal/handler/ai/createtrainingjobhandler.go new file mode 100644 index 00000000..9838c439 --- /dev/null +++ b/internal/handler/ai/createtrainingjobhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateTrainingJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateTrainingJobReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateTrainingJobLogic(r.Context(), svcCtx) + resp, err := l.CreateTrainingJob(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/createvisualizationjobhandler.go b/internal/handler/ai/createvisualizationjobhandler.go new file mode 100644 index 00000000..bebdd359 --- /dev/null +++ b/internal/handler/ai/createvisualizationjobhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CreateVisualizationJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateVisualizationJobReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewCreateVisualizationJobLogic(r.Context(), svcCtx) + resp, err := l.CreateVisualizationJob(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/deletealgorithmhandler.go b/internal/handler/ai/deletealgorithmhandler.go new file mode 100644 index 00000000..42d10abb --- /dev/null +++ b/internal/handler/ai/deletealgorithmhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteAlgorithmHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteAlgorithmReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewDeleteAlgorithmLogic(r.Context(), svcCtx) + resp, err := l.DeleteAlgorithm(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/deletedatasethandler.go b/internal/handler/ai/deletedatasethandler.go new file mode 100644 index 00000000..b9c99fa4 --- /dev/null +++ b/internal/handler/ai/deletedatasethandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteDataSetReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewDeleteDataSetLogic(r.Context(), svcCtx) + resp, err := l.DeleteDataSet(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/deleteservicehandler.go b/internal/handler/ai/deleteservicehandler.go new file mode 100644 index 00000000..66fc8bb1 --- /dev/null +++ b/internal/handler/ai/deleteservicehandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteServiceReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewDeleteServiceLogic(r.Context(), svcCtx) + resp, err := l.DeleteService(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/deletetrainingjobhandler.go b/internal/handler/ai/deletetrainingjobhandler.go new file mode 100644 index 00000000..e899df89 --- /dev/null +++ b/internal/handler/ai/deletetrainingjobhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteTrainingJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteTrainingJobReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewDeleteTrainingJobLogic(r.Context(), svcCtx) + resp, err := l.DeleteTrainingJob(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/getcenterlisthandler.go b/internal/handler/ai/getcenterlisthandler.go new file mode 100644 index 00000000..3b76501f --- /dev/null +++ b/internal/handler/ai/getcenterlisthandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func GetCenterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterListLogic(r.Context(), svcCtx) + resp, err := l.GetCenterList() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/ai/getcenteroverviewhandler.go b/internal/handler/ai/getcenteroverviewhandler.go new file mode 100644 index 00000000..c4c982a5 --- /dev/null +++ b/internal/handler/ai/getcenteroverviewhandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func GetCenterOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterOverviewLogic(r.Context(), svcCtx) + resp, err := l.GetCenterOverview() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/ai/getcenterqueueinghandler.go b/internal/handler/ai/getcenterqueueinghandler.go new file mode 100644 index 00000000..3ec25d4f --- /dev/null +++ b/internal/handler/ai/getcenterqueueinghandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func GetCenterQueueingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterQueueingLogic(r.Context(), svcCtx) + resp, err := l.GetCenterQueueing() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/ai/getcentertasklisthandler.go b/internal/handler/ai/getcentertasklisthandler.go new file mode 100644 index 00000000..7da507cb --- /dev/null +++ b/internal/handler/ai/getcentertasklisthandler.go @@ -0,0 +1,21 @@ +package ai + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func GetCenterTaskListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := ai.NewGetCenterTaskListLogic(r.Context(), svcCtx) + resp, err := l.GetCenterTaskList() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/ai/getexporttasksofdatasethandler.go b/internal/handler/ai/getexporttasksofdatasethandler.go new file mode 100644 index 00000000..0eba6777 --- /dev/null +++ b/internal/handler/ai/getexporttasksofdatasethandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetExportTasksOfDatasetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetExportTasksOfDatasetReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewGetExportTasksOfDatasetLogic(r.Context(), svcCtx) + resp, err := l.GetExportTasksOfDataset(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/getexporttaskstatusofdatasethandler.go b/internal/handler/ai/getexporttaskstatusofdatasethandler.go new file mode 100644 index 00000000..8ab02472 --- /dev/null +++ b/internal/handler/ai/getexporttaskstatusofdatasethandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetExportTaskStatusOfDatasetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetExportTaskStatusOfDatasetReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewGetExportTaskStatusOfDatasetLogic(r.Context(), svcCtx) + resp, err := l.GetExportTaskStatusOfDataset(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/getlisttrainingjobshandler.go b/internal/handler/ai/getlisttrainingjobshandler.go new file mode 100644 index 00000000..01c468c5 --- /dev/null +++ b/internal/handler/ai/getlisttrainingjobshandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetListTrainingJobsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListTrainingJobsreq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewGetListTrainingJobsLogic(r.Context(), svcCtx) + resp, err := l.GetListTrainingJobs(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/getnotebookstoragehandler.go b/internal/handler/ai/getnotebookstoragehandler.go new file mode 100644 index 00000000..e6a87098 --- /dev/null +++ b/internal/handler/ai/getnotebookstoragehandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetNotebookStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetNotebookStorageReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewGetNotebookStorageLogic(r.Context(), svcCtx) + resp, err := l.GetNotebookStorage(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/getvisualizationjobhandler.go b/internal/handler/ai/getvisualizationjobhandler.go new file mode 100644 index 00000000..b11fb437 --- /dev/null +++ b/internal/handler/ai/getvisualizationjobhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetVisualizationJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetVisualizationJobReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewGetVisualizationJobLogic(r.Context(), svcCtx) + resp, err := l.GetVisualizationJob(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/listalgorithmshandler.go b/internal/handler/ai/listalgorithmshandler.go new file mode 100644 index 00000000..458d22e7 --- /dev/null +++ b/internal/handler/ai/listalgorithmshandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListAlgorithmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListAlgorithmsReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewListAlgorithmsLogic(r.Context(), svcCtx) + resp, err := l.ListAlgorithms(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/listclustershandler.go b/internal/handler/ai/listclustershandler.go new file mode 100644 index 00000000..50718484 --- /dev/null +++ b/internal/handler/ai/listclustershandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListClustersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListClustersReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewListClustersLogic(r.Context(), svcCtx) + resp, err := l.ListClusters(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/listdatasethandler.go b/internal/handler/ai/listdatasethandler.go new file mode 100644 index 00000000..c0b6db56 --- /dev/null +++ b/internal/handler/ai/listdatasethandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DataSetReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewListDataSetLogic(r.Context(), svcCtx) + resp, err := l.ListDataSet(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/listimporthandler.go b/internal/handler/ai/listimporthandler.go new file mode 100644 index 00000000..5969d4de --- /dev/null +++ b/internal/handler/ai/listimporthandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListImportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListImportTasksReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewListImportLogic(r.Context(), svcCtx) + resp, err := l.ListImport(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/listnotebookhandler.go b/internal/handler/ai/listnotebookhandler.go new file mode 100644 index 00000000..0dcce8ad --- /dev/null +++ b/internal/handler/ai/listnotebookhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListNotebookReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewListNotebookLogic(r.Context(), svcCtx) + resp, err := l.ListNotebook(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/listserviceshandler.go b/internal/handler/ai/listserviceshandler.go new file mode 100644 index 00000000..33dec620 --- /dev/null +++ b/internal/handler/ai/listserviceshandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListServicesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListServicesReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewListServicesLogic(r.Context(), svcCtx) + resp, err := l.ListServices(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/mountnotebookstoragehandler.go b/internal/handler/ai/mountnotebookstoragehandler.go new file mode 100644 index 00000000..ca276779 --- /dev/null +++ b/internal/handler/ai/mountnotebookstoragehandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func MountNotebookStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.MountNotebookStorageReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewMountNotebookStorageLogic(r.Context(), svcCtx) + resp, err := l.MountNotebookStorage(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/proxyapihandler.go b/internal/handler/ai/proxyapihandler.go new file mode 100644 index 00000000..d376a92b --- /dev/null +++ b/internal/handler/ai/proxyapihandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ProxyApiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ChatReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewProxyApiLogic(r.Context(), svcCtx) + resp, err := l.ProxyApi(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/showalgorithmbyuuidhandler.go b/internal/handler/ai/showalgorithmbyuuidhandler.go new file mode 100644 index 00000000..02c14234 --- /dev/null +++ b/internal/handler/ai/showalgorithmbyuuidhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ShowAlgorithmByUuidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowAlgorithmByUuidReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewShowAlgorithmByUuidLogic(r.Context(), svcCtx) + resp, err := l.ShowAlgorithmByUuid(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/showservicehandler.go b/internal/handler/ai/showservicehandler.go new file mode 100644 index 00000000..3f994910 --- /dev/null +++ b/internal/handler/ai/showservicehandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ShowServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowServiceReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewShowServiceLogic(r.Context(), svcCtx) + resp, err := l.ShowService(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/startnotebookhandler.go b/internal/handler/ai/startnotebookhandler.go new file mode 100644 index 00000000..9b1cb044 --- /dev/null +++ b/internal/handler/ai/startnotebookhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func StartNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StartNotebookReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewStartNotebookLogic(r.Context(), svcCtx) + resp, err := l.StartNotebook(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/ai/stopnotebookhandler.go b/internal/handler/ai/stopnotebookhandler.go new file mode 100644 index 00000000..7afe018f --- /dev/null +++ b/internal/handler/ai/stopnotebookhandler.go @@ -0,0 +1,24 @@ +package ai + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func StopNotebookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StopNotebookReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := ai.NewStopNotebookLogic(r.Context(), svcCtx) + resp, err := l.StopNotebook(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/cloudlisthandler.go b/internal/handler/cloud/cloudlisthandler.go new file mode 100644 index 00000000..3c8bcf8c --- /dev/null +++ b/internal/handler/cloud/cloudlisthandler.go @@ -0,0 +1,16 @@ +package cloud + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CloudListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := cloud.NewCloudListLogic(r.Context(), svcCtx) + resp, err := l.CloudList() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/clusterinfohandler.go b/internal/handler/cloud/clusterinfohandler.go new file mode 100644 index 00000000..1838a89b --- /dev/null +++ b/internal/handler/cloud/clusterinfohandler.go @@ -0,0 +1,25 @@ +package cloud + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ClusterInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ClusterInfoReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := cloud.NewClusterInfoLogic(r.Context(), svcCtx) + resp, err := l.ClusterInfo(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/commitgeneraltaskhandler.go b/internal/handler/cloud/commitgeneraltaskhandler.go new file mode 100644 index 00000000..952d6ec0 --- /dev/null +++ b/internal/handler/cloud/commitgeneraltaskhandler.go @@ -0,0 +1,24 @@ +package cloud + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CommitGeneralTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GeneralTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := cloud.NewCommitGeneralTaskLogic(r.Context(), svcCtx) + err := l.CommitGeneralTask(&req) + result.HttpResult(r, w, nil, err) + } +} diff --git a/internal/handler/cloud/controllermetricshandler.go b/internal/handler/cloud/controllermetricshandler.go new file mode 100644 index 00000000..7b071c15 --- /dev/null +++ b/internal/handler/cloud/controllermetricshandler.go @@ -0,0 +1,24 @@ +package cloud + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ControllerMetricsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ControllerMetricsReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := cloud.NewControllerMetricsLogic(r.Context(), svcCtx) + resp, err := l.ControllerMetrics(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/deleteclusterhandler.go b/internal/handler/cloud/deleteclusterhandler.go new file mode 100644 index 00000000..042f7f49 --- /dev/null +++ b/internal/handler/cloud/deleteclusterhandler.go @@ -0,0 +1,24 @@ +package cloud + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteClusterReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := cloud.NewDeleteClusterLogic(r.Context(), svcCtx) + resp, err := l.DeleteCluster(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/deleteyamlhandler.go b/internal/handler/cloud/deleteyamlhandler.go new file mode 100644 index 00000000..1983a38e --- /dev/null +++ b/internal/handler/cloud/deleteyamlhandler.go @@ -0,0 +1,24 @@ +package cloud + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ApplyReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := cloud.NewDeleteYamlLogic(r.Context(), svcCtx) + resp, err := l.DeleteYaml(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/getclusterlisthandler.go b/internal/handler/cloud/getclusterlisthandler.go new file mode 100644 index 00000000..2499c617 --- /dev/null +++ b/internal/handler/cloud/getclusterlisthandler.go @@ -0,0 +1,24 @@ +package cloud + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetClusterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetClusterListReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := cloud.NewGetClusterListLogic(r.Context(), svcCtx) + resp, err := l.GetClusterList(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/podlogshandler.go b/internal/handler/cloud/podlogshandler.go new file mode 100644 index 00000000..7b2bc1cc --- /dev/null +++ b/internal/handler/cloud/podlogshandler.go @@ -0,0 +1,24 @@ +package cloud + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func PodLogsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.PodLogsReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := cloud.NewPodLogsLogic(r.Context(), svcCtx, w) + resp, err := l.PodLogs(&req, w) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/cloud/registerclusterhandler.go b/internal/handler/cloud/registerclusterhandler.go new file mode 100644 index 00000000..d65894f4 --- /dev/null +++ b/internal/handler/cloud/registerclusterhandler.go @@ -0,0 +1,24 @@ +package cloud + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func RegisterClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.RegisterClusterReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := cloud.NewRegisterClusterLogic(r.Context(), svcCtx) + resp, err := l.RegisterCluster(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/centerresourceshandler.go b/internal/handler/core/centerresourceshandler.go new file mode 100644 index 00000000..ba5dee9c --- /dev/null +++ b/internal/handler/core/centerresourceshandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CenterResourcesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewCenterResourcesLogic(r.Context(), svcCtx) + resp, err := l.CenterResources() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/committaskhandler.go b/internal/handler/core/committaskhandler.go new file mode 100644 index 00000000..8de6d93b --- /dev/null +++ b/internal/handler/core/committaskhandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CommitTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CommitTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewCommitTaskLogic(r.Context(), svcCtx) + err := l.CommitTask(&req) + result.HttpResult(r, w, nil, err) + } +} diff --git a/internal/handler/core/commitvmtaskhandler.go b/internal/handler/core/commitvmtaskhandler.go new file mode 100644 index 00000000..5eeecf1f --- /dev/null +++ b/internal/handler/core/commitvmtaskhandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CommitVmTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CommitVmTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewCommitVmTaskLogic(r.Context(), svcCtx) + resp, err := l.CommitVmTask(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/counttaskstatushandler.go b/internal/handler/core/counttaskstatushandler.go new file mode 100644 index 00000000..eec399d9 --- /dev/null +++ b/internal/handler/core/counttaskstatushandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CountTaskStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewCountTaskStatusLogic(r.Context(), svcCtx) + resp, err := l.CountTaskStatus() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/deletetaskhandler.go b/internal/handler/core/deletetaskhandler.go new file mode 100644 index 00000000..d3f5243d --- /dev/null +++ b/internal/handler/core/deletetaskhandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewDeleteTaskLogic(r.Context(), svcCtx) + err := l.DeleteTask(&req) + result.HttpResult(r, w, nil, err) + } +} diff --git a/internal/handler/core/getcomputilitystatisticshandler.go b/internal/handler/core/getcomputilitystatisticshandler.go new file mode 100644 index 00000000..90f93ef6 --- /dev/null +++ b/internal/handler/core/getcomputilitystatisticshandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +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() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/getcomputingpowerhandler.go b/internal/handler/core/getcomputingpowerhandler.go new file mode 100644 index 00000000..7c975d5c --- /dev/null +++ b/internal/handler/core/getcomputingpowerhandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetComputingPowerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetComputingPowerLogic(r.Context(), svcCtx) + resp, err := l.GetComputingPower() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/getdomainresourcehandler.go b/internal/handler/core/getdomainresourcehandler.go new file mode 100644 index 00000000..e5a4b657 --- /dev/null +++ b/internal/handler/core/getdomainresourcehandler.go @@ -0,0 +1,17 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func GetDomainResourceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetDomainResourceLogic(r.Context(), svcCtx) + resp, err := l.GetDomainResource() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/getgeneralinfohandler.go b/internal/handler/core/getgeneralinfohandler.go new file mode 100644 index 00000000..d9d071c0 --- /dev/null +++ b/internal/handler/core/getgeneralinfohandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetGeneralInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetGeneralInfoLogic(r.Context(), svcCtx) + resp, err := l.GetGeneralInfo() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/getpublicflavorhandler.go b/internal/handler/core/getpublicflavorhandler.go new file mode 100644 index 00000000..1ef4833b --- /dev/null +++ b/internal/handler/core/getpublicflavorhandler.go @@ -0,0 +1,28 @@ +package core + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetPublicFlavorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.PublicFlavorReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewGetPublicFlavorLogic(r.Context(), svcCtx) + resp, err := l.GetPublicFlavor(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/getpublicimagehandler.go b/internal/handler/core/getpublicimagehandler.go new file mode 100644 index 00000000..0cde040b --- /dev/null +++ b/internal/handler/core/getpublicimagehandler.go @@ -0,0 +1,28 @@ +package core + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetPublicImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.PublicImageReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewGetPublicImageLogic(r.Context(), svcCtx) + resp, err := l.GetPublicImage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/getpublicnetworkhandler.go b/internal/handler/core/getpublicnetworkhandler.go new file mode 100644 index 00000000..3f1dcb47 --- /dev/null +++ b/internal/handler/core/getpublicnetworkhandler.go @@ -0,0 +1,28 @@ +package core + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetPublicNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.PublicNetworkReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewGetPublicNetworkLogic(r.Context(), svcCtx) + resp, err := l.GetPublicNetwork(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/getregionhandler.go b/internal/handler/core/getregionhandler.go new file mode 100644 index 00000000..eab729d6 --- /dev/null +++ b/internal/handler/core/getregionhandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetRegionLogic(r.Context(), svcCtx) + resp, err := l.GetRegion() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/getresourcepanelconfighandler.go b/internal/handler/core/getresourcepanelconfighandler.go new file mode 100644 index 00000000..57c8a6d9 --- /dev/null +++ b/internal/handler/core/getresourcepanelconfighandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetResourcePanelConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetResourcePanelConfigLogic(r.Context(), svcCtx) + resp, err := l.GetResourcePanelConfig() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/getscreencharthandler.go b/internal/handler/core/getscreencharthandler.go new file mode 100644 index 00000000..9dd30a38 --- /dev/null +++ b/internal/handler/core/getscreencharthandler.go @@ -0,0 +1,17 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func GetScreenChartHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetScreenChartLogic(r.Context(), svcCtx) + resp, err := l.GetScreenChart() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/getscreeninfohandler.go b/internal/handler/core/getscreeninfohandler.go new file mode 100644 index 00000000..dfcf0c1d --- /dev/null +++ b/internal/handler/core/getscreeninfohandler.go @@ -0,0 +1,17 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func GetScreenInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetScreenInfoLogic(r.Context(), svcCtx) + resp, err := l.GetScreenInfo() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/homeoverviewhandler.go b/internal/handler/core/homeoverviewhandler.go new file mode 100644 index 00000000..d0de9a17 --- /dev/null +++ b/internal/handler/core/homeoverviewhandler.go @@ -0,0 +1,28 @@ +package core + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func HomeOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.HomeOverviewReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewHomeOverviewLogic(r.Context(), svcCtx) + resp, err := l.HomeOverview(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/jobtotalhandler.go b/internal/handler/core/jobtotalhandler.go new file mode 100644 index 00000000..8f718256 --- /dev/null +++ b/internal/handler/core/jobtotalhandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func JobTotalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewJobTotalLogic(r.Context(), svcCtx) + resp, err := l.JobTotal() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/listcenterhandler.go b/internal/handler/core/listcenterhandler.go new file mode 100644 index 00000000..84c6d21b --- /dev/null +++ b/internal/handler/core/listcenterhandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListCenterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewListCenterLogic(r.Context(), svcCtx) + resp, err := l.ListCenter() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/listclusterhandler.go b/internal/handler/core/listclusterhandler.go new file mode 100644 index 00000000..dc45e38d --- /dev/null +++ b/internal/handler/core/listclusterhandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListClusterReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewListClusterLogic(r.Context(), svcCtx) + resp, err := l.ListCluster(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/listnoticehandler.go b/internal/handler/core/listnoticehandler.go new file mode 100644 index 00000000..146b245b --- /dev/null +++ b/internal/handler/core/listnoticehandler.go @@ -0,0 +1,28 @@ +package core + +import ( + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func ListNoticeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req clientCore.ListNoticeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewListNoticeLogic(r.Context(), svcCtx) + resp, err := l.ListNotice(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/listregionhandler.go b/internal/handler/core/listregionhandler.go new file mode 100644 index 00000000..9b3bcc9d --- /dev/null +++ b/internal/handler/core/listregionhandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListRegionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewListRegionLogic(r.Context(), svcCtx) + resp, err := l.ListRegion() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/metricshandler.go b/internal/handler/core/metricshandler.go new file mode 100644 index 00000000..6ac6babd --- /dev/null +++ b/internal/handler/core/metricshandler.go @@ -0,0 +1,11 @@ +package core + +import ( + "github.com/prometheus/client_golang/prometheus/promhttp" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "net/http" +) + +func MetricsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return promhttp.Handler().ServeHTTP +} diff --git a/internal/handler/core/nodeassetshandler.go b/internal/handler/core/nodeassetshandler.go new file mode 100644 index 00000000..2ec21a18 --- /dev/null +++ b/internal/handler/core/nodeassetshandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func NodeAssetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewNodeAssetsLogic(r.Context(), svcCtx) + resp, err := l.NodeAssets() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/pagelisttaskhandler.go b/internal/handler/core/pagelisttaskhandler.go new file mode 100644 index 00000000..6c0ce4f9 --- /dev/null +++ b/internal/handler/core/pagelisttaskhandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func PageListTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.PageTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewPageListTaskLogic(r.Context(), svcCtx) + resp, err := l.PageListTask(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/participantlisthandler.go b/internal/handler/core/participantlisthandler.go new file mode 100644 index 00000000..e0680c26 --- /dev/null +++ b/internal/handler/core/participantlisthandler.go @@ -0,0 +1,16 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ParticipantListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewParticipantListLogic(r.Context(), svcCtx) + resp, err := l.ParticipantList() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/pulltaskinfohandler.go b/internal/handler/core/pulltaskinfohandler.go new file mode 100644 index 00000000..66494e9c --- /dev/null +++ b/internal/handler/core/pulltaskinfohandler.go @@ -0,0 +1,28 @@ +package core + +import ( + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func PullTaskInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req clientCore.PullTaskInfoReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewPullTaskInfoLogic(r.Context(), svcCtx) + resp, err := l.PullTaskInfo((*clientCore.PullTaskInfoReq)(&req)) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/pushnoticehandler.go b/internal/handler/core/pushnoticehandler.go new file mode 100644 index 00000000..91f4dad7 --- /dev/null +++ b/internal/handler/core/pushnoticehandler.go @@ -0,0 +1,28 @@ +package core + +import ( + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func PushNoticeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req clientCore.PushNoticeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewPushNoticeLogic(r.Context(), svcCtx) + resp, err := l.PushNotice(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/pushresourceinfohandler.go b/internal/handler/core/pushresourceinfohandler.go new file mode 100644 index 00000000..cd70488a --- /dev/null +++ b/internal/handler/core/pushresourceinfohandler.go @@ -0,0 +1,28 @@ +package core + +import ( + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func PushResourceInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req clientCore.PushResourceInfoReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewPushResourceInfoLogic(r.Context(), svcCtx) + resp, err := l.PushResourceInfo(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/pushtaskinfohandler.go b/internal/handler/core/pushtaskinfohandler.go new file mode 100644 index 00000000..01d8648d --- /dev/null +++ b/internal/handler/core/pushtaskinfohandler.go @@ -0,0 +1,28 @@ +package core + +import ( + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func PushTaskInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req clientCore.PushTaskInfoReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := core.NewPushTaskInfoLogic(r.Context(), svcCtx) + resp, err := l.PushTaskInfo(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/core/putresourcepanelconfighandler.go b/internal/handler/core/putresourcepanelconfighandler.go new file mode 100644 index 00000000..f607ed59 --- /dev/null +++ b/internal/handler/core/putresourcepanelconfighandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func PutResourcePanelConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ResourcePanelConfigReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewPutResourcePanelConfigLogic(r.Context(), svcCtx) + err := l.PutResourcePanelConfig(&req) + result.HttpResult(r, w, nil, err) + } +} diff --git a/internal/handler/core/scheduletaskbyyamlhandler.go b/internal/handler/core/scheduletaskbyyamlhandler.go new file mode 100644 index 00000000..038e0ed4 --- /dev/null +++ b/internal/handler/core/scheduletaskbyyamlhandler.go @@ -0,0 +1,36 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ScheduleTaskByYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ScheduleTaskByYamlReq + if err := httpx.Parse(r, &req); err != nil { + result.HttpResult(r, w, nil, err) + return + } + // 解析yaml文件 + _, fileHeader, err := r.FormFile("file") + if err != nil { + result.HttpResult(r, w, nil, err) + return + } + err = utils.Yaml2struct(fileHeader, &req) + if err != nil { + result.HttpResult(r, w, nil, err) + return + } + l := core.NewScheduleTaskByYamlLogic(r.Context(), svcCtx) + resp, err := l.ScheduleTaskByYaml(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/syncclusterloadhandler.go b/internal/handler/core/syncclusterloadhandler.go new file mode 100644 index 00000000..bfa7d298 --- /dev/null +++ b/internal/handler/core/syncclusterloadhandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func SyncClusterLoadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.SyncClusterLoadReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewSyncClusterLoadLogic(r.Context(), svcCtx) + err := l.SyncClusterLoad(&req) + result.HttpResult(r, w, nil, err) + } +} diff --git a/internal/handler/core/taskdetailshandler.go b/internal/handler/core/taskdetailshandler.go new file mode 100644 index 00000000..e3b7a85b --- /dev/null +++ b/internal/handler/core/taskdetailshandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func TaskDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.FId + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewTaskDetailsLogic(r.Context(), svcCtx) + resp, err := l.TaskDetails(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/core/tasklisthandler.go b/internal/handler/core/tasklisthandler.go new file mode 100644 index 00000000..70e1fe96 --- /dev/null +++ b/internal/handler/core/tasklisthandler.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func TaskListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.TaskListReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := core.NewTaskListLogic(r.Context(), svcCtx) + resp, err := l.TaskList(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/adddicthandler.go b/internal/handler/dictionary/adddicthandler.go new file mode 100644 index 00000000..36e8a1b7 --- /dev/null +++ b/internal/handler/dictionary/adddicthandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func AddDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DictEditReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewAddDictLogic(r.Context(), svcCtx) + resp, err := l.AddDict(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/adddictitemhandler.go b/internal/handler/dictionary/adddictitemhandler.go new file mode 100644 index 00000000..9d27207a --- /dev/null +++ b/internal/handler/dictionary/adddictitemhandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func AddDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DictItemEditReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewAddDictItemLogic(r.Context(), svcCtx) + resp, err := l.AddDictItem(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/deletedicthandler.go b/internal/handler/dictionary/deletedicthandler.go new file mode 100644 index 00000000..6425f68b --- /dev/null +++ b/internal/handler/dictionary/deletedicthandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CId + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewDeleteDictLogic(r.Context(), svcCtx) + resp, err := l.DeleteDict(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/deletedictitemhandler.go b/internal/handler/dictionary/deletedictitemhandler.go new file mode 100644 index 00000000..74574abc --- /dev/null +++ b/internal/handler/dictionary/deletedictitemhandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func DeleteDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CId + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewDeleteDictItemLogic(r.Context(), svcCtx) + resp, err := l.DeleteDictItem(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/editdicthandler.go b/internal/handler/dictionary/editdicthandler.go new file mode 100644 index 00000000..f707d1b2 --- /dev/null +++ b/internal/handler/dictionary/editdicthandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func EditDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DictEditReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewEditDictLogic(r.Context(), svcCtx) + resp, err := l.EditDict(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/editdictitemhandler.go b/internal/handler/dictionary/editdictitemhandler.go new file mode 100644 index 00000000..e2ba505a --- /dev/null +++ b/internal/handler/dictionary/editdictitemhandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func EditDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DictItemEditReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewEditDictItemLogic(r.Context(), svcCtx) + resp, err := l.EditDictItem(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/getdicthandler.go b/internal/handler/dictionary/getdicthandler.go new file mode 100644 index 00000000..26c6e18f --- /dev/null +++ b/internal/handler/dictionary/getdicthandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CId + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewGetDictLogic(r.Context(), svcCtx) + resp, err := l.GetDict(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/getdictitemhandler.go b/internal/handler/dictionary/getdictitemhandler.go new file mode 100644 index 00000000..2cbbce74 --- /dev/null +++ b/internal/handler/dictionary/getdictitemhandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func GetDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CId + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewGetDictItemLogic(r.Context(), svcCtx) + resp, err := l.GetDictItem(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/listdicthandler.go b/internal/handler/dictionary/listdicthandler.go new file mode 100644 index 00000000..31e73b67 --- /dev/null +++ b/internal/handler/dictionary/listdicthandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListDictHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DictReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewListDictLogic(r.Context(), svcCtx) + resp, err := l.ListDict(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/listdictitembycodehandler.go b/internal/handler/dictionary/listdictitembycodehandler.go new file mode 100644 index 00000000..7b219cb6 --- /dev/null +++ b/internal/handler/dictionary/listdictitembycodehandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListDictItemByCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DictCodeReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewListDictItemByCodeLogic(r.Context(), svcCtx) + resp, err := l.ListDictItemByCode(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/dictionary/listdictitemhandler.go b/internal/handler/dictionary/listdictitemhandler.go new file mode 100644 index 00000000..d4099112 --- /dev/null +++ b/internal/handler/dictionary/listdictitemhandler.go @@ -0,0 +1,24 @@ +package dictionary + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/dictionary" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ListDictItemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DictItemReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := dictionary.NewListDictItemLogic(r.Context(), svcCtx) + resp, err := l.ListDictItem(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/hpc/adaptersummaryhandler.go b/internal/handler/hpc/adaptersummaryhandler.go new file mode 100644 index 00000000..c78aa3ad --- /dev/null +++ b/internal/handler/hpc/adaptersummaryhandler.go @@ -0,0 +1,28 @@ +package hpc + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func AdapterSummaryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.HpcAdapterSummaryReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := hpc.NewAdapterSummaryLogic(r.Context(), svcCtx) + resp, err := l.AdapterSummary(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/hpc/commithpctaskhandler.go b/internal/handler/hpc/commithpctaskhandler.go new file mode 100644 index 00000000..ba7d6da8 --- /dev/null +++ b/internal/handler/hpc/commithpctaskhandler.go @@ -0,0 +1,24 @@ +package hpc + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func CommitHpcTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CommitHpcTaskReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := hpc.NewCommitHpcTaskLogic(r.Context(), svcCtx) + resp, err := l.CommitHpcTask(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/hpc/jobhandler.go b/internal/handler/hpc/jobhandler.go new file mode 100644 index 00000000..18c4185a --- /dev/null +++ b/internal/handler/hpc/jobhandler.go @@ -0,0 +1,28 @@ +package hpc + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func JobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.HpcJobReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := hpc.NewJobLogic(r.Context(), svcCtx) + resp, err := l.Job(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/hpc/overviewhandler.go b/internal/handler/hpc/overviewhandler.go new file mode 100644 index 00000000..3bab57d9 --- /dev/null +++ b/internal/handler/hpc/overviewhandler.go @@ -0,0 +1,28 @@ +package hpc + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func OverViewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.HpcOverViewReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := hpc.NewOverViewLogic(r.Context(), svcCtx) + resp, err := l.OverView(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/hpc/queueassetshandler.go b/internal/handler/hpc/queueassetshandler.go new file mode 100644 index 00000000..9a803a8e --- /dev/null +++ b/internal/handler/hpc/queueassetshandler.go @@ -0,0 +1,16 @@ +package hpc + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func QueueAssetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := hpc.NewQueueAssetsLogic(r.Context(), svcCtx) + resp, err := l.QueueAssets() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/hpc/resourcehandler.go b/internal/handler/hpc/resourcehandler.go new file mode 100644 index 00000000..754586f7 --- /dev/null +++ b/internal/handler/hpc/resourcehandler.go @@ -0,0 +1,28 @@ +package hpc + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ResourceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.HpcResourceReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := hpc.NewResourceLogic(r.Context(), svcCtx) + resp, err := l.Resource(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/inference/imageinferencehandler.go b/internal/handler/inference/imageinferencehandler.go new file mode 100644 index 00000000..aa50db42 --- /dev/null +++ b/internal/handler/inference/imageinferencehandler.go @@ -0,0 +1,24 @@ +package inference + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ImageInferenceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ImageInferenceReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := inference.NewImageInferenceLogic(r.Context(), svcCtx) + resp, err := l.ImageInfer(r, &req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/inference/inferencetaskdetailhandler.go b/internal/handler/inference/inferencetaskdetailhandler.go new file mode 100644 index 00000000..0575572b --- /dev/null +++ b/internal/handler/inference/inferencetaskdetailhandler.go @@ -0,0 +1,28 @@ +package inference + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func InferenceTaskDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.InferenceTaskDetailReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := inference.NewInferenceTaskDetailLogic(r.Context(), svcCtx) + resp, err := l.InferenceTaskDetail(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/inference/modelnamesbytypehandler.go b/internal/handler/inference/modelnamesbytypehandler.go new file mode 100644 index 00000000..022c9ce9 --- /dev/null +++ b/internal/handler/inference/modelnamesbytypehandler.go @@ -0,0 +1,25 @@ +package inference + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" +) + +func ModelNamesByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ModelNamesReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := inference.NewModelNamesByTypeLogic(r.Context(), svcCtx) + resp, err := l.ModelNamesByType(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/inference/modeltypeshandler.go b/internal/handler/inference/modeltypeshandler.go new file mode 100644 index 00000000..f42697a9 --- /dev/null +++ b/internal/handler/inference/modeltypeshandler.go @@ -0,0 +1,16 @@ +package inference + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ModelTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := inference.NewModelTypesLogic(r.Context(), svcCtx) + resp, err := l.ModelTypes() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/inference/texttotextinferencehandler.go b/internal/handler/inference/texttotextinferencehandler.go new file mode 100644 index 00000000..586f2876 --- /dev/null +++ b/internal/handler/inference/texttotextinferencehandler.go @@ -0,0 +1,25 @@ +package inference + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func TextToTextInferenceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.TextToTextInferenceReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := inference.NewTextToTextInferenceLogic(r.Context(), svcCtx) + resp, err := l.TextToTextInference(&req) + result.HttpResult(r, w, resp, err) + + } +} diff --git a/internal/handler/monitoring/adapterinfohandler.go b/internal/handler/monitoring/adapterinfohandler.go new file mode 100644 index 00000000..89661f62 --- /dev/null +++ b/internal/handler/monitoring/adapterinfohandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func AdapterInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdapterInfoReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewAdapterInfoLogic(r.Context(), svcCtx) + resp, err := l.AdapterInfo(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/monitoring/alertlisthandler.go b/internal/handler/monitoring/alertlisthandler.go new file mode 100644 index 00000000..571a6b3c --- /dev/null +++ b/internal/handler/monitoring/alertlisthandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func AlertListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AlertListReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewAlertListLogic(r.Context(), svcCtx) + resp, err := l.AlertList(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/monitoring/alertruleshandler.go b/internal/handler/monitoring/alertruleshandler.go new file mode 100644 index 00000000..aa2c9b07 --- /dev/null +++ b/internal/handler/monitoring/alertruleshandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func AlertRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AlertRulesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewAlertRulesLogic(r.Context(), svcCtx) + resp, err := l.AlertRules(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/monitoring/clustersloadhandler.go b/internal/handler/monitoring/clustersloadhandler.go new file mode 100644 index 00000000..b560cb98 --- /dev/null +++ b/internal/handler/monitoring/clustersloadhandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ClustersLoadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ClustersLoadReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewClustersLoadLogic(r.Context(), svcCtx) + resp, err := l.ClustersLoad(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/monitoring/createalertrulehandler.go b/internal/handler/monitoring/createalertrulehandler.go new file mode 100644 index 00000000..df1b0f03 --- /dev/null +++ b/internal/handler/monitoring/createalertrulehandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateAlertRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateAlertRuleReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewCreateAlertRuleLogic(r.Context(), svcCtx) + err := l.CreateAlertRule(&req) + result.HttpResult(r, w, nil, err) + } +} diff --git a/internal/handler/monitoring/deletealertrulehandler.go b/internal/handler/monitoring/deletealertrulehandler.go new file mode 100644 index 00000000..d3b50f14 --- /dev/null +++ b/internal/handler/monitoring/deletealertrulehandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteAlertRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteAlertRuleReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewDeleteAlertRuleLogic(r.Context(), svcCtx) + err := l.DeleteAlertRule(&req) + result.HttpResult(r, w, nil, err) + } +} diff --git a/internal/handler/monitoring/nodesloadtophandler.go b/internal/handler/monitoring/nodesloadtophandler.go new file mode 100644 index 00000000..da11e559 --- /dev/null +++ b/internal/handler/monitoring/nodesloadtophandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func NodesLoadTopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.NodesLoadTopReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewNodesLoadTopLogic(r.Context(), svcCtx) + resp, err := l.NodesLoadTop(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/monitoring/schedulesituationhandler.go b/internal/handler/monitoring/schedulesituationhandler.go new file mode 100644 index 00000000..452f1d01 --- /dev/null +++ b/internal/handler/monitoring/schedulesituationhandler.go @@ -0,0 +1,17 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func ScheduleSituationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := monitoring.NewScheduleSituationLogic(r.Context(), svcCtx) + resp, err := l.ScheduleSituation() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/monitoring/syncclusteralerthandler.go b/internal/handler/monitoring/syncclusteralerthandler.go new file mode 100644 index 00000000..a963a0dc --- /dev/null +++ b/internal/handler/monitoring/syncclusteralerthandler.go @@ -0,0 +1,28 @@ +package monitoring + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func SyncClusterAlertHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.SyncClusterAlertReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewSyncClusterAlertLogic(r.Context(), svcCtx) + err := l.SyncClusterAlert(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.Ok(w) + } + } +} diff --git a/internal/handler/monitoring/tasknumhandler.go b/internal/handler/monitoring/tasknumhandler.go new file mode 100644 index 00000000..384e494e --- /dev/null +++ b/internal/handler/monitoring/tasknumhandler.go @@ -0,0 +1,25 @@ +package monitoring + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/monitoring" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func TaskNumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.TaskNumReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := monitoring.NewTaskNumLogic(r.Context(), svcCtx) + resp, err := l.TaskNum(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/routes.go b/internal/handler/routes.go new file mode 100644 index 00000000..3693a59c --- /dev/null +++ b/internal/handler/routes.go @@ -0,0 +1,1306 @@ +// Code generated by goctl. DO NOT EDIT. +package handler + +import ( + "net/http" + + adapters "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/adapters" + ai "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/ai" + cloud "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/cloud" + core "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/core" + dictionary "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/dictionary" + hpc "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/hpc" + inference "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/inference" + monitoring "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/monitoring" + schedule "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/schedule" + storage "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/storage" + storelink "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/storelink" + vm "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + + "github.com/zeromicro/go-zero/rest" +) + +func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/core/participantList", + Handler: core.ParticipantListHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/core/scheduleTaskByYaml", + Handler: core.ScheduleTaskByYamlHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/core/commitTask", + Handler: core.CommitTaskHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/core/commitVmTask", + Handler: core.CommitVmTaskHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/core/deleteTask/:id", + Handler: core.DeleteTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/taskList", + Handler: core.TaskListHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/jobTotal", + Handler: core.JobTotalHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/listCenter", + Handler: core.ListCenterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/listCluster/:centerId", + Handler: core.ListClusterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getRegion", + Handler: core.GetRegionHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/listRegion", + Handler: core.ListRegionHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getComputingPower", + Handler: core.GetComputingPowerHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getGeneralInfo", + Handler: core.GetGeneralInfoHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getResourcePanelConfigHandler", + Handler: core.GetResourcePanelConfigHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/core/resourcePanelConfigHandler", + Handler: core.PutResourcePanelConfigHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getComputilityStatistics", + Handler: core.GetComputilityStatisticsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/assets", + Handler: core.NodeAssetsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/centerResources", + Handler: core.CenterResourcesHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/core/syncClusterLoad", + Handler: core.SyncClusterLoadHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/metrics", + Handler: core.MetricsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/pullTaskInfo", + Handler: core.PullTaskInfoHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/core/pushTaskInfo", + Handler: core.PushTaskInfoHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/core/pushResourceInfo", + Handler: core.PushResourceInfoHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/core/pushNotice", + Handler: core.PushNoticeHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/listNotice", + Handler: core.ListNoticeHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/task/list", + Handler: core.PageListTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/task/countTaskStatus", + Handler: core.CountTaskStatusHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/homeOverview", + Handler: core.HomeOverviewHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/task/details", + Handler: core.TaskDetailsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getPublicImage", + Handler: core.GetPublicImageHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getPublicFlavor", + Handler: core.GetPublicFlavorHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getPublicNetwork", + Handler: core.GetPublicNetworkHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getDomainResource", + Handler: core.GetDomainResourceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getScreenInfo", + Handler: core.GetScreenInfoHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getScreenChart", + Handler: core.GetScreenChartHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodPost, + Path: "/hpc/commitHpcTask", + Handler: hpc.CommitHpcTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/hpc/overview", + Handler: hpc.OverViewHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/hpc/adapterSummary", + Handler: hpc.AdapterSummaryHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/hpc/job", + Handler: hpc.JobHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/hpc/resource", + Handler: hpc.ResourceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/hpc/queueAssets", + 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), + }, + { + Method: http.MethodGet, + Path: "/cloud/controller/Metrics", + Handler: cloud.ControllerMetricsHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/cloud/registerCluster", + Handler: cloud.RegisterClusterHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/cloud/deleteCluster", + Handler: cloud.DeleteClusterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/clusterList", + Handler: cloud.GetClusterListHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/cloud/task/create", + Handler: cloud.CommitGeneralTaskHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/cloud/pod/logs", + Handler: cloud.PodLogsHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/ai/getCenterOverview", + Handler: ai.GetCenterOverviewHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getCenterQueueing", + Handler: ai.GetCenterQueueingHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getCenterList", + Handler: ai.GetCenterListHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getCenterTaskList", + Handler: ai.GetCenterTaskListHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/listDataSet/:projectId", + Handler: ai.ListDataSetHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/createDataSet/:projectId", + Handler: ai.CreateDataSetHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/ai/deleteDataSet/:projectId/:datasetId", + Handler: ai.DeleteDataSetHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/CreateTask/:projectId/:datasetId", + Handler: ai.CreateTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/ListImport/:projectId/:datasetId", + Handler: ai.ListImportHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/GetListTrainingJobs/:projectId", + Handler: ai.GetListTrainingJobsHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/ai/DeleteTrainingJob/:projectId/:trainingJobId", + Handler: ai.DeleteTrainingJobHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/CreateAlgorithm/:projectId", + Handler: ai.CreateAlgorithmHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/ListAlgorithms/:projectId", + Handler: ai.ListAlgorithmsHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/ai/DeleteAlgorithm/:projectId/:algorithmId", + Handler: ai.DeleteAlgorithmHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/CreateTrainingJob/:projectId", + Handler: ai.CreateTrainingJobHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/ShowAlgorithmByUuid/:projectId/:algorithmId", + Handler: ai.ShowAlgorithmByUuidHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/CreateExportTask/:projectId/:datasetId", + Handler: ai.CreateExportTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/GetExportTasksOfDataset/:projectId/:datasetId", + Handler: ai.GetExportTasksOfDatasetHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/GetExportTaskStatusOfDataset/:projectId/:resourceId/:taskId", + Handler: ai.GetExportTaskStatusOfDatasetHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/CreateProcessorTask", + Handler: ai.CreateProcessorTaskHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/CreateService/:projectId", + Handler: ai.CreateServiceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/ListServices/:projectId", + Handler: ai.ListServicesHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/ShowService/:projectId/:serviceId", + Handler: ai.ShowServiceHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/ai/DeleteService/:projectId/:serviceId", + Handler: ai.DeleteServiceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/ListClusters", + Handler: ai.ListClustersHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/listNotebook", + Handler: ai.ListNotebookHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/createNotebook", + Handler: ai.CreateNotebookHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/startNotebook", + Handler: ai.StartNotebookHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/stopNotebook", + Handler: ai.StopNotebookHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getNotebookStorage", + Handler: ai.GetNotebookStorageHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/mountNotebookStorage", + Handler: ai.MountNotebookStorageHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/ai/getVisualizationJob", + Handler: ai.GetVisualizationJobHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/CreateVisualizationJob", + Handler: ai.CreateVisualizationJobHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/ai/chat", + Handler: ai.ProxyApiHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/storage/screenStorage", + Handler: storage.ScreenStorageHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/storage/dailyPowerScreen", + Handler: storage.DailyPowerScreenHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/storage/perCenterComputerPowers", + Handler: storage.PerCenterComputerPowersHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + 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/getNetworkNum", + Handler: vm.GetNetworkNumHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/getImageNum", + Handler: vm.GetImageNumHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/getOpenstackOverview", + Handler: vm.GetOpenstackOverviewHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listServer", + Handler: vm.ListServerHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listServersDetailed", + Handler: vm.ListServersDetailedHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteServer", + Handler: vm.DeleteServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createServer", + Handler: vm.CreateServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createMulServer", + Handler: vm.CreateMulServerHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/getServersDetailedById", + Handler: vm.GetServersDetailedByIdHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateServer", + Handler: vm.UpdateServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/startServer", + Handler: vm.StartServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/stopServer", + Handler: vm.StopServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/rebootServer", + Handler: vm.RebootServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/pauseServer", + Handler: vm.PauseServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/unpauseServer", + Handler: vm.UnpauseServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/resizeServer", + Handler: vm.ResizeServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/migrateServer", + Handler: vm.MigrateServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/shelveServer", + Handler: vm.ShelveServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/changeAdministrativePassword", + Handler: vm.ChangeAdministrativePasswordHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/rescueServer", + Handler: vm.RescueServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/unRescueServer", + Handler: vm.UnRescueHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/suspendServer", + Handler: vm.SuspendServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/addSecurityGroupToServer", + Handler: vm.AddSecurityGroupToServerHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/removeSecurityGroup", + Handler: vm.RemoveSecurityGroupHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createFlavor", + Handler: vm.CreateFlavorHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/deleteFlavor", + Handler: vm.DeleteFlavorHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listImages", + Handler: vm.ListImagesHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteImage", + Handler: vm.DeleteImageHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createImage", + Handler: vm.CreateImageHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/uploadImage", + Handler: vm.UploadImageHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listNetworks", + Handler: vm.ListNetworksHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteNetwork", + Handler: vm.DeleteNetworkHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createNetwork", + Handler: vm.CreateNetworkHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createSubnet", + Handler: vm.CreateSubnetHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showNetworkDetails", + Handler: vm.ShowNetworkDetailsHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateNetwork", + Handler: vm.UpdateNetworkHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/bulkCreateNetworks", + Handler: vm.BulkCreateNetworksHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listSubnets", + Handler: vm.ListSubnetsHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteSubnet", + Handler: vm.DeleteSubnetHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateSubnet", + Handler: vm.UpdateSubnetHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listNetworkSegmentRanges", + Handler: vm.ListNetworkSegmentRangesRangeHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createNetworkSegmentRange", + Handler: vm.CreateNetworkSegmentRangeHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteNetworkSegmentRanges", + Handler: vm.DeleteNetworkSegmentRangesHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateNetworkSegmentRanges", + Handler: vm.UpdateNetworkSegmentRangesHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showNetworkSegmentRangeDetails", + Handler: vm.ShowNetworkSegmentRangeDetailsHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createPort", + Handler: vm.CreatePortHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listPortsReq", + Handler: vm.ListPortsHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deletePort", + Handler: vm.DeletePortHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updatePort", + Handler: vm.UpdatePortHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showPortDetails", + Handler: vm.ShowPortDetailsHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createRouter", + Handler: vm.CreateRouterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listRouters", + Handler: vm.ListRoutersHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteRouter", + Handler: vm.DeleteRouterHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateRouter", + Handler: vm.UpdateRouterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showRouterDetails", + Handler: vm.ShowRouterDetailsHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createFloatingIP", + Handler: vm.CreateFloatingIPHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listFloatingIPs", + Handler: vm.ListFloatingIPsHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteFloatingIP", + Handler: vm.DeleteFloatingIPHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateFloatingIP", + Handler: vm.UpdateFloatingIPHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showFloatingIPDetails", + Handler: vm.ShowFloatingIPDetailsHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createFirewallGroup", + Handler: vm.CreateFirewallGroupHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listFirewallGroups", + Handler: vm.ListFirewallGroupsHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteFirewallGroup", + Handler: vm.DeleteFirewallGroupHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateFirewallGroup", + Handler: vm.UpdateFirewallGroupHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showFirewallGroupDetails", + Handler: vm.ShowFirewallGroupDetailsHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createFirewallPolicy", + Handler: vm.CreateFirewallPolicyHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listFirewallPolicies", + Handler: vm.ListFirewallPoliciesHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteFirewallPolicy", + Handler: vm.DeleteFirewallPolicyHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showFirewallRuleDetails", + Handler: vm.ShowFirewallRuleDetailsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showFirewallPolicyDetails", + Handler: vm.ShowFirewallPolicyDetailsHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createFirewallRule", + Handler: vm.CreateFirewallRuleHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listFirewallRules", + Handler: vm.ListFirewallRulesHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteFirewallRule", + Handler: vm.DeleteFirewallRuleHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createSecurityGroup", + Handler: vm.CreateSecurityGroupHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listSecurityGroups", + Handler: vm.ListSecurityGroupsHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteSecurityGroup", + Handler: vm.DeleteSecurityGroupHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateSecurityGroup", + Handler: vm.UpdateSecurityGroupHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showSecurityGroup", + Handler: vm.ShowSecurityGroupHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createSecurityGroupRule", + Handler: vm.CreateSecurityGroupRuleHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listSecurityGroupRules", + Handler: vm.ListSecurityGroupRulesHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteSecurityGroupRule", + Handler: vm.DeleteSecurityGroupRuleHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showSecurityGroupRule", + Handler: vm.ShowSecurityGroupRuleHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listVolumesDetail", + Handler: vm.ListVolumesDetailHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteVolume", + Handler: vm.DeleteVolumeHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createVolume", + Handler: vm.CreateVolumeHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listFlavorsDetail", + Handler: vm.ListFlavorsDetailHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listVolumeTypes", + Handler: vm.ListVolumeTypesHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/vm/updateVolume", + Handler: vm.UpdateVolumeHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createVolumeTypes", + Handler: vm.CreateVolumeTypesHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteVolumeType", + Handler: vm.DeleteVolumeTypeHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listVolumes", + Handler: vm.ListVolumesHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/getVolumeDetailedById", + Handler: vm.GetVolumeDetailedByIdHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/listNodes", + Handler: vm.ListNodesHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/vm/createNode", + Handler: vm.CreateNodeHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/vm/deleteNode", + Handler: vm.DeleteNodeHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/vm/showNodeDetails", + Handler: vm.ShowNodeDetailsHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodPost, + Path: "/storelink/uploadImage", + Handler: storelink.UploadLinkImageHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/storelink/getImageList", + Handler: storelink.GetLinkImageListHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/storelink/deleteImage", + Handler: storelink.DeleteLinkImageHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/storelink/submitTask", + Handler: storelink.SubmitLinkTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/storelink/getTask", + Handler: storelink.GetLinkTaskHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/storelink/deleteTask", + Handler: storelink.DeleteLinkTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/storelink/getParticipants", + Handler: storelink.GetParticipantsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/storelink/getResourceSpecs", + Handler: storelink.GetAISpecsHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/adapter/list", + Handler: adapters.AdaptersListHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/adapter/create", + Handler: adapters.CreateAdapterHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/adapter/update", + Handler: adapters.UpdateAdapterHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/adapter/delete", + Handler: adapters.DeleteAdapterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/adapter/get", + Handler: adapters.GetAdapterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/adapter/cluster/list", + Handler: adapters.ClusterListHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/adapter/cluster/create", + Handler: adapters.CreateClusterHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/adapter/cluster/update", + Handler: adapters.UpdateClusterHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/adapter/cluster/delete", + Handler: adapters.DeleteClusterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/adapter/cluster/get", + Handler: adapters.GetClusterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/adapter/relation", + Handler: adapters.GetAdapterRelationHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/adapter/clusterSum", + Handler: adapters.GetClusterSumHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/schedule/ai/getResourceTypes", + Handler: schedule.ScheduleGetAiResourceTypesHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/ai/getTaskTypes", + Handler: schedule.ScheduleGetAiTaskTypesHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/ai/getDatasets/:adapterId", + Handler: schedule.ScheduleGetDatasetsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/ai/getStrategies", + Handler: schedule.ScheduleGetStrategyHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/ai/getAlgorithms/:adapterId/:resourceType/:taskType/:dataset", + Handler: schedule.ScheduleGetAlgorithmsHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/ai/getJobLog/:adapterId/:clusterId/:taskId/:instanceNum", + Handler: schedule.ScheduleGetAiJobLogLogHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/schedule/submit", + Handler: schedule.ScheduleSubmitHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/schedule/getOverview", + Handler: schedule.ScheduleGetOverviewHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/downloadAlgorithmCode", + Handler: schedule.DownloadAlgothmCodeHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/schedule/uploadAlgorithmCode", + Handler: schedule.UploadAlgothmCodeHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/getComputeCardsByCluster/:adapterId/:clusterId", + Handler: schedule.GetComputeCardsByClusterHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/schedule/getClusterBalanceById/:adapterId/:clusterId", + Handler: schedule.GetClusterBalanceByIdHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodPost, + Path: "/inference/text", + Handler: inference.TextToTextInferenceHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/inference/images", + Handler: inference.ImageInferenceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/inference/modelTypes", + Handler: inference.ModelTypesHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/inference/modelNames", + Handler: inference.ModelNamesByTypeHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/inference/taskDetail", + Handler: inference.InferenceTaskDetailHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/dict/:id", + Handler: dictionary.GetDictHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/dicts", + Handler: dictionary.ListDictHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/dict", + Handler: dictionary.AddDictHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/dict", + Handler: dictionary.EditDictHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/dict/:id", + Handler: dictionary.DeleteDictHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/dictItem/:id", + Handler: dictionary.GetDictItemHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/dictItems", + Handler: dictionary.ListDictItemHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/dictItem", + Handler: dictionary.AddDictItemHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/dictItem", + Handler: dictionary.EditDictItemHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/dictItem/:id", + Handler: dictionary.DeleteDictItemHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/dictItem/code/:dictCode", + Handler: dictionary.ListDictItemByCodeHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) + + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodPost, + Path: "/monitoring/alert/rule", + Handler: monitoring.CreateAlertRuleHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/monitoring/alert/rule", + Handler: monitoring.AlertRulesHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/monitoring/alert/rule", + Handler: monitoring.DeleteAlertRuleHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/monitoring/cluster/load", + Handler: monitoring.ClustersLoadHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/monitoring/node/top", + Handler: monitoring.NodesLoadTopHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/monitoring/alert/list", + Handler: monitoring.AlertListHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/monitoring/syncClusterAlert", + Handler: monitoring.SyncClusterAlertHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/monitoring/task/num", + Handler: monitoring.TaskNumHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/monitoring/adapter/info", + Handler: monitoring.AdapterInfoHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/monitoring/schedule/situation", + Handler: monitoring.ScheduleSituationHandler(serverCtx), + }, + }, + rest.WithPrefix("/pcm/v1"), + ) +} diff --git a/internal/handler/schedule/downloadalgothmcodehandler.go b/internal/handler/schedule/downloadalgothmcodehandler.go new file mode 100644 index 00000000..a7843511 --- /dev/null +++ b/internal/handler/schedule/downloadalgothmcodehandler.go @@ -0,0 +1,25 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" +) + +func DownloadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DownloadAlgorithmCodeReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := schedule.NewDownloadAlgothmCodeLogic(r.Context(), svcCtx) + resp, err := l.DownloadAlgorithmCode(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/schedule/getclusterbalancebyidhandler.go b/internal/handler/schedule/getclusterbalancebyidhandler.go new file mode 100644 index 00000000..35daeb17 --- /dev/null +++ b/internal/handler/schedule/getclusterbalancebyidhandler.go @@ -0,0 +1,26 @@ +package schedule + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetClusterBalanceByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetClusterBalanceByIdReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := schedule.NewGetClusterBalanceByIdLogic(r.Context(), svcCtx) + resp, err := l.GetClusterBalanceById(&req) + result.HttpResult(r, w, resp, err) + + } +} diff --git a/internal/handler/schedule/getcomputecardsbyclusterhandler.go b/internal/handler/schedule/getcomputecardsbyclusterhandler.go new file mode 100644 index 00000000..ca42e4f2 --- /dev/null +++ b/internal/handler/schedule/getcomputecardsbyclusterhandler.go @@ -0,0 +1,28 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetComputeCardsByClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetComputeCardsByClusterReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := schedule.NewGetComputeCardsByClusterLogic(r.Context(), svcCtx) + resp, err := l.GetComputeCardsByCluster(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/schedule/schedulegetaijoblogloghandler.go b/internal/handler/schedule/schedulegetaijoblogloghandler.go new file mode 100644 index 00000000..e9eb0099 --- /dev/null +++ b/internal/handler/schedule/schedulegetaijoblogloghandler.go @@ -0,0 +1,28 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ScheduleGetAiJobLogLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AiJobLogReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := schedule.NewScheduleGetAiJobLogLogLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetAiJobLogLog(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/schedule/schedulegetairesourcetypeshandler.go b/internal/handler/schedule/schedulegetairesourcetypeshandler.go new file mode 100644 index 00000000..751d7c96 --- /dev/null +++ b/internal/handler/schedule/schedulegetairesourcetypeshandler.go @@ -0,0 +1,16 @@ +package schedule + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScheduleGetAiResourceTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := schedule.NewScheduleGetAiResourceTypesLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetAiResourceTypes() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/schedule/schedulegetaitasktypeshandler.go b/internal/handler/schedule/schedulegetaitasktypeshandler.go new file mode 100644 index 00000000..9ed751be --- /dev/null +++ b/internal/handler/schedule/schedulegetaitasktypeshandler.go @@ -0,0 +1,16 @@ +package schedule + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScheduleGetAiTaskTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := schedule.NewScheduleGetAiTaskTypesLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetAiTaskTypes() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/schedule/schedulegetalgorithmshandler.go b/internal/handler/schedule/schedulegetalgorithmshandler.go new file mode 100644 index 00000000..02b6e0ec --- /dev/null +++ b/internal/handler/schedule/schedulegetalgorithmshandler.go @@ -0,0 +1,24 @@ +package schedule + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScheduleGetAlgorithmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AiAlgorithmsReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := schedule.NewScheduleGetAlgorithmsLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetAlgorithms(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/schedule/schedulegetdatasetshandler.go b/internal/handler/schedule/schedulegetdatasetshandler.go new file mode 100644 index 00000000..2bfdc710 --- /dev/null +++ b/internal/handler/schedule/schedulegetdatasetshandler.go @@ -0,0 +1,24 @@ +package schedule + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScheduleGetDatasetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AiDatasetsReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := schedule.NewScheduleGetDatasetsLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetDatasets(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/schedule/schedulegetoverviewhandler.go b/internal/handler/schedule/schedulegetoverviewhandler.go new file mode 100644 index 00000000..8d6a4878 --- /dev/null +++ b/internal/handler/schedule/schedulegetoverviewhandler.go @@ -0,0 +1,21 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func ScheduleGetOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := schedule.NewScheduleGetOverviewLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetOverview() + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/schedule/schedulegetstrategyhandler.go b/internal/handler/schedule/schedulegetstrategyhandler.go new file mode 100644 index 00000000..31422f56 --- /dev/null +++ b/internal/handler/schedule/schedulegetstrategyhandler.go @@ -0,0 +1,16 @@ +package schedule + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScheduleGetStrategyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := schedule.NewScheduleGetStrategyLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetStrategy() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/schedule/schedulesubmithandler.go b/internal/handler/schedule/schedulesubmithandler.go new file mode 100644 index 00000000..81e3acff --- /dev/null +++ b/internal/handler/schedule/schedulesubmithandler.go @@ -0,0 +1,24 @@ +package schedule + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScheduleSubmitHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ScheduleReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := schedule.NewScheduleSubmitLogic(r.Context(), svcCtx) + resp, err := l.ScheduleSubmit(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/schedule/uploadalgothmcodehandler.go b/internal/handler/schedule/uploadalgothmcodehandler.go new file mode 100644 index 00000000..af13a9c4 --- /dev/null +++ b/internal/handler/schedule/uploadalgothmcodehandler.go @@ -0,0 +1,25 @@ +package schedule + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" +) + +func UploadAlgothmCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UploadAlgorithmCodeReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := schedule.NewUploadAlgothmCodeLogic(r.Context(), svcCtx) + resp, err := l.UploadAlgorithmCode(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/storage/dailypowerscreenhandler.go b/internal/handler/storage/dailypowerscreenhandler.go new file mode 100644 index 00000000..9c28d735 --- /dev/null +++ b/internal/handler/storage/dailypowerscreenhandler.go @@ -0,0 +1,17 @@ +package storage + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storage" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func DailyPowerScreenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := storage.NewDailyPowerScreenLogic(r.Context(), svcCtx) + resp, err := l.DailyPowerScreen() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/storage/percentercomputerpowershandler.go b/internal/handler/storage/percentercomputerpowershandler.go new file mode 100644 index 00000000..f81dc9f8 --- /dev/null +++ b/internal/handler/storage/percentercomputerpowershandler.go @@ -0,0 +1,17 @@ +package storage + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storage" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +func PerCenterComputerPowersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := storage.NewPerCenterComputerPowersLogic(r.Context(), svcCtx) + resp, err := l.PerCenterComputerPowers() + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/storage/screenstoragehandler.go b/internal/handler/storage/screenstoragehandler.go new file mode 100644 index 00000000..cebffc15 --- /dev/null +++ b/internal/handler/storage/screenstoragehandler.go @@ -0,0 +1,24 @@ +package storage + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storage" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScreenStorageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StorageScreenReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := storage.NewScreenStorageLogic(r.Context(), svcCtx) + resp, err := l.ScreenStorage(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/internal/handler/storelink/deletelinkimagehandler.go b/internal/handler/storelink/deletelinkimagehandler.go new file mode 100644 index 00000000..90a1a197 --- /dev/null +++ b/internal/handler/storelink/deletelinkimagehandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteLinkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteLinkImageReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewDeleteLinkImageLogic(r.Context(), svcCtx) + resp, err := l.DeleteLinkImage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/storelink/deletelinktaskhandler.go b/internal/handler/storelink/deletelinktaskhandler.go new file mode 100644 index 00000000..060fa979 --- /dev/null +++ b/internal/handler/storelink/deletelinktaskhandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteLinkTaskReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewDeleteLinkTaskLogic(r.Context(), svcCtx) + resp, err := l.DeleteLinkTask(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/storelink/getaispecshandler.go b/internal/handler/storelink/getaispecshandler.go new file mode 100644 index 00000000..d0a1d148 --- /dev/null +++ b/internal/handler/storelink/getaispecshandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetAISpecsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetResourceSpecsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewGetAISpecsLogic(r.Context(), svcCtx) + resp, err := l.GetAISpecs(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/storelink/getlinkimagelisthandler.go b/internal/handler/storelink/getlinkimagelisthandler.go new file mode 100644 index 00000000..a2b922eb --- /dev/null +++ b/internal/handler/storelink/getlinkimagelisthandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetLinkImageListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetLinkImageListReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewGetLinkImageListLogic(r.Context(), svcCtx) + resp, err := l.GetLinkImageList(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/storelink/getlinktaskhandler.go b/internal/handler/storelink/getlinktaskhandler.go new file mode 100644 index 00000000..f6c915fe --- /dev/null +++ b/internal/handler/storelink/getlinktaskhandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetLinkTaskReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewGetLinkTaskLogic(r.Context(), svcCtx) + resp, err := l.GetLinkTask(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/storelink/getparticipantshandler.go b/internal/handler/storelink/getparticipantshandler.go new file mode 100644 index 00000000..2ecb8dda --- /dev/null +++ b/internal/handler/storelink/getparticipantshandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetParticipantsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetParticipantsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewGetParticipantsLogic(r.Context(), svcCtx) + resp, err := l.GetParticipants(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/storelink/submitlinktaskhandler.go b/internal/handler/storelink/submitlinktaskhandler.go new file mode 100644 index 00000000..767fba4a --- /dev/null +++ b/internal/handler/storelink/submitlinktaskhandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func SubmitLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.SubmitLinkTaskReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewSubmitLinkTaskLogic(r.Context(), svcCtx) + resp, err := l.SubmitLinkTask(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/storelink/uploadlinkimagehandler.go b/internal/handler/storelink/uploadlinkimagehandler.go new file mode 100644 index 00000000..9a456480 --- /dev/null +++ b/internal/handler/storelink/uploadlinkimagehandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/storelink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UploadLinkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UploadLinkImageReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewUploadLinkImageLogic(r.Context(), svcCtx) + resp, err := l.UploadLinkImage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/addsecuritygrouptoserverhandler.go b/internal/handler/vm/addsecuritygrouptoserverhandler.go new file mode 100644 index 00000000..d6256a60 --- /dev/null +++ b/internal/handler/vm/addsecuritygrouptoserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func AddSecurityGroupToServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AddSecurityGroupToServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewAddSecurityGroupToServerLogic(r.Context(), svcCtx) + resp, err := l.AddSecurityGroupToServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/bulkcreatenetworkshandler.go b/internal/handler/vm/bulkcreatenetworkshandler.go new file mode 100644 index 00000000..61fb4cb1 --- /dev/null +++ b/internal/handler/vm/bulkcreatenetworkshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func BulkCreateNetworksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.BulkCreateNetworksReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewBulkCreateNetworksLogic(r.Context(), svcCtx) + resp, err := l.BulkCreateNetworks(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/changeadministrativepasswordhandler.go b/internal/handler/vm/changeadministrativepasswordhandler.go new file mode 100644 index 00000000..99cdf65f --- /dev/null +++ b/internal/handler/vm/changeadministrativepasswordhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ChangeAdministrativePasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ChangeAdministrativePasswordReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewChangeAdministrativePasswordLogic(r.Context(), svcCtx) + resp, err := l.ChangeAdministrativePassword(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createfirewallgrouphandler.go b/internal/handler/vm/createfirewallgrouphandler.go new file mode 100644 index 00000000..9d04bd54 --- /dev/null +++ b/internal/handler/vm/createfirewallgrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateFirewallGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateFirewallGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateFirewallGroupLogic(r.Context(), svcCtx) + resp, err := l.CreateFirewallGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createfirewallpolicyhandler.go b/internal/handler/vm/createfirewallpolicyhandler.go new file mode 100644 index 00000000..132d8cc6 --- /dev/null +++ b/internal/handler/vm/createfirewallpolicyhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateFirewallPolicyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateFirewallPolicyReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateFirewallPolicyLogic(r.Context(), svcCtx) + resp, err := l.CreateFirewallPolicy(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createfirewallrulehandler.go b/internal/handler/vm/createfirewallrulehandler.go new file mode 100644 index 00000000..be2e0d1e --- /dev/null +++ b/internal/handler/vm/createfirewallrulehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateFirewallRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateFirewallRuleReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateFirewallRuleLogic(r.Context(), svcCtx) + resp, err := l.CreateFirewallRule(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createflavorhandler.go b/internal/handler/vm/createflavorhandler.go new file mode 100644 index 00000000..14805f12 --- /dev/null +++ b/internal/handler/vm/createflavorhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateFlavorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateFlavorReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateFlavorLogic(r.Context(), svcCtx) + resp, err := l.CreateFlavor(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createfloatingiphandler.go b/internal/handler/vm/createfloatingiphandler.go new file mode 100644 index 00000000..3cb67323 --- /dev/null +++ b/internal/handler/vm/createfloatingiphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateFloatingIPHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateFloatingIPReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateFloatingIPLogic(r.Context(), svcCtx) + resp, err := l.CreateFloatingIP(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createimagehandler.go b/internal/handler/vm/createimagehandler.go new file mode 100644 index 00000000..8c1ac5e1 --- /dev/null +++ b/internal/handler/vm/createimagehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/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/internal/handler/vm/createmulserverhandler.go b/internal/handler/vm/createmulserverhandler.go new file mode 100644 index 00000000..298ad39a --- /dev/null +++ b/internal/handler/vm/createmulserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateMulServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateMulServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateMulServerLogic(r.Context(), svcCtx) + resp, err := l.CreateMulServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createnetworkhandler.go b/internal/handler/vm/createnetworkhandler.go new file mode 100644 index 00000000..2932283b --- /dev/null +++ b/internal/handler/vm/createnetworkhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateNetworkReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateNetworkLogic(r.Context(), svcCtx) + resp, err := l.CreateNetwork(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createnetworksegmentrangehandler.go b/internal/handler/vm/createnetworksegmentrangehandler.go new file mode 100644 index 00000000..aa76647b --- /dev/null +++ b/internal/handler/vm/createnetworksegmentrangehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateNetworkSegmentRangeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateNetworkSegmentRangeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateNetworkSegmentRangeLogic(r.Context(), svcCtx) + resp, err := l.CreateNetworkSegmentRange(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createnodehandler.go b/internal/handler/vm/createnodehandler.go new file mode 100644 index 00000000..bd2c6bab --- /dev/null +++ b/internal/handler/vm/createnodehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateNodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateNodeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateNodeLogic(r.Context(), svcCtx) + resp, err := l.CreateNode(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createporthandler.go b/internal/handler/vm/createporthandler.go new file mode 100644 index 00000000..9c7f4c5c --- /dev/null +++ b/internal/handler/vm/createporthandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreatePortHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreatePortReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreatePortLogic(r.Context(), svcCtx) + resp, err := l.CreatePort(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createrouterhandler.go b/internal/handler/vm/createrouterhandler.go new file mode 100644 index 00000000..fdff9fa1 --- /dev/null +++ b/internal/handler/vm/createrouterhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateRouterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateRouterReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateRouterLogic(r.Context(), svcCtx) + resp, err := l.CreateRouter(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createsecuritygrouphandler.go b/internal/handler/vm/createsecuritygrouphandler.go new file mode 100644 index 00000000..d2c793ee --- /dev/null +++ b/internal/handler/vm/createsecuritygrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateSecurityGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateSecurityGroupLogic(r.Context(), svcCtx) + resp, err := l.CreateSecurityGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createsecuritygrouprulehandler.go b/internal/handler/vm/createsecuritygrouprulehandler.go new file mode 100644 index 00000000..0a0216b0 --- /dev/null +++ b/internal/handler/vm/createsecuritygrouprulehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateSecurityGroupRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateSecurityGroupRuleReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateSecurityGroupRuleLogic(r.Context(), svcCtx) + resp, err := l.CreateSecurityGroupRule(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createserverhandler.go b/internal/handler/vm/createserverhandler.go new file mode 100644 index 00000000..7211704e --- /dev/null +++ b/internal/handler/vm/createserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateServerLogic(r.Context(), svcCtx) + resp, err := l.CreateServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createsubnethandler.go b/internal/handler/vm/createsubnethandler.go new file mode 100644 index 00000000..209a3324 --- /dev/null +++ b/internal/handler/vm/createsubnethandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateSubnetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateSubnetReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateSubnetLogic(r.Context(), svcCtx) + resp, err := l.CreateSubnet(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createvolumehandler.go b/internal/handler/vm/createvolumehandler.go new file mode 100644 index 00000000..ddf4f0bc --- /dev/null +++ b/internal/handler/vm/createvolumehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateVolumeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateVolumeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateVolumeLogic(r.Context(), svcCtx) + resp, err := l.CreateVolume(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/createvolumetypeshandler.go b/internal/handler/vm/createvolumetypeshandler.go new file mode 100644 index 00000000..8dae8198 --- /dev/null +++ b/internal/handler/vm/createvolumetypeshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func CreateVolumeTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateVolumeTypeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewCreateVolumeTypesLogic(r.Context(), svcCtx) + resp, err := l.CreateVolumeTypes(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletefirewallgrouphandler.go b/internal/handler/vm/deletefirewallgrouphandler.go new file mode 100644 index 00000000..87c27eca --- /dev/null +++ b/internal/handler/vm/deletefirewallgrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteFirewallGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteFirewallGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteFirewallGroupLogic(r.Context(), svcCtx) + resp, err := l.DeleteFirewallGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletefirewallpolicyhandler.go b/internal/handler/vm/deletefirewallpolicyhandler.go new file mode 100644 index 00000000..949a0eb3 --- /dev/null +++ b/internal/handler/vm/deletefirewallpolicyhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteFirewallPolicyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteFirewallPolicyReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteFirewallPolicyLogic(r.Context(), svcCtx) + resp, err := l.DeleteFirewallPolicy(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletefirewallrulehandler.go b/internal/handler/vm/deletefirewallrulehandler.go new file mode 100644 index 00000000..edfd472a --- /dev/null +++ b/internal/handler/vm/deletefirewallrulehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteFirewallRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteFirewallRuleReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteFirewallRuleLogic(r.Context(), svcCtx) + resp, err := l.DeleteFirewallRule(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deleteflavorhandler.go b/internal/handler/vm/deleteflavorhandler.go new file mode 100644 index 00000000..2bd72db2 --- /dev/null +++ b/internal/handler/vm/deleteflavorhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteFlavorHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteFlavorReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteFlavorLogic(r.Context(), svcCtx) + resp, err := l.DeleteFlavor(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletefloatingiphandler.go b/internal/handler/vm/deletefloatingiphandler.go new file mode 100644 index 00000000..06aca718 --- /dev/null +++ b/internal/handler/vm/deletefloatingiphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteFloatingIPHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteFloatingIPReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteFloatingIPLogic(r.Context(), svcCtx) + resp, err := l.DeleteFloatingIP(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deleteimagehandler.go b/internal/handler/vm/deleteimagehandler.go new file mode 100644 index 00000000..40a517e1 --- /dev/null +++ b/internal/handler/vm/deleteimagehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteImageReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteImageLogic(r.Context(), svcCtx) + resp, err := l.DeleteImage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletenetworkhandler.go b/internal/handler/vm/deletenetworkhandler.go new file mode 100644 index 00000000..efc4f2ef --- /dev/null +++ b/internal/handler/vm/deletenetworkhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteNetworkReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteNetworkLogic(r.Context(), svcCtx) + resp, err := l.DeleteNetwork(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletenetworksegmentrangeshandler.go b/internal/handler/vm/deletenetworksegmentrangeshandler.go new file mode 100644 index 00000000..7e94a0ef --- /dev/null +++ b/internal/handler/vm/deletenetworksegmentrangeshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteNetworkSegmentRangesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteNetworkSegmentRangesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteNetworkSegmentRangesLogic(r.Context(), svcCtx) + resp, err := l.DeleteNetworkSegmentRanges(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletenodehandler.go b/internal/handler/vm/deletenodehandler.go new file mode 100644 index 00000000..645aa6da --- /dev/null +++ b/internal/handler/vm/deletenodehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteNodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteNodeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteNodeLogic(r.Context(), svcCtx) + resp, err := l.DeleteNode(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deleteporthandler.go b/internal/handler/vm/deleteporthandler.go new file mode 100644 index 00000000..2f113025 --- /dev/null +++ b/internal/handler/vm/deleteporthandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeletePortHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeletePortReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeletePortLogic(r.Context(), svcCtx) + resp, err := l.DeletePort(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deleterouterhandler.go b/internal/handler/vm/deleterouterhandler.go new file mode 100644 index 00000000..e85b3b3e --- /dev/null +++ b/internal/handler/vm/deleterouterhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteRouterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteRouterReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteRouterLogic(r.Context(), svcCtx) + resp, err := l.DeleteRouter(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletesecuritygrouphandler.go b/internal/handler/vm/deletesecuritygrouphandler.go new file mode 100644 index 00000000..2a21c181 --- /dev/null +++ b/internal/handler/vm/deletesecuritygrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteSecurityGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteSecurityGroupLogic(r.Context(), svcCtx) + resp, err := l.DeleteSecurityGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletesecuritygrouprulehandler.go b/internal/handler/vm/deletesecuritygrouprulehandler.go new file mode 100644 index 00000000..f22e8db7 --- /dev/null +++ b/internal/handler/vm/deletesecuritygrouprulehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteSecurityGroupRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteSecurityGroupRuleReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteSecurityGroupRuleLogic(r.Context(), svcCtx) + resp, err := l.DeleteSecurityGroupRule(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deleteserverhandler.go b/internal/handler/vm/deleteserverhandler.go new file mode 100644 index 00000000..e83a934d --- /dev/null +++ b/internal/handler/vm/deleteserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteServerLogic(r.Context(), svcCtx) + resp, err := l.DeleteServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletesubnethandler.go b/internal/handler/vm/deletesubnethandler.go new file mode 100644 index 00000000..2fe8d99d --- /dev/null +++ b/internal/handler/vm/deletesubnethandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteSubnetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteSubnetReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteSubnetLogic(r.Context(), svcCtx) + resp, err := l.DeleteSubnet(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletevolumehandler.go b/internal/handler/vm/deletevolumehandler.go new file mode 100644 index 00000000..96ac3531 --- /dev/null +++ b/internal/handler/vm/deletevolumehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteVolumeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteVolumeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteVolumeLogic(r.Context(), svcCtx) + resp, err := l.DeleteVolume(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/deletevolumetypehandler.go b/internal/handler/vm/deletevolumetypehandler.go new file mode 100644 index 00000000..e606634b --- /dev/null +++ b/internal/handler/vm/deletevolumetypehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func DeleteVolumeTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteVolumeTypeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewDeleteVolumeTypeLogic(r.Context(), svcCtx) + resp, err := l.DeleteVolumeType(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/getcomputelimitshandler.go b/internal/handler/vm/getcomputelimitshandler.go new file mode 100644 index 00000000..1cab45d5 --- /dev/null +++ b/internal/handler/vm/getcomputelimitshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetComputeLimitsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetComputeLimitsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewGetComputeLimitsLogic(r.Context(), svcCtx) + resp, err := l.GetComputeLimits(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/getimagenumhandler.go b/internal/handler/vm/getimagenumhandler.go new file mode 100644 index 00000000..6315e29c --- /dev/null +++ b/internal/handler/vm/getimagenumhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetImageNumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListImagesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewGetImageNumLogic(r.Context(), svcCtx) + resp, err := l.GetImageNum(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/getnetworknumhandler.go b/internal/handler/vm/getnetworknumhandler.go new file mode 100644 index 00000000..9c36afdb --- /dev/null +++ b/internal/handler/vm/getnetworknumhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetNetworkNumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListNetworksReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewGetNetworkNumLogic(r.Context(), svcCtx) + resp, err := l.GetNetworkNum(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/getopenstackoverviewhandler.go b/internal/handler/vm/getopenstackoverviewhandler.go new file mode 100644 index 00000000..2eebcc32 --- /dev/null +++ b/internal/handler/vm/getopenstackoverviewhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetOpenstackOverviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.OpenstackOverviewReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewGetOpenstackOverviewLogic(r.Context(), svcCtx) + resp, err := l.GetOpenstackOverview(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/getserversdetailedbyidhandler.go b/internal/handler/vm/getserversdetailedbyidhandler.go new file mode 100644 index 00000000..5c74b347 --- /dev/null +++ b/internal/handler/vm/getserversdetailedbyidhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetServersDetailedByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetServersDetailedByIdReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewGetServersDetailedByIdLogic(r.Context(), svcCtx) + resp, err := l.GetServersDetailedById(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/getvolumedetailedbyidhandler.go b/internal/handler/vm/getvolumedetailedbyidhandler.go new file mode 100644 index 00000000..71fb16a1 --- /dev/null +++ b/internal/handler/vm/getvolumedetailedbyidhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetVolumeDetailedByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetVolumeDetailedByIdReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewGetVolumeDetailedByIdLogic(r.Context(), svcCtx) + resp, err := l.GetVolumeDetailedById(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/getvolumelimitshandler.go b/internal/handler/vm/getvolumelimitshandler.go new file mode 100644 index 00000000..9b592c2d --- /dev/null +++ b/internal/handler/vm/getvolumelimitshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func GetVolumeLimitsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetVolumeLimitsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewGetVolumeLimitsLogic(r.Context(), svcCtx) + resp, err := l.GetVolumeLimits(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listfirewallgroupshandler.go b/internal/handler/vm/listfirewallgroupshandler.go new file mode 100644 index 00000000..0f4b271b --- /dev/null +++ b/internal/handler/vm/listfirewallgroupshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListFirewallGroupsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListFirewallGroupsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListFirewallGroupsLogic(r.Context(), svcCtx) + resp, err := l.ListFirewallGroups(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listfirewallpolicieshandler.go b/internal/handler/vm/listfirewallpolicieshandler.go new file mode 100644 index 00000000..dcbdab6c --- /dev/null +++ b/internal/handler/vm/listfirewallpolicieshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListFirewallPoliciesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListFirewallPoliciesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListFirewallPoliciesLogic(r.Context(), svcCtx) + resp, err := l.ListFirewallPolicies(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listfirewallruleshandler.go b/internal/handler/vm/listfirewallruleshandler.go new file mode 100644 index 00000000..e78f9936 --- /dev/null +++ b/internal/handler/vm/listfirewallruleshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListFirewallRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListFirewallRulesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListFirewallRulesLogic(r.Context(), svcCtx) + resp, err := l.ListFirewallRules(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listflavorsdetailhandler.go b/internal/handler/vm/listflavorsdetailhandler.go new file mode 100644 index 00000000..71a39cb6 --- /dev/null +++ b/internal/handler/vm/listflavorsdetailhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListFlavorsDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListFlavorsDetailReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListFlavorsDetailLogic(r.Context(), svcCtx) + resp, err := l.ListFlavorsDetail(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listfloatingipshandler.go b/internal/handler/vm/listfloatingipshandler.go new file mode 100644 index 00000000..6d4f5f3c --- /dev/null +++ b/internal/handler/vm/listfloatingipshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListFloatingIPsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListFloatingIPsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListFloatingIPsLogic(r.Context(), svcCtx) + resp, err := l.ListFloatingIPs(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listimageshandler.go b/internal/handler/vm/listimageshandler.go new file mode 100644 index 00000000..bda108e0 --- /dev/null +++ b/internal/handler/vm/listimageshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListImagesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListImagesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListImagesLogic(r.Context(), svcCtx) + resp, err := l.ListImages(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listnetworksegmentrangesrangehandler.go b/internal/handler/vm/listnetworksegmentrangesrangehandler.go new file mode 100644 index 00000000..a1c0dbc7 --- /dev/null +++ b/internal/handler/vm/listnetworksegmentrangesrangehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListNetworkSegmentRangesRangeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListNetworkSegmentRangesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListNetworkSegmentRangesRangeLogic(r.Context(), svcCtx) + resp, err := l.ListNetworkSegmentRangesRange(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listnetworkshandler.go b/internal/handler/vm/listnetworkshandler.go new file mode 100644 index 00000000..bbe785fd --- /dev/null +++ b/internal/handler/vm/listnetworkshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListNetworksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListNetworksReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListNetworksLogic(r.Context(), svcCtx) + resp, err := l.ListNetworks(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listnodeshandler.go b/internal/handler/vm/listnodeshandler.go new file mode 100644 index 00000000..6c747b4d --- /dev/null +++ b/internal/handler/vm/listnodeshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListNodesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListNodesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListNodesLogic(r.Context(), svcCtx) + resp, err := l.ListNodes(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listportshandler.go b/internal/handler/vm/listportshandler.go new file mode 100644 index 00000000..8cd1315b --- /dev/null +++ b/internal/handler/vm/listportshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListPortsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListPortsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListPortsLogic(r.Context(), svcCtx) + resp, err := l.ListPorts(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listroutershandler.go b/internal/handler/vm/listroutershandler.go new file mode 100644 index 00000000..a7c01243 --- /dev/null +++ b/internal/handler/vm/listroutershandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListRoutersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListRoutersReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListRoutersLogic(r.Context(), svcCtx) + resp, err := l.ListRouters(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listsecuritygroupruleshandler.go b/internal/handler/vm/listsecuritygroupruleshandler.go new file mode 100644 index 00000000..fca14c47 --- /dev/null +++ b/internal/handler/vm/listsecuritygroupruleshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListSecurityGroupRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListSecurityGroupRulesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListSecurityGroupRulesLogic(r.Context(), svcCtx) + resp, err := l.ListSecurityGroupRules(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listsecuritygroupshandler.go b/internal/handler/vm/listsecuritygroupshandler.go new file mode 100644 index 00000000..663ed838 --- /dev/null +++ b/internal/handler/vm/listsecuritygroupshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListSecurityGroupsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListSecurityGroupsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListSecurityGroupsLogic(r.Context(), svcCtx) + resp, err := l.ListSecurityGroups(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listserverhandler.go b/internal/handler/vm/listserverhandler.go new file mode 100644 index 00000000..c2cf0e91 --- /dev/null +++ b/internal/handler/vm/listserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListServersReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListServerLogic(r.Context(), svcCtx) + resp, err := l.ListServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listserversdetailedhandler.go b/internal/handler/vm/listserversdetailedhandler.go new file mode 100644 index 00000000..b1fb666a --- /dev/null +++ b/internal/handler/vm/listserversdetailedhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListServersDetailedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListServersDetailedReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListServersDetailedLogic(r.Context(), svcCtx) + resp, err := l.ListServersDetailed(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listsubnetshandler.go b/internal/handler/vm/listsubnetshandler.go new file mode 100644 index 00000000..74058625 --- /dev/null +++ b/internal/handler/vm/listsubnetshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListSubnetsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListSubnetsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListSubnetsLogic(r.Context(), svcCtx) + resp, err := l.ListSubnets(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listvolumesdetailhandler.go b/internal/handler/vm/listvolumesdetailhandler.go new file mode 100644 index 00000000..5c164f9b --- /dev/null +++ b/internal/handler/vm/listvolumesdetailhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListVolumesDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListVolumesDetailReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListVolumesDetailLogic(r.Context(), svcCtx) + resp, err := l.ListVolumesDetail(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listvolumeshandler.go b/internal/handler/vm/listvolumeshandler.go new file mode 100644 index 00000000..6cbe59b1 --- /dev/null +++ b/internal/handler/vm/listvolumeshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ListVolumesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListVolumesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewListVolumesLogic(r.Context(), svcCtx) + resp, err := l.ListVolumes(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/listvolumetypeshandler.go b/internal/handler/vm/listvolumetypeshandler.go new file mode 100644 index 00000000..426aab86 --- /dev/null +++ b/internal/handler/vm/listvolumetypeshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/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/internal/handler/vm/migrateserverhandler.go b/internal/handler/vm/migrateserverhandler.go new file mode 100644 index 00000000..8ee3306d --- /dev/null +++ b/internal/handler/vm/migrateserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func MigrateServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.MigrateServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewMigrateServerLogic(r.Context(), svcCtx) + resp, err := l.MigrateServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/pauseserverhandler.go b/internal/handler/vm/pauseserverhandler.go new file mode 100644 index 00000000..c8b4130c --- /dev/null +++ b/internal/handler/vm/pauseserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func PauseServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.PauseServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewPauseServerLogic(r.Context(), svcCtx) + resp, err := l.PauseServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/rebootserverhandler.go b/internal/handler/vm/rebootserverhandler.go new file mode 100644 index 00000000..41269593 --- /dev/null +++ b/internal/handler/vm/rebootserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func RebootServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.RebootServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewRebootServerLogic(r.Context(), svcCtx) + resp, err := l.RebootServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/removesecuritygrouphandler.go b/internal/handler/vm/removesecuritygrouphandler.go new file mode 100644 index 00000000..9ecd032b --- /dev/null +++ b/internal/handler/vm/removesecuritygrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func RemoveSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.RemoveSecurityGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewRemoveSecurityGroupLogic(r.Context(), svcCtx) + resp, err := l.RemoveSecurityGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/rescueserverhandler.go b/internal/handler/vm/rescueserverhandler.go new file mode 100644 index 00000000..b20f6584 --- /dev/null +++ b/internal/handler/vm/rescueserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func RescueServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.RescueServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewRescueServerLogic(r.Context(), svcCtx) + resp, err := l.RescueServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/resizeserverhandler.go b/internal/handler/vm/resizeserverhandler.go new file mode 100644 index 00000000..d2929cff --- /dev/null +++ b/internal/handler/vm/resizeserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ResizeServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ResizeServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewResizeServerLogic(r.Context(), svcCtx) + resp, err := l.ResizeServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/shelveserverhandler.go b/internal/handler/vm/shelveserverhandler.go new file mode 100644 index 00000000..8d5c0d63 --- /dev/null +++ b/internal/handler/vm/shelveserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShelveServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShelveServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShelveServerLogic(r.Context(), svcCtx) + resp, err := l.ShelveServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showfirewallgroupdetailshandler.go b/internal/handler/vm/showfirewallgroupdetailshandler.go new file mode 100644 index 00000000..0d180385 --- /dev/null +++ b/internal/handler/vm/showfirewallgroupdetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowFirewallGroupDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowFirewallGroupDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowFirewallGroupDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowFirewallGroupDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showfirewallpolicydetailshandler.go b/internal/handler/vm/showfirewallpolicydetailshandler.go new file mode 100644 index 00000000..9336c5ab --- /dev/null +++ b/internal/handler/vm/showfirewallpolicydetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowFirewallPolicyDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowFirewallPolicyDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowFirewallPolicyDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowFirewallPolicyDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showfirewallruledetailshandler.go b/internal/handler/vm/showfirewallruledetailshandler.go new file mode 100644 index 00000000..c6f8e1bb --- /dev/null +++ b/internal/handler/vm/showfirewallruledetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowFirewallRuleDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowFirewallRuleDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowFirewallRuleDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowFirewallRuleDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showfloatingipdetailshandler.go b/internal/handler/vm/showfloatingipdetailshandler.go new file mode 100644 index 00000000..5bbccb0f --- /dev/null +++ b/internal/handler/vm/showfloatingipdetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowFloatingIPDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowFloatingIPDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowFloatingIPDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowFloatingIPDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/shownetworkdetailshandler.go b/internal/handler/vm/shownetworkdetailshandler.go new file mode 100644 index 00000000..1a20e006 --- /dev/null +++ b/internal/handler/vm/shownetworkdetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowNetworkDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowNetworkDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowNetworkDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowNetworkDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/shownetworksegmentrangedetailshandler.go b/internal/handler/vm/shownetworksegmentrangedetailshandler.go new file mode 100644 index 00000000..953d1699 --- /dev/null +++ b/internal/handler/vm/shownetworksegmentrangedetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowNetworkSegmentRangeDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowNetworkSegmentRangeDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowNetworkSegmentRangeDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowNetworkSegmentRangeDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/shownodedetailshandler.go b/internal/handler/vm/shownodedetailshandler.go new file mode 100644 index 00000000..7205f2d1 --- /dev/null +++ b/internal/handler/vm/shownodedetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowNodeDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowNodeDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowNodeDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowNodeDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showportdetailshandler.go b/internal/handler/vm/showportdetailshandler.go new file mode 100644 index 00000000..ba4d2072 --- /dev/null +++ b/internal/handler/vm/showportdetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowPortDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowPortDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowPortDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowPortDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showrouterdetailshandler.go b/internal/handler/vm/showrouterdetailshandler.go new file mode 100644 index 00000000..da10ae87 --- /dev/null +++ b/internal/handler/vm/showrouterdetailshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowRouterDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowRouterDetailsReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowRouterDetailsLogic(r.Context(), svcCtx) + resp, err := l.ShowRouterDetails(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showsecuritygrouphandler.go b/internal/handler/vm/showsecuritygrouphandler.go new file mode 100644 index 00000000..4fd4da35 --- /dev/null +++ b/internal/handler/vm/showsecuritygrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowSecurityGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowSecurityGroupLogic(r.Context(), svcCtx) + resp, err := l.ShowSecurityGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/showsecuritygrouprulehandler.go b/internal/handler/vm/showsecuritygrouprulehandler.go new file mode 100644 index 00000000..bf07f758 --- /dev/null +++ b/internal/handler/vm/showsecuritygrouprulehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func ShowSecurityGroupRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ShowSecurityGroupRuleReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewShowSecurityGroupRuleLogic(r.Context(), svcCtx) + resp, err := l.ShowSecurityGroupRule(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/startserverhandler.go b/internal/handler/vm/startserverhandler.go new file mode 100644 index 00000000..179e7365 --- /dev/null +++ b/internal/handler/vm/startserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func StartServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StartServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewStartServerLogic(r.Context(), svcCtx) + resp, err := l.StartServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/stopserverhandler.go b/internal/handler/vm/stopserverhandler.go new file mode 100644 index 00000000..c37c7b23 --- /dev/null +++ b/internal/handler/vm/stopserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func StopServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.StopServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewStopServerLogic(r.Context(), svcCtx) + resp, err := l.StopServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/suspendserverhandler.go b/internal/handler/vm/suspendserverhandler.go new file mode 100644 index 00000000..f37d033b --- /dev/null +++ b/internal/handler/vm/suspendserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func SuspendServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.SuspendServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewSuspendServerLogic(r.Context(), svcCtx) + resp, err := l.SuspendServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/unpauseserverhandler.go b/internal/handler/vm/unpauseserverhandler.go new file mode 100644 index 00000000..59581de8 --- /dev/null +++ b/internal/handler/vm/unpauseserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UnpauseServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UnpauseServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUnpauseServerLogic(r.Context(), svcCtx) + resp, err := l.UnpauseServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/unrescuehandler.go b/internal/handler/vm/unrescuehandler.go new file mode 100644 index 00000000..deafa468 --- /dev/null +++ b/internal/handler/vm/unrescuehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UnRescueHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UnRescueServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUnRescueLogic(r.Context(), svcCtx) + resp, err := l.UnRescue(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updatefirewallgrouphandler.go b/internal/handler/vm/updatefirewallgrouphandler.go new file mode 100644 index 00000000..7285787b --- /dev/null +++ b/internal/handler/vm/updatefirewallgrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateFirewallGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateFirewallGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateFirewallGroupLogic(r.Context(), svcCtx) + resp, err := l.UpdateFirewallGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updatefloatingiphandler.go b/internal/handler/vm/updatefloatingiphandler.go new file mode 100644 index 00000000..7a61d49f --- /dev/null +++ b/internal/handler/vm/updatefloatingiphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateFloatingIPHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateFloatingIPReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateFloatingIPLogic(r.Context(), svcCtx) + resp, err := l.UpdateFloatingIP(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updatenetworkhandler.go b/internal/handler/vm/updatenetworkhandler.go new file mode 100644 index 00000000..b135c50b --- /dev/null +++ b/internal/handler/vm/updatenetworkhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateNetworkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateNetworkReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateNetworkLogic(r.Context(), svcCtx) + resp, err := l.UpdateNetwork(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updatenetworksegmentrangeshandler.go b/internal/handler/vm/updatenetworksegmentrangeshandler.go new file mode 100644 index 00000000..c0a10707 --- /dev/null +++ b/internal/handler/vm/updatenetworksegmentrangeshandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateNetworkSegmentRangesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateNetworkSegmentRangesReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateNetworkSegmentRangesLogic(r.Context(), svcCtx) + resp, err := l.UpdateNetworkSegmentRanges(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updateporthandler.go b/internal/handler/vm/updateporthandler.go new file mode 100644 index 00000000..90f59e0e --- /dev/null +++ b/internal/handler/vm/updateporthandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdatePortHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdatePortReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdatePortLogic(r.Context(), svcCtx) + resp, err := l.UpdatePort(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updaterouterhandler.go b/internal/handler/vm/updaterouterhandler.go new file mode 100644 index 00000000..6fb46a10 --- /dev/null +++ b/internal/handler/vm/updaterouterhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateRouterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateRouterReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateRouterLogic(r.Context(), svcCtx) + resp, err := l.UpdateRouter(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updatesecuritygrouphandler.go b/internal/handler/vm/updatesecuritygrouphandler.go new file mode 100644 index 00000000..e197b83a --- /dev/null +++ b/internal/handler/vm/updatesecuritygrouphandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateSecurityGroupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateSecurityGroupReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateSecurityGroupLogic(r.Context(), svcCtx) + resp, err := l.UpdateSecurityGroup(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updateserverhandler.go b/internal/handler/vm/updateserverhandler.go new file mode 100644 index 00000000..e8854612 --- /dev/null +++ b/internal/handler/vm/updateserverhandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateServerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateServerReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateServerLogic(r.Context(), svcCtx) + resp, err := l.UpdateServer(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updatesubnethandler.go b/internal/handler/vm/updatesubnethandler.go new file mode 100644 index 00000000..78a7b485 --- /dev/null +++ b/internal/handler/vm/updatesubnethandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateSubnetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateSubnetReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateSubnetLogic(r.Context(), svcCtx) + resp, err := l.UpdateSubnet(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/updatevolumehandler.go b/internal/handler/vm/updatevolumehandler.go new file mode 100644 index 00000000..52110fc0 --- /dev/null +++ b/internal/handler/vm/updatevolumehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +func UpdateVolumeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateVolumeReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := vm.NewUpdateVolumeLogic(r.Context(), svcCtx) + resp, err := l.UpdateVolume(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/internal/handler/vm/uploadimagehandler.go b/internal/handler/vm/uploadimagehandler.go new file mode 100644 index 00000000..e89ddc5a --- /dev/null +++ b/internal/handler/vm/uploadimagehandler.go @@ -0,0 +1,28 @@ +package vm + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/vm" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/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/internal/logic/adapters/adapterslistlogic.go b/internal/logic/adapters/adapterslistlogic.go new file mode 100644 index 00000000..a62d9921 --- /dev/null +++ b/internal/logic/adapters/adapterslistlogic.go @@ -0,0 +1,59 @@ +package adapters + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AdaptersListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAdaptersListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdaptersListLogic { + return &AdaptersListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AdaptersListLogic) AdaptersList(req *types.AdapterQueryReq) (resp *types.PageResult, err error) { + limit := req.PageSize + offset := req.PageSize * (req.PageNum - 1) + resp = &types.PageResult{} + var list []types.AdapterInfo + db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") + + if req.Name != "" { + db = db.Where("name LIKE ?", "%"+req.Name+"%") + } + if req.Nickname != "" { + db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%") + } + if req.Type != "" { + db = db.Where("type = ?", req.Type) + } + if req.Version != "" { + db = db.Where("version = ?", req.Version) + } + var total int64 + err = db.Count(&total).Error + + if err != nil { + return resp, err + } + db = db.Where("deleted_at is null").Limit(limit).Offset(offset) + err = db.Order("create_time desc").Find(&list).Error + + resp.List = list + resp.PageSize = req.PageSize + resp.PageNum = req.PageNum + resp.Total = total + + return resp, nil +} diff --git a/internal/logic/adapters/clusterlistlogic.go b/internal/logic/adapters/clusterlistlogic.go new file mode 100644 index 00000000..9b15e1a5 --- /dev/null +++ b/internal/logic/adapters/clusterlistlogic.go @@ -0,0 +1,80 @@ +package adapters + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ClusterListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterListLogic { + return &ClusterListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.PageResult, err error) { + limit := req.PageSize + offset := req.PageSize * (req.PageNum - 1) + resp = &types.PageResult{} + var list []types.ClusterInfo + db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_cluster") + + db = db.Joins("left join t_adapter on t_adapter.id = t_cluster.adapter_id"). + Where("t_cluster.deleted_at is null") + if req.Name != "" { + db = db.Where("t_cluster.name LIKE ?", "%"+req.Name+"%") + } + if req.AdapterId != "" { + db = db.Where("t_cluster.adapter_id = ?", req.AdapterId) + } + if req.Nickname != "" { + db = db.Where("t_cluster.nickname LIKE ?", "%"+req.Nickname+"%") + } + if req.Label != "" { + db = db.Where("t_cluster.label = ?", req.Label) + } + if req.Version != "" { + db = db.Where("t_cluster.version = ?", req.Version) + } + if req.ProducerDict != "" { + db = db.Where("t_cluster.producer_dict = ?", req.ProducerDict) + } + if req.RegionDict != "" { + db = db.Where("t_cluster.region_dict = ?", req.RegionDict) + } + if req.Type != "" { + db = db.Where("t_adapter.type = ?", req.Type) + } + if req.ResourceType != "" { + db = db.Where("t_adapter.resource_type = ?", req.ResourceType) + } + + //count total + var total int64 + err = db.Select("*").Count(&total).Error + if err != nil { + return resp, err + } + + db = db.Limit(limit).Offset(offset) + err = db.Select("t_cluster.*").Order("t_cluster.create_time desc").Scan(&list).Error + if err != nil { + return resp, err + } + resp.List = list + resp.PageSize = req.PageSize + resp.PageNum = req.PageNum + resp.Total = total + + return resp, nil +} diff --git a/internal/logic/adapters/createadapterlogic.go b/internal/logic/adapters/createadapterlogic.go new file mode 100644 index 00000000..61cd6c81 --- /dev/null +++ b/internal/logic/adapters/createadapterlogic.go @@ -0,0 +1,67 @@ +package adapters + +import ( + "context" + "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + "time" +) + +type CreateAdapterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAdapterLogic { + return &CreateAdapterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateAdapterLogic) CreateAdapter(req *types.AdapterCreateReq) (resp *types.AdapterResp, err error) { + adapter := types.AdapterInfo{} + utils.Convert(req, &adapter) + //check name + exist := l.svcCtx.DbEngin.Table("t_adapter").Where("name = ?", req.Name).First(&types.AdapterInfo{}).Error + if !errors.Is(exist, gorm.ErrRecordNotFound) { + return nil, errors.New("name already exists") + } + //check type + var arr = [...]string{"0", "1", "2"} + found := false + for _, str := range arr { + if str == req.Type { + found = true + break + } + } + if found == false { + return nil, errors.New("type not found") + } + + //check resourceTypeDict + sql := `select t_dict_item.item_value + from t_dict + join t_dict_item on t_dict.id = t_dict_item.dict_id + where dict_code = 'adapter_type' and item_value = ? + and t_dict_item.parent_id != 0` + err = l.svcCtx.DbEngin.Raw(sql, req.ResourceType).First(&types.DictItemInfo{}).Error + if errors.Is(err, gorm.ErrRecordNotFound) { + return nil, errors.New("resourceType error, please check!") + } + adapter.Id = utils.GenSnowflakeIDStr() + adapter.CreateTime = time.Now().Format("2006-01-02 15:04:05") + result := l.svcCtx.DbEngin.Table("t_adapter").Create(&adapter) + if result.Error != nil { + return nil, result.Error + } + + return +} diff --git a/internal/logic/adapters/createclusterlogic.go b/internal/logic/adapters/createclusterlogic.go new file mode 100644 index 00000000..526de536 --- /dev/null +++ b/internal/logic/adapters/createclusterlogic.go @@ -0,0 +1,66 @@ +package adapters + +import ( + "context" + "errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateClusterLogic { + return &CreateClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) { + adapter := &types.AdapterInfo{} + result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.AdapterId) + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + return nil, errors.New("adapter does not exist") + } + cluster := types.ClusterInfo{} + utils.Convert(req, &cluster) + cluster.Id = utils.GenSnowflakeIDStr() + cluster.CreateTime = time.Now().Format("2006-01-02 15:04:05") + cluster.OwnerId = "0" + tx := l.svcCtx.DbEngin.Table("t_cluster").Create(&cluster) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return nil, errors.New("cluster create failed") + } + + // push cluster info to adapter + var adapterServer string + l.svcCtx.DbEngin.Raw("select server from t_adapter where id = ?", req.AdapterId).Scan(&adapterServer) + response, err := l.svcCtx.HttpClient.R(). + SetBody(&types.ClusterInfo{ + Name: req.Name, + Server: req.Server, + Token: req.Token, + MonitorServer: req.MonitorServer, + }). + ForceContentType("application/json"). + Post(adapterServer + "/api/v1/cluster/info") + if err != nil { + return nil, err + } + if response.IsError() { + return nil, errors.New(string(response.Body())) + } + return +} diff --git a/internal/logic/adapters/deleteadapterlogic.go b/internal/logic/adapters/deleteadapterlogic.go new file mode 100644 index 00000000..8cedd296 --- /dev/null +++ b/internal/logic/adapters/deleteadapterlogic.go @@ -0,0 +1,44 @@ +package adapters + +import ( + "context" + "github.com/pkg/errors" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteAdapterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAdapterLogic { + return &DeleteAdapterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteAdapterLogic) DeleteAdapter(req *types.AdapterDelReq) (resp *types.AdapterResp, err error) { + var sId int64 + l.svcCtx.DbEngin.Table("t_adapter").Raw("select a.id from t_cluster c left join t_adapter a on c.adapter_id=a.id where a.id = ? ", req.Id).Scan(&sId) + if sId != 0 { + return nil, errors.New("Delete failed,The adapter is associated with a cluster") + } + db := l.svcCtx.DbEngin.Table("t_adapter").Where("id = ?", req.Id).First(&types.AdapterInfo{}) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Adapter does not exist") + } + tx := l.svcCtx.DbEngin.Table("t_adapter").Delete(types.AdapterInfo{}, req.Id) + if tx.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Delete adapter failed") + } + return +} diff --git a/internal/logic/adapters/deleteclusterlogic.go b/internal/logic/adapters/deleteclusterlogic.go new file mode 100644 index 00000000..c9f67df2 --- /dev/null +++ b/internal/logic/adapters/deleteclusterlogic.go @@ -0,0 +1,39 @@ +package adapters + +import ( + "context" + "github.com/pkg/errors" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClusterLogic { + return &DeleteClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteClusterLogic) DeleteCluster(req *types.FId) (resp *types.ClusterResp, err error) { + db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&types.ClusterInfo{}) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Cluster does not exist") + } + tx := l.svcCtx.DbEngin.Table("t_cluster").Delete(types.AdapterInfo{}, req.Id) + if tx.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Delete Cluster failed") + } + return +} diff --git a/internal/logic/adapters/getadapterlogic.go b/internal/logic/adapters/getadapterlogic.go new file mode 100644 index 00000000..92c52236 --- /dev/null +++ b/internal/logic/adapters/getadapterlogic.go @@ -0,0 +1,35 @@ +package adapters + +import ( + "context" + "github.com/pkg/errors" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetAdapterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdapterLogic { + return &GetAdapterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetAdapterLogic) GetAdapter(req *types.AdapterDelReq) (resp *types.AdapterInfo, err error) { + resp = &types.AdapterInfo{} + db := l.svcCtx.DbEngin.Table("t_adapter").Where("id = ?", req.Id).First(&resp) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Adapter does not exist") + } + return +} diff --git a/internal/logic/adapters/getadapterrelationlogic.go b/internal/logic/adapters/getadapterrelationlogic.go new file mode 100644 index 00000000..3e44e8b6 --- /dev/null +++ b/internal/logic/adapters/getadapterrelationlogic.go @@ -0,0 +1,89 @@ +package adapters + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetAdapterRelationLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetAdapterRelationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdapterRelationLogic { + return &GetAdapterRelationLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterRelationQueryReq) (resp *types.PageResult, err error) { + resp = &types.PageResult{} + var list []types.AdapterInfo + db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") + + if req.Name != "" { + db = db.Where("name LIKE ?", "%"+req.Name+"%") + } + if req.Nickname != "" { + db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%") + } + if req.Type != "" { + db = db.Where("type = ?", req.Type) + } + if req.Version != "" { + db = db.Where("version = ?", req.Version) + } + + err = db.Where("deleted_at is null").Order("create_time desc").Find(&list).Error + + if err != nil { + return resp, err + } + + rlist := make([]*types.ClusterRelationInfo, 0) + for _, v := range list { + cr := &types.ClusterRelationInfo{} + utils.Convert(&v, &cr) + clusters := make([]*types.ClusterInfo, 0) + l.svcCtx.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL and adapter_id = ? ORDER BY create_time Desc", v.Id).Scan(&clusters) + for _, c := range clusters { + cr = &types.ClusterRelationInfo{} + utils.Convert(&v, &cr) + cr.CId = c.Id + cr.CAdapterId = c.AdapterId + cr.CName = c.Name + cr.CNickname = c.Nickname + cr.CDescription = c.Description + cr.CServer = c.Server + cr.CMonitorServer = c.MonitorServer + cr.CUsername = c.Username + cr.CPassword = c.Password + cr.CToken = c.Token + cr.CAk = c.Ak + cr.CSk = c.Sk + cr.CRegion = c.Region + cr.CProjectId = c.ProjectId + cr.CVersion = c.Version + cr.CLabel = c.Label + cr.COwnerId = c.OwnerId + cr.CAuthType = c.AuthType + cr.CRegionDict = c.RegionDict + cr.CProducerDict = c.ProducerDict + cr.CCreateTime = c.CreateTime + rlist = append(rlist, cr) + } + if len(clusters) == 0 { + rlist = append(rlist, cr) + } + } + resp.List = rlist + return resp, nil +} diff --git a/internal/logic/adapters/getclusterlogic.go b/internal/logic/adapters/getclusterlogic.go new file mode 100644 index 00000000..f5b8952e --- /dev/null +++ b/internal/logic/adapters/getclusterlogic.go @@ -0,0 +1,36 @@ +package adapters + +import ( + "context" + "github.com/pkg/errors" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterLogic { + return &GetClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetClusterLogic) GetCluster(req *types.FId) (resp *types.ClusterInfo, err error) { + resp = &types.ClusterInfo{} + db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&resp) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Adapter does not exist") + } + + return +} diff --git a/internal/logic/adapters/getclustersumlogic.go b/internal/logic/adapters/getclustersumlogic.go new file mode 100644 index 00000000..9bd2997e --- /dev/null +++ b/internal/logic/adapters/getclustersumlogic.go @@ -0,0 +1,67 @@ +package adapters + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetClusterSumLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetClusterSumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterSumLogic { + return &GetClusterSumLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetClusterSumLogic) GetClusterSum(req *types.ClusterSumReq) (resp *types.ClusterSumReqResp, err error) { + // todo: add your logic here and delete this line + resp = &types.ClusterSumReqResp{} + + var AdapterSum int // + var podSum int // + var vmSum int // + var TaskSum int // + // + sqlStr := "SELECT COUNT(*) FROM `t_adapter` t where t.type ='0' and deleted_at is null" + tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&AdapterSum) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + //vm + sqlStrVm := "SELECT COUNT(*) FROM `t_adapter` t left join t_cluster tc on t.id=tc.adapter_id where t.type = '0' and t.resource_type='02' and tc.deleted_at is null" + txClusterVm := l.svcCtx.DbEngin.Raw(sqlStrVm).Scan(&vmSum) + if txClusterVm.Error != nil { + logx.Error(err) + return nil, txClusterVm.Error + } + //pod + sqlStrPod := "SELECT COUNT(*) FROM `t_adapter` t left join t_cluster tc on t.id=tc.adapter_id where t.type = '0' and t.resource_type='02' and tc.deleted_at is null" + txClusterPod := l.svcCtx.DbEngin.Raw(sqlStrPod).Scan(&podSum) + if txClusterPod.Error != nil { + logx.Error(err) + return nil, txClusterPod.Error + } + // + sqlStrTask := "SELECT COUNT(*) FROM `task` where adapter_type_dict = '0'" + txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&TaskSum) + if txTask.Error != nil { + logx.Error(err) + return nil, txTask.Error + } + resp.TaskSum = TaskSum + resp.VmSum = vmSum + resp.PodSum = podSum + resp.AdapterSum = AdapterSum + return resp, nil +} diff --git a/internal/logic/adapters/updateadapterlogic.go b/internal/logic/adapters/updateadapterlogic.go new file mode 100644 index 00000000..215f205f --- /dev/null +++ b/internal/logic/adapters/updateadapterlogic.go @@ -0,0 +1,38 @@ +package adapters + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateAdapterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAdapterLogic { + return &UpdateAdapterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateAdapterLogic) UpdateAdapter(req *types.AdapterReq) (resp *types.AdapterResp, err error) { + adapter := &types.AdapterInfo{} + result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.Id) + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + return nil, errors.New("adapter does not exist") + } + utils.Convert(req, &adapter) + l.svcCtx.DbEngin.Table("t_adapter").Model(&adapter).Updates(&adapter) + return +} diff --git a/internal/logic/adapters/updateclusterlogic.go b/internal/logic/adapters/updateclusterlogic.go new file mode 100644 index 00000000..7f260bd8 --- /dev/null +++ b/internal/logic/adapters/updateclusterlogic.go @@ -0,0 +1,38 @@ +package adapters + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateClusterLogic { + return &UpdateClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) { + cluster := &types.ClusterInfo{} + result := l.svcCtx.DbEngin.Table("t_cluster").First(&cluster, req.Id) + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + return nil, errors.New("cluster does not exist") + } + utils.Convert(req, &cluster) + l.svcCtx.DbEngin.Table("t_cluster").Model(&cluster).Updates(&cluster) + return +} diff --git a/internal/logic/ai/createalgorithmlogic.go b/internal/logic/ai/createalgorithmlogic.go new file mode 100644 index 00000000..89eec6af --- /dev/null +++ b/internal/logic/ai/createalgorithmlogic.go @@ -0,0 +1,57 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" +) + +type CreateAlgorithmLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlgorithmLogic { + return &CreateAlgorithmLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateAlgorithmLogic) CreateAlgorithm(req *types.CreateAlgorithmReq) (resp *types.CreateAlgorithmResp, err error) { + modelartsReq := &modelarts.CreateAlgorithmReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + ListAlgorithmsResp, err := l.svcCtx.ModelArtsRpc.CreateAlgorithm(l.ctx, modelartsReq) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&ListAlgorithmsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListAlgorithmsResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/createdatasetlogic.go b/internal/logic/ai/createdatasetlogic.go new file mode 100644 index 00000000..a02b49d0 --- /dev/null +++ b/internal/logic/ai/createdatasetlogic.go @@ -0,0 +1,58 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateDataSetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDataSetLogic { + return &CreateDataSetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateDataSetLogic) CreateDataSet(req *types.CreateDataSetReq) (resp *types.CreateDataSetResp, err error) { + // todo: add your logic here and delete this line + + modelartsReq := &modelarts.CreateDataSetReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + CreateDataSetResp, err := l.svcCtx.ModelArtsRpc.CreateDataSet(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + resp = &types.CreateDataSetResp{} + + err = copier.CopyWithOption(&resp, &CreateDataSetResp, copier.Option{Converters: utils.Converters}) + return resp, nil + +} diff --git a/internal/logic/ai/createexporttasklogic.go b/internal/logic/ai/createexporttasklogic.go new file mode 100644 index 00000000..d2358e6c --- /dev/null +++ b/internal/logic/ai/createexporttasklogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateExportTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateExportTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateExportTaskLogic { + return &CreateExportTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateExportTaskLogic) CreateExportTask(req *types.CreateExportTaskReq) (resp *types.ExportTaskDataResp, err error) { + + modelartsReq := &modelarts.ExportTaskReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + CreateExportTaskResp, err := l.svcCtx.ModelArtsRpc.ExportTask(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateExportTaskResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateExportTaskResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/createnotebooklogic.go b/internal/logic/ai/createnotebooklogic.go new file mode 100644 index 00000000..d6a8736e --- /dev/null +++ b/internal/logic/ai/createnotebooklogic.go @@ -0,0 +1,56 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateNotebookLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNotebookLogic { + return &CreateNotebookLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateNotebookLogic) CreateNotebook(req *types.CreateNotebookReq) (resp *types.CreateNotebookResp, err error) { + modelartsReq := &modelarts.CreateNotebookReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + createNotebookResp, err := l.svcCtx.ModelArtsRpc.CreateNotebook(l.ctx, modelartsReq) + + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to create notebook"), "Failed to create notebook err : %v ,req:%+v", err, req) + } + resp = &types.CreateNotebookResp{} + err = copier.CopyWithOption(resp, createNotebookResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + + return resp, nil +} diff --git a/internal/logic/ai/createprocessortasklogic.go b/internal/logic/ai/createprocessortasklogic.go new file mode 100644 index 00000000..607b3e80 --- /dev/null +++ b/internal/logic/ai/createprocessortasklogic.go @@ -0,0 +1,56 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateProcessorTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateProcessorTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProcessorTaskLogic { + return &CreateProcessorTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateProcessorTaskLogic) CreateProcessorTask(req *types.CreateProcessorTaskReq) (resp *types.CreateProcessorTaskResp, err error) { + modelartsReq := &modelarts.CreateProcessorTaskReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + CreateProcessorTaskResp, err := l.svcCtx.ModelArtsRpc.CreateProcessorTask(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + resp = &types.CreateProcessorTaskResp{} + + err = copier.CopyWithOption(&resp, &CreateProcessorTaskResp, copier.Option{Converters: utils.Converters}) + + return resp, nil +} diff --git a/internal/logic/ai/createservicelogic.go b/internal/logic/ai/createservicelogic.go new file mode 100644 index 00000000..7ade166e --- /dev/null +++ b/internal/logic/ai/createservicelogic.go @@ -0,0 +1,58 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic { + return &CreateServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *types.CreateServiceResp, err error) { + modelartsReq := &modelarts.CreateServiceReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + CreateServiceResp, err := l.svcCtx.ModelArtsRpc.CreateService(l.ctx, modelartsReq) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&CreateServiceResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateServiceResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/createtasklogic.go b/internal/logic/ai/createtasklogic.go new file mode 100644 index 00000000..1ffe1105 --- /dev/null +++ b/internal/logic/ai/createtasklogic.go @@ -0,0 +1,60 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTaskLogic { + return &CreateTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateTaskLogic) CreateTask(req *types.ImportTaskDataReq) (resp *types.ImportTaskDataResp, err error) { + modelartsReq := &modelarts.ImportTaskDataReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + ImportTaskDataResp, err := l.svcCtx.ModelArtsRpc.CreateTask(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ImportTaskDataResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ImportTaskDataResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/createtrainingjoblogic.go b/internal/logic/ai/createtrainingjoblogic.go new file mode 100644 index 00000000..0e0dc61e --- /dev/null +++ b/internal/logic/ai/createtrainingjoblogic.go @@ -0,0 +1,60 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateTrainingJobLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic { + return &CreateTrainingJobLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateTrainingJobLogic) CreateTrainingJob(req *types.CreateTrainingJobReq) (resp *types.CreateTrainingJobResp, err error) { + // todo: add your logic here and delete this line + //modelartsType := req.ModelartsType + modelartsReq := &modelarts.CreateTrainingJobReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + CreateTrainingJobResp, err := l.svcCtx.ModelArtsRpc.CreateTrainingJob(l.ctx, modelartsReq) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&CreateTrainingJobResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateTrainingJobResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/createvisualizationjoblogic.go b/internal/logic/ai/createvisualizationjoblogic.go new file mode 100644 index 00000000..d71b9a09 --- /dev/null +++ b/internal/logic/ai/createvisualizationjoblogic.go @@ -0,0 +1,44 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateVisualizationJobLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVisualizationJobLogic { + return &CreateVisualizationJobLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateVisualizationJobLogic) CreateVisualizationJob(req *types.CreateVisualizationJobReq) (resp *types.CreateVisualizationJobResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/ai/deletealgorithmlogic.go b/internal/logic/ai/deletealgorithmlogic.go new file mode 100644 index 00000000..c3115856 --- /dev/null +++ b/internal/logic/ai/deletealgorithmlogic.go @@ -0,0 +1,67 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + "strings" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteAlgorithmLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlgorithmLogic { + return &DeleteAlgorithmLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteAlgorithmLogic) DeleteAlgorithm(req *types.DeleteAlgorithmReq) (resp *types.DeleteAlgorithmResp, err error) { + modelartsReq := &modelarts.DeleteAlgorithmsReq{} + reqByte, err := json.Marshal(req) + if err != nil { + return nil, err + } + payload := strings.NewReader(string(reqByte)) + println(payload) + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + DeleteAlgorithmResp, err := l.svcCtx.ModelArtsRpc.DeleteAlgorithms(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteAlgorithmResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteAlgorithmResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/deletedatasetlogic.go b/internal/logic/ai/deletedatasetlogic.go new file mode 100644 index 00000000..546faab8 --- /dev/null +++ b/internal/logic/ai/deletedatasetlogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteDataSetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDataSetLogic { + return &DeleteDataSetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteDataSetLogic) DeleteDataSet(req *types.DeleteDataSetReq) (resp *types.DeleteDataSetResp, err error) { + // todo: add your logic here and delete this line + modelartsReq := &modelarts.DeleteDataSetReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + deleteDataSetResp, err := l.svcCtx.ModelArtsRpc.DeleteDataSet(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&deleteDataSetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &deleteDataSetResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/deleteservicelogic.go b/internal/logic/ai/deleteservicelogic.go new file mode 100644 index 00000000..bf49ea67 --- /dev/null +++ b/internal/logic/ai/deleteservicelogic.go @@ -0,0 +1,59 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServiceLogic { + return &DeleteServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteServiceLogic) DeleteService(req *types.DeleteServiceReq) (resp *types.DeleteServiceResp, err error) { + modelartsReq := &modelarts.DeleteServiceReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + deleteServiceResp, err := l.svcCtx.ModelArtsRpc.DeleteService(l.ctx, modelartsReq) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&deleteServiceResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &deleteServiceResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/deletetrainingjoblogic.go b/internal/logic/ai/deletetrainingjoblogic.go new file mode 100644 index 00000000..7d4fa07e --- /dev/null +++ b/internal/logic/ai/deletetrainingjoblogic.go @@ -0,0 +1,58 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteTrainingJobLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTrainingJobLogic { + return &DeleteTrainingJobLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteTrainingJobLogic) DeleteTrainingJob(req *types.DeleteTrainingJobReq) (resp *types.DeleteTrainingJobResp, err error) { + modelartsReq := &modelarts.DeleteTrainingJobReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + deleteTrainingJobResp, err := l.svcCtx.ModelArtsRpc.DeleteTrainingJob(l.ctx, modelartsReq) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&deleteTrainingJobResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &deleteTrainingJobResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/getcenterlistlogic.go b/internal/logic/ai/getcenterlistlogic.go new file mode 100644 index 00000000..0ba9e775 --- /dev/null +++ b/internal/logic/ai/getcenterlistlogic.go @@ -0,0 +1,43 @@ +package ai + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCenterListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterListLogic { + return &GetCenterListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterListLogic) GetCenterList() (resp *types.CenterListResp, err error) { + resp = &types.CenterListResp{} + + adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") + if err != nil { + return nil, err + } + + for _, adapter := range adapterList { + a := &types.AiCenter{ + Name: adapter.Name, + StackName: adapter.Nickname, + Version: adapter.Version, + } + resp.List = append(resp.List, a) + } + + return resp, nil +} diff --git a/internal/logic/ai/getcenteroverviewlogic.go b/internal/logic/ai/getcenteroverviewlogic.go new file mode 100644 index 00000000..d4aecdb9 --- /dev/null +++ b/internal/logic/ai/getcenteroverviewlogic.go @@ -0,0 +1,164 @@ +package ai + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "strconv" + "sync" + "time" +) + +type GetCenterOverviewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterOverviewLogic { + return &GetCenterOverviewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterOverviewLogic) GetCenterOverview() (resp *types.CenterOverviewResp, err error) { + resp = &types.CenterOverviewResp{} + var mu sync.RWMutex + ch := make(chan struct{}) + + var centerNum int32 + var taskNum int32 + var cardNum int32 + var totalTops float64 + + adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") + if err != nil { + return nil, err + } + centerNum = int32(len(adapterList)) + resp.CenterNum = centerNum + + go l.updateClusterResource(&mu, ch, adapterList) + + for _, adapter := range adapterList { + taskList, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByAdapterId(adapter.Id) + if err != nil { + continue + } + taskNum += int32(len(taskList)) + } + resp.TaskNum = taskNum + + for _, adapter := range adapterList { + clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) + if err != nil { + continue + } + for _, cluster := range clusters.List { + mu.RLock() + clusterResource, err := l.svcCtx.Scheduler.AiStorages.GetClusterResourcesById(cluster.Id) + mu.RUnlock() + + if err != nil { + continue + } + cardNum += int32(clusterResource.CardTotal) + totalTops += clusterResource.CardTopsTotal + } + } + resp.CardNum = cardNum + resp.PowerInTops = totalTops + + select { + case _ = <-ch: + return resp, nil + case <-time.After(1 * time.Second): + return resp, nil + } +} + +func (l *GetCenterOverviewLogic) updateClusterResource(mu *sync.RWMutex, ch chan<- struct{}, list []*types.AdapterInfo) { + var wg sync.WaitGroup + for _, adapter := range list { + clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) + if err != nil { + continue + } + for _, cluster := range clusters.List { + c := cluster + mu.RLock() + clusterResource, err := l.svcCtx.Scheduler.AiStorages.GetClusterResourcesById(c.Id) + mu.RUnlock() + if err != nil { + continue + } + wg.Add(1) + go func() { + _, ok := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id] + if !ok { + wg.Done() + return + } + stat, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][c.Id].GetResourceStats(l.ctx) + if err != nil { + wg.Done() + return + } + if stat == nil { + wg.Done() + return + } + clusterType, err := strconv.ParseInt(adapter.Type, 10, 64) + if err != nil { + wg.Done() + return + } + var cardTotal int64 + var topsTotal float64 + for _, card := range stat.CardsAvail { + cardTotal += int64(card.CardNum) + topsTotal += card.TOpsAtFp16 * float64(card.CardNum) + } + + mu.Lock() + if (models.TClusterResource{} == *clusterResource) { + err = l.svcCtx.Scheduler.AiStorages.SaveClusterResources(adapter.Id, c.Id, c.Name, clusterType, float64(stat.CpuCoreAvail), float64(stat.CpuCoreTotal), + stat.MemAvail, stat.MemTotal, stat.DiskAvail, stat.DiskTotal, float64(stat.GpuAvail), float64(stat.GpuTotal), cardTotal, topsTotal) + if err != nil { + mu.Unlock() + wg.Done() + return + } + } else { + if stat.CpuCoreTotal == 0 || stat.MemTotal == 0 || stat.DiskTotal == 0 { + wg.Done() + return + } + clusterResource.CardTotal = cardTotal + clusterResource.CardTopsTotal = topsTotal + clusterResource.CpuAvail = float64(stat.CpuCoreAvail) + clusterResource.CpuTotal = float64(stat.CpuCoreTotal) + clusterResource.MemAvail = stat.MemAvail + clusterResource.MemTotal = stat.MemTotal + clusterResource.DiskAvail = stat.DiskAvail + clusterResource.DiskTotal = stat.DiskTotal + + err := l.svcCtx.Scheduler.AiStorages.UpdateClusterResources(clusterResource) + if err != nil { + mu.Unlock() + wg.Done() + return + } + } + mu.Unlock() + wg.Done() + }() + } + } + wg.Wait() + ch <- struct{}{} +} diff --git a/internal/logic/ai/getcenterqueueinglogic.go b/internal/logic/ai/getcenterqueueinglogic.go new file mode 100644 index 00000000..d0408a57 --- /dev/null +++ b/internal/logic/ai/getcenterqueueinglogic.go @@ -0,0 +1,73 @@ +package ai + +import ( + "context" + "sort" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCenterQueueingLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterQueueingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterQueueingLogic { + return &GetCenterQueueingLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterQueueingLogic) GetCenterQueueing() (resp *types.CenterQueueingResp, err error) { + resp = &types.CenterQueueingResp{} + + adapters, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") + if err != nil { + return nil, err + } + + for _, adapter := range adapters { + clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id) + if err != nil { + continue + } + for _, cluster := range clusters.List { + queues, err := l.svcCtx.Scheduler.AiStorages.GetClusterTaskQueues(adapter.Id, cluster.Id) + if err != nil { + continue + } + if queues == nil { + continue + } + //todo sync current task queues + current := &types.CenterQueue{ + Name: cluster.Name, + QueueingNum: int32(queues[0].QueueNum), + } + history := &types.CenterQueue{ + Name: cluster.Name, + QueueingNum: int32(queues[0].QueueNum), + } + resp.Current = append(resp.Current, current) + resp.History = append(resp.History, history) + + } + } + + sortQueueingNum(resp.Current) + sortQueueingNum(resp.History) + + return resp, nil +} + +func sortQueueingNum(q []*types.CenterQueue) { + sort.Slice(q, func(i, j int) bool { + return q[i].QueueingNum > q[j].QueueingNum + }) +} diff --git a/internal/logic/ai/getcentertasklistlogic.go b/internal/logic/ai/getcentertasklistlogic.go new file mode 100644 index 00000000..90e3e497 --- /dev/null +++ b/internal/logic/ai/getcentertasklistlogic.go @@ -0,0 +1,136 @@ +package ai + +import ( + "context" + "errors" + "fmt" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "strconv" + "sync" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCenterTaskListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCenterTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCenterTaskListLogic { + return &GetCenterTaskListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCenterTaskListLogic) GetCenterTaskList() (resp *types.CenterTaskListResp, err error) { + resp = &types.CenterTaskListResp{} + var mu sync.RWMutex + ch := make(chan struct{}) + + adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1") + if err != nil { + return nil, err + } + + go l.updateAiTaskStatus(&mu, ch, adapterList) + + for _, adapter := range adapterList { + mu.RLock() + taskList, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByAdapterId(adapter.Id) + mu.RUnlock() + if err != nil { + continue + } + if len(taskList) == 0 { + continue + } + for _, task := range taskList { + var elapsed time.Duration + switch task.Status { + case constants.Completed: + end, err := time.ParseInLocation(constants.Layout, task.EndTime, time.Local) + if err != nil { + elapsed = time.Duration(0) + } + start, err := time.ParseInLocation(constants.Layout, task.StartTime, time.Local) + if err != nil { + elapsed = time.Duration(0) + } + elapsed = end.Sub(start) + case constants.Running: + elapsed = time.Now().Sub(task.CommitTime) + default: + elapsed = 0 + } + + t := &types.AiTask{ + Name: task.Name, + Status: task.Status, + Cluster: task.ClusterName, + Card: task.Card, + TimeElapsed: int32(elapsed.Seconds()), + } + resp.List = append(resp.List, t) + } + } + + select { + case _ = <-ch: + return resp, nil + case <-time.After(2 * time.Second): + return resp, nil + } +} + +func (l *GetCenterTaskListLogic) updateAiTaskStatus(mu *sync.RWMutex, ch chan<- struct{}, list []*types.AdapterInfo) { + var wg sync.WaitGroup + for _, adapter := range list { + taskList, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByAdapterId(adapter.Id) + if err != nil { + continue + } + if len(taskList) == 0 { + continue + } + for _, task := range taskList { + t := task + if t.Status == constants.Completed || task.Status == constants.Failed || task.Status == constants.Stopped { + continue + } + wg.Add(1) + go func() { + trainingTask, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[adapter.Id][strconv.FormatInt(t.ClusterId, 10)].GetTrainingTask(l.ctx, t.JobId) + if err != nil { + msg := fmt.Sprintf("AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) + logx.Errorf(errors.New(msg).Error()) + wg.Done() + return + } + if trainingTask == nil { + wg.Done() + return + } + t.Status = trainingTask.Status + t.StartTime = trainingTask.Start + t.EndTime = trainingTask.End + mu.Lock() + err = l.svcCtx.Scheduler.AiStorages.UpdateAiTask(t) + mu.Unlock() + if err != nil { + wg.Done() + return + } + wg.Done() + }() + } + } + wg.Wait() + ch <- struct{}{} +} diff --git a/internal/logic/ai/getexporttasksofdatasetlogic.go b/internal/logic/ai/getexporttasksofdatasetlogic.go new file mode 100644 index 00000000..6451c84a --- /dev/null +++ b/internal/logic/ai/getexporttasksofdatasetlogic.go @@ -0,0 +1,60 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetExportTasksOfDatasetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetExportTasksOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTasksOfDatasetLogic { + return &GetExportTasksOfDatasetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetExportTasksOfDatasetLogic) GetExportTasksOfDataset(req *types.GetExportTasksOfDatasetReq) (resp *types.GetExportTasksOfDatasetResp, err error) { + modelartsReq := &modelarts.GetExportTasksOfDatasetReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + GetExportTasksOfDatasetResp, err := l.svcCtx.ModelArtsRpc.GetExportTasksOfDataset(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&GetExportTasksOfDatasetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &GetExportTasksOfDatasetResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/getexporttaskstatusofdatasetlogic.go b/internal/logic/ai/getexporttaskstatusofdatasetlogic.go new file mode 100644 index 00000000..b5eae3b9 --- /dev/null +++ b/internal/logic/ai/getexporttaskstatusofdatasetlogic.go @@ -0,0 +1,59 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetExportTaskStatusOfDatasetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetExportTaskStatusOfDatasetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExportTaskStatusOfDatasetLogic { + return &GetExportTaskStatusOfDatasetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetExportTaskStatusOfDatasetLogic) GetExportTaskStatusOfDataset(req *types.GetExportTaskStatusOfDatasetReq) (resp *types.GetExportTaskStatusOfDatasetResp, err error) { + modelartsReq := &modelarts.GetExportTaskStatusOfDatasetReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + GetExportTaskStatusOfDatasetResp, err := l.svcCtx.ModelArtsRpc.GetExportTaskStatusOfDataset(l.ctx, modelartsReq) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&GetExportTaskStatusOfDatasetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &GetExportTaskStatusOfDatasetResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/getlisttrainingjobslogic.go b/internal/logic/ai/getlisttrainingjobslogic.go new file mode 100644 index 00000000..39594638 --- /dev/null +++ b/internal/logic/ai/getlisttrainingjobslogic.go @@ -0,0 +1,104 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetListTrainingJobsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetListTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetListTrainingJobsLogic { + return &GetListTrainingJobsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetListTrainingJobsLogic) GetListTrainingJobs(req *types.ListTrainingJobsreq) (resp *types.ListTrainingJobsresp, err error) { + modelartsReq := &modelarts.ListTrainingJobsreq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetListTrainingJobs(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&listDataSetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: utils.Converters}) + return resp, nil + /* modelartsType := req.ModelartsType + switch modelartsType { + case "octops": + octopusReq := &octopus.GetTrainJobListReq{} + err = copier.CopyWithOption(octopusReq, req, copier.Option{Converters: utils.Converters}) + listTrainJobResp, err := l.svcCtx.OctopusRpc.GetTrainJobList(l.ctx, octopusReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db TrainJobs list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&listTrainJobResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &listTrainJobResp, copier.Option{Converters: utils.Converters}) + case "cn-north-4.myhuawei": + modelartsReq := &modelarts.ListTrainingJobsreq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetListTrainingJobs(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db TrainJobs list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&listDataSetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: utils.Converters}) + case "cn-east-293.njaci": + modelartsReq := &modelarts.ListTrainingJobsreq{} + + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetListTrainingJobs(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db TrainJobs list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&listDataSetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: utils.Converters}) + }*/ + +} diff --git a/internal/logic/ai/getnotebookstoragelogic.go b/internal/logic/ai/getnotebookstoragelogic.go new file mode 100644 index 00000000..9c14b574 --- /dev/null +++ b/internal/logic/ai/getnotebookstoragelogic.go @@ -0,0 +1,44 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetNotebookStorageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNotebookStorageLogic { + return &GetNotebookStorageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetNotebookStorageLogic) GetNotebookStorage(req *types.GetNotebookStorageReq) (resp *types.GetNotebookStorageResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/ai/getvisualizationjoblogic.go b/internal/logic/ai/getvisualizationjoblogic.go new file mode 100644 index 00000000..6de4c4fb --- /dev/null +++ b/internal/logic/ai/getvisualizationjoblogic.go @@ -0,0 +1,44 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetVisualizationJobLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetVisualizationJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVisualizationJobLogic { + return &GetVisualizationJobLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetVisualizationJobLogic) GetVisualizationJob(req *types.GetVisualizationJobReq) (resp *types.GetVisualizationJobResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/ai/listalgorithmslogic.go b/internal/logic/ai/listalgorithmslogic.go new file mode 100644 index 00000000..dfce47ff --- /dev/null +++ b/internal/logic/ai/listalgorithmslogic.go @@ -0,0 +1,59 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListAlgorithmsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAlgorithmsLogic { + return &ListAlgorithmsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListAlgorithmsLogic) ListAlgorithms(req *types.ListAlgorithmsReq) (resp *types.ListAlgorithmsResp, err error) { + modelartsReq := &modelarts.ListAlgorithmsReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: false, DeepCopy: true, Converters: utils.Converters}) + ListAlgorithmsResp, err := l.svcCtx.ModelArtsRpc.ListAlgorithms(l.ctx, modelartsReq) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&ListAlgorithmsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListAlgorithmsResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/listclusterslogic.go b/internal/logic/ai/listclusterslogic.go new file mode 100644 index 00000000..e9a0600b --- /dev/null +++ b/internal/logic/ai/listclusterslogic.go @@ -0,0 +1,56 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListClustersLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListClustersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClustersLogic { + return &ListClustersLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListClustersLogic) ListClusters(req *types.ListClustersReq) (resp *types.ListClustersResp, err error) { + // todo: add your logic here and delete this line + modelartsReq := &modelarts.ListClustersReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + ListClustersResp, err := l.svcCtx.ModelArtsRpc.ListClusters(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + resp = &types.ListClustersResp{} + err = copier.CopyWithOption(&resp, &ListClustersResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/listdatasetlogic.go b/internal/logic/ai/listdatasetlogic.go new file mode 100644 index 00000000..8c488dff --- /dev/null +++ b/internal/logic/ai/listdatasetlogic.go @@ -0,0 +1,63 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListDataSetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDataSetLogic { + return &ListDataSetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListDataSetLogic) ListDataSet(req *types.DataSetReq) (resp *types.DataSetResp, err error) { + // todo: add your logic here and delete this line + modelartsReq := &modelarts.DataSetReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + //err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + DataSetResp, err := l.svcCtx.ModelArtsRpc.GetDatasetList(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DataSetResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DataSetResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/listimportlogic.go b/internal/logic/ai/listimportlogic.go new file mode 100644 index 00000000..a77d8857 --- /dev/null +++ b/internal/logic/ai/listimportlogic.go @@ -0,0 +1,55 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListImportLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListImportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListImportLogic { + return &ListImportLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListImportLogic) ListImport(req *types.ListImportTasksReq) (resp *types.ListImportTasksResp, err error) { + modelartsReq := &modelarts.ListImportTasksReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetImportTaskList(l.ctx, modelartsReq) + marshal, err := json.Marshal(&listDataSetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/listnotebooklogic.go b/internal/logic/ai/listnotebooklogic.go new file mode 100644 index 00000000..b02c181d --- /dev/null +++ b/internal/logic/ai/listnotebooklogic.go @@ -0,0 +1,57 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListNotebookLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNotebookLogic { + return &ListNotebookLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListNotebookLogic) ListNotebook(req *types.ListNotebookReq) (resp *types.ListNotebookResp, err error) { + modelartsReq := &modelarts.ListNotebookReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + + listNotebookResp, err := l.svcCtx.ModelArtsRpc.ListNotebook(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get notebook list"), "Failed to get notebook list err : %v ,req:%+v", err, req) + } + + resp = &types.ListNotebookResp{} + err = copier.CopyWithOption(resp, listNotebookResp, copier.Option{Converters: utils.Converters}) + + return resp, nil +} diff --git a/internal/logic/ai/listserviceslogic.go b/internal/logic/ai/listserviceslogic.go new file mode 100644 index 00000000..fad59484 --- /dev/null +++ b/internal/logic/ai/listserviceslogic.go @@ -0,0 +1,58 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListServicesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListServicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServicesLogic { + return &ListServicesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListServicesLogic) ListServices(req *types.ListServicesReq) (resp *types.ListServicesResp, err error) { + modelartsReq := &modelarts.ListServicesReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + ListServicesResp, err := l.svcCtx.ModelArtsRpc.ListServices(l.ctx, modelartsReq) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&ListServicesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListServicesResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/mountnotebookstoragelogic.go b/internal/logic/ai/mountnotebookstoragelogic.go new file mode 100644 index 00000000..a7436ae7 --- /dev/null +++ b/internal/logic/ai/mountnotebookstoragelogic.go @@ -0,0 +1,44 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type MountNotebookStorageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewMountNotebookStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MountNotebookStorageLogic { + return &MountNotebookStorageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *MountNotebookStorageLogic) MountNotebookStorage(req *types.MountNotebookStorageReq) (resp *types.MountNotebookStorageResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/ai/proxyapilogic.go b/internal/logic/ai/proxyapilogic.go new file mode 100644 index 00000000..64e27fb8 --- /dev/null +++ b/internal/logic/ai/proxyapilogic.go @@ -0,0 +1,91 @@ +package ai + +import ( + "bytes" + "context" + "crypto/tls" + "encoding/json" + "github.com/go-resty/resty/v2" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/hws" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ProxyApiLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewProxyApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProxyApiLogic { + return &ProxyApiLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +const ( + XProjectID = "d18190e28e3f45a281ef0b0696ec9d52" + XStage = "RELEASE" + ContentType = "application/json" +) + +func (l *ProxyApiLogic) ProxyApi(req *types.ChatReq) (resp *types.ChatResult, err error) { + logx.Infof("【开始处理请求,目标URL: %s】", req.ApiUrl) + + jsonBytes, err := json.Marshal(&req.ReqData) + if err != nil { + logx.Errorf("【序列化请求数据失败: %v】", err) + return nil, errors.New("请求数据序列化失败") + } + + resp = &types.ChatResult{} + + // 构建 HTTP 请求 + request, err := http.NewRequest("POST", req.ApiUrl, bytes.NewBuffer(jsonBytes)) + if err != nil { + logx.Errorf("【构建 HTTP 请求失败: %v】", err) + return nil, errors.New("网络错误,请稍后重试") + } + + signer := &hws.Signer{ + Key: "UNEHPHO4Z7YSNPKRXFE4", + Secret: "JWXCE9qcYbc7RjpSRIWt4WgG3ZKF6Q4lPzkJReX9", + } + + if err := signer.Sign(request); err != nil { + logx.Errorf("【接口签名错误: %v】", err) + return nil, errors.New("网络错误,请稍后重试") + } + + client := resty.New().SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) + + response, err := client.R(). + SetHeader("X-Project-Id", XProjectID). + SetHeader("x-stage", XStage). + SetHeader("Content-Type", ContentType). + SetHeader("Authorization", request.Header.Get(hws.HeaderXAuthorization)). + SetHeader("X-Sdk-Date", request.Header.Get(hws.HeaderXDateTime)). + SetBody(jsonBytes). + SetResult(&resp). + Post(req.ApiUrl) + + if err != nil { + logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", req.ApiUrl, err.Error()) + return nil, errors.New("网络错误,请稍后重试") + } + + if response.StatusCode() != 200 { + logx.Errorf("【远程调用接口URL:%s, 返回错误: %s】", req.ApiUrl, response.Body()) + return nil, errors.New("网络错误,请稍后重试") + } + + logx.Infof("【请求处理成功,目标URL: %s】", req.ApiUrl) + return resp, nil +} diff --git a/internal/logic/ai/showalgorithmbyuuidlogic.go b/internal/logic/ai/showalgorithmbyuuidlogic.go new file mode 100644 index 00000000..910b7632 --- /dev/null +++ b/internal/logic/ai/showalgorithmbyuuidlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowAlgorithmByUuidLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowAlgorithmByUuidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowAlgorithmByUuidLogic { + return &ShowAlgorithmByUuidLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowAlgorithmByUuidLogic) ShowAlgorithmByUuid(req *types.ShowAlgorithmByUuidReq) (resp *types.ShowAlgorithmByUuidResp, err error) { + + modelartsReq := &modelarts.ShowAlgorithmByUuidReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + ShowAlgorithmByUuidResp, err := l.svcCtx.ModelArtsRpc.ShowAlgorithmByUuid(l.ctx, modelartsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowAlgorithmByUuidResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowAlgorithmByUuidResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/showservicelogic.go b/internal/logic/ai/showservicelogic.go new file mode 100644 index 00000000..cdcfeba3 --- /dev/null +++ b/internal/logic/ai/showservicelogic.go @@ -0,0 +1,59 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + "github.com/jinzhu/copier" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowServiceLogic { + return &ShowServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowServiceLogic) ShowService(req *types.ShowServiceReq) (resp *types.ShowServiceResp, err error) { + modelartsReq := &modelarts.ShowServiceReq{} + err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters}) + ShowServiceResp, err := l.svcCtx.ModelArtsRpc.ShowService(l.ctx, modelartsReq) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + marshal, err := json.Marshal(&ShowServiceResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowServiceResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/ai/startnotebooklogic.go b/internal/logic/ai/startnotebooklogic.go new file mode 100644 index 00000000..940f3345 --- /dev/null +++ b/internal/logic/ai/startnotebooklogic.go @@ -0,0 +1,44 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type StartNotebookLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewStartNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartNotebookLogic { + return &StartNotebookLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *StartNotebookLogic) StartNotebook(req *types.StartNotebookReq) (resp *types.StartNotebookResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/ai/stopnotebooklogic.go b/internal/logic/ai/stopnotebooklogic.go new file mode 100644 index 00000000..fecfe874 --- /dev/null +++ b/internal/logic/ai/stopnotebooklogic.go @@ -0,0 +1,44 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package ai + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type StopNotebookLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewStopNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopNotebookLogic { + return &StopNotebookLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *StopNotebookLogic) StopNotebook(req *types.StopNotebookReq) (resp *types.StopNotebookResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/cloud/cloudlistlogic.go b/internal/logic/cloud/cloudlistlogic.go new file mode 100644 index 00000000..bc01ddfe --- /dev/null +++ b/internal/logic/cloud/cloudlistlogic.go @@ -0,0 +1,50 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package cloud + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" +) + +type CloudListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCloudListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CloudListLogic { + return &CloudListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CloudListLogic) CloudList() (resp *types.CloudListResp, err error) { + // 查询数据库中数算任务列表 + var clouds []*models.Cloud + tx := l.svcCtx.DbEngin.Find(&clouds) + if tx.Error != nil { + return nil, tx.Error + } + result := types.CloudListResp{} + utils.Convert(clouds, &result.Clouds) + return &result, nil +} diff --git a/internal/logic/cloud/clusterinfologic.go b/internal/logic/cloud/clusterinfologic.go new file mode 100644 index 00000000..c926d8e5 --- /dev/null +++ b/internal/logic/cloud/clusterinfologic.go @@ -0,0 +1,30 @@ +package cloud + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ClusterInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewClusterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterInfoLogic { + return &ClusterInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ClusterInfoLogic) ClusterInfo(req *types.ClusterInfoReq) (resp *types.ClusterInfoResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/cloud/commitgeneraltasklogic.go b/internal/logic/cloud/commitgeneraltasklogic.go new file mode 100644 index 00000000..0a101cea --- /dev/null +++ b/internal/logic/cloud/commitgeneraltasklogic.go @@ -0,0 +1,168 @@ +package cloud + +import ( + "bytes" + "context" + "github.com/pkg/errors" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "io" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + syaml "k8s.io/apimachinery/pkg/runtime/serializer/yaml" + kyaml "k8s.io/apimachinery/pkg/util/yaml" + "strconv" + "strings" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CommitGeneralTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCommitGeneralTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitGeneralTaskLogic { + return &CommitGeneralTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) error { + tx := l.svcCtx.DbEngin.Begin() + // 执行回滚或者提交操作 + defer func() { + if p := recover(); p != nil { + tx.Rollback() + logx.Error(p) + } else if tx.Error != nil { + logx.Info("rollback, error", tx.Error) + tx.Rollback() + } else { + tx = tx.Commit() + logx.Info("commit success") + } + }() + //TODO adapter + adapterId, _ := strconv.ParseUint(req.AdapterIds[0], 10, 64) + var clusters []*models.CloudModel + err := tx.Raw("SELECT * FROM `t_cluster` where adapter_id in ? and id in ?", req.AdapterIds, req.ClusterIds).Scan(&clusters).Error + if err != nil { + logx.Errorf("CommitGeneralTask() => sql execution error: %v", err) + return errors.Errorf("the cluster does not match the drive resources. Check the data") + } + taskCloud := cloud.TaskCloudModel{} + opt := &option.CloudOption{} + utils.Convert(&req, &opt) + sc, _ := schedulers.NewCloudScheduler(l.ctx, "", l.svcCtx.Scheduler, opt, tx, l.svcCtx.PromClient) + + results, err := l.svcCtx.Scheduler.AssignAndSchedule(sc) + if err != nil { + logx.Errorf("AssignAndSchedule() => execution error: %v", err) + return err + } + + rs := (results).([]*schedulers.CloudResult) + + var synergyStatus int64 + if len(rs) > 1 { + synergyStatus = 1 + } + var strategy int64 + sqlStr := `select t_dict_item.item_value + from t_dict + left join t_dict_item on t_dict.id = t_dict_item.dict_id + where item_text = ? + and t_dict.dict_code = 'schedule_Strategy'` + //查询调度策略 + err = tx.Raw(sqlStr, req.Strategy).Scan(&strategy).Error + taskModel := models.Task{ + Id: utils.GenSnowflakeID(), + Status: constants.Saved, + Name: req.Name, + CommitTime: time.Now(), + YamlString: strings.Join(req.ReqBody, "\n---\n"), + AdapterTypeDict: "0", + SynergyStatus: synergyStatus, + Strategy: strategy, + } + var taskClouds []cloud.TaskCloudModel + adapterName := "" + tx.Table("t_adapter").Select("name").Where("id=?", adapterId).Find(&adapterName) + for _, r := range rs { + for _, s := range req.ReqBody { + sStruct := UnMarshalK8sStruct(s, int64(r.Replica)) + unString, _ := sStruct.MarshalJSON() + taskCloud.Id = utils.GenSnowflakeIDUint() + taskCloud.Name = sStruct.GetName() + "-" + sStruct.GetKind() + taskCloud.TaskId = uint(taskModel.Id) + clusterId, _ := strconv.ParseUint(r.ClusterId, 10, 64) + taskCloud.AdapterId = uint(adapterId) + taskCloud.AdapterName = adapterName + taskCloud.ClusterId = uint(clusterId) + taskCloud.ClusterName = r.ClusterName + taskCloud.Status = constants.Saved + taskCloud.YamlString = string(unString) + taskCloud.Kind = sStruct.GetKind() + taskCloud.Namespace = sStruct.GetNamespace() + taskClouds = append(taskClouds, taskCloud) + } + } + noticeInfo := clientCore.NoticeInfo{ + AdapterId: int64(adapterId), + AdapterName: adapterName, + NoticeType: "create", + TaskName: req.Name, + Incident: "任务创建中", + CreatedTime: time.Now(), + } + 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") + } + return nil +} + +func UnMarshalK8sStruct(yamlString string, replica int64) *unstructured.Unstructured { + unstructuredObj := &unstructured.Unstructured{} + d := kyaml.NewYAMLOrJSONDecoder(bytes.NewBufferString(yamlString), 4096) + var err error + for { + var rawObj runtime.RawExtension + err = d.Decode(&rawObj) + if err == io.EOF { + break + } + obj := &unstructured.Unstructured{} + syaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme).Decode(rawObj.Raw, nil, obj) + unstructuredMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) + if err != nil { + logx.Errorf("UnMarshalK8sStruct() => Execution failure err:%v", err) + } + unstructuredObj = &unstructured.Unstructured{Object: unstructuredMap} + // 命名空间为空 设置默认值 + if len(unstructuredObj.GetNamespace()) == 0 { + unstructuredObj.SetNamespace("default") + } + //设置副本数 + if unstructuredObj.GetKind() == "Deployment" || unstructuredObj.GetKind() == "StatefulSet" { + unstructured.SetNestedField(unstructuredObj.Object, replica, "spec", "replicas") + } + } + return unstructuredObj +} diff --git a/internal/logic/cloud/controllermetricslogic.go b/internal/logic/cloud/controllermetricslogic.go new file mode 100644 index 00000000..46ba3791 --- /dev/null +++ b/internal/logic/cloud/controllermetricslogic.go @@ -0,0 +1,46 @@ +package cloud + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + "time" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ControllerMetricsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewControllerMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ControllerMetricsLogic { + return &ControllerMetricsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ControllerMetricsLogic) ControllerMetrics(req *types.ControllerMetricsReq) (resp *types.ControllerMetricsResp, err error) { + resp = &types.ControllerMetricsResp{} + if _, ok := l.svcCtx.MonitorClient[req.ParticipantId]; ok { + if len(req.Pod) != 0 { + resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.PodOption{ + PodName: req.Pod, + }) + } else { + + resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.ControllerOption{ + WorkloadName: req.WorkloadName, + }) + } + } else { + return nil, error2.NewCodeError(400, "prometheus endpoint invalid!") + } + + return resp, nil +} diff --git a/internal/logic/cloud/deleteclusterlogic.go b/internal/logic/cloud/deleteclusterlogic.go new file mode 100644 index 00000000..10fdfe0b --- /dev/null +++ b/internal/logic/cloud/deleteclusterlogic.go @@ -0,0 +1,37 @@ +package cloud + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClusterLogic { + return &DeleteClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteClusterLogic) DeleteCluster(req *types.DeleteClusterReq) (*types.CloudResp, error) { + // 删除集群信息 + var resp types.CloudResp + tx := l.svcCtx.DbEngin.Where("name = ?", req.Name).Delete(&models.ScParticipantPhyInfo{}) + if tx.Error != nil { + return nil, tx.Error + } + resp.Code = string(200) + resp.Msg = "success" + resp.Data = "" + return &resp, nil +} diff --git a/internal/logic/cloud/deleteyamllogic.go b/internal/logic/cloud/deleteyamllogic.go new file mode 100644 index 00000000..7ce39fcc --- /dev/null +++ b/internal/logic/cloud/deleteyamllogic.go @@ -0,0 +1,44 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package cloud + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteYamlLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteYamlLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteYamlLogic { + return &DeleteYamlLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteYamlLogic) DeleteYaml(req *types.ApplyReq) (resp *types.DeleteResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/cloud/getclusterlistlogic.go b/internal/logic/cloud/getclusterlistlogic.go new file mode 100644 index 00000000..2743f0f7 --- /dev/null +++ b/internal/logic/cloud/getclusterlistlogic.go @@ -0,0 +1,30 @@ +package cloud + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetClusterListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterListLogic { + return &GetClusterListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetClusterListLogic) GetClusterList(req *types.GetClusterListReq) (resp *types.GetClusterListResp, err error) { + resp = &types.GetClusterListResp{} + //clusters := []models.ScParticipantPhyInfo{} + l.svcCtx.DbEngin.Find(resp.Clusters).Where("id", req.Id) + return resp, nil +} diff --git a/internal/logic/cloud/listcloudclusterlogic.go b/internal/logic/cloud/listcloudclusterlogic.go new file mode 100644 index 00000000..78cd78d1 --- /dev/null +++ b/internal/logic/cloud/listcloudclusterlogic.go @@ -0,0 +1,30 @@ +package cloud + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListCloudClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListCloudClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListCloudClusterLogic { + return &ListCloudClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListCloudClusterLogic) ListCloudCluster(req *types.ListClusterReq) (resp *types.CloudListResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/cloud/podlogslogic.go b/internal/logic/cloud/podlogslogic.go new file mode 100644 index 00000000..918e38b2 --- /dev/null +++ b/internal/logic/cloud/podlogslogic.go @@ -0,0 +1,30 @@ +package cloud + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "net/http" +) + +type PodLogsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext + w http.ResponseWriter +} + +func NewPodLogsLogic(ctx context.Context, svcCtx *svc.ServiceContext, w http.ResponseWriter) *PodLogsLogic { + return &PodLogsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + w: w, + } +} + +func (l *PodLogsLogic) PodLogs(req *types.PodLogsReq, w http.ResponseWriter) (resp string, err error) { + // todo: add your logic here and delete this line + return +} diff --git a/internal/logic/cloud/registerclusterlogic.go b/internal/logic/cloud/registerclusterlogic.go new file mode 100644 index 00000000..930017ca --- /dev/null +++ b/internal/logic/cloud/registerclusterlogic.go @@ -0,0 +1,68 @@ +package cloud + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "strconv" + + "github.com/zeromicro/go-zero/core/logx" +) + +type RegisterClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewRegisterClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterClusterLogic { + return &RegisterClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (*types.CloudResp, error) { + var phyInfos []models.ScParticipantPhyInfo + var resp types.CloudResp + + l.svcCtx.DbEngin.Raw("select * from sc_participant_phy_info where `name` = ?", req.Name).Scan(&phyInfos) + if len(phyInfos) != 0 { + resp.Code = "400" + resp.Msg = "cluster name already exist" + resp.Data = "" + return &resp, nil + } + + participant := models.ScParticipantPhyInfo{ + Token: req.Token, + Name: req.Name, + Address: req.Address, + Type: "CLOUD", + Id: utils.GenSnowflakeID(), + MetricsUrl: req.MetricsUrl, + } + tx := l.svcCtx.DbEngin.Create(&participant) + if tx.Error != nil { + return nil, tx.Error + } + + labelInfo := models.ScParticipantLabelInfo{ + Id: utils.GenSnowflakeID(), + ParticipantId: participant.Id, + Key: "cloud", + Value: "sealos", + } + tx2 := l.svcCtx.DbEngin.Create(&labelInfo) + if tx2.Error != nil { + return nil, tx.Error + } + + resp.Code = string(200) + resp.Msg = "success" + resp.Data = "participantId:" + strconv.FormatInt(participant.Id, 10) + return &resp, nil +} diff --git a/internal/logic/core/centerresourceslogic.go b/internal/logic/core/centerresourceslogic.go new file mode 100644 index 00000000..29471a08 --- /dev/null +++ b/internal/logic/core/centerresourceslogic.go @@ -0,0 +1,73 @@ +package core + +import ( + "context" + "github.com/prometheus/common/model" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + "strconv" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CenterResourcesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCenterResourcesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CenterResourcesLogic { + return &CenterResourcesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CenterResourcesLogic) CenterResources() (resp *types.CenterResourcesResp, err error) { + resp = &types.CenterResourcesResp{} + rawData, err := l.svcCtx.PromClient.GetRawData("center_top3", tracker.AdapterOption{}) + if err != nil { + return nil, err + } + var centersIndex []*types.CenterIndex + data := rawData.(model.Vector) + for _, d := range data { + for _, v := range d.Metric { + num, err := strconv.ParseInt(string(v), 10, 64) + if err != nil { + return nil, err + } + centersIndex = append(centersIndex, &types.CenterIndex{Id: num}) + } + } + for _, centerIndex := range centersIndex { + // Query the types of resource centers + l.svcCtx.DbEngin.Raw("select name,type as CenterType from t_adapter where id = ?", centerIndex.Id).Scan(¢erIndex) + var clustersName string + l.svcCtx.DbEngin.Raw("SELECT GROUP_CONCAT(name SEPARATOR '|' ) as clustersName from t_cluster where adapter_id = ?", centerIndex.Id).Scan(&clustersName) + cpuRawData, err := l.svcCtx.PromClient.GetRawData("center_cpu_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName}) + cpuData := cpuRawData.(model.Vector) + if err != nil { + return nil, err + } + centerIndex.Cpu = cpuData[0].Value.String() + memoryRawData, err := l.svcCtx.PromClient.GetRawData("center_memory_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName}) + if err != nil { + return nil, err + } + memoryData := memoryRawData.(model.Vector) + + centerIndex.Memory = memoryData[0].Value.String() + diskRawData, err := l.svcCtx.PromClient.GetRawData("center_disk_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName}) + if err != nil { + return nil, err + } + diskData := diskRawData.(model.Vector) + centerIndex.Storage = diskData[0].Value.String() + resp.CentersIndex = append(resp.CentersIndex, *centerIndex) + } + return resp, nil +} diff --git a/internal/logic/core/committasklogic.go b/internal/logic/core/committasklogic.go new file mode 100644 index 00000000..1e373277 --- /dev/null +++ b/internal/logic/core/committasklogic.go @@ -0,0 +1,66 @@ +package core + +import ( + "context" + "github.com/ghodss/yaml" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/mqs" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/response" + "strings" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CommitTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCommitTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitTaskLogic { + return &CommitTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CommitTaskLogic) CommitTask(req *types.CommitTaskReq) error { + //req.YamlList转换为json + var yamlStr []string + for _, s := range req.YamlList { + j2, err := yaml.YAMLToJSON([]byte(s)) + if err != nil { + logx.Errorf("Failed to convert yaml to JSON, err: %v", err) + return err + } + yamlStr = append(yamlStr, string(j2)) + } + result := strings.Join(yamlStr, ",") + taskModel := models.Task{ + Status: constants.Saved, + Name: req.Name, + CommitTime: time.Now(), + NsID: req.NsID, + YamlString: "[" + result + "]", + } + // 保存任务数据到数据库 + tx := l.svcCtx.DbEngin.Create(&taskModel) + if tx.Error != nil { + return tx.Error + } + task := response.TaskInfo{ + TaskId: taskModel.Id, + MatchLabels: req.MatchLabels, + NsID: req.NsID, + Metadata: req.YamlList, + Replicas: req.Replicas, + } + mqs.InsQueue.Beta.Add(&task) + return nil +} diff --git a/internal/logic/core/commitvmtasklogic.go b/internal/logic/core/commitvmtasklogic.go new file mode 100644 index 00000000..7e79514b --- /dev/null +++ b/internal/logic/core/commitvmtasklogic.go @@ -0,0 +1,170 @@ +package core + +import ( + "context" + "fmt" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "strconv" + "time" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CommitVmTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCommitVmTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitVmTaskLogic { + return &CommitVmTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *types.CommitVmTaskResp, err error) { + // todo: add your logic here and delete this line + resp = &types.CommitVmTaskResp{} + tx := l.svcCtx.DbEngin.Begin() + var adaptersName string + var clusterName string + //Building the main task structure + defer func() { + if p := recover(); p != nil { + tx.Rollback() + logx.Error(p) + } else if tx.Error != nil { + logx.Info("rollback, error", tx.Error) + tx.Rollback() + } else { + tx = tx.Commit() + logx.Info("commit success") + } + }() + //TODO adapter + adapterId, _ := strconv.ParseUint(req.AdapterIds[0], 10, 64) + taskVm := models.TaskVm{} + //TODO 执行策略返回集群跟 Replica + opt := &option.VmOption{} + utils.Convert(&req, &opt) + // 2、Initialize scheduler + vmSchdl, _ := schedulers.NewVmScheduler(l.ctx, "", l.svcCtx.Scheduler, opt, l.svcCtx.DbEngin, l.svcCtx.PromClient) + if err != nil { + return nil, err + } + // 3、Return scheduling results + results, err := l.svcCtx.Scheduler.AssignAndSchedule(vmSchdl) + if err != nil { + logx.Errorf("AssignAndSchedule() => execution error: %v", err) + return nil, err + } + rs := (results).([]*schedulers.VmResult) + var synergyStatus int64 + if len(rs) > 1 { + synergyStatus = 1 + } + var strategy int64 + sqlStr := `select t_dict_item.item_value + from t_dict + left join t_dict_item on t_dict.id = t_dict_item.dict_id + where item_text = ? + and t_dict.dict_code = 'schedule_Strategy'` + //查询调度策略 + err = tx.Raw(sqlStr, req.Strategy).Scan(&strategy).Error + taskModel := models.Task{ + Id: utils.GenSnowflakeID(), + Status: constants.Saved, + Name: req.Name, + CommitTime: time.Now(), + Description: "vm task", + AdapterTypeDict: "0", + SynergyStatus: synergyStatus, + Strategy: strategy, + } + //var taskVms models.TaskVm + var VmObject types.TaskVm + for _, r := range rs { + for _, clusterId := range req.ClusterIds { + if r.Replica > 0 && r.ClusterId == clusterId { + fmt.Println("", clusterId) + sql := `SELECT vi.image_id as image,vf.flavor_id as flavor,vn.network_id as uuid,vi.cluster_name as platform FROM + vm_flavor vf + LEFT JOIN vm_image vi ON vf.cluster_id = vi.cluster_id + LEFT JOIN vm_network vn ON vf.cluster_id = vn.cluster_id + WHERE + vi.cluster_id = ? + AND vf.public_flavor_id = ? + AND vi.public_image_id = ? + AND vn.public_network_id = ?` + txVm := l.svcCtx.DbEngin.Raw(sql, clusterId, req.FlavorRef, req.ImageRef, req.Uuid).Scan(&VmObject) + if txVm.Error != nil { + logx.Error(err) + return nil, txVm.Error + } + /* if err2 != nil { + logx.Errorf("CommitGeneralTask() => sql execution error: %v", err) + //return errors.Errorf("the cluster does not match the drive resources. Check the data"), nil + }*/ + taskVm.Name = req.Name + taskVm.TaskId = taskModel.Id + taskVm.Status = "Saved" + taskVm.StartTime = time.Now().String() + taskVm.MinCount = req.MinCount + taskVm.ImageRef = VmObject.Image + taskVm.FlavorRef = VmObject.Flavor + taskVm.Uuid = VmObject.Uuid + taskVm.Platform = VmObject.Platform + taskVm.AdapterId = int64(adapterId) + l.svcCtx.DbEngin.Raw("select name from t_adapter where id= ?", int64(adapterId)).Scan(&adaptersName) + taskVm.AdapterName = adaptersName + l.svcCtx.DbEngin.Raw("select name from t_cluster where id= ?", r.ClusterId).Scan(&clusterName) + taskVm.ClusterName = clusterName + taskVm.ClusterId, err = strconv.ParseInt(clusterId, 10, 64) + taskVm.VmName = req.VmName + taskVm.Replicas = req.Replicas + if err != nil { + fmt.Println("Error converting string to int64:", err) + return + } + tx = l.svcCtx.DbEngin.Create(&taskVm) + if tx.Error != nil { + return nil, tx.Error + } + } + } + } + adapterName := "" + tx.Table("t_adapter").Select("name").Where("id=?", adapterId).Find(&adapterName) + noticeInfo := clientCore.NoticeInfo{ + AdapterId: int64(adapterId), + AdapterName: adapterName, + NoticeType: "create", + TaskName: req.Name, + Incident: "任务创建中", + CreatedTime: time.Now(), + } + // Save task data to database + + tf := l.svcCtx.DbEngin.Create(&taskModel) + if tf.Error != nil { + return nil, tf.Error + } + result := l.svcCtx.DbEngin.Table("task_vm").Create(&taskVm) + result = l.svcCtx.DbEngin.Table("t_notice").Create(¬iceInfo) + if result.Error != nil { + logx.Errorf("Task creation failure, err: %v", result.Error) + } + + resp.Code = 200 + resp.Msg = "Success" + return resp, nil +} diff --git a/internal/logic/core/counttaskstatuslogic.go b/internal/logic/core/counttaskstatuslogic.go new file mode 100644 index 00000000..e0c5fd69 --- /dev/null +++ b/internal/logic/core/counttaskstatuslogic.go @@ -0,0 +1,41 @@ +package core + +import ( + "context" + "github.com/pkg/errors" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CountTaskStatusLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCountTaskStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CountTaskStatusLogic { + return &CountTaskStatusLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CountTaskStatusLogic) CountTaskStatus() (resp *types.TaskStatusResp, err error) { + resp = &types.TaskStatusResp{} + sqlStr := `SELECT + COUNT(CASE WHEN status = 'Succeeded' THEN 1 END) AS Succeeded, + COUNT(CASE WHEN status = 'Failed' THEN 1 END) AS Failed, + COUNT(CASE WHEN status = 'Running' THEN 1 END) AS Running, + COUNT(CASE WHEN status = 'Saved' THEN 1 END) AS Saved + FROM task;` + err = l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp).Error + if err != nil { + logx.Errorf("CountTaskStatus() => sql execution error: %v", err) + return nil, errors.Errorf("Description Failed to collect statistics on the status of a task. Please try again later") + } + return +} diff --git a/internal/logic/core/deletetasklogic.go b/internal/logic/core/deletetasklogic.go new file mode 100644 index 00000000..f5ca4be0 --- /dev/null +++ b/internal/logic/core/deletetasklogic.go @@ -0,0 +1,56 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTaskLogic { + return &DeleteTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteTaskLogic) DeleteTask(req *types.DeleteTaskReq) error { + // 删除主任务信息 + l.svcCtx.DbEngin.Model(&models.Task{}).Where("id", req.Id).Update("status", "Deleted") + tx := l.svcCtx.DbEngin.Delete(&models.Task{}, req.Id) + if tx.Error != nil { + return tx.Error + } + // 将子任务状态修改为待删除 + tx = l.svcCtx.DbEngin.Model(&models.Cloud{}).Where("task_id", req.Id).Update("status", constants.WaitDelete) + l.svcCtx.DbEngin.Where("task_id = ?", req.Id).Delete(&models.Cloud{}, req.Id) + if tx.Error != nil { + return tx.Error + } + return nil +} diff --git a/internal/logic/core/getcomputilitystatisticslogic.go b/internal/logic/core/getcomputilitystatisticslogic.go new file mode 100644 index 00000000..48811f86 --- /dev/null +++ b/internal/logic/core/getcomputilitystatisticslogic.go @@ -0,0 +1,117 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "fmt" + "strconv" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/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/internal/logic/core/getcomputingpowerlogic.go b/internal/logic/core/getcomputingpowerlogic.go new file mode 100644 index 00000000..37a26f33 --- /dev/null +++ b/internal/logic/core/getcomputingpowerlogic.go @@ -0,0 +1,107 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" + "log" +) + +type GetComputingPowerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetComputingPowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputingPowerLogic { + return &GetComputingPowerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +type client struct { +} + +func (c *client) getComputingPower(cp computingPower, l *GetComputingPowerLogic) float32 { + return cp.GetComputing(l) +} + +type OctopusComputingPower struct { +} + +type AcComputingPower struct { +} + +type computingPower interface { + GetComputing(l *GetComputingPowerLogic) float32 +} + +// 启智章鱼资源算力 +func (cp OctopusComputingPower) GetComputing(l *GetComputingPowerLogic) float32 { + octopusCpReq := &octopus.ResourceReq{} + octopusCpResp, err := l.svcCtx.OctopusRpc.GetComputingPower(l.ctx, octopusCpReq) + if err != nil { + log.Println("OctopusRpc 算力请求失败", err) + } + return octopusCpResp.POpsAtFp16 +} + +// 曙光账号算力 +func (cp AcComputingPower) GetComputing(l *GetComputingPowerLogic) float32 { + acCpReq := &hpcAC.ResourceReq{} + acCpResp, err := l.svcCtx.ACRpc.GetComputingPower(l.ctx, acCpReq) + if err != nil { + log.Println("ACRpc 算力请求失败", err) + } + return acCpResp.POpsAtFp16 +} + +func (l *GetComputingPowerLogic) GetComputingPower() (resp *types.CpResp, err error) { + + apiResp := types.CpResp{} + + c := client{} + ot := OctopusComputingPower{} + ac := AcComputingPower{} + a := c.getComputingPower(ot, l) + b := c.getComputingPower(ac, l) + + apiResp.POpsAtFp16 = a + b + ////启智章鱼资源算力 + //octopusCpReq := &octopus.ResourceReq{} + //octopusCpResp, err := l.svcCtx.OctopusRpc.GetComputingPower(l.ctx, octopusCpReq) + //if err != nil { + // log.Println("OctopusRpc 算力请求失败", err) + //} + // + ////曙光账号算力 + //acCpReq := &hpcAC.ResourceReq{} + //acCpResp, err := l.svcCtx.ACRpc.GetComputingPower(l.ctx, acCpReq) + //if err != nil { + // log.Println("ACRpc 算力请求失败", err) + //} + // + //computingPowerAggregated := acCpResp.POpsAtFp16 + octopusCpResp.POpsAtFp16 + //apiResp.POpsAtFp16 = computingPowerAggregated + + return &apiResp, nil +} diff --git a/internal/logic/core/getdomainresourcelogic.go b/internal/logic/core/getdomainresourcelogic.go new file mode 100644 index 00000000..ce960339 --- /dev/null +++ b/internal/logic/core/getdomainresourcelogic.go @@ -0,0 +1,31 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetDomainResourceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetDomainResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDomainResourceLogic { + return &GetDomainResourceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetDomainResourceLogic) GetDomainResource() (resp *types.DomainResourceResp, err error) { + resp = &types.DomainResourceResp{} + l.svcCtx.DbEngin.Raw("select * from screen_domain where delete_flag = 0").Scan(&resp.DomainResourceList) + return resp, nil + +} diff --git a/internal/logic/core/getgeneralinfologic.go b/internal/logic/core/getgeneralinfologic.go new file mode 100644 index 00000000..938f1f00 --- /dev/null +++ b/internal/logic/core/getgeneralinfologic.go @@ -0,0 +1,67 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" + "log" +) + +type GetGeneralInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetGeneralInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGeneralInfoLogic { + return &GetGeneralInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetGeneralInfoLogic) GetGeneralInfo() (resp *types.GiResp, err error) { + apiResp := types.GiResp{} + + //启智章鱼资源统计 + octopusGiReq := &octopus.ResourceReq{} + octopusGiResp, err := l.svcCtx.OctopusRpc.GetGeneralInfo(l.ctx, octopusGiReq) + if err != nil { + log.Println("OctopusRpc 资源请求失败", err) + } + + //曙光账号资源统计 + acGiReq := &hpcAC.ResourceReq{} + acGiResp, err := l.svcCtx.ACRpc.GetGeneralInfo(l.ctx, acGiReq) + if err != nil { + log.Println("ACRpc 资源请求失败", err) + } + + cpu := octopusGiResp.CpuCoreNum + acGiResp.CpuCoreNum + storage := acGiResp.StorageInGib + mem := octopusGiResp.MemoryInGib + acGiResp.MemoryInGib + + apiResp.StorageInGib = storage + apiResp.CpuNum = cpu + apiResp.MemoryInGib = mem + + return &apiResp, nil +} diff --git a/internal/logic/core/getpublicflavorlogic.go b/internal/logic/core/getpublicflavorlogic.go new file mode 100644 index 00000000..9dd8880f --- /dev/null +++ b/internal/logic/core/getpublicflavorlogic.go @@ -0,0 +1,40 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetPublicFlavorLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetPublicFlavorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicFlavorLogic { + return &GetPublicFlavorLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetPublicFlavorLogic) GetPublicFlavor(req *types.PublicFlavorReq) (resp *types.PublicFlavorResp, err error) { + // todo: add your logic here and delete this line + resp = &types.PublicFlavorResp{} + var flavorDict []types.FlavorDict + sqlStrTask := "SELECT * FROM `vm_flavor_dict`" + txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&flavorDict) + if txTask.Error != nil { + logx.Error(err) + return nil, txTask.Error + } + resp.Code = 200 + resp.Message = "success" + resp.FlavorDict = flavorDict + return resp, nil +} diff --git a/internal/logic/core/getpublicimagelogic.go b/internal/logic/core/getpublicimagelogic.go new file mode 100644 index 00000000..fad02090 --- /dev/null +++ b/internal/logic/core/getpublicimagelogic.go @@ -0,0 +1,40 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetPublicImageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetPublicImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicImageLogic { + return &GetPublicImageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetPublicImageLogic) GetPublicImage(req *types.PublicImageReq) (resp *types.PublicImageResp, err error) { + // todo: add your logic here and delete this line + resp = &types.PublicImageResp{} + var iamgeDict []types.ImageDict + sqlStrTask := "SELECT * FROM `vm_image_dict`" + txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&iamgeDict) + if txTask.Error != nil { + logx.Error(err) + return nil, txTask.Error + } + resp.Code = 200 + resp.Message = "success" + resp.ImageDict = iamgeDict + return resp, nil +} diff --git a/internal/logic/core/getpublicnetworklogic.go b/internal/logic/core/getpublicnetworklogic.go new file mode 100644 index 00000000..8ba60214 --- /dev/null +++ b/internal/logic/core/getpublicnetworklogic.go @@ -0,0 +1,39 @@ +package core + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetPublicNetworkLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetPublicNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPublicNetworkLogic { + return &GetPublicNetworkLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetPublicNetworkLogic) GetPublicNetwork(req *types.PublicNetworkReq) (resp *types.PublicNetworkResp, err error) { + // todo: add your logic here and delete this line + resp = &types.PublicNetworkResp{} + var networkDict []types.NetworkDict + sqlStrTask := "SELECT * FROM `vm_network_dict`" + txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&networkDict) + if txTask.Error != nil { + logx.Error(err) + return nil, txTask.Error + } + resp.Code = 200 + resp.Message = "success" + resp.NetworkDict = networkDict + return resp, nil +} diff --git a/internal/logic/core/getregionlogic.go b/internal/logic/core/getregionlogic.go new file mode 100644 index 00000000..dd218e3c --- /dev/null +++ b/internal/logic/core/getregionlogic.go @@ -0,0 +1,55 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetRegionLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetRegionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRegionLogic { + return &GetRegionLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetRegionLogic) GetRegion() (resp *types.GetRegionResp, err error) { + resp = &types.GetRegionResp{} + var regionSlurmArray []models.RegionSlurm + regionNameDb := l.svcCtx.DbEngin.Find(®ionSlurmArray).Not("RegionName = ?", "") + softStackDb := l.svcCtx.DbEngin.Find(®ionSlurmArray).Not("SoftStack = ?", "") + resp = &types.GetRegionResp{ + Code: 200, + Msg: "Success", + Data: types.RegionNum{ + RegionSum: regionNameDb.RowsAffected, + SoftStackSum: softStackDb.RowsAffected, + }, + } + return resp, err +} diff --git a/internal/logic/core/getresourcepanelconfiglogic.go b/internal/logic/core/getresourcepanelconfiglogic.go new file mode 100644 index 00000000..5b1d6632 --- /dev/null +++ b/internal/logic/core/getresourcepanelconfiglogic.go @@ -0,0 +1,45 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" +) + +type GetResourcePanelConfigLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetResourcePanelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetResourcePanelConfigLogic { + return &GetResourcePanelConfigLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetResourcePanelConfigLogic) GetResourcePanelConfig() (resp *types.ResourcePanelConfigResp, err error) { + rpcModel := models.ResourcePanelConfig{} + l.svcCtx.DbEngin.Find(&rpcModel) + utils.Convert(rpcModel, &resp) + return resp, nil +} diff --git a/internal/logic/core/getscreenchartlogic.go b/internal/logic/core/getscreenchartlogic.go new file mode 100644 index 00000000..ddf6b501 --- /dev/null +++ b/internal/logic/core/getscreenchartlogic.go @@ -0,0 +1,33 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetScreenChartLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetScreenChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenChartLogic { + return &GetScreenChartLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetScreenChartLogic) GetScreenChart() (resp *types.ScreenChartResp, err error) { + resp = &types.ScreenChartResp{} + l.svcCtx.DbEngin.Raw("select cpu_avg from screen_chart").Scan(&resp.CpuAvg) + l.svcCtx.DbEngin.Raw("select cpu_load from screen_chart").Scan(&resp.CpuLoad) + l.svcCtx.DbEngin.Raw("select memory_avg from screen_chart").Scan(&resp.MemoryAvg) + l.svcCtx.DbEngin.Raw("select memory_load from screen_chart").Scan(&resp.MemoryLoad) + return +} diff --git a/internal/logic/core/getscreeninfologic.go b/internal/logic/core/getscreeninfologic.go new file mode 100644 index 00000000..f4119972 --- /dev/null +++ b/internal/logic/core/getscreeninfologic.go @@ -0,0 +1,30 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetScreenInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetScreenInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenInfoLogic { + return &GetScreenInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetScreenInfoLogic) GetScreenInfo() (resp *types.ScreenInfoResp, err error) { + resp = &types.ScreenInfoResp{} + l.svcCtx.DbEngin.Raw("select * from screen").Scan(resp) + return +} diff --git a/internal/logic/core/homeoverviewlogic.go b/internal/logic/core/homeoverviewlogic.go new file mode 100644 index 00000000..3767d28f --- /dev/null +++ b/internal/logic/core/homeoverviewlogic.go @@ -0,0 +1,73 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type HomeOverviewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewHomeOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HomeOverviewLogic { + return &HomeOverviewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *HomeOverviewLogic) HomeOverview(req *types.HomeOverviewReq) (resp *types.HomeOverviewResp, err error) { + // todo: add your logic here and delete this line + resp = &types.HomeOverviewResp{} + var AdapterSum int // + var StorageSum float32 // + var ClusterSum int // + var TaskSum int // + //Task + sqlStrTask := "SELECT COUNT(*) FROM `task`" + txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&TaskSum) + if txTask.Error != nil { + logx.Error(err) + return nil, txTask.Error + } + + //Storage + sqlStrStorage := "SELECT SUM(t.storage_space) as storageSum FROM `t_storage_device` t" + txStorage := l.svcCtx.DbEngin.Raw(sqlStrStorage).Scan(&StorageSum) + if txTask.Error != nil { + logx.Error(err) + return nil, txStorage.Error + } + + //Cluster + sqlStrCluster := "SELECT COUNT(*) FROM `t_cluster`" + txCluster := l.svcCtx.DbEngin.Raw(sqlStrCluster).Scan(&ClusterSum) + if txTask.Error != nil { + logx.Error(err) + return nil, txCluster.Error + } + + //Adapter + sqlStrAdapter := "SELECT COUNT(*) FROM `t_adapter`" + txAdapter := l.svcCtx.DbEngin.Raw(sqlStrAdapter).Scan(&AdapterSum) + if txTask.Error != nil { + logx.Error(err) + return nil, txAdapter.Error + } + + resp.Data.TaskSum = int64(TaskSum) + resp.Data.StorageSum = StorageSum + resp.Data.AdaptSum = int64(AdapterSum) + resp.Data.ClusterSum = int64(ClusterSum) + + resp.Code = 200 + resp.Message = "Success" + return resp, nil +} diff --git a/internal/logic/core/jobtotallogic.go b/internal/logic/core/jobtotallogic.go new file mode 100644 index 00000000..58aceace --- /dev/null +++ b/internal/logic/core/jobtotallogic.go @@ -0,0 +1,114 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/enum" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" + "k8s.io/apimachinery/pkg/util/json" +) + +type JobTotalLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +type Job struct { + TotalSize int `json:"totalSize"` + OtJobs []OtJob `json:"otJobs"` +} + +type OtJob struct { + Name string `json:"name"` + Status string `json:"status"` + Tasks []Task `json:"tasks"` +} + +type Task struct { + CenterName []string `json:"centerName"` +} + +func NewJobTotalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobTotalLogic { + return &JobTotalLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *JobTotalLogic) JobTotal() (resp *types.JobTotalResp, err error) { + // 获取任务时间信息 + resp = &types.JobTotalResp{} + bytes, err := httputils.HttpGet("GET", "http://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/alljobinfo") + if err != nil { + return nil, err + } + json.Unmarshal(bytes, resp) + + // 获取其他任务信息 + jobs := &Job{} + jobBytes, err := httputils.HttpGet("GET", "http://grampus.openi.org.cn/openapi/v1/sharescreen/trainjob?pageIndex=1&pageSize=10") + if err != nil { + return nil, err + } + json.Unmarshal(jobBytes, jobs) + + for _, job := range jobs.OtJobs { + trainJob := types.TrainJob{ + Name: job.Name, + Status: enum.ExternalStatus(job.Status).String(), + Strategy: 0, + SynergyStatus: "未协同", + } + if job.Tasks[0].CenterName != nil { + trainJob.ParticipantName = job.Tasks[0].CenterName[0] + } + resp.TrainJobs = append(resp.TrainJobs, trainJob) + } + + var tasks []models.Task + tx := l.svcCtx.DbEngin.Find(&tasks) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + if len(tasks) == 0 { + return nil, nil + } + for _, task := range tasks { + var participantName string + tx := l.svcCtx.DbEngin.Raw("SELECT name from sc_participant_phy_info where id in (SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.participant_id) ,GROUP_CONCAT(DISTINCT a.participant_id) ,GROUP_CONCAT(DISTINCT c.participant_id))as service_name from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?)", task.Id).Scan(&participantName) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + // 承接方转义 + resp.TrainJobs = append(resp.TrainJobs, types.TrainJob{ + ParticipantName: participantName, + Name: task.Name, + Strategy: int(task.Strategy), + SynergyStatus: enum.SynergyStatus(task.SynergyStatus).String(), + Status: task.Status, + }) + + } + return resp, nil +} diff --git a/internal/logic/core/listcenterlogic.go b/internal/logic/core/listcenterlogic.go new file mode 100644 index 00000000..6dd03dbc --- /dev/null +++ b/internal/logic/core/listcenterlogic.go @@ -0,0 +1,100 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" +) + +type ListCenterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListCenterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListCenterLogic { + return &ListCenterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListCenterLogic) ListCenter() (*types.ListCenterResp, error) { + var centers []types.Center + var centersModel *[]models.CenterOverview + + //var centersModel []models.ComputeCenter + var resp types.ListCenterResp + + l.svcCtx.DbEngin.Raw("select cc.*, ac.cluster_num, ac.node_num, ac.cpu_num, ac.gpu_num, ac.managed_flops, ac.unmanaged_flops, ac.managed_storage, ac.unmanaged_storage, hc.cluster_num, c.node_num, hc.cpu_num, hc.gpu_num, hc.managed_flops, hc.unmanaged_flops, hc.managed_storage, hc.unmanaged_storage, c.cluster_num, c.node_num, c.cpu_num, c.gpu_num, c.managed_flops, c.unmanaged_flops, c.managed_storage, c.unmanaged_storage, ct.edwc, ct.ydyl\nfrom compute_center cc\nleft join ai_center ac on cc.id = ac.id\nleft join hpc_center hc on cc.id = hc.id\nleft join cloud_center c on cc.id = c.id\nleft join center_tag ct on cc.id = ct.id").Scan(¢ersModel) + + var centerModelV = *centersModel + + for _, overview := range centerModelV { + var center types.Center + center.Id = overview.Id.Int64 + center.CenterSource = overview.CenterSource.String + center.SourceId = overview.SourceId.String + center.Name = overview.Name.String + center.Description = overview.Description.String + center.Type = overview.Type.String + center.Area = overview.Area.String + center.City = overview.City.String + center.Longitude = overview.Longitude.Float64 + center.Latitude = overview.Latitude.Float64 + center.Status = overview.Status.String + center.UserNum = overview.UserNum.Int64 + center.CloudClusterNum = overview.CloudClusterNum.Int64 + center.AiClusterNum = overview.AiClusterNum.Int64 + center.HpcClusterNum = overview.HpcClusterNum.Int64 + center.CloudNodeNum = overview.CloudNodeNum.Int64 + center.AiNodeNum = overview.AiNodeNum.Int64 + center.HpcNodeNum = overview.HpcNodeNum.Int64 + center.CloudCpuNum = overview.CloudCpuNum.Int64 + center.AiCpuNum = overview.AiCpuNum.Int64 + center.HpcCpuNum = overview.HpcCpuNum.Int64 + center.CloudGpuNum = overview.CloudGpuNum.Int64 + center.AiGpuNum = overview.AiGpuNum.Int64 + center.HpcGpuNum = overview.HpcGpuNum.Int64 + center.CloudMngFlops = overview.CloudMngFlops.Int64 + center.AiMngFlops = overview.AiMngFlops.Int64 + center.HpcMngFlops = overview.HpcMngFlops.Int64 + center.CloudUmngFlops = overview.CloudUmngFlops.Int64 + center.AiUmngFlops = overview.AiUmngFlops.Int64 + center.HpcUmngFlops = overview.HpcUmngFlops.Int64 + center.CloudMngStorage = overview.CloudMngStorage.Int64 + center.AiMngStorage = overview.AiMngStorage.Int64 + center.HpcMngStorage = overview.HpcMngStorage.Int64 + center.CloudUmngStorage = overview.CloudUmngStorage.Int64 + center.AiUmngStorage = overview.AiUmngStorage.Int64 + center.HpcUmngStorage = overview.HpcUmngStorage.Int64 + center.Edwc = overview.Edwc.Bool + center.Ydyl = overview.Ydyl.Bool + center.HubCode = overview.HubCode.Int64 + center.DeletedFlag = overview.DeletedFlag.Int64 + centers = append(centers, center) + } + + resp.Code = 200 + resp.Msg = "success" + resp.Data.TotalCount = len(centers) + resp.Data.Centers = centers + return &resp, nil +} diff --git a/internal/logic/core/listclusterlogic.go b/internal/logic/core/listclusterlogic.go new file mode 100644 index 00000000..bd336b58 --- /dev/null +++ b/internal/logic/core/listclusterlogic.go @@ -0,0 +1,76 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" +) + +type ListClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClusterLogic { + return &ListClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListClusterLogic) ListCluster(req *types.ListClusterReq) (*types.ListClusterResp, error) { + + var clusters []types.ComputeCluster + var clustersModel *[]models.ComputeCluster + + //var centersModel []models.ComputeCenter + var resp types.ListClusterResp + + l.svcCtx.DbEngin.Raw("select * from compute_cluster where center_id = ?", req.CenterId).Scan(&clustersModel) + + if clustersModel == nil { + resp.Code = 200 + resp.Msg = "success" + resp.Data.TotalCount = 0 + return &resp, nil + } + var clustersModelV = *clustersModel + + for _, clusterModel := range clustersModelV { + var cluster types.ComputeCluster + cluster.Id = clusterModel.Id + cluster.Name = clusterModel.Name.String + cluster.Type = clusterModel.Type.String + cluster.JcceDomainId = clusterModel.JcceDomainId.Int64 + cluster.JcceDomainName = clusterModel.JcceDomainName.String + cluster.Longitude = clusterModel.Longitude.Float64 + cluster.Latitude = clusterModel.Latitude.Float64 + cluster.Description = clusterModel.Description.String + clusters = append(clusters, cluster) + } + + resp.Code = 200 + resp.Msg = "success" + resp.Data.TotalCount = len(clusters) + resp.Data.Clusters = clusters + return &resp, nil + +} diff --git a/internal/logic/core/listnoticelogic.go b/internal/logic/core/listnoticelogic.go new file mode 100644 index 00000000..be6e6061 --- /dev/null +++ b/internal/logic/core/listnoticelogic.go @@ -0,0 +1,36 @@ +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +type ListNoticeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNoticeLogic { + return &ListNoticeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListNoticeLogic) ListNotice(req *clientCore.ListNoticeReq) (*clientCore.ListNoticeResp, error) { + var notices []clientCore.NoticeInfo + + var resp clientCore.ListNoticeResp + + l.svcCtx.DbEngin.Raw("select * from t_notice order by created_time desc").Scan(¬ices) + for _, notice := range notices { + resp.Data = append(resp.Data, notice) + } + resp.Code = 200 + resp.Msg = "success" + return &resp, nil +} diff --git a/internal/logic/core/listregionlogic.go b/internal/logic/core/listregionlogic.go new file mode 100644 index 00000000..0087d75b --- /dev/null +++ b/internal/logic/core/listregionlogic.go @@ -0,0 +1,68 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" +) + +type ListRegionLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListRegionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListRegionLogic { + return &ListRegionLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListRegionLogic) ListRegion() (resp *types.ListRegionResp, err error) { + // todo: add your logic here and delete this line + var regionSlurmArray []models.RegionSlurm + var regions []types.Region + var jobCount int64 + var regionResult []types.Region + l.svcCtx.DbEngin.Find(®ionSlurmArray) + utils.Convert(regionSlurmArray, ®ions) + // 查询超算上的job todo + for _, region := range regions { + if region.RegionName == "Changsha HPC Center" { + l.svcCtx.DbEngin.Raw("select count(*) from task t join hpc h on t.id = h.task_id and t.status != 'Completed' and h.service_name = 'th'").Scan(&jobCount) + region.RunningJobs = jobCount + } + if region.RegionName == "Zhijiang HPC Center" { + l.svcCtx.DbEngin.Raw("select count(*) from task t join hpc h on t.id = h.task_id and t.status != 'Completed' and h.service_name = 'ac'").Scan(&jobCount) + region.RunningJobs = jobCount + } + regionResult = append(regionResult, region) + + } + + resp = &types.ListRegionResp{ + Code: 200, + Msg: "Success", + Data: regionResult, + } + return +} diff --git a/internal/logic/core/metricslogic.go b/internal/logic/core/metricslogic.go new file mode 100644 index 00000000..1dd30c8b --- /dev/null +++ b/internal/logic/core/metricslogic.go @@ -0,0 +1,28 @@ +package core + +import ( + "context" + + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +type MetricsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MetricsLogic { + return &MetricsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *MetricsLogic) Metrics() error { + // todo: add your logic here and delete this line + + return nil +} diff --git a/internal/logic/core/nodeassetslogic.go b/internal/logic/core/nodeassetslogic.go new file mode 100644 index 00000000..f6d50405 --- /dev/null +++ b/internal/logic/core/nodeassetslogic.go @@ -0,0 +1,49 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type NodeAssetsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewNodeAssetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NodeAssetsLogic { + return &NodeAssetsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *NodeAssetsLogic) NodeAssets() (resp *types.NodeAssetsResp, err error) { + // 查询数据库系节点动态资源信息 + + nodeResp := types.NodeAssetsResp{} + tx := l.svcCtx.DbEngin.Raw("SELECT ppi.`name`,nai.* FROM sc_node_avail_info nai left join sc_participant_phy_info ppi on ppi.id = nai.participant_id WHERE nai.id IN ( SELECT MAX( id ) FROM sc_node_avail_info WHERE deleted_flag = 0 GROUP BY participant_id, node_name) ").Scan(&nodeResp.NodeAssets) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + return &nodeResp, nil +} diff --git a/internal/logic/core/pagelisttasklogic.go b/internal/logic/core/pagelisttasklogic.go new file mode 100644 index 00000000..6b5bfbc8 --- /dev/null +++ b/internal/logic/core/pagelisttasklogic.go @@ -0,0 +1,75 @@ +package core + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/status" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils" + "time" + + "github.com/zeromicro/go-zero/core/logx" +) + +type PageListTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPageListTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PageListTaskLogic { + return &PageListTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PageListTaskLogic) PageListTask(req *types.PageTaskReq) (resp *types.PageResult, err error) { + limit := req.PageSize + offset := req.PageSize * (req.PageNum - 1) + resp = &types.PageResult{} + var list []*types.TaskModel + db := l.svcCtx.DbEngin.Model(&types.TaskModel{}).Table("task") + + db = db.Where("deleted_at is null") + if req.Name != "" { + db = db.Where("name LIKE ?", "%"+req.Name+"%") + } + + //count total + var total int64 + err = db.Count(&total).Error + db.Limit(limit).Offset(offset) + + if err != nil { + return resp, err + } + err = db.Order("created_time desc").Find(&list).Error + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + + // 更新智算任务状态 + go status.UpdateTaskStatus(l.svcCtx, list) + go status.UpdateAiTaskStatus(l.svcCtx, list) + + for _, model := range list { + if model.StartTime != "" && model.EndTime == "" { + startTime := timeutils.TimeStringToGoTime(model.StartTime) + model.RunningTime = int64(time.Now().Sub(startTime).Seconds()) + } + if model.StartTime != "" && model.EndTime != "" { + startTime := timeutils.TimeStringToGoTime(model.StartTime) + endTime := timeutils.TimeStringToGoTime(model.EndTime) + model.RunningTime = int64(endTime.Sub(startTime).Seconds()) + } + } + resp.List = &list + resp.PageSize = req.PageSize + resp.PageNum = req.PageNum + resp.Total = total + + return +} diff --git a/internal/logic/core/participantlistlogic.go b/internal/logic/core/participantlistlogic.go new file mode 100644 index 00000000..c7659598 --- /dev/null +++ b/internal/logic/core/participantlistlogic.go @@ -0,0 +1,49 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" +) + +type ParticipantListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewParticipantListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ParticipantListLogic { + return &ParticipantListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ParticipantListLogic) ParticipantList() (resp *types.ParticipantListResp, err error) { + var participants []types.Participant + + tx := l.svcCtx.DbEngin.Raw("SELECT ppi.id,ppi.name,ppi.address,ppi.metrics_url ,ti.tenant_name,(CASE ppi.type WHEN '0' THEN '数算' WHEN '1' THEN '智算' WHEN '2' THEN '超算' ELSE '' END) as type_name from sc_participant_phy_info ppi LEFT JOIN sc_tenant_info ti on ti.id = ppi.tenant_id where ppi.deleted_flag = '0'").Scan(&participants) + if tx.Error != nil { + return nil, tx.Error + } + result := types.ParticipantListResp{} + utils.Convert(participants, &result.Participants) + return &result, nil +} diff --git a/internal/logic/core/pulltaskinfologic.go b/internal/logic/core/pulltaskinfologic.go new file mode 100644 index 00000000..4833e71c --- /dev/null +++ b/internal/logic/core/pulltaskinfologic.go @@ -0,0 +1,95 @@ +package core + +import ( + "context" + "github.com/jinzhu/copier" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +type PullTaskInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPullTaskInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PullTaskInfoLogic { + return &PullTaskInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PullTaskInfoLogic) PullTaskInfo(req *clientCore.PullTaskInfoReq) (*clientCore.PullTaskInfoResp, error) { + resp := clientCore.PullTaskInfoResp{} + + // check the kind of adapter + var kind int32 + l.svcCtx.DbEngin.Raw("select type as kind from `t_adapter` where id = ?", req.AdapterId).Scan(&kind) + // pull task list from database + switch kind { + case 2: + var hpcModelList []models.TaskHpc + err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &hpcModelList) + if err != nil { + return nil, err + } + utils.Convert(hpcModelList, &resp.HpcInfoList) + if len(resp.HpcInfoList) > 0 { + for i, hpcInfo := range hpcModelList { + err := copier.CopyWithOption(resp.HpcInfoList[i], hpcInfo, copier.Option{Converters: utils.Converters}) + if err != nil { + return nil, err + } + var clusterType string + l.svcCtx.DbEngin.Raw("SELECT label FROM `t_cluster` where id = ? ", hpcInfo.ClusterId).Scan(&clusterType) + + resp.HpcInfoList[i].ClusterType = clusterType + } + } + case 0: + var resourceType int32 + l.svcCtx.DbEngin.Raw("select resource_type as resourceType from `t_adapter` where id = ?", req.AdapterId).Scan(&resourceType) + switch resourceType { + case 01: + var cloudModelList []cloud.TaskCloudModel + err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &cloudModelList) + if err != nil { + return nil, err + } + utils.Convert(cloudModelList, &resp.CloudInfoList) + case 02: + var vmModelList []models.TaskVm + err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &vmModelList) + if err != nil { + return nil, err + } + utils.Convert(vmModelList, &resp.VmInfoList) + } + + case 1: + var aiModelList []models.Ai + err := findModelList(req.AdapterId, l.svcCtx.DbEngin, &aiModelList) + if err != nil { + return nil, err + } + utils.Convert(aiModelList, &resp.AiInfoList) + } + return &resp, nil +} + +func findModelList(adapterId int64, dbEngin *gorm.DB, data interface{}) error { + tx := dbEngin.Where("cluster_id in (select id from t_cluster where adapter_id = ?) AND status not in "+ + "('Deleted', 'Succeeded', 'COMPLETED', 'Completed', 'Failed','FAIL','statC','statE')", adapterId).Find(data) + if tx.Error != nil { + return tx.Error + } + return nil +} diff --git a/internal/logic/core/pushnoticelogic.go b/internal/logic/core/pushnoticelogic.go new file mode 100644 index 00000000..521a72fc --- /dev/null +++ b/internal/logic/core/pushnoticelogic.go @@ -0,0 +1,31 @@ +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +type PushNoticeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPushNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushNoticeLogic { + return &PushNoticeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PushNoticeLogic) PushNotice(req *clientCore.PushNoticeReq) (resp *clientCore.PushNoticeResp, err error) { + result := l.svcCtx.DbEngin.Table("t_notice").Create(&req.NoticeInfo) + if result.Error != nil { + return nil, result.Error + } + + return +} diff --git a/internal/logic/core/pushresourceinfologic.go b/internal/logic/core/pushresourceinfologic.go new file mode 100644 index 00000000..e0523c6c --- /dev/null +++ b/internal/logic/core/pushresourceinfologic.go @@ -0,0 +1,28 @@ +package core + +import ( + "context" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +type PushResourceInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPushResourceInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushResourceInfoLogic { + return &PushResourceInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PushResourceInfoLogic) PushResourceInfo(req *clientCore.PushResourceInfoReq) (resp *clientCore.PushResourceInfoResp, err error) { + + return +} diff --git a/internal/logic/core/pushtaskinfologic.go b/internal/logic/core/pushtaskinfologic.go new file mode 100644 index 00000000..bdecf5e3 --- /dev/null +++ b/internal/logic/core/pushtaskinfologic.go @@ -0,0 +1,214 @@ +package core + +import ( + "context" + "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/logx" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gorm.io/gorm" + "strings" + "time" +) + +type PushTaskInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPushTaskInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushTaskInfoLogic { + return &PushTaskInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PushTaskInfoLogic) PushTaskInfo(req *clientCore.PushTaskInfoReq) (*clientCore.PushTaskInfoResp, error) { + resp := clientCore.PushTaskInfoResp{} + var kind int32 + l.svcCtx.DbEngin.Raw("select type as kind from t_adapter where id = ?", req.AdapterId).Scan(&kind) + switch kind { + case 0: + var resourceType int32 + l.svcCtx.DbEngin.Raw("select resource_type as resourceType from `t_adapter` where id = ?", req.AdapterId).Scan(&resourceType) + switch resourceType { + case 01: + for _, cloudInfo := range req.CloudInfoList { + var taskId uint + result := l.svcCtx.DbEngin.Table("task_cloud").Select("task_id").Where("task_id = ?", cloudInfo.TaskId).Find(&taskId) + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + return nil, errors.New("Record does not exist") + } + l.svcCtx.DbEngin.Exec("update task_cloud set status = ?,start_time = ?,result = ? where task_id = ?", + cloudInfo.Status, cloudInfo.StartTime, cloudInfo.Result, cloudInfo.TaskId) + var taskName string + l.svcCtx.DbEngin.Raw("select name as kind from task where id = ?", taskId).Scan(&taskName) + noticeInfo := clientCore.NoticeInfo{ + TaskId: cloudInfo.TaskId, + AdapterId: cloudInfo.AdapterId, + AdapterName: cloudInfo.AdapterName, + ClusterId: cloudInfo.ClusterId, + ClusterName: cloudInfo.ClusterName, + TaskName: taskName, + } + syncTask(l.svcCtx.DbEngin, noticeInfo) + } + case 02: + for _, vmInfo := range req.VmInfoList { + l.svcCtx.DbEngin.Exec("update task_vm set status = ?,start_time = ? where cluster_id = ? and task_id = ? and name = ?", + vmInfo.Status, vmInfo.StartTime, vmInfo.ClusterId, vmInfo.TaskId, vmInfo.Name) + noticeInfo := clientCore.NoticeInfo{ + TaskId: vmInfo.TaskId, + AdapterId: vmInfo.AdapterId, + AdapterName: vmInfo.AdapterName, + ClusterId: vmInfo.ClusterId, + ClusterName: vmInfo.ClusterName, + TaskName: vmInfo.Name, + } + syncTask(l.svcCtx.DbEngin, noticeInfo) + } + } + + case 2: + for _, hpcInfo := range req.HpcInfoList { + l.svcCtx.DbEngin.Exec("update task_hpc set status = ?,start_time = ?,job_id = ? where cluster_id = ? and task_id = ? and name = ?", + hpcInfo.Status, hpcInfo.StartTime, hpcInfo.JobId, hpcInfo.ClusterId, hpcInfo.TaskId, hpcInfo.Name) + noticeInfo := clientCore.NoticeInfo{ + TaskId: hpcInfo.TaskId, + AdapterId: hpcInfo.AdapterId, + AdapterName: hpcInfo.AdapterName, + ClusterId: hpcInfo.ClusterId, + ClusterName: hpcInfo.ClusterName, + TaskName: hpcInfo.Name, + } + syncTask(l.svcCtx.DbEngin, noticeInfo) + } + case 1: + for _, aiInfo := range req.AiInfoList { + l.svcCtx.DbEngin.Exec("update task_ai set status = ?,start_time = ?,project_id = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?", + aiInfo.Status, aiInfo.StartTime, aiInfo.ProjectId, aiInfo.JobId, req.AdapterId, aiInfo.TaskId, aiInfo.Name) + noticeInfo := clientCore.NoticeInfo{ + TaskId: aiInfo.TaskId, + AdapterId: aiInfo.AdapterId, + AdapterName: aiInfo.AdapterName, + ClusterId: aiInfo.ClusterId, + ClusterName: aiInfo.ClusterName, + TaskName: aiInfo.Name, + } + syncTask(l.svcCtx.DbEngin, noticeInfo) + } + } + return &resp, nil +} + +func syncTask(gorm *gorm.DB, noticeInfo clientCore.NoticeInfo) { + + var allStatus string + tx := gorm.Raw("SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.status) ,GROUP_CONCAT(DISTINCT a.status) ,GROUP_CONCAT(DISTINCT c.status))as status from task t left join task_hpc h on t.id = h.task_id left join task_cloud c on t.id = c.task_id left join task_vm v on t.id = v.task_id left join task_ai a on t.id = a.task_id where t.id = ?", noticeInfo.TaskId).Scan(&allStatus) + if tx.Error != nil { + logx.Error(tx.Error) + } + allStatus = strings.ToUpper(allStatus) + for pcmStatus, ProviderStatus := range clientCore.StatusMapping { + for _, originalStatus := range ProviderStatus { + // if Failed type status appears in subTask then update mainTask to Failed + if pcmStatus == "Failed" && strings.Contains(allStatus, originalStatus) { + updateTask(gorm, noticeInfo.TaskId, constants.Failed) + noticeInfo := clientCore.NoticeInfo{ + AdapterId: noticeInfo.AdapterId, + AdapterName: noticeInfo.AdapterName, + ClusterId: noticeInfo.ClusterId, + ClusterName: noticeInfo.ClusterName, + NoticeType: "failed", + TaskName: noticeInfo.TaskName, + Incident: "任务执行失败,请查看日志!", + CreatedTime: time.Now(), + } + gorm.Table("t_notice").Create(¬iceInfo) + return + // no Failed type status in subTask,if Saved type status appears in subTask then update mainTask to Saved + } else if pcmStatus == "Saved" && strings.Contains(allStatus, originalStatus) { + if getTaskStatus(gorm, noticeInfo.TaskId) != "Saved" { + updateTask(gorm, noticeInfo.TaskId, constants.Saved) + noticeInfo := clientCore.NoticeInfo{ + AdapterId: noticeInfo.AdapterId, + AdapterName: noticeInfo.AdapterName, + ClusterId: noticeInfo.ClusterId, + ClusterName: noticeInfo.ClusterName, + NoticeType: "saved", + TaskName: noticeInfo.TaskName, + Incident: "任务已处于队列中!", + CreatedTime: time.Now(), + } + gorm.Table("t_notice").Create(¬iceInfo) + return + } else { + return + } + // no Failed and Saved type status in subTask,if Running type status appears in subTask then update mainTask to Running + } else if pcmStatus == "Running" && strings.Contains(allStatus, originalStatus) { + if getTaskStatus(gorm, noticeInfo.TaskId) != "Running" { + updateTask(gorm, noticeInfo.TaskId, constants.Running) + noticeInfo := clientCore.NoticeInfo{ + AdapterId: noticeInfo.AdapterId, + AdapterName: noticeInfo.AdapterName, + ClusterId: noticeInfo.ClusterId, + ClusterName: noticeInfo.ClusterName, + NoticeType: "running", + TaskName: noticeInfo.TaskName, + Incident: "任务状态切换为运行中!", + CreatedTime: time.Now(), + } + gorm.Table("t_notice").Create(¬iceInfo) + return + } else { + return + } + + // at last, mainTask should be succeeded + } else { + if strings.Contains(allStatus, originalStatus) { + updateTask(gorm, noticeInfo.TaskId, constants.Succeeded) + noticeInfo := clientCore.NoticeInfo{ + AdapterId: noticeInfo.AdapterId, + AdapterName: noticeInfo.AdapterName, + ClusterId: noticeInfo.ClusterId, + ClusterName: noticeInfo.ClusterName, + NoticeType: "succeeded", + TaskName: noticeInfo.TaskName, + Incident: "任务执行完成!", + CreatedTime: time.Now(), + } + gorm.Table("t_notice").Create(¬iceInfo) + return + } + } + } + } +} + +func updateTask(gorm *gorm.DB, taskId int64, status string) { + now := time.Now() + var task models.Task + gorm.Where("id = ? ", taskId).Find(&task) + if task.Status != status { + task.Status = status + if status == constants.Running { + task.StartTime = &now + } + if task.Status == constants.Failed || task.Status == constants.Succeeded { + task.EndTime = &now + } + gorm.Updates(&task) + } +} + +func getTaskStatus(gorm *gorm.DB, taskId int64) (status string) { + var task models.Task + gorm.Where("id = ? ", taskId).Find(&task) + return task.Status +} diff --git a/internal/logic/core/putresourcepanelconfiglogic.go b/internal/logic/core/putresourcepanelconfiglogic.go new file mode 100644 index 00000000..9f1f349a --- /dev/null +++ b/internal/logic/core/putresourcepanelconfiglogic.go @@ -0,0 +1,53 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "time" +) + +type PutResourcePanelConfigLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPutResourcePanelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PutResourcePanelConfigLogic { + return &PutResourcePanelConfigLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PutResourcePanelConfigLogic) PutResourcePanelConfig(req *types.ResourcePanelConfigReq) error { + rpcModel := models.ResourcePanelConfig{} + utils.Convert(req, &rpcModel) + rpcModel.UpdateTime = time.Now() + + update := l.svcCtx.DbEngin.Model(&rpcModel).Updates(rpcModel) + err := update.Error + if err != nil { + logx.WithContext(l.ctx).Errorf("PCM 资源面板数据更新失败 err: %s", err.Error()) + return err + } + return nil +} diff --git a/internal/logic/core/scheduletaskbyyamllogic.go b/internal/logic/core/scheduletaskbyyamllogic.go new file mode 100644 index 00000000..203d5045 --- /dev/null +++ b/internal/logic/core/scheduletaskbyyamllogic.go @@ -0,0 +1,83 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "k8s.io/apimachinery/pkg/util/json" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleTaskByYamlLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleTaskByYamlLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleTaskByYamlLogic { + return &ScheduleTaskByYamlLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleTaskByYamlLogic) ScheduleTaskByYaml(req *types.ScheduleTaskByYamlReq) (resp *types.ScheduleTaskByYamlResp, err error) { + resp = &types.ScheduleTaskByYamlResp{} + bytes, err := json.Marshal(req) + if err != nil { + return nil, err + } + // 构建主任务结构体 + taskModel := models.Task{ + Status: constants.Saved, + Description: req.Description, + Name: req.Name, + YamlString: string(bytes), + CommitTime: time.Now(), + NsID: req.NsID, + } + // 保存任务数据到数据库 + tx := l.svcCtx.DbEngin.Create(&taskModel) + if tx.Error != nil { + return nil, tx.Error + } + + // 遍历子任务放入任务队列中 + for _, task := range req.Tasks { + task.NsID = req.NsID + task.TaskId = taskModel.Id + + // 将任务数据转换成消息体 + reqMessage, err := json.Marshal(task) + if err != nil { + logx.Error(err) + return nil, err + } + publish := l.svcCtx.RedisClient.Publish(context.Background(), task.TaskType, reqMessage) + if publish.Err() != nil { + return nil, publish.Err() + } + } + resp.TaskId = taskModel.Id + return resp, nil +} diff --git a/internal/logic/core/syncclusterloadlogic.go b/internal/logic/core/syncclusterloadlogic.go new file mode 100644 index 00000000..184f213f --- /dev/null +++ b/internal/logic/core/syncclusterloadlogic.go @@ -0,0 +1,35 @@ +package core + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" +) + +type SyncClusterLoadLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewSyncClusterLoadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncClusterLoadLogic { + return &SyncClusterLoadLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *SyncClusterLoadLogic) SyncClusterLoad(req *types.SyncClusterLoadReq) error { + if nil != req.ClusterLoadRecords { + for _, record := range req.ClusterLoadRecords { + var param tracker.ClusterLoadRecord + tool.Convert(record, ¶m) + tracker.SyncClusterLoad(param) + } + } + return nil +} diff --git a/internal/logic/core/taskdetailslogic.go b/internal/logic/core/taskdetailslogic.go new file mode 100644 index 00000000..b2a87830 --- /dev/null +++ b/internal/logic/core/taskdetailslogic.go @@ -0,0 +1,60 @@ +package core + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + + "github.com/zeromicro/go-zero/core/logx" +) + +type TaskDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewTaskDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskDetailsLogic { + return &TaskDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsResp, err error) { + resp = &types.TaskDetailsResp{} + task := &models.Task{} + if errors.Is(l.svcCtx.DbEngin.Where("id", req.Id).First(&task).Error, gorm.ErrRecordNotFound) { + return nil, errors.New("记录不存在") + } + clusterIds := make([]string, 0) + var cList []*types.ClusterInfo + var subList []*types.SubTaskInfo + switch task.AdapterTypeDict { + case "0": + l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", task.Id).Scan(&subList) + if len(subList) <= 0 { + l.svcCtx.DbEngin.Table("task_vm").Where("task_id", task.Id).Find(&subList) + } + case "1": + l.svcCtx.DbEngin.Table("task_ai").Where("task_id", task.Id).Scan(&subList) + case "2": + l.svcCtx.DbEngin.Table("task_hpc").Where("task_id", task.Id).Scan(&subList) + } + for _, sub := range subList { + clusterIds = append(clusterIds, sub.ClusterId) + } + err = l.svcCtx.DbEngin.Table("t_cluster").Where("id in ?", clusterIds).Scan(&cList).Error + if err != nil { + return resp, err + } + utils.Convert(&task, &resp) + resp.ClusterInfos = cList + resp.SubTaskInfos = subList + return +} diff --git a/internal/logic/core/tasklistlogic.go b/internal/logic/core/tasklistlogic.go new file mode 100644 index 00000000..83c04062 --- /dev/null +++ b/internal/logic/core/tasklistlogic.go @@ -0,0 +1,175 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package core + +import ( + "context" + "fmt" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "strconv" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type TaskListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskListLogic { + return &TaskListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *TaskListLogic) TaskList(req *types.TaskListReq) (resp *types.TaskListResp, err error) { + resp = &types.TaskListResp{} + + // 查询任务数据 + var tasks []models.Task + offset := (req.PageNum - 1) * req.PageSize + tx := l.svcCtx.DbEngin.Order("created_time desc").Offset(offset).Limit(req.PageSize).Find(&tasks) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + if len(tasks) == 0 { + return nil, nil + } + + // 更新智算任务状态 + var ch = make(chan struct{}) + go l.updateAitaskStatus(tasks, ch) + + // 查询任务总数 + l.svcCtx.DbEngin.Model(&models.Task{}).Count(&resp.TotalCount) + + // 查询任务异常数 + l.svcCtx.DbEngin.Model(&models.Task{}).Where("status = ?", "Failed").Count(&resp.AlarmCount) + + // 正常任务数 + resp.NormalCount = resp.TotalCount - resp.AlarmCount + for _, task := range tasks { + type PInfo struct { + Id int64 + Name string + Address string + } + pInfo := PInfo{} + tx := l.svcCtx.DbEngin.Raw("SELECT id,name,address from sc_participant_phy_info where id in (SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.participant_id) ,GROUP_CONCAT(DISTINCT a.participant_id) ,GROUP_CONCAT(DISTINCT c.participant_id))as service_name from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?)", task.Id).Scan(&pInfo) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + // 获取p端状态 + pStatus := "Unknown" + key := fmt.Sprintf("ps_%s-%d", pInfo.Address, pInfo.Id) + hGetAll := l.svcCtx.RedisClient.HGetAll(l.ctx, key) + if hGetAll.Err() != nil { + return nil, err + } + if len(hGetAll.Val()) != 0 { + parseInt, err := strconv.ParseInt(hGetAll.Val()["lastHeartbeat"], 10, 64) + if err != nil { + return nil, err + } + + if (time.Now().Unix() - parseInt) < 15 { + + pStatus = "Normal" + } + } + resp.Tasks = append(resp.Tasks, types.Task{ + Id: task.Id, + Name: task.Name, + Status: task.Status, + StartTime: task.StartTime.Format("2006-01-02 15:04:05"), + EndTime: task.EndTime.Format("2006-01-02 15:04:05"), + ParticipantId: pInfo.Id, + ParticipantName: pInfo.Name, + ParticipantStatus: pStatus, + }) + + } + + select { + case _ = <-ch: + return resp, nil + case <-time.After(1 * time.Second): + return resp, nil + } +} + +func (l *TaskListLogic) updateAitaskStatus(tasks []models.Task, ch chan<- struct{}) { + for _, task := range tasks { + if task.AdapterTypeDict != "1" { + continue + } + if task.Status == constants.Succeeded { + continue + } + + var aiTask []*models.TaskAi + tx := l.svcCtx.DbEngin.Raw("select * from task_ai where `task_id` = ? ", task.Id).Scan(&aiTask) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return + } + + start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local) + end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local) + var status = constants.Succeeded + for _, a := range aiTask { + s, _ := time.ParseInLocation(constants.Layout, a.StartTime, time.Local) + e, _ := time.ParseInLocation(constants.Layout, a.EndTime, time.Local) + + if s.Before(start) { + start = s + } + + if e.After(end) { + end = e + } + + if a.Status == constants.Failed { + status = a.Status + break + } + + if a.Status == constants.Running { + status = a.Status + continue + } + } + + task.Status = status + task.StartTime = &start + task.EndTime = &end + + tx = l.svcCtx.DbEngin.Updates(task) + if tx.Error != nil { + return + } + } + ch <- struct{}{} +} diff --git a/internal/logic/dictionary/adddictitemlogic.go b/internal/logic/dictionary/adddictitemlogic.go new file mode 100644 index 00000000..9b297829 --- /dev/null +++ b/internal/logic/dictionary/adddictitemlogic.go @@ -0,0 +1,55 @@ +package dictionary + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddDictItemLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAddDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddDictItemLogic { + return &AddDictItemLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AddDictItemLogic) AddDictItem(req *types.DictItemEditReq) (resp *types.DictItemResp, err error) { + dict := &types.DictInfo{} + result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.DictId) + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + return nil, errors.New("Dictionary does not exist") + } + var dictItem types.DictItemInfo + dictItem.DictId = req.DictId + dictItem.ItemText = req.ItemText + dictItem.ItemValue = req.ItemValue + dictItem.Description = req.Description + dictItem.SortOrder = req.SortOrder + dictItem.ParentId = "0" + if req.ParentId != "" { + dictItem.ParentId = req.ParentId + } + dictItem.Status = req.Status + dictItem.Id = utils.GenSnowflakeIDStr() + dictItem.CreateTime = time.Now().Format("2006-01-02 15:04:05") + result = l.svcCtx.DbEngin.Table("t_dict_item").Create(&dictItem) + if result.Error != nil { + logx.Errorf("Failed to create dictionary item , errors: %s", result.Error) + return nil, result.Error + } + return +} diff --git a/internal/logic/dictionary/adddictlogic.go b/internal/logic/dictionary/adddictlogic.go new file mode 100644 index 00000000..d5816143 --- /dev/null +++ b/internal/logic/dictionary/adddictlogic.go @@ -0,0 +1,43 @@ +package dictionary + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddDictLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAddDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddDictLogic { + return &AddDictLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AddDictLogic) AddDict(req *types.DictEditReq) (resp *types.DictResp, err error) { + dict := &types.DictInfo{} + dict.DictName = req.DictName + dict.DictCode = req.DictCode + dict.Type = req.Type + dict.Description = req.Description + dict.Id = utils.GenSnowflakeIDStr() + dict.CreateTime = time.Now().Format("2006-01-02 15:04:05") + dict.Status = req.Status + result := l.svcCtx.DbEngin.Table("t_dict").Create(&dict) + if result.Error != nil { + logx.Errorf("Failed to create dictionary , errors: %s", result.Error) + return nil, result.Error + } + return +} diff --git a/internal/logic/dictionary/deletedictitemlogic.go b/internal/logic/dictionary/deletedictitemlogic.go new file mode 100644 index 00000000..b65c3898 --- /dev/null +++ b/internal/logic/dictionary/deletedictitemlogic.go @@ -0,0 +1,39 @@ +package dictionary + +import ( + "context" + "github.com/pkg/errors" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteDictItemLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictItemLogic { + return &DeleteDictItemLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteDictItemLogic) DeleteDictItem(req *types.CId) (resp *types.DictItemResp, err error) { + db := l.svcCtx.DbEngin.Table("t_dict_item").Where("id = ?", req.Id).First(&types.DictItemInfo{}) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Dictionary item does not exist") + } + tx := l.svcCtx.DbEngin.Table("t_dict_item").Delete(types.DictItemInfo{}, req.Id) + if tx.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Delete dictionary item failed") + } + return +} diff --git a/internal/logic/dictionary/deletedictlogic.go b/internal/logic/dictionary/deletedictlogic.go new file mode 100644 index 00000000..6378ef59 --- /dev/null +++ b/internal/logic/dictionary/deletedictlogic.go @@ -0,0 +1,43 @@ +package dictionary + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteDictLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictLogic { + return &DeleteDictLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteDictLogic) DeleteDict(req *types.CId) (resp *types.DictResp, err error) { + var sId int64 + l.svcCtx.DbEngin.Table("t_dict").Raw("select d.id from t_dict_item di left join t_dict d on di.dict_id=d.id where d.id=? limit 1", req.Id).Scan(&sId) + if sId != 0 { + return nil, errors.New("Delete failed,The dictionary is associated with a dictionary item") + } + db := l.svcCtx.DbEngin.Table("t_dict").Where("id = ?", req.Id).First(&types.DictInfo{}) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Dictionary does not exist") + } + tx := l.svcCtx.DbEngin.Table("t_dict").Delete(types.DictInfo{}, req.Id) + if tx.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Delete dictionary failed") + } + return +} diff --git a/internal/logic/dictionary/editdictitemlogic.go b/internal/logic/dictionary/editdictitemlogic.go new file mode 100644 index 00000000..5c78586d --- /dev/null +++ b/internal/logic/dictionary/editdictitemlogic.go @@ -0,0 +1,39 @@ +package dictionary + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type EditDictItemLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewEditDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditDictItemLogic { + return &EditDictItemLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *EditDictItemLogic) EditDictItem(req *types.DictItemEditReq) (resp *types.DictItemResp, err error) { + dictItem := &types.DictItemInfo{} + result := l.svcCtx.DbEngin.Table("t_dict_item").First(&dictItem, req.Id) + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + logx.Errorf("Dictionary data editing failure. errors: %s", result.Error) + return nil, errors.New("DictItem does not exist") + } + utils.Convert(req, &dictItem) + l.svcCtx.DbEngin.Table("t_dict_item").Model(&dictItem).Updates(&dictItem) + return +} diff --git a/internal/logic/dictionary/editdictlogic.go b/internal/logic/dictionary/editdictlogic.go new file mode 100644 index 00000000..9f49028f --- /dev/null +++ b/internal/logic/dictionary/editdictlogic.go @@ -0,0 +1,41 @@ +package dictionary + +import ( + "context" + "fmt" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type EditDictLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewEditDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditDictLogic { + return &EditDictLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *EditDictLogic) EditDict(req *types.DictEditReq) (resp *types.DictResp, err error) { + dict := &types.DictInfo{} + result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.Id) + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + logx.Errorf("Dictionary editing failure. errors: %s", result.Error) + return nil, errors.New("Dict does not exist") + } + utils.Convert(req, &dict) + tx := l.svcCtx.DbEngin.Table("t_dict").Model(&dict).Updates(&dict) + fmt.Println(tx) + return +} diff --git a/internal/logic/dictionary/getdictitemlogic.go b/internal/logic/dictionary/getdictitemlogic.go new file mode 100644 index 00000000..fd62b1ca --- /dev/null +++ b/internal/logic/dictionary/getdictitemlogic.go @@ -0,0 +1,38 @@ +package dictionary + +import ( + "context" + "github.com/pkg/errors" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetDictItemLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictItemLogic { + return &GetDictItemLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetDictItemLogic) GetDictItem(req *types.CId) (resp *types.DictItemResp, err error) { + resp = &types.DictItemResp{} + item := &types.DictItemInfo{} + db := l.svcCtx.DbEngin.Table("t_dict_item").Where("id = ?", req.Id).First(&item) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Dictionary item does not exist") + } + tool.Convert(item, &resp) + return +} diff --git a/internal/logic/dictionary/getdictlogic.go b/internal/logic/dictionary/getdictlogic.go new file mode 100644 index 00000000..ae499b88 --- /dev/null +++ b/internal/logic/dictionary/getdictlogic.go @@ -0,0 +1,38 @@ +package dictionary + +import ( + "context" + "github.com/pkg/errors" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetDictLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictLogic { + return &GetDictLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetDictLogic) GetDict(req *types.CId) (resp *types.DictResp, err error) { + resp = &types.DictResp{} + dict := &types.DictInfo{} + db := l.svcCtx.DbEngin.Table("t_dict").Where("id = ?", req.Id).First(&dict) + if db.Error != nil { + logx.Errorf("err %v", db.Error.Error()) + return nil, errors.New("Dictionary does not exist") + } + tool.Convert(dict, &resp) + return +} diff --git a/internal/logic/dictionary/listdictitembycodelogic.go b/internal/logic/dictionary/listdictitembycodelogic.go new file mode 100644 index 00000000..c764dd3f --- /dev/null +++ b/internal/logic/dictionary/listdictitembycodelogic.go @@ -0,0 +1,60 @@ +package dictionary + +import ( + "context" + "github.com/pkg/errors" + "sort" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListDictItemByCodeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListDictItemByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictItemByCodeLogic { + return &ListDictItemByCodeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListDictItemByCodeLogic) ListDictItemByCode(req *types.DictCodeReq) (resp *types.PageResult, err error) { + var dictList []types.DictItemInfo + resp = &types.PageResult{} + db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict") + + // 左连接查询 + err = db.Select("t_dict_item.*").Joins("left join t_dict_item on t_dict.id = t_dict_item.dict_id"). + Where("t_dict.dict_code = ?", req.DictCode). + Where("t_dict_item.status", 1). + Order("t_dict_item.sort_order").Scan(&dictList).Error + if err != nil { + logx.Errorf("ListDictItemByCode()=> failed %s", err.Error()) + return nil, errors.New("description Failed to query dictionary entry data") + } + + // 找出第一级字典项,(父字典项id为0) + dictItemFormat := make([]types.DictItemInfo, 0) + for _, item := range dictList { + if item.ParentId == "0" { + dictItemFormat = append(dictItemFormat, item) + } + } + // 排序 + sort.Slice(dictItemFormat, func(i, j int) bool { + return dictItemFormat[i].SortOrder < dictItemFormat[j].SortOrder + }) + + // 递归找出一级路由下面的子路由 + getTreeMap(dictItemFormat, dictList) + + resp.List = dictItemFormat + return resp, nil +} diff --git a/internal/logic/dictionary/listdictitemlogic.go b/internal/logic/dictionary/listdictitemlogic.go new file mode 100644 index 00000000..d83b5be8 --- /dev/null +++ b/internal/logic/dictionary/listdictitemlogic.go @@ -0,0 +1,88 @@ +package dictionary + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "sort" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListDictItemLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictItemLogic { + return &ListDictItemLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListDictItemLogic) ListDictItem(req *types.DictItemReq) (resp *types.PageResult, err error) { + resp = &types.PageResult{} + var dictList []types.DictItemInfo + db := l.svcCtx.DbEngin.Model(&types.DictItemInfo{}).Table("t_dict_item") + + if req.ItemText != "" { + db = db.Where("item_text LIKE ?", "%"+req.ItemText+"%") + } + if req.ItemValue != "" { + db = db.Where("item_value LIKE ?", "%"+req.ItemValue+"%") + } + if req.Type != "" { + db = db.Where("type = ?", req.Type) + } + if req.ParentId != "" { + db = db.Where("parent_id = ?", req.ParentId) + } + if req.Status != "" { + db = db.Where("status = ?", req.Status) + } + if req.DictId != "" { + db = db.Where("dict_id = ?", req.DictId) + } + err = db.Order("sort_order").Find(&dictList).Error + + // 找出第一级字典项,(父字典项id为0) + dictItemFormat := make([]types.DictItemInfo, 0) + for _, item := range dictList { + if item.ParentId == "0" { + dictItemFormat = append(dictItemFormat, item) + } + } + // 排序 + sort.Slice(dictItemFormat, func(i, j int) bool { + return dictItemFormat[i].SortOrder < dictItemFormat[j].SortOrder + }) + + // 递归找出一级路由下面的子路由 + getTreeMap(dictItemFormat, dictList) + + resp.List = dictItemFormat + + return resp, nil +} + +func getTreeMap(dictItemFormat []types.DictItemInfo, dictItems []types.DictItemInfo) { + for index, itemF := range dictItemFormat { + for _, dictItem := range dictItems { + if itemF.Id == dictItem.ParentId { + // itemF 只是个复制值 + //itemF.Children = append(itemF.Children, dictItem) + dictItemFormat[index].Children = append(dictItemFormat[index].Children, dictItem) + } + } + if len(dictItemFormat[index].Children) > 0 { + // 排序 + sort.Slice(dictItemFormat[index].Children, func(i, j int) bool { + return dictItemFormat[index].Children[i].SortOrder < dictItemFormat[index].Children[j].SortOrder + }) + getTreeMap(dictItemFormat[index].Children, dictItems) + } + } +} diff --git a/internal/logic/dictionary/listdictlogic.go b/internal/logic/dictionary/listdictlogic.go new file mode 100644 index 00000000..21995ed0 --- /dev/null +++ b/internal/logic/dictionary/listdictlogic.go @@ -0,0 +1,59 @@ +package dictionary + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListDictLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictLogic { + return &ListDictLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListDictLogic) ListDict(req *types.DictReq) (resp *types.PageResult, err error) { + limit := req.PageSize + offset := req.PageSize * (req.PageNum - 1) + resp = &types.PageResult{} + var dictList []types.DictInfo + db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict") + + if req.DictName != "" { + db = db.Where("dict_name LIKE ?", "%"+req.DictName+"%") + } + if req.DictCode != "" { + db = db.Where("dict_code LIKE ?", "%"+req.DictCode+"%") + } + if req.Type != "" { + db = db.Where("type = ?", req.Type) + } + if req.Status != "" { + db = db.Where("status = ?", req.Status) + } + var total int64 + err = db.Count(&total).Error + + if err != nil { + return resp, err + } + db = db.Limit(limit).Offset(offset) + err = db.Order("create_time desc").Find(&dictList).Error + + resp.List = dictList + resp.PageSize = req.PageSize + resp.PageNum = req.PageNum + resp.Total = total + + return resp, nil +} diff --git a/internal/logic/hpc/adaptersummarylogic.go b/internal/logic/hpc/adaptersummarylogic.go new file mode 100644 index 00000000..f71c6e6c --- /dev/null +++ b/internal/logic/hpc/adaptersummarylogic.go @@ -0,0 +1,37 @@ +package hpc + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AdapterSummaryLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAdapterSummaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdapterSummaryLogic { + return &AdapterSummaryLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AdapterSummaryLogic) AdapterSummary(req *types.HpcAdapterSummaryReq) (resp *types.HpcAdapterSummaryResp, err error) { + var hpcAdapterSummary []types.HPCAdapterSummary + + l.svcCtx.DbEngin.Raw("SELECT ta.NAME AS adapter_name,count( DISTINCT label ) as stack_count,count( DISTINCT tc.id ) as cluster_count,count( DISTINCT th.id) as task_count FROM t_adapter ta LEFT JOIN t_cluster tc ON ta.id = tc.adapter_id LEFT JOIN task_hpc th ON ta.id = th.adapter_id WHERE ta.type = 2 GROUP BY ta.id").Scan(&hpcAdapterSummary) + + resp = &types.HpcAdapterSummaryResp{ + Code: 200, + Msg: "success", + Data: hpcAdapterSummary, + } + return resp, nil +} diff --git a/internal/logic/hpc/commithpctasklogic.go b/internal/logic/hpc/commithpctasklogic.go new file mode 100644 index 00000000..7ce450a1 --- /dev/null +++ b/internal/logic/hpc/commithpctasklogic.go @@ -0,0 +1,135 @@ +package hpc + +import ( + "context" + "errors" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "k8s.io/apimachinery/pkg/util/json" + "math/rand" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CommitHpcTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCommitHpcTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommitHpcTaskLogic { + return &CommitHpcTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *types.CommitHpcTaskResp, err error) { + + // 构建主任务结构体 + taskModel := models.Task{ + Name: req.Name, + Description: req.Description, + Status: constants.Saved, + Strategy: 0, + SynergyStatus: 0, + CommitTime: time.Now(), + AdapterTypeDict: "2", + } + + // 保存任务数据到数据库 + tx := l.svcCtx.DbEngin.Create(&taskModel) + if tx.Error != nil { + return nil, tx.Error + } + + var clusterIds []int64 + l.svcCtx.DbEngin.Raw("SELECT id FROM `t_cluster` where adapter_id in ? and label = ?", req.AdapterIds, req.ClusterType).Scan(&clusterIds) + if len(clusterIds) == 0 || clusterIds == nil { + resp.Code = 400 + resp.Msg = "no cluster found" + return resp, nil + } + + var clusterName string + var adapterId int64 + var adapterName string + clusterId := clusterIds[rand.Intn(len(clusterIds))] + l.svcCtx.DbEngin.Raw("SELECT nickname FROM `t_cluster` where id = ?", clusterId).Scan(&clusterName) + l.svcCtx.DbEngin.Raw("SELECT adapter_id FROM `t_cluster` where id = ?", clusterId).Scan(&adapterId) + l.svcCtx.DbEngin.Raw("SELECT name FROM `t_adapter` where id = ?", adapterId).Scan(&adapterName) + if len(adapterName) == 0 || adapterName == "" { + return nil, errors.New("no corresponding adapter found") + } + env, _ := json.Marshal(req.Environment) + + hpcInfo := models.TaskHpc{ + TaskId: taskModel.Id, + AdapterId: uint(adapterId), + AdapterName: adapterName, + ClusterId: uint(clusterId), + ClusterName: clusterName, + Name: taskModel.Name, + Status: "Saved", + CmdScript: req.CmdScript, + StartTime: time.Now().String(), + CardCount: req.CardCount, + WorkDir: req.WorkDir, + WallTime: req.WallTime, + AppType: req.AppType, + AppName: req.AppName, + Queue: req.Queue, + SubmitType: req.SubmitType, + NNode: req.NNode, + StdOutFile: req.StdOutFile, + StdErrFile: req.StdErrFile, + StdInput: req.StdInput, + DeletedFlag: 0, + CreatedBy: 0, + CreatedTime: time.Now(), + UpdatedBy: 0, + UpdatedTime: time.Now(), + Environment: string(env), + } + + tx = l.svcCtx.DbEngin.Create(&hpcInfo) + if tx.Error != nil { + return nil, tx.Error + } + noticeInfo := clientCore.NoticeInfo{ + AdapterId: adapterId, + AdapterName: adapterName, + ClusterId: clusterId, + ClusterName: clusterName, + NoticeType: "create", + TaskName: req.Name, + Incident: "任务创建中", + CreatedTime: time.Now(), + } + result := l.svcCtx.DbEngin.Table("t_notice").Create(¬iceInfo) + if result.Error != nil { + logx.Errorf("Task creation failure, err: %v", result.Error) + } + // todo mq task manage + //reqMessage, err := json.Marshal(mqInfo) + //if err != nil { + // logx.Error(err) + // return nil, err + //} + //publish := l.svcCtx.RedisClient.Publish(context.Background(), mqInfo.TaskType, reqMessage) + //if publish.Err() != nil { + // return nil, publish.Err() + //} + resp = &types.CommitHpcTaskResp{ + Code: 200, + Msg: "success", + TaskId: taskModel.Id, + } + return resp, nil +} diff --git a/internal/logic/hpc/joblogic.go b/internal/logic/hpc/joblogic.go new file mode 100644 index 00000000..2463cc7f --- /dev/null +++ b/internal/logic/hpc/joblogic.go @@ -0,0 +1,36 @@ +package hpc + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type JobLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobLogic { + return &JobLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *JobLogic) Job(req *types.HpcJobReq) (resp *types.HpcJobResp, err error) { + + var job []types.Job + l.svcCtx.DbEngin.Raw("SELECT th.NAME as job_name,t.description as job_desc,t.commit_time as submit_time,th.STATUS as job_status,ta.name as adapter_name,tc.name as cluster_name,tc.label as cluster_type FROM task_hpc th LEFT JOIN task t ON t.id = th.task_id JOIN t_cluster tc on th.cluster_id = tc.id JOIN t_adapter ta on tc.adapter_id = ta.id").Scan(&job) + resp = &types.HpcJobResp{ + Code: 200, + Msg: "success", + Data: job, + } + return resp, nil +} diff --git a/internal/logic/hpc/overviewlogic.go b/internal/logic/hpc/overviewlogic.go new file mode 100644 index 00000000..be88bf1a --- /dev/null +++ b/internal/logic/hpc/overviewlogic.go @@ -0,0 +1,37 @@ +package hpc + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type OverViewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewOverViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OverViewLogic { + return &OverViewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *OverViewLogic) OverView(req *types.HpcOverViewReq) (resp *types.HpcOverViewResp, err error) { + + var overView types.HPCOverView + tx := l.svcCtx.DbEngin.Raw("SELECT count( DISTINCT a.id ) as adapter_count,count( DISTINCT label ) as stack_count,count( c.id ) as cluster_count,(select count(*) from task_hpc) as task_count FROM t_cluster c JOIN t_adapter a ON c.adapter_id = a.id AND a.type = 2 ").Scan(&overView) + + println(tx) + resp = &types.HpcOverViewResp{ + Code: 200, + Msg: "success", + Data: overView, + } + return resp, nil +} diff --git a/internal/logic/hpc/queueassetslogic.go b/internal/logic/hpc/queueassetslogic.go new file mode 100644 index 00000000..af1ef97f --- /dev/null +++ b/internal/logic/hpc/queueassetslogic.go @@ -0,0 +1,48 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package hpc + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type QueueAssetsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewQueueAssetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueueAssetsLogic { + return &QueueAssetsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *QueueAssetsLogic) QueueAssets() (resp *types.QueueAssetsResp, err error) { + // 查询数据库队列资源信息 + var queueAssetsResp types.QueueAssetsResp + tx := l.svcCtx.DbEngin.Raw("SELECT qpi.*,ti.tenant_name FROM sc_queue_phy_info qpi left join sc_participant_phy_info ppi on ppi.id = qpi.participant_id left JOIN sc_tenant_info ti on ti.id = ppi.tenant_id WHERE qpi.created_time IN ( SELECT MAX( created_time ) FROM sc_queue_phy_info WHERE deleted_flag = 0 GROUP BY participant_id, queue_name ) ").Scan(&queueAssetsResp.QueueAssets) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } + return &queueAssetsResp, nil +} diff --git a/internal/logic/hpc/resourcelogic.go b/internal/logic/hpc/resourcelogic.go new file mode 100644 index 00000000..eb09da64 --- /dev/null +++ b/internal/logic/hpc/resourcelogic.go @@ -0,0 +1,58 @@ +package hpc + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ResourceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResourceLogic { + return &ResourceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ResourceLogic) Resource(req *types.HpcResourceReq) (resp *types.HpcResourceResp, err error) { + + type hpcResourceOV struct { + CpuAvail float64 `json:"cpu_avail"` + CpuTotal float64 `json:"cpu_total"` + MemAvail float64 `json:"mem_avail"` + MemTotal float64 `json:"mem_total"` + DiskAvail float64 `json:"disk_avail"` + DiskTotal float64 `json:"disk_total"` + GpuAvail float64 `json:"gpu_avail"` + GpuTotal float64 `json:"gpu_total"` + } + var hrov hpcResourceOV + l.svcCtx.DbEngin.Raw("SELECT sum(cpu_avail) as cpu_avail,sum(cpu_total) as cpu_total,sum(mem_avail) as mem_avail,sum(mem_total) as mem_total,sum(disk_avail) as disk_avail,sum(disk_total) as disk_total,sum(gpu_avail) as gpu_avail,sum(gpu_total) as gpu_total FROM t_cluster_resource where cluster_type = 2").Scan(&hrov) + + hpcResource := types.HPCResource{ + GPUCardsTotal: hrov.GpuTotal, + CPUCoresTotal: hrov.CpuTotal, + RAMTotal: hrov.MemTotal, + GPUCardsUsed: hrov.GpuTotal - hrov.GpuAvail, + CPUCoresUsed: hrov.CpuTotal - hrov.CpuAvail, + RAMUsed: hrov.MemTotal - hrov.MemAvail, + GPURate: (hrov.GpuTotal - hrov.GpuAvail) / hrov.GpuTotal, + CPURate: (hrov.CpuTotal - hrov.CpuAvail) / hrov.CpuTotal, + RAMRate: (hrov.MemTotal - hrov.MemAvail) / hrov.MemTotal, + } + + resp = &types.HpcResourceResp{ + Code: 200, + Msg: "success", + Data: hpcResource, + } + return resp, nil +} diff --git a/internal/logic/inference/imageinferencelogic.go b/internal/logic/inference/imageinferencelogic.go new file mode 100644 index 00000000..1673aed1 --- /dev/null +++ b/internal/logic/inference/imageinferencelogic.go @@ -0,0 +1,139 @@ +package inference + +import ( + "context" + "errors" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "net/http" +) + +type ImageInferenceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewImageInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ImageInferenceLogic { + return &ImageInferenceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// +//func (l *ImageInferenceLogic) ImageInference(req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) { +// return nil, nil +//} + +func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) { + resp = &types.ImageInferenceResp{} + opt := &option.InferOption{ + TaskName: req.TaskName, + TaskDesc: req.TaskDesc, + AdapterId: req.AdapterId, + AiClusterIds: req.AiClusterIds, + ModelName: req.ModelName, + ModelType: req.ModelType, + Strategy: req.Strategy, + StaticWeightMap: req.StaticWeightMap, + } + + var ts []*inference.ImageFile + + uploadedFiles := r.MultipartForm.File + + if len(uploadedFiles) == 0 { + return nil, errors.New("Images does not exist") + } + + if len(uploadedFiles["images"]) == 0 { + return nil, errors.New("Images does not exist") + } + + for _, header := range uploadedFiles["images"] { + file, err := header.Open() + if err != nil { + return nil, err + } + defer file.Close() + var ir types.ImageResult + ir.ImageName = header.Filename + t := inference.ImageFile{ + ImageResult: &ir, + File: file, + } + ts = append(ts, &t) + } + + _, ok := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[opt.AdapterId] + if !ok { + return nil, errors.New("AdapterId does not exist") + } + + var strat strategy.Strategy + switch opt.Strategy { + case strategy.STATIC_WEIGHT: + strat = strategy.NewStaticWeightStrategy(opt.StaticWeightMap, int32(len(ts))) + if err != nil { + return nil, err + } + default: + return nil, errors.New("no strategy has been chosen") + } + clusters, err := strat.Schedule() + if err != nil { + return nil, err + } + + if clusters == nil || len(clusters) == 0 { + return nil, errors.New("clusters is nil") + } + + //save task + var synergystatus int64 + if len(clusters) > 1 { + synergystatus = 1 + } + + strategyCode, err := l.svcCtx.Scheduler.AiStorages.GetStrategyCode(opt.Strategy) + if err != nil { + return nil, err + } + adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId) + if err != nil { + return nil, err + } + id, err := l.svcCtx.Scheduler.AiStorages.SaveTask(opt.TaskName, strategyCode, synergystatus, "11") + if err != nil { + return nil, err + } + + l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "create", "任务创建中") + + for i := len(clusters) - 1; i >= 0; i-- { + if clusters[i].Replicas == 0 { + clusters = append(clusters[:i], clusters[i+1:]...) + } + } + + //save taskai + for _, c := range clusters { + clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(c.ClusterId) + opt.Replica = c.Replicas + err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, c.ClusterId, clusterName, "", constants.Saved, "") + if err != nil { + return nil, err + } + } + + go l.svcCtx.Scheduler.AiService.ImageInfer(opt, id, adapterName, clusters, ts) + + return resp, nil +} diff --git a/internal/logic/inference/inferencetaskdetaillogic.go b/internal/logic/inference/inferencetaskdetaillogic.go new file mode 100644 index 00000000..02e6b3e4 --- /dev/null +++ b/internal/logic/inference/inferencetaskdetaillogic.go @@ -0,0 +1,58 @@ +package inference + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type InferenceTaskDetailLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewInferenceTaskDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InferenceTaskDetailLogic { + return &InferenceTaskDetailLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *InferenceTaskDetailLogic) InferenceTaskDetail(req *types.InferenceTaskDetailReq) (resp *types.InferenceTaskDetailResp, err error) { + // todo: add your logic here and delete this line + + var taskAiSub []*models.TaskAiSub + var results []types.InferenceResult + l.svcCtx.DbEngin.Table("task_ai_sub").Where("task_id", req.TaskId).Scan(&taskAiSub) + + if len(taskAiSub) != 0 { + for _, sub := range taskAiSub { + result := types.InferenceResult{ + TaskName: sub.TaskName, + TaskAiName: sub.TaskAiName, + ImageName: sub.ImageName, + Result: sub.Result, + Card: sub.Card, + ClusterName: sub.ClusterName, + } + results = append(results, result) + } + } else { + return nil, nil + } + + resp = &types.InferenceTaskDetailResp{ + Code: 200, + Msg: "success", + InferenceResults: results, + } + + return resp, nil + +} diff --git a/internal/logic/inference/modelnamesbytypelogic.go b/internal/logic/inference/modelnamesbytypelogic.go new file mode 100644 index 00000000..b36b4405 --- /dev/null +++ b/internal/logic/inference/modelnamesbytypelogic.go @@ -0,0 +1,36 @@ +package inference + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ModelNamesByTypeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewModelNamesByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModelNamesByTypeLogic { + return &ModelNamesByTypeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ModelNamesByTypeLogic) ModelNamesByType(req *types.ModelNamesReq) (resp *types.ModelNamesResp, err error) { + resp = &types.ModelNamesResp{} + models, err := storeLink.GetModelNamesByType(req.Type) + if err != nil { + logx.Errorf("ModelNamesByType err: %v", err) + return nil, err + } + resp.ModelNames = models + return resp, nil +} diff --git a/internal/logic/inference/modeltypeslogic.go b/internal/logic/inference/modeltypeslogic.go new file mode 100644 index 00000000..807915cf --- /dev/null +++ b/internal/logic/inference/modeltypeslogic.go @@ -0,0 +1,32 @@ +package inference + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ModelTypesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewModelTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModelTypesLogic { + return &ModelTypesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ModelTypesLogic) ModelTypes() (resp *types.ModelTypesResp, err error) { + resp = &types.ModelTypesResp{} + mTypes := storeLink.GetModelTypes() + resp.ModelTypes = mTypes + return resp, nil +} diff --git a/internal/logic/inference/texttotextinferencelogic.go b/internal/logic/inference/texttotextinferencelogic.go new file mode 100644 index 00000000..8bf9fcfd --- /dev/null +++ b/internal/logic/inference/texttotextinferencelogic.go @@ -0,0 +1,150 @@ +package inference + +import ( + "context" + "errors" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "strconv" + "sync" + "time" +) + +type TextToTextInferenceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewTextToTextInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TextToTextInferenceLogic { + return &TextToTextInferenceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *TextToTextInferenceLogic) TextToTextInference(req *types.TextToTextInferenceReq) (resp *types.TextToTextInferenceResp, err error) { + resp = &types.TextToTextInferenceResp{} + opt := &option.InferOption{ + TaskName: req.TaskName, + TaskDesc: req.TaskDesc, + AdapterId: req.AdapterId, + AiClusterIds: req.AiClusterIds, + ModelName: req.ModelName, + ModelType: req.ModelType, + } + + _, ok := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[opt.AdapterId] + if !ok { + return nil, errors.New("AdapterId does not exist") + } + + //save task + var synergystatus int64 + var strategyCode int64 + adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId) + if err != nil { + return nil, err + } + + id, err := l.svcCtx.Scheduler.AiStorages.SaveTask(opt.TaskName, strategyCode, synergystatus, "12") + if err != nil { + return nil, err + } + + var wg sync.WaitGroup + var cluster_ch = make(chan struct { + urls []*collector.InferUrl + clusterId string + clusterName string + }, len(opt.AiClusterIds)) + + var cs []struct { + urls []*collector.InferUrl + clusterId string + clusterName string + } + collectorMap := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[opt.AdapterId] + + //save taskai + for _, clusterId := range opt.AiClusterIds { + wg.Add(1) + go func(cId string) { + urls, err := collectorMap[cId].GetInferUrl(l.ctx, opt) + if err != nil { + wg.Done() + return + } + clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(cId) + + s := struct { + urls []*collector.InferUrl + clusterId string + clusterName string + }{ + urls: urls, + clusterId: cId, + clusterName: clusterName, + } + + cluster_ch <- s + wg.Done() + return + }(clusterId) + } + wg.Wait() + close(cluster_ch) + + for s := range cluster_ch { + cs = append(cs, s) + } + + if len(cs) == 0 { + clusterId := opt.AiClusterIds[0] + clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(opt.AiClusterIds[0]) + err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, clusterId, clusterName, "", constants.Failed, "") + if err != nil { + return nil, err + } + l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") + } + + for _, c := range cs { + clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(c.clusterId) + err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, c.clusterId, clusterName, "", constants.Saved, "") + if err != nil { + return nil, err + } + } + + var aiTaskList []*models.TaskAi + tx := l.svcCtx.DbEngin.Raw("select * from task_ai where `task_id` = ? ", id).Scan(&aiTaskList) + if tx.Error != nil { + return nil, tx.Error + + } + + for i, t := range aiTaskList { + if strconv.Itoa(int(t.ClusterId)) == cs[i].clusterId { + t.Status = constants.Completed + t.EndTime = time.Now().Format(time.RFC3339) + url := cs[i].urls[0].Url + storeLink.FORWARD_SLASH + "chat" + t.InferUrl = url + err := l.svcCtx.Scheduler.AiStorages.UpdateAiTask(t) + if err != nil { + logx.Errorf(tx.Error.Error()) + } + } + } + + l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "completed", "任务完成") + + return resp, nil +} diff --git a/internal/logic/monitoring/adapterinfologic.go b/internal/logic/monitoring/adapterinfologic.go new file mode 100644 index 00000000..d1016be1 --- /dev/null +++ b/internal/logic/monitoring/adapterinfologic.go @@ -0,0 +1,31 @@ +package monitoring + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AdapterInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAdapterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdapterInfoLogic { + return &AdapterInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AdapterInfoLogic) AdapterInfo(req *types.AdapterInfoReq) (resp *types.AdapterInfoResp, err error) { + // todo: add your logic here and delete this line + resp = &types.AdapterInfoResp{} + l.svcCtx.DbEngin.Raw("select ta.name , ta.version from t_adapter ta,t_cluster tc where tc.id = ? and tc.adapter_id = ta.id", req.ClusterId).Scan(resp) + return resp, nil +} diff --git a/internal/logic/monitoring/alertlistlogic.go b/internal/logic/monitoring/alertlistlogic.go new file mode 100644 index 00000000..099f9b82 --- /dev/null +++ b/internal/logic/monitoring/alertlistlogic.go @@ -0,0 +1,62 @@ +package monitoring + +import ( + "context" + "fmt" + v1 "github.com/prometheus/client_golang/api/prometheus/v1" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AlertListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAlertListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertListLogic { + return &AlertListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +type AlertListResp struct { + Mode int `json:"code"` + Msg string `json:"msg"` + Data map[string][]*v1.Alert `json:"data"` +} + +func (l *AlertListLogic) AlertList(req *types.AlertListReq) (resp *types.AlertListResp, err error) { + resp = &types.AlertListResp{ + AlertMap: make(map[string]interface{}), + } + + // query server http url. + var clusterArray []string + + sql := "select distinct tc.name from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and label = 'kubernetes' and ta.type = ?" + if len(req.AdapterId) > 0 { + sql = fmt.Sprintf("select distinct tc.name from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and label = 'kubernetes' and ta.type = ? and ta.id = %s", req.AdapterId) + } + if len(req.ClusterId) > 0 { + sql = fmt.Sprintf("select distinct tc.name from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and label = 'kubernetes' and ta.type = ? and tc.id = %s", req.ClusterId) + } + l.svcCtx.DbEngin.Raw(sql, req.AlertType).Scan(&clusterArray) + + for _, clusterName := range clusterArray { + getResult := l.svcCtx.RedisClient.Get(l.ctx, clusterName) + if len(getResult.Val()) != 0 { + var alerts []v1.Alert + json.Unmarshal([]byte(getResult.Val()), &alerts) + + resp.AlertMap[clusterName] = alerts + } + + } + return resp, nil +} diff --git a/internal/logic/monitoring/alertruleslogic.go b/internal/logic/monitoring/alertruleslogic.go new file mode 100644 index 00000000..15c42046 --- /dev/null +++ b/internal/logic/monitoring/alertruleslogic.go @@ -0,0 +1,40 @@ +package monitoring + +import ( + "context" + "fmt" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AlertRulesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAlertRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertRulesLogic { + return &AlertRulesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AlertRulesLogic) AlertRules(req *types.AlertRulesReq) (resp *types.AlertRulesResp, err error) { + resp = &types.AlertRulesResp{} + var alertRules []types.AlertRule + sql := fmt.Sprintf("SELECT ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.alert_type = %s AND ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id", req.AlertType) + if req.AdapterId != "" { + sql = fmt.Sprintf("SELECT ar.*,GROUP_CONCAT( tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',' ) AS cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id JOIN t_adapter ta ON ta.id = tc.adapter_id WHERE ar.alert_type = %s AND ta.id = %s AND ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id", req.AlertType, req.AdapterId) + } + if req.ClusterId != "" { + sql = fmt.Sprintf("SELECT ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.alert_type = %s AND ar.cluster_id = %s AND ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id", req.AlertType, req.ClusterId) + } + l.svcCtx.DbEngin.Raw(sql).Scan(&alertRules) + resp.AlertRules = alertRules + return resp, nil +} diff --git a/internal/logic/monitoring/clustersloadlogic.go b/internal/logic/monitoring/clustersloadlogic.go new file mode 100644 index 00000000..5a26d998 --- /dev/null +++ b/internal/logic/monitoring/clustersloadlogic.go @@ -0,0 +1,34 @@ +package monitoring + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + "time" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ClustersLoadLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewClustersLoadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClustersLoadLogic { + return &ClustersLoadLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ClustersLoadLogic) ClustersLoad(req *types.ClustersLoadReq) (resp *types.ClustersLoadResp, err error) { + resp = &types.ClustersLoadResp{} + metrics := []string{"cluster_cpu_utilisation", "cluster_cpu_avail", "cluster_cpu_total", "cluster_memory_total", "cluster_memory_avail", "cluster_memory_utilisation", "cluster_disk_utilisation", "cluster_disk_avail", "cluster_disk_total", "cluster_pod_utilisation"} + result := l.svcCtx.PromClient.GetNamedMetrics(metrics, time.Now(), tracker.ClusterOption{ClusterName: req.ClusterName}) + resp.Data = result + return resp, nil +} diff --git a/internal/logic/monitoring/createalertrulelogic.go b/internal/logic/monitoring/createalertrulelogic.go new file mode 100644 index 00000000..9ee3a6f1 --- /dev/null +++ b/internal/logic/monitoring/createalertrulelogic.go @@ -0,0 +1,120 @@ +package monitoring + +import ( + "context" + v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + v12 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/apimachinery/pkg/util/json" + "strconv" +) + +type CreateAlertRuleLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateAlertRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlertRuleLogic { + return &CreateAlertRuleLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +type RuleSelectorResp struct { + Code int `json:"code"` + Msg string `json:"msg"` + Prometheus v1.Prometheus `json:"data"` +} + +func (l *CreateAlertRuleLogic) CreateAlertRule(req *types.CreateAlertRuleReq) error { + + // save to db + var alertRule models.AlertRule + tool.Convert(req, &alertRule) + alertRule.ClusterId, _ = strconv.ParseInt(req.CLusterId, 10, 64) + alertRule.Id = tool.GenSnowflakeID() + tx := l.svcCtx.DbEngin.Save(&alertRule) + if tx.Error != nil { + return tx.Error + } + + // query cluster http url. + var server string + l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) + + // rule selector + var ruleSelectorResp RuleSelectorResp + + response, err := l.svcCtx.HttpClient.R(). + SetQueryParams(map[string]string{ + "clusterName": req.ClusterName, + }). + SetResult(&ruleSelectorResp). + ForceContentType("application/json"). + Get(server + "/api/v1/monitoring/rule/selector") + if err != nil || response.IsError() { + logx.Error(response) + return err + } + // Data Filling + ruleDuration := v1.Duration(req.Duration) + rule := &v1.PrometheusRule{ + TypeMeta: v12.TypeMeta{Kind: "PrometheusRule", + APIVersion: "monitoring.coreos.com/v1"}, + ObjectMeta: v12.ObjectMeta{ + Name: req.Name, + Namespace: ruleSelectorResp.Prometheus.ObjectMeta.Namespace, + Labels: ruleSelectorResp.Prometheus.Spec.RuleSelector.MatchLabels, + }, + Spec: v1.PrometheusRuleSpec{ + Groups: []v1.RuleGroup{ + { + Name: "example-group", + Rules: []v1.Rule{ + { + Alert: req.Name, + Expr: intstr.FromString(req.PromQL), + For: &ruleDuration, + Labels: map[string]string{ + "severity": req.AlertLevel, + }, + Annotations: map[string]string{"description": req.Annotations}, + }, + }, + }, + }, + }, + } + + ruleBytes, err := json.Marshal(rule) + if err != nil { + return err + } + + // create prometheus rule + response, err = l.svcCtx.HttpClient.R(). + SetBody(&OperateStruct{ + ClusterName: req.ClusterName, + YamlString: string(ruleBytes), + }). + ForceContentType("application/json"). + Post(server + "/api/v1/operate/apply") + if err != nil || response.IsError() { + return err + } + + return nil +} + +type OperateStruct struct { + ClusterName string `json:"clusterName"` + YamlString string `json:"yamlString"` +} diff --git a/internal/logic/monitoring/deletealertrulelogic.go b/internal/logic/monitoring/deletealertrulelogic.go new file mode 100644 index 00000000..e8da52d4 --- /dev/null +++ b/internal/logic/monitoring/deletealertrulelogic.go @@ -0,0 +1,66 @@ +package monitoring + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteAlertRuleLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteAlertRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlertRuleLogic { + return &DeleteAlertRuleLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteAlertRuleLogic) DeleteAlertRule(req *types.DeleteAlertRuleReq) error { + // Delete data from the database + l.svcCtx.DbEngin.Delete(&types.AlertRule{}, "id = ?", req.Id) + + // query cluster http url. + var server string + l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) + + // create prometheus rule + response, err := l.svcCtx.HttpClient.R(). + SetBody(&CrdStruct{ + ClusterName: req.ClusterName, + Name: req.Name, + Grv: Grv{ + Group: "monitoring.coreos.com", + Version: "v1", + Resource: "prometheusrules", + }, + }). + ForceContentType("application/json"). + Delete(server + "/api/v1/crd") + if err != nil { + return err + } + if err != nil || response.IsError() { + return err + } + return nil +} + +type Grv struct { + Group string `json:"group"` + Version string `json:"version"` + Resource string `json:"resource"` +} + +type CrdStruct struct { + ClusterName string `json:"clusterName"` + Grv Grv `json:"grv"` + Name string `json:"name"` +} diff --git a/internal/logic/monitoring/nodesloadtoplogic.go b/internal/logic/monitoring/nodesloadtoplogic.go new file mode 100644 index 00000000..2c44ca3c --- /dev/null +++ b/internal/logic/monitoring/nodesloadtoplogic.go @@ -0,0 +1,44 @@ +package monitoring + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type NodesLoadTopLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewNodesLoadTopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NodesLoadTopLogic { + return &NodesLoadTopLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *NodesLoadTopLogic) NodesLoadTop(req *types.NodesLoadTopReq) (resp *types.NodesLoadTopResp, err error) { + + resp = &types.NodesLoadTopResp{} + + var server string + l.svcCtx.DbEngin.Raw("select ta.server from t_adapter ta,t_cluster tc where ta.id = tc.adapter_id and tc.name = ?", &req.ClusterName).Scan(&server) + response, err := l.svcCtx.HttpClient.R(). + SetQueryParams(map[string]string{ + "clusterName": req.ClusterName, + "metrics": req.Metrics, + }). + SetResult(&resp). + ForceContentType("application/json"). + Get(server + "/api/v1/monitoring/node") + if err != nil || response.IsError() { + return nil, err + } + return resp, nil +} diff --git a/internal/logic/monitoring/schedulesituationlogic.go b/internal/logic/monitoring/schedulesituationlogic.go new file mode 100644 index 00000000..7efa663f --- /dev/null +++ b/internal/logic/monitoring/schedulesituationlogic.go @@ -0,0 +1,82 @@ +package monitoring + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "strings" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleSituationLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleSituationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleSituationLogic { + return &ScheduleSituationLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleSituationLogic) ScheduleSituation() (resp *types.ScheduleSituationResp, err error) { + resp = &types.ScheduleSituationResp{} + // node region + tx := l.svcCtx.DbEngin.Raw("SELECT c.id, c.name, tdi.id AS category, count(DISTINCT ta.id)+count(DISTINCT tc.id)+COUNT(DISTINCT th.id)+COUNT(tv.id) as value FROM t_cluster c LEFT JOIN t_dict_item tdi ON c.region_dict = tdi.id left JOIN task_ai ta ON ta.cluster_id = c.id left JOIN task_cloud tc ON tc.cluster_id = c.id left JOIN task_hpc th ON th.cluster_id = c.id left JOIN task_vm tv ON tv.cluster_id = c.id WHERE tc.deleted_at IS NULL GROUP BY c.id").Scan(&resp.Nodes) + if tx.Error != nil { + return nil, tx.Error + } + + // hpc + var hpcLinks []string + tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT( distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_hpc WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&hpcLinks) + if tx.Error != nil { + return nil, tx.Error + } + LinksHandler(hpcLinks, resp) + // cloud + var cloudLinks []string + tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT(distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_cloud WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&cloudLinks) + if tx.Error != nil { + return nil, tx.Error + } + LinksHandler(cloudLinks, resp) + // ai + var aiLinks []string + tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT(distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_ai WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&aiLinks) + if tx.Error != nil { + return nil, tx.Error + } + LinksHandler(aiLinks, resp) + // vm + var vmLinks []string + tx = l.svcCtx.DbEngin.Raw("SELECT distinct GROUP_CONCAT(distinct cluster_id SEPARATOR ',') as cluster_ids FROM task_vm WHERE deleted_at IS NULL GROUP BY task_id HAVING COUNT(*) > 1;").Scan(&vmLinks) + if tx.Error != nil { + return nil, tx.Error + } + LinksHandler(vmLinks, resp) + + // categories + tx = l.svcCtx.DbEngin.Raw("select tdi.item_text as name from t_dict_item tdi,t_dict td where td.dict_code = 'cluster_region_dict' and tdi.dict_id = td.id").Scan(&resp.Categories) + if tx.Error != nil { + return nil, tx.Error + } + return resp, nil +} + +func LinksHandler(sources []string, resp *types.ScheduleSituationResp) { + for _, source := range sources { + links := strings.Split(source, ",") + + for i := 1; i < len(links); i++ { + if links[i] != links[i-1] { + resp.Links = append(resp.Links, types.Link{Source: links[i], Target: links[i-1]}) + } + } + } + +} diff --git a/internal/logic/monitoring/syncclusteralertlogic.go b/internal/logic/monitoring/syncclusteralertlogic.go new file mode 100644 index 00000000..7725d8ae --- /dev/null +++ b/internal/logic/monitoring/syncclusteralertlogic.go @@ -0,0 +1,44 @@ +package monitoring + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "k8s.io/apimachinery/pkg/util/json" + "time" + + "github.com/zeromicro/go-zero/core/logx" +) + +type SyncClusterAlertLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewSyncClusterAlertLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncClusterAlertLogic { + return &SyncClusterAlertLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *SyncClusterAlertLogic) SyncClusterAlert(req *types.SyncClusterAlertReq) error { + + if len(req.AlertRecordsMap) != 0 { + for k, v := range req.AlertRecordsMap { + bytes, err := json.Marshal(v) + if err != nil { + return err + } + setCmd := l.svcCtx.RedisClient.Set(l.ctx, k, bytes, 1*time.Minute) + if setCmd.Err() != nil { + logx.Error(setCmd.Err()) + } + + } + } + + return nil +} diff --git a/internal/logic/monitoring/tasknumlogic.go b/internal/logic/monitoring/tasknumlogic.go new file mode 100644 index 00000000..e7cb75e9 --- /dev/null +++ b/internal/logic/monitoring/tasknumlogic.go @@ -0,0 +1,33 @@ +package monitoring + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type TaskNumLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewTaskNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskNumLogic { + return &TaskNumLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *TaskNumLogic) TaskNum(req *types.TaskNumReq) (resp *types.TaskNumResp, err error) { + resp = &types.TaskNumResp{} + l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ? and status = 'running'", req.ClusterId).Scan(resp.Current) + l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = '' and DATE(start_time) = CURDATE()", req.ClusterId).Scan(resp.Today) + l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ?", req.ClusterId).Scan(resp.History) + l.svcCtx.DbEngin.Raw("SELECT COUNT(id) from task_cloud where cluster_id = ? and status = 'failed'", req.ClusterId).Scan(resp.Failed) + return resp, nil +} diff --git a/internal/logic/schedule/downloadalgothmcodelogic.go b/internal/logic/schedule/downloadalgothmcodelogic.go new file mode 100644 index 00000000..3c97ac0b --- /dev/null +++ b/internal/logic/schedule/downloadalgothmcodelogic.go @@ -0,0 +1,37 @@ +package schedule + +import ( + "context" + "strings" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DownloadAlgothmCodeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDownloadAlgothmCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DownloadAlgothmCodeLogic { + return &DownloadAlgothmCodeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DownloadAlgothmCodeLogic) DownloadAlgorithmCode(req *types.DownloadAlgorithmCodeReq) (resp *types.DownloadAlgorithmCodeResp, err error) { + resp = &types.DownloadAlgorithmCodeResp{} + code, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].DownloadAlgorithmCode(l.ctx, + req.ResourceType, strings.ToLower(req.Card), req.TaskType, req.Dataset, req.Algorithm) + if err != nil { + return nil, err + } + resp.Code = code + + return resp, nil +} diff --git a/internal/logic/schedule/getclusterbalancebyidlogic.go b/internal/logic/schedule/getclusterbalancebyidlogic.go new file mode 100644 index 00000000..300c8741 --- /dev/null +++ b/internal/logic/schedule/getclusterbalancebyidlogic.go @@ -0,0 +1,35 @@ +package schedule + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetClusterBalanceByIdLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetClusterBalanceByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterBalanceByIdLogic { + return &GetClusterBalanceByIdLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetClusterBalanceByIdLogic) GetClusterBalanceById(req *types.GetClusterBalanceByIdReq) (resp *types.GetClusterBalanceByIdResp, err error) { + resp = &types.GetClusterBalanceByIdResp{} + balance, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].GetUserBalance(l.ctx) + if err != nil { + return nil, err + } + resp.Balance = balance + + return resp, nil +} diff --git a/internal/logic/schedule/getcomputecardsbyclusterlogic.go b/internal/logic/schedule/getcomputecardsbyclusterlogic.go new file mode 100644 index 00000000..5c087e7c --- /dev/null +++ b/internal/logic/schedule/getcomputecardsbyclusterlogic.go @@ -0,0 +1,35 @@ +package schedule + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetComputeCardsByClusterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetComputeCardsByClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputeCardsByClusterLogic { + return &GetComputeCardsByClusterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetComputeCardsByClusterLogic) GetComputeCardsByCluster(req *types.GetComputeCardsByClusterReq) (resp *types.GetComputeCardsByClusterResp, err error) { + resp = &types.GetComputeCardsByClusterResp{} + cards, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].GetComputeCards(l.ctx) + if err != nil { + return nil, err + } + resp.Cards = cards + + return resp, nil +} diff --git a/internal/logic/schedule/schedulegetaijoblogloglogic.go b/internal/logic/schedule/schedulegetaijoblogloglogic.go new file mode 100644 index 00000000..a8529b1c --- /dev/null +++ b/internal/logic/schedule/schedulegetaijoblogloglogic.go @@ -0,0 +1,40 @@ +package schedule + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetAiJobLogLogLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetAiJobLogLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAiJobLogLogLogic { + return &ScheduleGetAiJobLogLogLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetAiJobLogLogLogic) ScheduleGetAiJobLogLog(req *types.AiJobLogReq) (resp *types.AiJobLogResp, err error) { + resp = &types.AiJobLogResp{} + + id, err := l.svcCtx.Scheduler.AiStorages.GetAiTaskIdByClusterIdAndTaskId(req.ClusterId, req.TaskId) + if err != nil { + return nil, err + } + log, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].GetTrainingTaskLog(l.ctx, id, req.InstanceNum) + if err != nil { + return nil, err + } + + resp.Log = log + return resp, nil +} diff --git a/internal/logic/schedule/schedulegetairesourcetypeslogic.go b/internal/logic/schedule/schedulegetairesourcetypeslogic.go new file mode 100644 index 00000000..a757fc1d --- /dev/null +++ b/internal/logic/schedule/schedulegetairesourcetypeslogic.go @@ -0,0 +1,33 @@ +package schedule + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetAiResourceTypesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetAiResourceTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAiResourceTypesLogic { + return &ScheduleGetAiResourceTypesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetAiResourceTypesLogic) ScheduleGetAiResourceTypes() (resp *types.AiResourceTypesResp, err error) { + resp = &types.AiResourceTypesResp{} + resourceTypes := storeLink.GetResourceTypes() + resp.ResourceTypes = resourceTypes + + return resp, nil +} diff --git a/internal/logic/schedule/schedulegetaitasktypeslogic.go b/internal/logic/schedule/schedulegetaitasktypeslogic.go new file mode 100644 index 00000000..40a64dbc --- /dev/null +++ b/internal/logic/schedule/schedulegetaitasktypeslogic.go @@ -0,0 +1,33 @@ +package schedule + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetAiTaskTypesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetAiTaskTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAiTaskTypesLogic { + return &ScheduleGetAiTaskTypesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetAiTaskTypesLogic) ScheduleGetAiTaskTypes() (resp *types.AiTaskTypesResp, err error) { + resp = &types.AiTaskTypesResp{} + taskTypes := storeLink.GetTaskTypes() + resp.TaskTypes = taskTypes + + return resp, nil +} diff --git a/internal/logic/schedule/schedulegetalgorithmslogic.go b/internal/logic/schedule/schedulegetalgorithmslogic.go new file mode 100644 index 00000000..34febcd4 --- /dev/null +++ b/internal/logic/schedule/schedulegetalgorithmslogic.go @@ -0,0 +1,35 @@ +package schedule + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetAlgorithmsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAlgorithmsLogic { + return &ScheduleGetAlgorithmsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetAlgorithmsLogic) ScheduleGetAlgorithms(req *types.AiAlgorithmsReq) (resp *types.AiAlgorithmsResp, err error) { + resp = &types.AiAlgorithmsResp{} + algorithms, err := storeLink.GetAlgorithms(l.ctx, l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId], req.ResourceType, req.TaskType, req.Dataset) + if err != nil { + return nil, err + } + resp.Algorithms = algorithms + return resp, nil +} diff --git a/internal/logic/schedule/schedulegetdatasetslogic.go b/internal/logic/schedule/schedulegetdatasetslogic.go new file mode 100644 index 00000000..3cde31bc --- /dev/null +++ b/internal/logic/schedule/schedulegetdatasetslogic.go @@ -0,0 +1,37 @@ +package schedule + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetDatasetsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetDatasetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetDatasetsLogic { + return &ScheduleGetDatasetsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetDatasetsLogic) ScheduleGetDatasets(req *types.AiDatasetsReq) (resp *types.AiDatasetsResp, err error) { + resp = &types.AiDatasetsResp{} + names, err := storeLink.GetDatasetsNames(l.ctx, l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId]) + if err != nil { + logx.Errorf("GetDatasetsNames err: %v", err) + return nil, errors.New("网络异常,请稍后重试.") + } + resp.Datasets = names + return resp, nil +} diff --git a/internal/logic/schedule/schedulegetoverviewlogic.go b/internal/logic/schedule/schedulegetoverviewlogic.go new file mode 100644 index 00000000..ad3de8ce --- /dev/null +++ b/internal/logic/schedule/schedulegetoverviewlogic.go @@ -0,0 +1,30 @@ +package schedule + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetOverviewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetOverviewLogic { + return &ScheduleGetOverviewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetOverviewLogic) ScheduleGetOverview() (resp *types.ScheduleOverviewResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/schedule/schedulegetstrategylogic.go b/internal/logic/schedule/schedulegetstrategylogic.go new file mode 100644 index 00000000..29f7ef57 --- /dev/null +++ b/internal/logic/schedule/schedulegetstrategylogic.go @@ -0,0 +1,32 @@ +package schedule + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetStrategyLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetStrategyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetStrategyLogic { + return &ScheduleGetStrategyLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetStrategyLogic) ScheduleGetStrategy() (resp *types.AiStrategyResp, err error) { + resp = &types.AiStrategyResp{} + names := strategy.GetStrategyNames() + resp.Strategies = names + + return resp, nil +} diff --git a/internal/logic/schedule/schedulesubmitlogic.go b/internal/logic/schedule/schedulesubmitlogic.go new file mode 100644 index 00000000..7f0c06be --- /dev/null +++ b/internal/logic/schedule/schedulesubmitlogic.go @@ -0,0 +1,106 @@ +package schedule + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "strconv" + "strings" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleSubmitLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleSubmitLogic { + return &ScheduleSubmitLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *types.ScheduleResp, err error) { + resp = &types.ScheduleResp{} + opt := &option.AiOption{ + AdapterId: req.AiOption.AdapterId, + ClusterIds: req.AiOption.AiClusterIds, + TaskName: req.AiOption.TaskName, + ResourceType: req.AiOption.ResourceType, + Replica: req.AiOption.Replica, + ComputeCard: req.AiOption.ComputeCard, + Tops: req.AiOption.Tops, + TaskType: req.AiOption.TaskType, + DatasetsName: req.AiOption.Datasets, + AlgorithmName: req.AiOption.Algorithm, + StrategyName: req.AiOption.Strategy, + ClusterToStaticWeight: req.AiOption.StaticWeightMap, + Params: req.AiOption.Params, + Envs: req.AiOption.Envs, + Cmd: req.AiOption.Cmd, + } + aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt) + if err != nil { + return nil, err + } + + results, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl) + if err != nil { + return nil, err + } + + switch opt.GetOptionType() { + case option.AI: + rs := (results).([]*schedulers.AiResult) + var synergystatus int64 + if len(rs) > 1 { + synergystatus = 1 + } + strategyCode, err := l.svcCtx.Scheduler.AiStorages.GetStrategyCode(req.AiOption.Strategy) + if err != nil { + return nil, err + } + adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(rs[0].AdapterId) + if err != nil { + return nil, err + } + id, err := l.svcCtx.Scheduler.AiStorages.SaveTask(req.AiOption.TaskName, strategyCode, synergystatus, "10") + if err != nil { + return nil, err + } + + for _, r := range rs { + scheResult := &types.ScheduleResult{} + scheResult.ClusterId = r.ClusterId + scheResult.TaskId = strconv.FormatInt(id, 10) + scheResult.JobId = r.JobId + scheResult.Strategy = r.Strategy + scheResult.Card = strings.ToUpper(r.Card) + scheResult.Replica = r.Replica + scheResult.Msg = r.Msg + + opt.ComputeCard = strings.ToUpper(r.Card) + + clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(r.ClusterId) + + err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, adapterName, r.ClusterId, clusterName, r.JobId, constants.Saved, r.Msg) + if err != nil { + return nil, err + } + + l.svcCtx.Scheduler.AiStorages.AddNoticeInfo(r.AdapterId, adapterName, r.ClusterId, clusterName, r.TaskName, "create", "任务创建中") + + resp.Results = append(resp.Results, scheResult) + } + + } + + return resp, nil +} diff --git a/internal/logic/schedule/uploadalgothmcodelogic.go b/internal/logic/schedule/uploadalgothmcodelogic.go new file mode 100644 index 00000000..6b87fda1 --- /dev/null +++ b/internal/logic/schedule/uploadalgothmcodelogic.go @@ -0,0 +1,35 @@ +package schedule + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UploadAlgothmCodeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUploadAlgothmCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadAlgothmCodeLogic { + return &UploadAlgothmCodeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UploadAlgothmCodeLogic) UploadAlgorithmCode(req *types.UploadAlgorithmCodeReq) (resp *types.UploadAlgorithmCodeResp, err error) { + resp = &types.UploadAlgorithmCodeResp{} + err = l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[req.AdapterId][req.ClusterId].UploadAlgorithmCode(l.ctx, + req.ResourceType, req.Card, req.TaskType, req.Dataset, req.Algorithm, req.Code) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/internal/logic/storage/dailypowerscreenlogic.go b/internal/logic/storage/dailypowerscreenlogic.go new file mode 100644 index 00000000..c4cb0a6f --- /dev/null +++ b/internal/logic/storage/dailypowerscreenlogic.go @@ -0,0 +1,40 @@ +package storage + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" + "k8s.io/apimachinery/pkg/util/json" + "strings" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DailyPowerScreenLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DailyPowerScreenLogic { + return &DailyPowerScreenLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DailyPowerScreenLogic) DailyPowerScreen() (resp *types.DailyPowerScreenResp, err error) { + resp = &types.DailyPowerScreenResp{} + statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/dailytrend", strings.NewReader(``)) + + if statusCode == 200 { + json.Unmarshal(body, &resp.Chart) + println(resp) + } else if statusCode != 200 { + return nil, err + } + return resp, nil +} diff --git a/internal/logic/storage/percentercomputerpowerslogic.go b/internal/logic/storage/percentercomputerpowerslogic.go new file mode 100644 index 00000000..56c5b73f --- /dev/null +++ b/internal/logic/storage/percentercomputerpowerslogic.go @@ -0,0 +1,39 @@ +package storage + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" + "k8s.io/apimachinery/pkg/util/json" + "strings" + + "github.com/zeromicro/go-zero/core/logx" +) + +type PerCenterComputerPowersLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPerCenterComputerPowersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerCenterComputerPowersLogic { + return &PerCenterComputerPowersLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers() (resp *types.PerCenterComputerPowersResp, err error) { + resp = &types.PerCenterComputerPowersResp{} + statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/percenter", strings.NewReader(``)) + + if statusCode == 200 { + json.Unmarshal(body, &resp.Chart) + println(resp) + } else if statusCode != 200 { + return nil, err + } + return resp, nil +} diff --git a/internal/logic/storage/screenstoragelogic.go b/internal/logic/storage/screenstoragelogic.go new file mode 100644 index 00000000..34c2cd60 --- /dev/null +++ b/internal/logic/storage/screenstoragelogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storage + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/jcce-pcm/pcm-participant-ceph/ceph" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScreenStorageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScreenStorageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScreenStorageLogic { + return &ScreenStorageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScreenStorageLogic) ScreenStorage(req *types.StorageScreenReq) (resp *types.StorageScreenResp, err error) { + // todo: add your logic here and delete this line + storageScreenReq := &ceph.StorageScreenReq{} + err = copier.CopyWithOption(storageScreenReq, req, copier.Option{Converters: utils.Converters}) + StorageScreenResp, err := l.svcCtx.CephRpc.StorageScreen(l.ctx, storageScreenReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db storage list"), "Failed to get db storage list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&StorageScreenResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &StorageScreenResp, copier.Option{Converters: utils.Converters}) + return resp, nil +} diff --git a/internal/logic/storelink/deletelinkimagelogic.go b/internal/logic/storelink/deletelinkimagelogic.go new file mode 100644 index 00000000..e94e916d --- /dev/null +++ b/internal/logic/storelink/deletelinkimagelogic.go @@ -0,0 +1,74 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteLinkImageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkImageLogic { + return &DeleteLinkImageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteLinkImageLogic) DeleteLinkImage(req *types.DeleteLinkImageReq) (resp *types.DeleteLinkImageResp, err error) { + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.DeleteLinkImageResp{} + resp.Success = false + resp.ErrorMsg = "partId不存在" + return resp, nil + } + + storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) + if storelink == nil { + return nil, nil + } + + img, err := storelink.ILinkage.DeleteImage(l.ctx, req.ImageId) + if err != nil { + return nil, err + } + if img == nil { + return nil, storeLink.ERROR_RESP_EMPTY + } + + resp = &types.DeleteLinkImageResp{} + //转换成统一返回类型 + imgResp, err := storeLink.ConvertType(img, resp, participant) + if err != nil { + return nil, err + } + if imgResp == nil { + return nil, storeLink.ERROR_CONVERT_EMPTY + } + + return imgResp.(*types.DeleteLinkImageResp), nil +} diff --git a/internal/logic/storelink/deletelinktasklogic.go b/internal/logic/storelink/deletelinktasklogic.go new file mode 100644 index 00000000..7fd6d7a4 --- /dev/null +++ b/internal/logic/storelink/deletelinktasklogic.go @@ -0,0 +1,74 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteLinkTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkTaskLogic { + return &DeleteLinkTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteLinkTaskLogic) DeleteLinkTask(req *types.DeleteLinkTaskReq) (resp *types.DeleteLinkTaskResp, err error) { + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.DeleteLinkTaskResp{} + resp.Success = false + resp.ErrorMsg = "partId不存在" + return resp, nil + } + + storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) + if storelink == nil { + return nil, nil + } + + task, err := storelink.ILinkage.DeleteTask(l.ctx, req.TaskId) + if err != nil { + return nil, err + } + if task == nil { + return nil, storeLink.ERROR_RESP_EMPTY + } + + resp = &types.DeleteLinkTaskResp{} + //转换成统一返回类型 + taskResp, err := storeLink.ConvertType(task, resp, participant) + if err != nil { + return nil, err + } + if taskResp == nil { + return nil, storeLink.ERROR_CONVERT_EMPTY + } + + return taskResp.(*types.DeleteLinkTaskResp), nil +} diff --git a/internal/logic/storelink/getaispecslogic.go b/internal/logic/storelink/getaispecslogic.go new file mode 100644 index 00000000..f7307836 --- /dev/null +++ b/internal/logic/storelink/getaispecslogic.go @@ -0,0 +1,74 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" +) + +type GetAISpecsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetAISpecsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAISpecsLogic { + return &GetAISpecsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetAISpecsLogic) GetAISpecs(req *types.GetResourceSpecsReq) (resp *types.GetResourceSpecsResp, err error) { + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.GetResourceSpecsResp{} + resp.Success = false + resp.ResourceSpecs = nil + resp.ErrorMsg = "partId不存在" + return resp, nil + } + + storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) + if storelink == nil { + return nil, nil + } + + specs, err := storelink.ILinkage.QuerySpecs(l.ctx) + if err != nil { + return nil, err + } + if specs == nil { + return nil, storeLink.ERROR_RESP_EMPTY + } + + resp = &types.GetResourceSpecsResp{} + //转换成统一返回类型 + specsResp, err := storeLink.ConvertType(specs, resp, participant) + if err != nil { + return nil, err + } + if specsResp == nil { + return nil, storeLink.ERROR_CONVERT_EMPTY + } + + return specsResp.(*types.GetResourceSpecsResp), nil +} diff --git a/internal/logic/storelink/getlinkimagelistlogic.go b/internal/logic/storelink/getlinkimagelistlogic.go new file mode 100644 index 00000000..883a9dd7 --- /dev/null +++ b/internal/logic/storelink/getlinkimagelistlogic.go @@ -0,0 +1,74 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" +) + +type GetLinkImageListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetLinkImageListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLinkImageListLogic { + return &GetLinkImageListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetLinkImageListLogic) GetLinkImageList(req *types.GetLinkImageListReq) (resp *types.GetLinkImageListResp, err error) { + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.GetLinkImageListResp{} + resp.Success = false + resp.Images = nil + resp.ErrorMsg = "partId不存在" + return resp, nil + } + + storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) + if storelink == nil { + return nil, nil + } + + list, err := storelink.ILinkage.QueryImageList(l.ctx) + if err != nil { + return nil, err + } + if list == nil { + return nil, storeLink.ERROR_RESP_EMPTY + } + + resp = &types.GetLinkImageListResp{} + //转换成统一返回类型 + listResp, err := storeLink.ConvertType(list, resp, participant) + if err != nil { + return nil, err + } + if listResp == nil { + return nil, storeLink.ERROR_CONVERT_EMPTY + } + + return listResp.(*types.GetLinkImageListResp), nil +} diff --git a/internal/logic/storelink/getlinktasklogic.go b/internal/logic/storelink/getlinktasklogic.go new file mode 100644 index 00000000..0e230840 --- /dev/null +++ b/internal/logic/storelink/getlinktasklogic.go @@ -0,0 +1,75 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetLinkTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLinkTaskLogic { + return &GetLinkTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetLinkTaskLogic) GetLinkTask(req *types.GetLinkTaskReq) (resp *types.GetLinkTaskResp, err error) { + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.GetLinkTaskResp{} + resp.Success = false + resp.Task = nil + resp.ErrorMsg = "partId不存在" + return resp, nil + } + + storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) + if storelink == nil { + return nil, nil + } + + task, err := storelink.ILinkage.QueryTask(l.ctx, req.TaskId) + if err != nil { + return nil, err + } + if task == nil { + return nil, storeLink.ERROR_RESP_EMPTY + } + + resp = &types.GetLinkTaskResp{} + //转换成统一返回类型 + taskResp, err := storeLink.ConvertType(task, resp, participant) + if err != nil { + return nil, err + } + if taskResp == nil { + return nil, storeLink.ERROR_CONVERT_EMPTY + } + + return taskResp.(*types.GetLinkTaskResp), nil +} diff --git a/internal/logic/storelink/getparticipantslogic.go b/internal/logic/storelink/getparticipantslogic.go new file mode 100644 index 00000000..ee791756 --- /dev/null +++ b/internal/logic/storelink/getparticipantslogic.go @@ -0,0 +1,60 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +type GetParticipantsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetParticipantsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetParticipantsLogic { + return &GetParticipantsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetParticipantsLogic) GetParticipants(req *types.GetParticipantsReq) (resp *types.GetParticipantsResp, err error) { + participants := storeLink.GetParticipants(l.svcCtx.DbEngin) + resp = &types.GetParticipantsResp{} + + if participants == nil { + resp.Success = false + resp.Participants = nil + return resp, nil + } + + for _, participant := range participants { + var p types.ParticipantSl + p.ParticipantId = participant.Id + p.ParticipantType = storeLink.AITYPE[participant.Type] + p.ParticipantName = participant.Name + resp.Participants = append(resp.Participants, &p) + } + + resp.Success = true + return resp, nil + +} diff --git a/internal/logic/storelink/submitlinktasklogic.go b/internal/logic/storelink/submitlinktasklogic.go new file mode 100644 index 00000000..555922b5 --- /dev/null +++ b/internal/logic/storelink/submitlinktasklogic.go @@ -0,0 +1,86 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "github.com/zeromicro/go-zero/core/logx" +) + +type SubmitLinkTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitLinkTaskLogic { + return &SubmitLinkTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) { + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.SubmitLinkTaskResp{} + resp.Success = false + resp.TaskId = "" + resp.ErrorMsg = "partId不存在" + return resp, nil + } + + storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) + if storelink == nil { + return nil, nil + } + + var params []string + if len(req.Params) != 0 { + for _, v := range req.Params { + param := v.Key + storeLink.COMMA + v.Val + params = append(params, param) + } + } + var envs []string + if len(req.Envs) != 0 { + for _, v := range req.Envs { + env := v.Key + storeLink.COMMA + v.Val + envs = append(envs, env) + } + } + task, err := storelink.ILinkage.SubmitTask(l.ctx, req.ImageId, req.Cmd, envs, params, req.ResourceId, "", "", "pytorch") + if err != nil { + return nil, err + } + + resp = &types.SubmitLinkTaskResp{} + //转换成统一返回类型 + taskResp, err := storeLink.ConvertType(task, resp, participant) + if err != nil { + return nil, err + } + if taskResp == nil { + return nil, storeLink.ERROR_CONVERT_EMPTY + } + + return taskResp.(*types.SubmitLinkTaskResp), nil +} diff --git a/internal/logic/storelink/uploadlinkimagelogic.go b/internal/logic/storelink/uploadlinkimagelogic.go new file mode 100644 index 00000000..5d8c6b81 --- /dev/null +++ b/internal/logic/storelink/uploadlinkimagelogic.go @@ -0,0 +1,75 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storelink + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UploadLinkImageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUploadLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLinkImageLogic { + return &UploadLinkImageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UploadLinkImageLogic) UploadLinkImage(req *types.UploadLinkImageReq) (resp *types.UploadLinkImageResp, err error) { + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + if *participant == (models.StorelinkCenter{}) { + resp = &types.UploadLinkImageResp{} + resp.Success = false + resp.Image = nil + resp.ErrorMsg = "partId不存在" + return resp, nil + } + + storelink := storeLink.NewStoreLink(l.svcCtx.OctopusRpc, l.svcCtx.ModelArtsRpc, l.svcCtx.ModelArtsImgRpc, l.svcCtx.ACRpc, participant) + if storelink == nil { + return nil, nil + } + + img, err := storelink.ILinkage.UploadImage(l.ctx, req.FilePath) + if err != nil { + return nil, err + } + if img == nil { + return nil, storeLink.ERROR_RESP_EMPTY + } + + resp = &types.UploadLinkImageResp{} + //转换成统一返回类型 + imgResp, err := storeLink.ConvertType(img, resp, participant) + if err != nil { + return nil, err + } + if imgResp == nil { + return nil, storeLink.ERROR_CONVERT_EMPTY + } + + return imgResp.(*types.UploadLinkImageResp), nil +} diff --git a/internal/logic/vm/addsecuritygrouptoserverlogic.go b/internal/logic/vm/addsecuritygrouptoserverlogic.go new file mode 100644 index 00000000..fad0c359 --- /dev/null +++ b/internal/logic/vm/addsecuritygrouptoserverlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddSecurityGroupToServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAddSecurityGroupToServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddSecurityGroupToServerLogic { + return &AddSecurityGroupToServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AddSecurityGroupToServerLogic) AddSecurityGroupToServer(req *types.AddSecurityGroupToServerReq) (resp *types.AddSecurityGroupToServerResp, err error) { + // todo: add your logic here and delete this line + AddSecurityGroupToServerReq := &openstack.AddSecurityGroupToServerReq{} + err = copier.CopyWithOption(AddSecurityGroupToServerReq, req, copier.Option{Converters: utils.Converters}) + AddSecurityGroupToServerResp, err := l.svcCtx.OpenstackRpc.AddSecurityGroupToServer(l.ctx, AddSecurityGroupToServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&AddSecurityGroupToServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &AddSecurityGroupToServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/bulkcreatenetworkslogic.go b/internal/logic/vm/bulkcreatenetworkslogic.go new file mode 100644 index 00000000..073fdb54 --- /dev/null +++ b/internal/logic/vm/bulkcreatenetworkslogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type BulkCreateNetworksLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewBulkCreateNetworksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BulkCreateNetworksLogic { + return &BulkCreateNetworksLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *BulkCreateNetworksLogic) BulkCreateNetworks(req *types.BulkCreateNetworksReq) (resp *types.BulkCreateNetworksResp, err error) { + // todo: add your logic here and delete this line + BulkCreateNetworksReq := &openstack.BulkCreateNetworksReq{} + err = copier.CopyWithOption(BulkCreateNetworksReq, req, copier.Option{Converters: tool.Converters}) + BulkCreateNetworksResp, err := l.svcCtx.OpenstackRpc.BulkCreateNetworks(l.ctx, BulkCreateNetworksReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&BulkCreateNetworksResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &BulkCreateNetworksResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/changeadministrativepasswordlogic.go b/internal/logic/vm/changeadministrativepasswordlogic.go new file mode 100644 index 00000000..ee42cc56 --- /dev/null +++ b/internal/logic/vm/changeadministrativepasswordlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ChangeAdministrativePasswordLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewChangeAdministrativePasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChangeAdministrativePasswordLogic { + return &ChangeAdministrativePasswordLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ChangeAdministrativePasswordLogic) ChangeAdministrativePassword(req *types.ChangeAdministrativePasswordReq) (resp *types.ChangeAdministrativePasswordResp, err error) { + // todo: add your logic here and delete this line + ChangeAdministrativePasswordReq := &openstack.ChangeAdministrativePasswordReq{} + err = copier.CopyWithOption(ChangeAdministrativePasswordReq, req, copier.Option{Converters: utils.Converters}) + ChangeAdministrativePasswordResp, err := l.svcCtx.OpenstackRpc.ChangeAdministrativePassword(l.ctx, ChangeAdministrativePasswordReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ChangeAdministrativePasswordResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ChangeAdministrativePasswordResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createfirewallgrouplogic.go b/internal/logic/vm/createfirewallgrouplogic.go new file mode 100644 index 00000000..ef93bd80 --- /dev/null +++ b/internal/logic/vm/createfirewallgrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateFirewallGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateFirewallGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFirewallGroupLogic { + return &CreateFirewallGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateFirewallGroupLogic) CreateFirewallGroup(req *types.CreateFirewallGroupReq) (resp *types.CreateFirewallGroupResp, err error) { + // todo: add your logic here and delete this line + CreateFirewallGroupReq := &openstack.CreateFirewallGroupReq{} + err = copier.CopyWithOption(CreateFirewallGroupReq, req, copier.Option{Converters: utils.Converters}) + CreateFirewallGroupResp, err := l.svcCtx.OpenstackRpc.CreateFirewallGroup(l.ctx, CreateFirewallGroupReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateFirewallGroupResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateFirewallGroupResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createfirewallpolicylogic.go b/internal/logic/vm/createfirewallpolicylogic.go new file mode 100644 index 00000000..4c8c2ed8 --- /dev/null +++ b/internal/logic/vm/createfirewallpolicylogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateFirewallPolicyLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateFirewallPolicyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFirewallPolicyLogic { + return &CreateFirewallPolicyLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateFirewallPolicyLogic) CreateFirewallPolicy(req *types.CreateFirewallPolicyReq) (resp *types.CreateFirewallPolicyResp, err error) { + // todo: add your logic here and delete this line + CreateFirewallPolicyReq := &openstack.CreateFirewallPolicyReq{} + err = copier.CopyWithOption(CreateFirewallPolicyReq, req, copier.Option{Converters: utils.Converters}) + CreateFirewallPolicyResp, err := l.svcCtx.OpenstackRpc.CreateFirewallPolicy(l.ctx, CreateFirewallPolicyReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateFirewallPolicyResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateFirewallPolicyResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createfirewallrulelogic.go b/internal/logic/vm/createfirewallrulelogic.go new file mode 100644 index 00000000..ccc0ad9a --- /dev/null +++ b/internal/logic/vm/createfirewallrulelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateFirewallRuleLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateFirewallRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFirewallRuleLogic { + return &CreateFirewallRuleLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateFirewallRuleLogic) CreateFirewallRule(req *types.CreateFirewallRuleReq) (resp *types.CreateFirewallRuleResp, err error) { + // todo: add your logic here and delete this line + CreateFirewallRuleReq := &openstack.CreateFirewallRuleReq{} + err = copier.CopyWithOption(CreateFirewallRuleReq, req, copier.Option{Converters: utils.Converters}) + CreateFirewallRuleResp, err := l.svcCtx.OpenstackRpc.CreateFirewallRule(l.ctx, CreateFirewallRuleReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateFirewallRuleResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateFirewallRuleResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createflavorlogic.go b/internal/logic/vm/createflavorlogic.go new file mode 100644 index 00000000..52429e6d --- /dev/null +++ b/internal/logic/vm/createflavorlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateFlavorLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateFlavorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFlavorLogic { + return &CreateFlavorLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateFlavorLogic) CreateFlavor(req *types.CreateFlavorReq) (resp *types.CreateFlavorResp, err error) { + // todo: add your logic here and delete this line + CreateFlavorReq := &openstack.CreateFlavorReq{} + err = copier.CopyWithOption(CreateFlavorReq, req, copier.Option{Converters: utils.Converters}) + CreateFlavorResp, err := l.svcCtx.OpenstackRpc.CreateFlavor(l.ctx, CreateFlavorReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateFlavorResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateFlavorResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createfloatingiplogic.go b/internal/logic/vm/createfloatingiplogic.go new file mode 100644 index 00000000..da015c6a --- /dev/null +++ b/internal/logic/vm/createfloatingiplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateFloatingIPLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateFloatingIPLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateFloatingIPLogic { + return &CreateFloatingIPLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateFloatingIPLogic) CreateFloatingIP(req *types.CreateFloatingIPReq) (resp *types.CreateFloatingIPResp, err error) { + // todo: add your logic here and delete this line + CreateFloatingIPReq := &openstack.CreateFloatingIPReq{} + err = copier.CopyWithOption(CreateFloatingIPReq, req, copier.Option{Converters: utils.Converters}) + CreateFloatingIPResp, err := l.svcCtx.OpenstackRpc.CreateFloatingIP(l.ctx, CreateFloatingIPReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateFloatingIPResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateFloatingIPResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createimagelogic.go b/internal/logic/vm/createimagelogic.go new file mode 100644 index 00000000..38e25cda --- /dev/null +++ b/internal/logic/vm/createimagelogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "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: utils.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: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createmulserverlogic.go b/internal/logic/vm/createmulserverlogic.go new file mode 100644 index 00000000..1f5836c0 --- /dev/null +++ b/internal/logic/vm/createmulserverlogic.go @@ -0,0 +1,82 @@ +package vm + +import ( + "context" + "fmt" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateMulServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateMulServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateMulServerLogic { + return &CreateMulServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// ServerLinks 表示服务器链接的结构体 +type ServerLinks struct { + Href string `json:"href"` // 注意:在JSON中,"href "有一个额外的空格,需要移除 + Rel string `json:"rel"` +} + +// SecurityGroup 表示安全组的结构体 +type SecurityGroup struct { + Name string `json:"name"` +} + +// Server 表示服务器的结构体 +type Server struct { + ID string `json:"id"` + Links []ServerLinks `json:"links"` + OSDCFDiskConfig string `json:"OS_DCF_diskConfig"` + SecurityGroups []SecurityGroup `json:"security_groups"` + AdminPass string `json:"adminPass"` +} + +// Response 表示整个响应的结构体 +type Response struct { + Server Server `json:"server"` +} + +func (l *CreateMulServerLogic) CreateMulServer(req *types.CreateMulServerReq) (resp *types.CreateMulServerResp, err error) { + // todo: add your logic here and delete this line + CreateServerReq := &openstack.CreateServerReq{} + var response Response + fmt.Println("请求入参:", req) + for _, server := range req.CreateMulServer { + fmt.Println("入参参数:", server) + err = copier.CopyWithOption(CreateServerReq, server, copier.Option{Converters: utils.Converters}) + CreateServerResp, err := l.svcCtx.OpenstackRpc.CreateServer(l.ctx, CreateServerReq) + fmt.Println("返回结果:", CreateServerResp) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to create Server list"), "Failed to get db Server list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateServerResp) + fmt.Println("返回结果b:", marshal) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &response) + } + err = copier.CopyWithOption(&resp, &response, copier.Option{Converters: utils.Converters}) + fmt.Println("返回结果c:", resp) + return resp, err +} diff --git a/internal/logic/vm/createnetworklogic.go b/internal/logic/vm/createnetworklogic.go new file mode 100644 index 00000000..bc3df417 --- /dev/null +++ b/internal/logic/vm/createnetworklogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateNetworkLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNetworkLogic { + return &CreateNetworkLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateNetworkLogic) CreateNetwork(req *types.CreateNetworkReq) (resp *types.CreateNetworkResp, err error) { + // todo: add your logic here and delete this line + CreateNetworkReq := &openstack.CreateNetworkReq{} + err = copier.CopyWithOption(CreateNetworkReq, req, copier.Option{Converters: utils.Converters}) + CreateNetworkResp, err := l.svcCtx.OpenstackRpc.CreateNetwork(l.ctx, CreateNetworkReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateNetworkResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateNetworkResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createnetworksegmentrangelogic.go b/internal/logic/vm/createnetworksegmentrangelogic.go new file mode 100644 index 00000000..ca9e59a5 --- /dev/null +++ b/internal/logic/vm/createnetworksegmentrangelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateNetworkSegmentRangeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateNetworkSegmentRangeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNetworkSegmentRangeLogic { + return &CreateNetworkSegmentRangeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateNetworkSegmentRangeLogic) CreateNetworkSegmentRange(req *types.CreateNetworkSegmentRangeReq) (resp *types.CreateNetworkSegmentRangeResp, err error) { + // todo: add your logic here and delete this line + CreateNetworkSegmentRangeReq := &openstack.CreateNetworkSegmentRangeReq{} + err = copier.CopyWithOption(CreateNetworkSegmentRangeReq, req, copier.Option{Converters: utils.Converters}) + CreateNetworkSegmentRangeResp, err := l.svcCtx.OpenstackRpc.CreateNetworkSegmentRange(l.ctx, CreateNetworkSegmentRangeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateNetworkSegmentRangeResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateNetworkSegmentRangeResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createnodelogic.go b/internal/logic/vm/createnodelogic.go new file mode 100644 index 00000000..9c2c8ddb --- /dev/null +++ b/internal/logic/vm/createnodelogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateNodeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateNodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNodeLogic { + return &CreateNodeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateNodeLogic) CreateNode(req *types.CreateNodeReq) (resp *types.CreateNodeResp, err error) { + // todo: add your logic here and delete this line + CreateNodeReq := &openstack.CreateNodeReq{} + err = copier.CopyWithOption(CreateNodeReq, req, copier.Option{Converters: tool.Converters}) + CreateNodeResp, err := l.svcCtx.OpenstackRpc.CreateNode(l.ctx, CreateNodeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateNodeResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateNodeResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createportlogic.go b/internal/logic/vm/createportlogic.go new file mode 100644 index 00000000..633c8ab0 --- /dev/null +++ b/internal/logic/vm/createportlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreatePortLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreatePortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePortLogic { + return &CreatePortLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreatePortLogic) CreatePort(req *types.CreatePortReq) (resp *types.CreatePortResp, err error) { + // todo: add your logic here and delete this line + CreatePortReq := &openstack.CreatePortReq{} + err = copier.CopyWithOption(CreatePortReq, req, copier.Option{Converters: utils.Converters}) + CreatePortResp, err := l.svcCtx.OpenstackRpc.CreatePort(l.ctx, CreatePortReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreatePortResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreatePortResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createrouterlogic.go b/internal/logic/vm/createrouterlogic.go new file mode 100644 index 00000000..69a4b024 --- /dev/null +++ b/internal/logic/vm/createrouterlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateRouterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateRouterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRouterLogic { + return &CreateRouterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateRouterLogic) CreateRouter(req *types.CreateRouterReq) (resp *types.CreateRouterResp, err error) { + // todo: add your logic here and delete this line + CreateRouterReq := &openstack.CreateRouterReq{} + err = copier.CopyWithOption(CreateRouterReq, req, copier.Option{Converters: utils.Converters}) + CreateRouterResp, err := l.svcCtx.OpenstackRpc.CreateRouter(l.ctx, CreateRouterReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateRouterResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateRouterResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createsecuritygrouplogic.go b/internal/logic/vm/createsecuritygrouplogic.go new file mode 100644 index 00000000..ae1455a1 --- /dev/null +++ b/internal/logic/vm/createsecuritygrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateSecurityGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSecurityGroupLogic { + return &CreateSecurityGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateSecurityGroupLogic) CreateSecurityGroup(req *types.CreateSecurityGroupReq) (resp *types.CreateSecurityGroupResp, err error) { + // todo: add your logic here and delete this line + CreateSecurityGroupReq := &openstack.CreateSecurityGroupReq{} + err = copier.CopyWithOption(CreateSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) + CreateSecurityGroupResp, err := l.svcCtx.OpenstackRpc.CreateSecurityGroup(l.ctx, CreateSecurityGroupReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateSecurityGroupResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateSecurityGroupResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createsecuritygrouprulelogic.go b/internal/logic/vm/createsecuritygrouprulelogic.go new file mode 100644 index 00000000..0c7d9357 --- /dev/null +++ b/internal/logic/vm/createsecuritygrouprulelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateSecurityGroupRuleLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateSecurityGroupRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSecurityGroupRuleLogic { + return &CreateSecurityGroupRuleLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateSecurityGroupRuleLogic) CreateSecurityGroupRule(req *types.CreateSecurityGroupRuleReq) (resp *types.CreateSecurityGroupRuleResp, err error) { + // todo: add your logic here and delete this line + CreateSecurityGroupRuleReq := &openstack.CreateSecurityGroupRuleReq{} + err = copier.CopyWithOption(CreateSecurityGroupRuleReq, req, copier.Option{Converters: utils.Converters}) + CreateSecurityGroupRuleResp, err := l.svcCtx.OpenstackRpc.CreateSecurityGroupRule(l.ctx, CreateSecurityGroupRuleReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateSecurityGroupRuleResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateSecurityGroupRuleResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createserverlogic.go b/internal/logic/vm/createserverlogic.go new file mode 100644 index 00000000..c6aee1d4 --- /dev/null +++ b/internal/logic/vm/createserverlogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServerLogic { + return &CreateServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateServerLogic) CreateServer(req *types.CreateServerReq) (resp *types.CreateServerResp, err error) { + // todo: add your logic here and delete this line + CreateServerReq := &openstack.CreateServerReq{} + err = copier.CopyWithOption(CreateServerReq, req, copier.Option{Converters: utils.Converters}) + CreateServerResp, err := l.svcCtx.OpenstackRpc.CreateServer(l.ctx, CreateServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createsubnetlogic.go b/internal/logic/vm/createsubnetlogic.go new file mode 100644 index 00000000..73b85119 --- /dev/null +++ b/internal/logic/vm/createsubnetlogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateSubnetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateSubnetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSubnetLogic { + return &CreateSubnetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateSubnetLogic) CreateSubnet(req *types.CreateSubnetReq) (resp *types.CreateSubnetResp, err error) { + // todo: add your logic here and delete this line + CreateSubnetReq := &openstack.CreateSubnetReq{} + err = copier.CopyWithOption(CreateSubnetReq, req, copier.Option{Converters: utils.Converters}) + CreateSubnetResp, err := l.svcCtx.OpenstackRpc.CreateSubnet(l.ctx, CreateSubnetReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateSubnetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateSubnetResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createvolumelogic.go b/internal/logic/vm/createvolumelogic.go new file mode 100644 index 00000000..3f4ffeec --- /dev/null +++ b/internal/logic/vm/createvolumelogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateVolumeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVolumeLogic { + return &CreateVolumeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateVolumeLogic) CreateVolume(req *types.CreateVolumeReq) (resp *types.CreateVolumeResp, err error) { + // todo: add your logic here and delete this line + CreateVolumeReq := &openstack.CreateVolumeReq{} + err = copier.CopyWithOption(CreateVolumeReq, req, copier.Option{Converters: utils.Converters}) + CreateVolumeResp, err := l.svcCtx.OpenstackRpc.CreateVolume(l.ctx, CreateVolumeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateVolumeResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateVolumeResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/createvolumetypeslogic.go b/internal/logic/vm/createvolumetypeslogic.go new file mode 100644 index 00000000..5b922fea --- /dev/null +++ b/internal/logic/vm/createvolumetypeslogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateVolumeTypesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateVolumeTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVolumeTypesLogic { + return &CreateVolumeTypesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateVolumeTypesLogic) CreateVolumeTypes(req *types.CreateVolumeTypeReq) (resp *types.CreateVolumeTypeResp, err error) { + // todo: add your logic here and delete this line + CreateVolumeTypeReq := &openstack.CreateVolumeTypeReq{} + err = copier.CopyWithOption(CreateVolumeTypeReq, req, copier.Option{Converters: tool.Converters}) + CreateVolumeTypeResp, err := l.svcCtx.OpenstackRpc.CreateVolumeTypes(l.ctx, CreateVolumeTypeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&CreateVolumeTypeResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateVolumeTypeResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletefirewallgrouplogic.go b/internal/logic/vm/deletefirewallgrouplogic.go new file mode 100644 index 00000000..44925f2a --- /dev/null +++ b/internal/logic/vm/deletefirewallgrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteFirewallGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteFirewallGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFirewallGroupLogic { + return &DeleteFirewallGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteFirewallGroupLogic) DeleteFirewallGroup(req *types.DeleteFirewallGroupReq) (resp *types.DeleteFirewallGroupResp, err error) { + // todo: add your logic here and delete this line + DeleteFirewallGroupReq := &openstack.DeleteFirewallGroupReq{} + err = copier.CopyWithOption(DeleteFirewallGroupReq, req, copier.Option{Converters: utils.Converters}) + DeleteFirewallGroupResp, err := l.svcCtx.OpenstackRpc.DeleteFirewallGroup(l.ctx, DeleteFirewallGroupReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteFirewallGroupResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteFirewallGroupResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletefirewallpolicylogic.go b/internal/logic/vm/deletefirewallpolicylogic.go new file mode 100644 index 00000000..3d5604b2 --- /dev/null +++ b/internal/logic/vm/deletefirewallpolicylogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteFirewallPolicyLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteFirewallPolicyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFirewallPolicyLogic { + return &DeleteFirewallPolicyLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteFirewallPolicyLogic) DeleteFirewallPolicy(req *types.DeleteFirewallPolicyReq) (resp *types.DeleteFirewallPolicyResp, err error) { + // todo: add your logic here and delete this line + DeleteFirewallPolicyReq := &openstack.DeleteFirewallPolicyReq{} + err = copier.CopyWithOption(DeleteFirewallPolicyReq, req, copier.Option{Converters: utils.Converters}) + DeleteFirewallPolicyResp, err := l.svcCtx.OpenstackRpc.DeleteFirewallPolicy(l.ctx, DeleteFirewallPolicyReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteFirewallPolicyResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteFirewallPolicyResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletefirewallrulelogic.go b/internal/logic/vm/deletefirewallrulelogic.go new file mode 100644 index 00000000..777831da --- /dev/null +++ b/internal/logic/vm/deletefirewallrulelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteFirewallRuleLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteFirewallRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFirewallRuleLogic { + return &DeleteFirewallRuleLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteFirewallRuleLogic) DeleteFirewallRule(req *types.DeleteFirewallRuleReq) (resp *types.DeleteFirewallRuleResp, err error) { + // todo: add your logic here and delete this line + DeleteFirewallRuleReq := &openstack.DeleteFirewallPolicyReq{} + err = copier.CopyWithOption(DeleteFirewallRuleReq, req, copier.Option{Converters: utils.Converters}) + DeleteFirewallRuleResp, err := l.svcCtx.OpenstackRpc.DeleteFirewallPolicy(l.ctx, DeleteFirewallRuleReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteFirewallRuleResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteFirewallRuleResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deleteflavorlogic.go b/internal/logic/vm/deleteflavorlogic.go new file mode 100644 index 00000000..24be5341 --- /dev/null +++ b/internal/logic/vm/deleteflavorlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteFlavorLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteFlavorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFlavorLogic { + return &DeleteFlavorLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteFlavorLogic) DeleteFlavor(req *types.DeleteFlavorReq) (resp *types.DeleteFlavorResp, err error) { + // todo: add your logic here and delete this line + DeleteFlavorReq := &openstack.DeleteFlavorReq{} + err = copier.CopyWithOption(DeleteFlavorReq, req, copier.Option{Converters: utils.Converters}) + DeleteFlavorResp, err := l.svcCtx.OpenstackRpc.DeleteFlavor(l.ctx, DeleteFlavorReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteFlavorResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteFlavorResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletefloatingiplogic.go b/internal/logic/vm/deletefloatingiplogic.go new file mode 100644 index 00000000..5db6df01 --- /dev/null +++ b/internal/logic/vm/deletefloatingiplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteFloatingIPLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteFloatingIPLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFloatingIPLogic { + return &DeleteFloatingIPLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteFloatingIPLogic) DeleteFloatingIP(req *types.DeleteFloatingIPReq) (resp *types.DeleteFloatingIPResp, err error) { + // todo: add your logic here and delete this line + DeleteFloatingIPReq := &openstack.DeleteFloatingIPReq{} + err = copier.CopyWithOption(DeleteFloatingIPReq, req, copier.Option{Converters: utils.Converters}) + DeleteFloatingIPResp, err := l.svcCtx.OpenstackRpc.DeleteFloatingIP(l.ctx, DeleteFloatingIPReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteFloatingIPResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteFloatingIPResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deleteimagelogic.go b/internal/logic/vm/deleteimagelogic.go new file mode 100644 index 00000000..909d1d5a --- /dev/null +++ b/internal/logic/vm/deleteimagelogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteImageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteImageLogic { + return &DeleteImageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteImageLogic) DeleteImage(req *types.DeleteImageReq) (resp *types.DeleteImageResp, err error) { + // todo: add your logic here and delete this line + DeleteImageReq := &openstack.DeleteImageReq{} + err = copier.CopyWithOption(DeleteImageReq, req, copier.Option{Converters: utils.Converters}) + DeleteImageResp, err := l.svcCtx.OpenstackRpc.DeleteImage(l.ctx, DeleteImageReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteImageResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteImageResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletenetworklogic.go b/internal/logic/vm/deletenetworklogic.go new file mode 100644 index 00000000..39c713c4 --- /dev/null +++ b/internal/logic/vm/deletenetworklogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteNetworkLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNetworkLogic { + return &DeleteNetworkLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteNetworkLogic) DeleteNetwork(req *types.DeleteNetworkReq) (resp *types.DeleteNetworkResp, err error) { + // todo: add your logic here and delete this line + DeleteNetworkReq := &openstack.DeleteNetworkReq{} + err = copier.CopyWithOption(DeleteNetworkReq, req, copier.Option{Converters: utils.Converters}) + DeleteNetworkResp, err := l.svcCtx.OpenstackRpc.DeleteNetwork(l.ctx, DeleteNetworkReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to delete network "), "Failed to delete network err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteNetworkResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteNetworkResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletenetworksegmentrangeslogic.go b/internal/logic/vm/deletenetworksegmentrangeslogic.go new file mode 100644 index 00000000..aa1d7667 --- /dev/null +++ b/internal/logic/vm/deletenetworksegmentrangeslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteNetworkSegmentRangesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteNetworkSegmentRangesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNetworkSegmentRangesLogic { + return &DeleteNetworkSegmentRangesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteNetworkSegmentRangesLogic) DeleteNetworkSegmentRanges(req *types.DeleteNetworkSegmentRangesReq) (resp *types.DeleteNetworkSegmentRangesResp, err error) { + // todo: add your logic here and delete this line + DeleteNetworkSegmentRangesReq := &openstack.DeleteNetworkSegmentRangesReq{} + err = copier.CopyWithOption(DeleteNetworkSegmentRangesReq, req, copier.Option{Converters: utils.Converters}) + DeleteNetworkSegmentRangesResp, err := l.svcCtx.OpenstackRpc.DeleteNetworkSegmentRanges(l.ctx, DeleteNetworkSegmentRangesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteNetworkSegmentRangesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteNetworkSegmentRangesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletenodelogic.go b/internal/logic/vm/deletenodelogic.go new file mode 100644 index 00000000..a0ba89bd --- /dev/null +++ b/internal/logic/vm/deletenodelogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteNodeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteNodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteNodeLogic { + return &DeleteNodeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteNodeLogic) DeleteNode(req *types.DeleteNodeReq) (resp *types.DeleteNodeResp, err error) { + // todo: add your logic here and delete this line + DeleteNodeReq := &openstack.DeleteNodeReq{} + err = copier.CopyWithOption(DeleteNodeReq, req, copier.Option{Converters: tool.Converters}) + DeleteNodeResp, err := l.svcCtx.OpenstackRpc.DeleteNode(l.ctx, DeleteNodeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteNodeResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteNodeResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deleteportlogic.go b/internal/logic/vm/deleteportlogic.go new file mode 100644 index 00000000..218703ee --- /dev/null +++ b/internal/logic/vm/deleteportlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeletePortLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeletePortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePortLogic { + return &DeletePortLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeletePortLogic) DeletePort(req *types.DeletePortReq) (resp *types.DeletePortResp, err error) { + // todo: add your logic here and delete this line + DeletePortReq := &openstack.DeletePortReq{} + err = copier.CopyWithOption(DeletePortReq, req, copier.Option{Converters: utils.Converters}) + DeletePortResp, err := l.svcCtx.OpenstackRpc.DeletePort(l.ctx, DeletePortReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeletePortResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeletePortResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deleterouterlogic.go b/internal/logic/vm/deleterouterlogic.go new file mode 100644 index 00000000..f83096cf --- /dev/null +++ b/internal/logic/vm/deleterouterlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteRouterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteRouterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRouterLogic { + return &DeleteRouterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteRouterLogic) DeleteRouter(req *types.DeleteRouterReq) (resp *types.DeleteRouterResp, err error) { + // todo: add your logic here and delete this line + DeleteRouterReq := &openstack.DeleteRouterReq{} + err = copier.CopyWithOption(DeleteRouterReq, req, copier.Option{Converters: utils.Converters}) + DeleteRouterResp, err := l.svcCtx.OpenstackRpc.DeleteRouter(l.ctx, DeleteRouterReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteRouterResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteRouterResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletesecuritygrouplogic.go b/internal/logic/vm/deletesecuritygrouplogic.go new file mode 100644 index 00000000..f866b1cd --- /dev/null +++ b/internal/logic/vm/deletesecuritygrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteSecurityGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSecurityGroupLogic { + return &DeleteSecurityGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteSecurityGroupLogic) DeleteSecurityGroup(req *types.DeleteSecurityGroupReq) (resp *types.DeleteSecurityGroupResp, err error) { + // todo: add your logic here and delete this line + DeleteSecurityGroupReq := &openstack.DeleteSecurityGroupReq{} + err = copier.CopyWithOption(DeleteSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) + DeleteSecurityGroupResp, err := l.svcCtx.OpenstackRpc.DeleteSecurityGroup(l.ctx, DeleteSecurityGroupReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteSecurityGroupResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteSecurityGroupResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletesecuritygrouprulelogic.go b/internal/logic/vm/deletesecuritygrouprulelogic.go new file mode 100644 index 00000000..dc84d958 --- /dev/null +++ b/internal/logic/vm/deletesecuritygrouprulelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteSecurityGroupRuleLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteSecurityGroupRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSecurityGroupRuleLogic { + return &DeleteSecurityGroupRuleLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteSecurityGroupRuleLogic) DeleteSecurityGroupRule(req *types.DeleteSecurityGroupRuleReq) (resp *types.DeleteSecurityGroupRuleResp, err error) { + // todo: add your logic here and delete this line + DeleteSecurityGroupRuleReq := &openstack.DeleteSecurityGroupRuleReq{} + err = copier.CopyWithOption(DeleteSecurityGroupRuleReq, req, copier.Option{Converters: utils.Converters}) + DeleteSecurityGroupRuleResp, err := l.svcCtx.OpenstackRpc.DeleteSecurityGroupRule(l.ctx, DeleteSecurityGroupRuleReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteSecurityGroupRuleResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteSecurityGroupRuleResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deleteserverlogic.go b/internal/logic/vm/deleteserverlogic.go new file mode 100644 index 00000000..af21d511 --- /dev/null +++ b/internal/logic/vm/deleteserverlogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteServerLogic { + return &DeleteServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteServerLogic) DeleteServer(req *types.DeleteServerReq) (resp *types.DeleteServerResp, err error) { + // todo: add your logic here and delete this line + DeleteServerReq := &openstack.DeleteServerReq{} + err = copier.CopyWithOption(DeleteServerReq, req, copier.Option{Converters: utils.Converters}) + DeleteServerResp, err := l.svcCtx.OpenstackRpc.DeleteServer(l.ctx, DeleteServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletesubnetlogic.go b/internal/logic/vm/deletesubnetlogic.go new file mode 100644 index 00000000..38e49f6f --- /dev/null +++ b/internal/logic/vm/deletesubnetlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteSubnetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteSubnetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSubnetLogic { + return &DeleteSubnetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteSubnetLogic) DeleteSubnet(req *types.DeleteSubnetReq) (resp *types.DeleteSubnetResp, err error) { + // todo: add your logic here and delete this line + DeleteSubnetReq := &openstack.DeleteSubnetReq{} + err = copier.CopyWithOption(DeleteSubnetReq, req, copier.Option{Converters: utils.Converters}) + DeleteSubnetResp, err := l.svcCtx.OpenstackRpc.DeleteSubnet(l.ctx, DeleteSubnetReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteSubnetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteSubnetResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletevolumelogic.go b/internal/logic/vm/deletevolumelogic.go new file mode 100644 index 00000000..a4b0fd04 --- /dev/null +++ b/internal/logic/vm/deletevolumelogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteVolumeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteVolumeLogic { + return &DeleteVolumeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteVolumeLogic) DeleteVolume(req *types.DeleteVolumeReq) (resp *types.DeleteVolumeResp, err error) { + // todo: add your logic here and delete this line + DeleteVolumeReq := &openstack.DeleteVolumeReq{} + err = copier.CopyWithOption(DeleteVolumeReq, req, copier.Option{Converters: utils.Converters}) + DeleteVolumeResp, err := l.svcCtx.OpenstackRpc.DeleteVolume(l.ctx, DeleteVolumeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteVolumeResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteVolumeResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/deletevolumetypelogic.go b/internal/logic/vm/deletevolumetypelogic.go new file mode 100644 index 00000000..d2c6b525 --- /dev/null +++ b/internal/logic/vm/deletevolumetypelogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteVolumeTypeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteVolumeTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteVolumeTypeLogic { + return &DeleteVolumeTypeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteVolumeTypeLogic) DeleteVolumeType(req *types.DeleteVolumeTypeReq) (resp *types.DeleteVolumeTypeResp, err error) { + // todo: add your logic here and delete this line + DeleteVolumeTypeReq := &openstack.DeleteVolumeTypeReq{} + err = copier.CopyWithOption(DeleteVolumeTypeReq, req, copier.Option{Converters: tool.Converters}) + DeleteVolumeTypeResp, err := l.svcCtx.OpenstackRpc.DeleteVolumeTypes(l.ctx, DeleteVolumeTypeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&DeleteVolumeTypeResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &DeleteVolumeTypeResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/getcomputelimitslogic.go b/internal/logic/vm/getcomputelimitslogic.go new file mode 100644 index 00000000..4ed2b572 --- /dev/null +++ b/internal/logic/vm/getcomputelimitslogic.go @@ -0,0 +1,60 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "encoding/json" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetComputeLimitsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetComputeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetComputeLimitsLogic { + return &GetComputeLimitsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetComputeLimitsLogic) GetComputeLimits(req *types.GetComputeLimitsReq) (resp *types.GetComputeLimitsResp, err error) { + GetComputeLimitsReq := &openstack.GetComputeLimitsReq{} + err = copier.CopyWithOption(GetComputeLimitsReq, req, copier.Option{Converters: utils.Converters}) + GetComputeLimitsResp, err := l.svcCtx.OpenstackRpc.GetComputeLimits(l.ctx, GetComputeLimitsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&GetComputeLimitsResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &GetComputeLimitsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/getimagenumlogic.go b/internal/logic/vm/getimagenumlogic.go new file mode 100644 index 00000000..f9f0aaa5 --- /dev/null +++ b/internal/logic/vm/getimagenumlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "fmt" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetImageNumLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetImageNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImageNumLogic { + return &GetImageNumLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetImageNumLogic) GetImageNum(req *types.ListImagesReq) (resp *types.ImageNum, err error) { + // todo: add your logic here and delete this line + resp = &types.ImageNum{} + listImagesReq := &openstack.ListImagesReq{} + listImagesReq.Platform = req.Platform + //err = copier.CopyWithOption(ListImagesReq, req, copier.Option{Converters: utils.Converters}) + ListImagesResp, err := l.svcCtx.OpenstackRpc.ListImages(l.ctx, listImagesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Networks list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + var count int = len(ListImagesResp.Images) + resp.ImageNum = int32(count) + fmt.Println(count) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + return resp, err +} diff --git a/internal/logic/vm/getnetworknumlogic.go b/internal/logic/vm/getnetworknumlogic.go new file mode 100644 index 00000000..04275863 --- /dev/null +++ b/internal/logic/vm/getnetworknumlogic.go @@ -0,0 +1,47 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetNetworkNumLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetNetworkNumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNetworkNumLogic { + return &GetNetworkNumLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetNetworkNumLogic) GetNetworkNum(req *types.ListNetworksReq) (resp *types.NetworkNum, err error) { + // todo: add your logic here and delete this line + resp = &types.NetworkNum{} + ListNetworksReq := &openstack.ListNetworksReq{} + err = copier.CopyWithOption(ListNetworksReq, req, copier.Option{Converters: utils.Converters}) + ListNetworksResp, err := l.svcCtx.OpenstackRpc.ListNetworks(l.ctx, ListNetworksReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Networks list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + var count int = len(ListNetworksResp.Networks) + resp.NetworkNum = int32(count) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + return resp, err +} diff --git a/internal/logic/vm/getopenstackoverviewlogic.go b/internal/logic/vm/getopenstackoverviewlogic.go new file mode 100644 index 00000000..69b43169 --- /dev/null +++ b/internal/logic/vm/getopenstackoverviewlogic.go @@ -0,0 +1,35 @@ +package vm + +import ( + "context" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" +) + +type GetOpenstackOverviewLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetOpenstackOverviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOpenstackOverviewLogic { + return &GetOpenstackOverviewLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetOpenstackOverviewLogic) GetOpenstackOverview(req *types.OpenstackOverviewReq) (resp *types.OpenstackOverviewResp, err error) { + // todo: add your logic here and delete this line + var openstackOverview types.OpenstackOverview + sqlStr := "SELECT t.max_total_cores,t.max_total_ram_size,t.max_total_volumes FROM `vm_openstack_overview` t left join t_cluster tc on t.cluster_id=tc.id where tc.`name` = ?" + l.svcCtx.DbEngin.Raw(sqlStr, req.Platform).Scan(&openstackOverview) + resp = &types.OpenstackOverviewResp{ + Code: 200, + Msg: "success", + Data: openstackOverview, + } + return resp, err +} diff --git a/internal/logic/vm/getserversdetailedbyidlogic.go b/internal/logic/vm/getserversdetailedbyidlogic.go new file mode 100644 index 00000000..5d576e3c --- /dev/null +++ b/internal/logic/vm/getserversdetailedbyidlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetServersDetailedByIdLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetServersDetailedByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetServersDetailedByIdLogic { + return &GetServersDetailedByIdLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetServersDetailedByIdLogic) GetServersDetailedById(req *types.GetServersDetailedByIdReq) (resp *types.GetServersDetailedByIdResp, err error) { + // todo: add your logic here and delete this line + GetServersDetailedByIdReq := &openstack.GetServersDetailedByIdReq{} + err = copier.CopyWithOption(GetServersDetailedByIdReq, req, copier.Option{Converters: tool.Converters}) + GetServersDetailedByIdResp, err := l.svcCtx.OpenstackRpc.GetServersDetailedById(l.ctx, GetServersDetailedByIdReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&GetServersDetailedByIdResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &GetServersDetailedByIdResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/getvolumedetailedbyidlogic.go b/internal/logic/vm/getvolumedetailedbyidlogic.go new file mode 100644 index 00000000..e3195f74 --- /dev/null +++ b/internal/logic/vm/getvolumedetailedbyidlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetVolumeDetailedByIdLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetVolumeDetailedByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVolumeDetailedByIdLogic { + return &GetVolumeDetailedByIdLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetVolumeDetailedByIdLogic) GetVolumeDetailedById(req *types.GetVolumeDetailedByIdReq) (resp *types.GetVolumeDetailedByIdResp, err error) { + // todo: add your logic here and delete this line + GetVolumeDetailedByIdReq := &openstack.GetVolumeDetailedByIdReq{} + err = copier.CopyWithOption(GetVolumeDetailedByIdReq, req, copier.Option{Converters: tool.Converters}) + GetVolumeDetailedByIdResp, err := l.svcCtx.OpenstackRpc.GetVolumeDetailedById(l.ctx, GetVolumeDetailedByIdReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&GetVolumeDetailedByIdResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &GetVolumeDetailedByIdResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/getvolumelimitslogic.go b/internal/logic/vm/getvolumelimitslogic.go new file mode 100644 index 00000000..16ee45f7 --- /dev/null +++ b/internal/logic/vm/getvolumelimitslogic.go @@ -0,0 +1,60 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "encoding/json" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetVolumeLimitsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetVolumeLimitsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVolumeLimitsLogic { + return &GetVolumeLimitsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetVolumeLimitsLogic) GetVolumeLimits(req *types.GetVolumeLimitsReq) (resp *types.GetVolumeLimitsResp, err error) { + GetVolumeLimitsReq := &openstack.GetVolumeLimitsReq{} + err = copier.CopyWithOption(GetVolumeLimitsReq, req, copier.Option{Converters: utils.Converters}) + GetVolumeLimitsResp, err := l.svcCtx.OpenstackRpc.GetVolumeLimits(l.ctx, GetVolumeLimitsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&GetVolumeLimitsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &GetVolumeLimitsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listfirewallgroupslogic.go b/internal/logic/vm/listfirewallgroupslogic.go new file mode 100644 index 00000000..8111421d --- /dev/null +++ b/internal/logic/vm/listfirewallgroupslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListFirewallGroupsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListFirewallGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFirewallGroupsLogic { + return &ListFirewallGroupsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListFirewallGroupsLogic) ListFirewallGroups(req *types.ListFirewallGroupsReq) (resp *types.ListFirewallGroupsResp, err error) { + // todo: add your logic here and delete this line + ListFirewallGroupsReq := &openstack.ListFirewallGroupsReq{} + err = copier.CopyWithOption(ListFirewallGroupsReq, req, copier.Option{Converters: utils.Converters}) + ListFirewallGroupsResp, err := l.svcCtx.OpenstackRpc.ListFirewallGroups(l.ctx, ListFirewallGroupsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListFirewallGroupsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListFirewallGroupsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listfirewallpolicieslogic.go b/internal/logic/vm/listfirewallpolicieslogic.go new file mode 100644 index 00000000..e5ce2e0e --- /dev/null +++ b/internal/logic/vm/listfirewallpolicieslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListFirewallPoliciesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListFirewallPoliciesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFirewallPoliciesLogic { + return &ListFirewallPoliciesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListFirewallPoliciesLogic) ListFirewallPolicies(req *types.ListFirewallPoliciesReq) (resp *types.ListFirewallPoliciesResp, err error) { + // todo: add your logic here and delete this line + ListFirewallPoliciesReq := &openstack.ListFirewallPoliciesReq{} + err = copier.CopyWithOption(ListFirewallPoliciesReq, req, copier.Option{Converters: utils.Converters}) + ListFirewallPoliciesResp, err := l.svcCtx.OpenstackRpc.ListFirewallPolicies(l.ctx, ListFirewallPoliciesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListFirewallPoliciesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListFirewallPoliciesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listfirewallruleslogic.go b/internal/logic/vm/listfirewallruleslogic.go new file mode 100644 index 00000000..b042005a --- /dev/null +++ b/internal/logic/vm/listfirewallruleslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListFirewallRulesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListFirewallRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFirewallRulesLogic { + return &ListFirewallRulesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListFirewallRulesLogic) ListFirewallRules(req *types.ListFirewallRulesReq) (resp *types.ListFirewallRulesResp, err error) { + // todo: add your logic here and delete this line + ListFirewallRulesReq := &openstack.ListFirewallRulesReq{} + err = copier.CopyWithOption(ListFirewallRulesReq, req, copier.Option{Converters: utils.Converters}) + ListFirewallRulesResp, err := l.svcCtx.OpenstackRpc.ListFirewallRules(l.ctx, ListFirewallRulesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListFirewallRulesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListFirewallRulesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listflavorsdetaillogic.go b/internal/logic/vm/listflavorsdetaillogic.go new file mode 100644 index 00000000..63b10961 --- /dev/null +++ b/internal/logic/vm/listflavorsdetaillogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListFlavorsDetailLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListFlavorsDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFlavorsDetailLogic { + return &ListFlavorsDetailLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListFlavorsDetailLogic) ListFlavorsDetail(req *types.ListFlavorsDetailReq) (resp *types.ListFlavorsDetailResp, err error) { + // todo: add your logic here and delete this line + ListFlavorsDetailReq := &openstack.ListFlavorsDetailReq{} + err = copier.CopyWithOption(ListFlavorsDetailReq, req, copier.Option{Converters: utils.Converters}) + ListFlavorsDetailResp, err := l.svcCtx.OpenstackRpc.ListFlavorsDetail(l.ctx, ListFlavorsDetailReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListFlavorsDetailResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListFlavorsDetailResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listfloatingipslogic.go b/internal/logic/vm/listfloatingipslogic.go new file mode 100644 index 00000000..c1ba592a --- /dev/null +++ b/internal/logic/vm/listfloatingipslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListFloatingIPsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListFloatingIPsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListFloatingIPsLogic { + return &ListFloatingIPsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListFloatingIPsLogic) ListFloatingIPs(req *types.ListFloatingIPsReq) (resp *types.ListFloatingIPsResp, err error) { + // todo: add your logic here and delete this line + ListFloatingIPsReq := &openstack.ListFloatingIPsReq{} + err = copier.CopyWithOption(ListFloatingIPsReq, req, copier.Option{Converters: utils.Converters}) + ListFloatingIPsResp, err := l.svcCtx.OpenstackRpc.ListFloatingIPs(l.ctx, ListFloatingIPsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListFloatingIPsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListFloatingIPsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listimageslogic.go b/internal/logic/vm/listimageslogic.go new file mode 100644 index 00000000..24332f3a --- /dev/null +++ b/internal/logic/vm/listimageslogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListImagesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListImagesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListImagesLogic { + return &ListImagesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListImagesLogic) ListImages(req *types.ListImagesReq) (resp *types.ListImagesResp, err error) { + // todo: add your logic here and delete this line + ListImagesReq := &openstack.ListImagesReq{} + err = copier.CopyWithOption(ListImagesReq, req, copier.Option{Converters: utils.Converters}) + ListImagesResp, err := l.svcCtx.OpenstackRpc.ListImages(l.ctx, ListImagesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListImagesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListImagesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listnetworksegmentrangesrangelogic.go b/internal/logic/vm/listnetworksegmentrangesrangelogic.go new file mode 100644 index 00000000..70554ceb --- /dev/null +++ b/internal/logic/vm/listnetworksegmentrangesrangelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListNetworkSegmentRangesRangeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListNetworkSegmentRangesRangeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNetworkSegmentRangesRangeLogic { + return &ListNetworkSegmentRangesRangeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListNetworkSegmentRangesRangeLogic) ListNetworkSegmentRangesRange(req *types.ListNetworkSegmentRangesReq) (resp *types.ListNetworkSegmentRangesResp, err error) { + // todo: add your logic here and delete this line + ListNetworkSegmentRangesReq := &openstack.ListNetworkSegmentRangesReq{} + err = copier.CopyWithOption(ListNetworkSegmentRangesReq, req, copier.Option{Converters: utils.Converters}) + ListNetworkSegmentRangesResp, err := l.svcCtx.OpenstackRpc.ListNetworkSegmentRanges(l.ctx, ListNetworkSegmentRangesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListNetworkSegmentRangesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListNetworkSegmentRangesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listnetworkslogic.go b/internal/logic/vm/listnetworkslogic.go new file mode 100644 index 00000000..df195272 --- /dev/null +++ b/internal/logic/vm/listnetworkslogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListNetworksLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListNetworksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNetworksLogic { + return &ListNetworksLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListNetworksLogic) ListNetworks(req *types.ListNetworksReq) (resp *types.ListNetworksResp, err error) { + // todo: add your logic here and delete this line + ListNetworksReq := &openstack.ListNetworksReq{} + err = copier.CopyWithOption(ListNetworksReq, req, copier.Option{Converters: utils.Converters}) + ListNetworksResp, err := l.svcCtx.OpenstackRpc.ListNetworks(l.ctx, ListNetworksReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Networks list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListNetworksResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListNetworksResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listnodeslogic.go b/internal/logic/vm/listnodeslogic.go new file mode 100644 index 00000000..76e35245 --- /dev/null +++ b/internal/logic/vm/listnodeslogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListNodesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListNodesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNodesLogic { + return &ListNodesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListNodesLogic) ListNodes(req *types.ListNodesReq) (resp *types.ListNodesResp, err error) { + // todo: add your logic here and delete this line + ListNodesReq := &openstack.ListNodesReq{} + err = copier.CopyWithOption(ListNodesReq, req, copier.Option{Converters: tool.Converters}) + ListNodesResp, err := l.svcCtx.OpenstackRpc.ListNodes(l.ctx, ListNodesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListNodesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListNodesResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listportslogic.go b/internal/logic/vm/listportslogic.go new file mode 100644 index 00000000..1883e6a0 --- /dev/null +++ b/internal/logic/vm/listportslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListPortsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListPortsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPortsLogic { + return &ListPortsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListPortsLogic) ListPorts(req *types.ListPortsReq) (resp *types.ListPortsResp, err error) { + // todo: add your logic here and delete this line + ListPortsReq := &openstack.ListPortsReq{} + err = copier.CopyWithOption(ListPortsReq, req, copier.Option{Converters: utils.Converters}) + ListPortsResp, err := l.svcCtx.OpenstackRpc.ListPorts(l.ctx, ListPortsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListPortsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListPortsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listrouterslogic.go b/internal/logic/vm/listrouterslogic.go new file mode 100644 index 00000000..6a5ad5da --- /dev/null +++ b/internal/logic/vm/listrouterslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListRoutersLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListRoutersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListRoutersLogic { + return &ListRoutersLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListRoutersLogic) ListRouters(req *types.ListRoutersReq) (resp *types.ListRoutersResp, err error) { + // todo: add your logic here and delete this line + ListRoutersReq := &openstack.ListRoutersReq{} + err = copier.CopyWithOption(ListRoutersReq, req, copier.Option{Converters: utils.Converters}) + ListRoutersResp, err := l.svcCtx.OpenstackRpc.ListRouters(l.ctx, ListRoutersReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListRoutersResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListRoutersResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listsecuritygroupruleslogic.go b/internal/logic/vm/listsecuritygroupruleslogic.go new file mode 100644 index 00000000..f9da2f2f --- /dev/null +++ b/internal/logic/vm/listsecuritygroupruleslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListSecurityGroupRulesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListSecurityGroupRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSecurityGroupRulesLogic { + return &ListSecurityGroupRulesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListSecurityGroupRulesLogic) ListSecurityGroupRules(req *types.ListSecurityGroupRulesReq) (resp *types.ListSecurityGroupRulesResp, err error) { + // todo: add your logic here and delete this line + ListSecurityGroupRulesReq := &openstack.ListSecurityGroupRulesReq{} + err = copier.CopyWithOption(ListSecurityGroupRulesReq, req, copier.Option{Converters: utils.Converters}) + ListSecurityGroupRulesResp, err := l.svcCtx.OpenstackRpc.ListSecurityGroupRules(l.ctx, ListSecurityGroupRulesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListSecurityGroupRulesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListSecurityGroupRulesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listsecuritygroupslogic.go b/internal/logic/vm/listsecuritygroupslogic.go new file mode 100644 index 00000000..87dc4435 --- /dev/null +++ b/internal/logic/vm/listsecuritygroupslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListSecurityGroupsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListSecurityGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSecurityGroupsLogic { + return &ListSecurityGroupsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListSecurityGroupsLogic) ListSecurityGroups(req *types.ListSecurityGroupsReq) (resp *types.ListSecurityGroupsResp, err error) { + // todo: add your logic here and delete this line + ListSecurityGroupsReq := &openstack.ListSecurityGroupsReq{} + err = copier.CopyWithOption(ListSecurityGroupsReq, req, copier.Option{Converters: utils.Converters}) + ListSecurityGroupsResp, err := l.svcCtx.OpenstackRpc.ListSecurityGroups(l.ctx, ListSecurityGroupsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListSecurityGroupsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListSecurityGroupsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listserverlogic.go b/internal/logic/vm/listserverlogic.go new file mode 100644 index 00000000..42a1e1b2 --- /dev/null +++ b/internal/logic/vm/listserverlogic.go @@ -0,0 +1,60 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" +) + +type ListServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServerLogic { + return &ListServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListServerLogic) ListServer(req *types.ListServersReq) (resp *types.ListServersResp, err error) { + // todo: add your logic here and delete this line + ListServersReq := &openstack.ListServersReq{} + err = copier.CopyWithOption(ListServersReq, req, copier.Option{Converters: utils.Converters}) + ListServersResp, err := l.svcCtx.OpenstackRpc.ListServers(l.ctx, ListServersReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListServersResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListServersResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listserversdetailedlogic.go b/internal/logic/vm/listserversdetailedlogic.go new file mode 100644 index 00000000..5f01f1fa --- /dev/null +++ b/internal/logic/vm/listserversdetailedlogic.go @@ -0,0 +1,55 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" +) + +type ListServersDetailedLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListServersDetailedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListServersDetailedLogic { + return &ListServersDetailedLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListServersDetailedLogic) ListServersDetailed(req *types.ListServersDetailedReq) (resp *types.ListServersDetailedResp, err error) { + resp = &types.ListServersDetailedResp{} + ListServersDetailedReq := &openstack.ListServersDetailedReq{} + err = copier.CopyWithOption(ListServersDetailedReq, req, copier.Option{Converters: utils.Converters}) + ListServersDetailedResp, err := l.svcCtx.OpenstackRpc.ListServersDetailed(l.ctx, ListServersDetailedReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + utils.Convert(&ListServersDetailedResp.Servers, &resp.ServersDetailed) + err = copier.CopyWithOption(&resp, &ListServersDetailedResp, copier.Option{Converters: utils.Converters}) + return resp, err + +} diff --git a/internal/logic/vm/listsubnetslogic.go b/internal/logic/vm/listsubnetslogic.go new file mode 100644 index 00000000..34f6ecaf --- /dev/null +++ b/internal/logic/vm/listsubnetslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListSubnetsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListSubnetsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSubnetsLogic { + return &ListSubnetsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListSubnetsLogic) ListSubnets(req *types.ListSubnetsReq) (resp *types.ListSubnetsResp, err error) { + // todo: add your logic here and delete this line + ListSubnetsReq := &openstack.ListSubnetsReq{} + err = copier.CopyWithOption(ListSubnetsReq, req, copier.Option{Converters: utils.Converters}) + ListSubnetsResp, err := l.svcCtx.OpenstackRpc.ListSubnets(l.ctx, ListSubnetsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ListSubnetsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListSubnetsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listvolumesdetaillogic.go b/internal/logic/vm/listvolumesdetaillogic.go new file mode 100644 index 00000000..72470405 --- /dev/null +++ b/internal/logic/vm/listvolumesdetaillogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListVolumesDetailLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListVolumesDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVolumesDetailLogic { + return &ListVolumesDetailLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListVolumesDetailLogic) ListVolumesDetail(req *types.ListVolumesDetailReq) (resp *types.ListVolumesDetailResp, err error) { + // todo: add your logic here and delete this line + ListVolumesDetailReq := &openstack.ListVolumesDetailReq{} + err = copier.CopyWithOption(ListVolumesDetailReq, req, copier.Option{Converters: utils.Converters}) + ListVolumesDetailResp, err := l.svcCtx.OpenstackRpc.ListVolumesDetail(l.ctx, ListVolumesDetailReq) + 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(&ListVolumesDetailResp) + if err != nil { + return nil, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListVolumesDetailResp, copier.Option{Converters: utils.Converters}) + return resp, err + +} diff --git a/internal/logic/vm/listvolumeslogic.go b/internal/logic/vm/listvolumeslogic.go new file mode 100644 index 00000000..3647fc46 --- /dev/null +++ b/internal/logic/vm/listvolumeslogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListVolumesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListVolumesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVolumesLogic { + return &ListVolumesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListVolumesLogic) ListVolumes(req *types.ListVolumesReq) (resp *types.ListVolumesResp, err error) { + // todo: add your logic here and delete this line + ListVolumesReq := &openstack.ListVolumesReq{} + err = copier.CopyWithOption(ListVolumesReq, req, copier.Option{Converters: tool.Converters}) + ListVolumesResp, err := l.svcCtx.OpenstackRpc.ListVolumes(l.ctx, ListVolumesReq) + 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(&ListVolumesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListVolumesResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/listvolumetypeslogic.go b/internal/logic/vm/listvolumetypeslogic.go new file mode 100644 index 00000000..af308cbe --- /dev/null +++ b/internal/logic/vm/listvolumetypeslogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "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: utils.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, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ListVolumeTypesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/migrateserverlogic.go b/internal/logic/vm/migrateserverlogic.go new file mode 100644 index 00000000..1b093ec8 --- /dev/null +++ b/internal/logic/vm/migrateserverlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type MigrateServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewMigrateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MigrateServerLogic { + return &MigrateServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *MigrateServerLogic) MigrateServer(req *types.MigrateServerReq) (resp *types.MigrateServerResp, err error) { + // todo: add your logic here and delete this line + MigrateServerReq := &openstack.MigrateServerReq{} + err = copier.CopyWithOption(MigrateServerReq, req, copier.Option{Converters: utils.Converters}) + MigrateServerResp, err := l.svcCtx.OpenstackRpc.MigrateServer(l.ctx, MigrateServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&MigrateServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &MigrateServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/pauseserverlogic.go b/internal/logic/vm/pauseserverlogic.go new file mode 100644 index 00000000..63ce8204 --- /dev/null +++ b/internal/logic/vm/pauseserverlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type PauseServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewPauseServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PauseServerLogic { + return &PauseServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *PauseServerLogic) PauseServer(req *types.PauseServerReq) (resp *types.PauseServerResp, err error) { + // todo: add your logic here and delete this line + PauseServerReq := &openstack.PauseServerReq{} + err = copier.CopyWithOption(PauseServerReq, req, copier.Option{Converters: tool.Converters}) + PauseServerResp, err := l.svcCtx.OpenstackRpc.PauseServer(l.ctx, PauseServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&PauseServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &PauseServerResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/rebootserverlogic.go b/internal/logic/vm/rebootserverlogic.go new file mode 100644 index 00000000..6e0a2e61 --- /dev/null +++ b/internal/logic/vm/rebootserverlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type RebootServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewRebootServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RebootServerLogic { + return &RebootServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *RebootServerLogic) RebootServer(req *types.RebootServerReq) (resp *types.RebootServerResp, err error) { + // todo: add your logic here and delete this line + RebootServerReq := &openstack.RebootServerReq{} + err = copier.CopyWithOption(RebootServerReq, req, copier.Option{Converters: tool.Converters}) + RebootServerResp, err := l.svcCtx.OpenstackRpc.RebootServer(l.ctx, RebootServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&RebootServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &RebootServerResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/removesecuritygrouplogic.go b/internal/logic/vm/removesecuritygrouplogic.go new file mode 100644 index 00000000..7d999cfc --- /dev/null +++ b/internal/logic/vm/removesecuritygrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type RemoveSecurityGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewRemoveSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveSecurityGroupLogic { + return &RemoveSecurityGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *RemoveSecurityGroupLogic) RemoveSecurityGroup(req *types.RemoveSecurityGroupReq) (resp *types.RemoveSecurityGroupResp, err error) { + // todo: add your logic here and delete this line + CreateImageReq := &openstack.CreateImageReq{} + err = copier.CopyWithOption(CreateImageReq, req, copier.Option{Converters: utils.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: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/rescueserverlogic.go b/internal/logic/vm/rescueserverlogic.go new file mode 100644 index 00000000..89ad5a41 --- /dev/null +++ b/internal/logic/vm/rescueserverlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type RescueServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewRescueServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RescueServerLogic { + return &RescueServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *RescueServerLogic) RescueServer(req *types.RescueServerReq) (resp *types.RescueServerResp, err error) { + // todo: add your logic here and delete this line + RescueServerReq := &openstack.RescueServerReq{} + err = copier.CopyWithOption(RescueServerReq, req, copier.Option{Converters: utils.Converters}) + RescueServerResp, err := l.svcCtx.OpenstackRpc.RescueServer(l.ctx, RescueServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&RescueServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &RescueServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/resizeserverlogic.go b/internal/logic/vm/resizeserverlogic.go new file mode 100644 index 00000000..9f4b0c82 --- /dev/null +++ b/internal/logic/vm/resizeserverlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ResizeServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewResizeServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResizeServerLogic { + return &ResizeServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ResizeServerLogic) ResizeServer(req *types.ResizeServerReq) (resp *types.ResizeServerResp, err error) { + // todo: add your logic here and delete this line + ResizeServerReq := &openstack.ResizeServerReq{} + err = copier.CopyWithOption(ResizeServerReq, req, copier.Option{Converters: utils.Converters}) + ResizeServerResp, err := l.svcCtx.OpenstackRpc.ResizeServer(l.ctx, ResizeServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ResizeServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ResizeServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/shelveserverlogic.go b/internal/logic/vm/shelveserverlogic.go new file mode 100644 index 00000000..054f647b --- /dev/null +++ b/internal/logic/vm/shelveserverlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShelveServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShelveServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShelveServerLogic { + return &ShelveServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShelveServerLogic) ShelveServer(req *types.ShelveServerReq) (resp *types.ShelveServerResp, err error) { + // todo: add your logic here and delete this line + ShelveServerReq := &openstack.ShelveServerReq{} + err = copier.CopyWithOption(ShelveServerReq, req, copier.Option{Converters: utils.Converters}) + ShelveServerResp, err := l.svcCtx.OpenstackRpc.ShelveServer(l.ctx, ShelveServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShelveServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShelveServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showfirewallgroupdetailslogic.go b/internal/logic/vm/showfirewallgroupdetailslogic.go new file mode 100644 index 00000000..bac6da25 --- /dev/null +++ b/internal/logic/vm/showfirewallgroupdetailslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowFirewallGroupDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowFirewallGroupDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFirewallGroupDetailsLogic { + return &ShowFirewallGroupDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowFirewallGroupDetailsLogic) ShowFirewallGroupDetails(req *types.ShowFirewallGroupDetailsReq) (resp *types.ShowFirewallGroupDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowFirewallGroupDetailsReq := &openstack.ShowFirewallGroupDetailsReq{} + err = copier.CopyWithOption(ShowFirewallGroupDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowFirewallGroupDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFirewallGroupDetails(l.ctx, ShowFirewallGroupDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowFirewallGroupDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowFirewallGroupDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showfirewallpolicydetailslogic.go b/internal/logic/vm/showfirewallpolicydetailslogic.go new file mode 100644 index 00000000..9ce4913d --- /dev/null +++ b/internal/logic/vm/showfirewallpolicydetailslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowFirewallPolicyDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowFirewallPolicyDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFirewallPolicyDetailsLogic { + return &ShowFirewallPolicyDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowFirewallPolicyDetailsLogic) ShowFirewallPolicyDetails(req *types.ShowFirewallPolicyDetailsReq) (resp *types.ShowFirewallPolicyDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowFirewallPolicyDetailsReq := &openstack.ShowFirewallPolicyDetailsReq{} + err = copier.CopyWithOption(ShowFirewallPolicyDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowFirewallPolicyDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFirewallPolicyDetails(l.ctx, ShowFirewallPolicyDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowFirewallPolicyDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowFirewallPolicyDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showfirewallruledetailslogic.go b/internal/logic/vm/showfirewallruledetailslogic.go new file mode 100644 index 00000000..c34a5586 --- /dev/null +++ b/internal/logic/vm/showfirewallruledetailslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowFirewallRuleDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowFirewallRuleDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFirewallRuleDetailsLogic { + return &ShowFirewallRuleDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowFirewallRuleDetailsLogic) ShowFirewallRuleDetails(req *types.ShowFirewallRuleDetailsReq) (resp *types.ShowFirewallRuleDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowFirewallRuleDetailsReq := &openstack.ShowFirewallRuleDetailsReq{} + err = copier.CopyWithOption(ShowFirewallRuleDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowFirewallRuleDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFirewallRuleDetails(l.ctx, ShowFirewallRuleDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowFirewallRuleDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowFirewallRuleDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showfloatingipdetailslogic.go b/internal/logic/vm/showfloatingipdetailslogic.go new file mode 100644 index 00000000..56785314 --- /dev/null +++ b/internal/logic/vm/showfloatingipdetailslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowFloatingIPDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowFloatingIPDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowFloatingIPDetailsLogic { + return &ShowFloatingIPDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowFloatingIPDetailsLogic) ShowFloatingIPDetails(req *types.ShowFloatingIPDetailsReq) (resp *types.ShowFloatingIPDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowFloatingIPDetailsReq := &openstack.ShowFloatingIPDetailsReq{} + err = copier.CopyWithOption(ShowFloatingIPDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowFloatingIPDetailsResp, err := l.svcCtx.OpenstackRpc.ShowFloatingIPDetails(l.ctx, ShowFloatingIPDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowFloatingIPDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowFloatingIPDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/shownetworkdetailslogic.go b/internal/logic/vm/shownetworkdetailslogic.go new file mode 100644 index 00000000..c47ec38d --- /dev/null +++ b/internal/logic/vm/shownetworkdetailslogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowNetworkDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowNetworkDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNetworkDetailsLogic { + return &ShowNetworkDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowNetworkDetailsLogic) ShowNetworkDetails(req *types.ShowNetworkDetailsReq) (resp *types.ShowNetworkDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowNetworkDetailsReq := &openstack.ShowNetworkDetailsReq{} + err = copier.CopyWithOption(ShowNetworkDetailsReq, req, copier.Option{Converters: tool.Converters}) + ShowNetworkDetailsResp, err := l.svcCtx.OpenstackRpc.ShowNetworkDetails(l.ctx, ShowNetworkDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get Servers list"), "Failed to get db Servers list err : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowNetworkDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowNetworkDetailsResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/shownetworksegmentrangedetailslogic.go b/internal/logic/vm/shownetworksegmentrangedetailslogic.go new file mode 100644 index 00000000..4450fdb0 --- /dev/null +++ b/internal/logic/vm/shownetworksegmentrangedetailslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowNetworkSegmentRangeDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowNetworkSegmentRangeDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNetworkSegmentRangeDetailsLogic { + return &ShowNetworkSegmentRangeDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowNetworkSegmentRangeDetailsLogic) ShowNetworkSegmentRangeDetails(req *types.ShowNetworkSegmentRangeDetailsReq) (resp *types.ShowNetworkSegmentRangeDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowNetworkSegmentRangeDetailsReq := &openstack.ShowNetworkSegmentRangeDetailsReq{} + err = copier.CopyWithOption(ShowNetworkSegmentRangeDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowNetworkSegmentRangeDetailsResp, err := l.svcCtx.OpenstackRpc.ShowNetworkSegmentRangeDetails(l.ctx, ShowNetworkSegmentRangeDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowNetworkSegmentRangeDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowNetworkSegmentRangeDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/shownodedetailslogic.go b/internal/logic/vm/shownodedetailslogic.go new file mode 100644 index 00000000..76dc87ce --- /dev/null +++ b/internal/logic/vm/shownodedetailslogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowNodeDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowNodeDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowNodeDetailsLogic { + return &ShowNodeDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowNodeDetailsLogic) ShowNodeDetails(req *types.ShowNodeDetailsReq) (resp *types.ShowNodeDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowNodeDetailsReq := &openstack.ShowNodeDetailsReq{} + err = copier.CopyWithOption(ShowNodeDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowNodeDetailsResp, err := l.svcCtx.OpenstackRpc.ShowNodeDetails(l.ctx, ShowNodeDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowNodeDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowNodeDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showportdetailslogic.go b/internal/logic/vm/showportdetailslogic.go new file mode 100644 index 00000000..9710b22c --- /dev/null +++ b/internal/logic/vm/showportdetailslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowPortDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowPortDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowPortDetailsLogic { + return &ShowPortDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowPortDetailsLogic) ShowPortDetails(req *types.ShowPortDetailsReq) (resp *types.ShowPortDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowPortDetailsReq := &openstack.ShowPortDetailsReq{} + err = copier.CopyWithOption(ShowPortDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowPortDetailsResp, err := l.svcCtx.OpenstackRpc.ShowPortDetails(l.ctx, ShowPortDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowPortDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowPortDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showrouterdetailslogic.go b/internal/logic/vm/showrouterdetailslogic.go new file mode 100644 index 00000000..a36cfb9d --- /dev/null +++ b/internal/logic/vm/showrouterdetailslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowRouterDetailsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowRouterDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowRouterDetailsLogic { + return &ShowRouterDetailsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowRouterDetailsLogic) ShowRouterDetails(req *types.ShowRouterDetailsReq) (resp *types.ShowRouterDetailsResp, err error) { + // todo: add your logic here and delete this line + ShowRouterDetailsReq := &openstack.ShowRouterDetailsReq{} + err = copier.CopyWithOption(ShowRouterDetailsReq, req, copier.Option{Converters: utils.Converters}) + ShowRouterDetailsResp, err := l.svcCtx.OpenstackRpc.ShowRouterDetails(l.ctx, ShowRouterDetailsReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowRouterDetailsResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowRouterDetailsResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showsecuritygrouplogic.go b/internal/logic/vm/showsecuritygrouplogic.go new file mode 100644 index 00000000..060b4da6 --- /dev/null +++ b/internal/logic/vm/showsecuritygrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowSecurityGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowSecurityGroupLogic { + return &ShowSecurityGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowSecurityGroupLogic) ShowSecurityGroup(req *types.ShowSecurityGroupReq) (resp *types.ShowSecurityGroupResp, err error) { + // todo: add your logic here and delete this line + ShowSecurityGroupReq := &openstack.ShowSecurityGroupReq{} + err = copier.CopyWithOption(ShowSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) + ShowSecurityGroupResp, err := l.svcCtx.OpenstackRpc.ShowSecurityGroup(l.ctx, ShowSecurityGroupReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowSecurityGroupResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowSecurityGroupResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/showsecuritygrouprulelogic.go b/internal/logic/vm/showsecuritygrouprulelogic.go new file mode 100644 index 00000000..07cd8977 --- /dev/null +++ b/internal/logic/vm/showsecuritygrouprulelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ShowSecurityGroupRuleLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewShowSecurityGroupRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowSecurityGroupRuleLogic { + return &ShowSecurityGroupRuleLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ShowSecurityGroupRuleLogic) ShowSecurityGroupRule(req *types.ShowSecurityGroupRuleReq) (resp *types.ShowSecurityGroupRuleResp, err error) { + // todo: add your logic here and delete this line + ShowSecurityGroupRuleReq := &openstack.ShowSecurityGroupRuleReq{} + err = copier.CopyWithOption(ShowSecurityGroupRuleReq, req, copier.Option{Converters: utils.Converters}) + ShowSecurityGroupRuleResp, err := l.svcCtx.OpenstackRpc.ShowSecurityGroupRule(l.ctx, ShowSecurityGroupRuleReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&ShowSecurityGroupRuleResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &ShowSecurityGroupRuleResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/startserverlogic.go b/internal/logic/vm/startserverlogic.go new file mode 100644 index 00000000..3e88edc9 --- /dev/null +++ b/internal/logic/vm/startserverlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type StartServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewStartServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartServerLogic { + return &StartServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *StartServerLogic) StartServer(req *types.StartServerReq) (resp *types.StartServerResp, err error) { + // todo: add your logic here and delete this line + StartServerReq := &openstack.StartServerReq{} + err = copier.CopyWithOption(StartServerReq, req, copier.Option{Converters: tool.Converters}) + StartServerResp, err := l.svcCtx.OpenstackRpc.StartServer(l.ctx, StartServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&StartServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &StartServerResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/stopserverlogic.go b/internal/logic/vm/stopserverlogic.go new file mode 100644 index 00000000..54e1a042 --- /dev/null +++ b/internal/logic/vm/stopserverlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type StopServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewStopServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StopServerLogic { + return &StopServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *StopServerLogic) StopServer(req *types.StopServerReq) (resp *types.StopServerResp, err error) { + // todo: add your logic here and delete this line + StopServerReq := &openstack.StopServerReq{} + err = copier.CopyWithOption(StopServerReq, req, copier.Option{Converters: tool.Converters}) + StopServerResp, err := l.svcCtx.OpenstackRpc.StopServer(l.ctx, StopServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&StopServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &StopServerResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/suspendserverlogic.go b/internal/logic/vm/suspendserverlogic.go new file mode 100644 index 00000000..e741af49 --- /dev/null +++ b/internal/logic/vm/suspendserverlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type SuspendServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewSuspendServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SuspendServerLogic { + return &SuspendServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *SuspendServerLogic) SuspendServer(req *types.SuspendServerReq) (resp *types.SuspendServerResp, err error) { + // todo: add your logic here and delete this line + SuspendServerReq := &openstack.SuspendServerReq{} + err = copier.CopyWithOption(SuspendServerReq, req, copier.Option{Converters: utils.Converters}) + SuspendServerResp, err := l.svcCtx.OpenstackRpc.SuspendServer(l.ctx, SuspendServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&SuspendServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &SuspendServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/unpauseserverlogic.go b/internal/logic/vm/unpauseserverlogic.go new file mode 100644 index 00000000..78ad2a4e --- /dev/null +++ b/internal/logic/vm/unpauseserverlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UnpauseServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUnpauseServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnpauseServerLogic { + return &UnpauseServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UnpauseServerLogic) UnpauseServer(req *types.UnpauseServerReq) (resp *types.UnpauseServerResp, err error) { + // todo: add your logic here and delete this line + UnpauseServerReq := &openstack.UnpauseServerReq{} + err = copier.CopyWithOption(UnpauseServerReq, req, copier.Option{Converters: utils.Converters}) + UnpauseServerResp, err := l.svcCtx.OpenstackRpc.UnpauseServer(l.ctx, UnpauseServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UnpauseServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UnpauseServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/unrescuelogic.go b/internal/logic/vm/unrescuelogic.go new file mode 100644 index 00000000..84acca8c --- /dev/null +++ b/internal/logic/vm/unrescuelogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UnRescueLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUnRescueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnRescueLogic { + return &UnRescueLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UnRescueLogic) UnRescue(req *types.UnRescueServerReq) (resp *types.UnRescueServerResp, err error) { + // todo: add your logic here and delete this line + UnRescueServerReq := &openstack.UnRescueServerReq{} + err = copier.CopyWithOption(UnRescueServerReq, req, copier.Option{Converters: utils.Converters}) + UnRescueServerResp, err := l.svcCtx.OpenstackRpc.UnRescue(l.ctx, UnRescueServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UnRescueServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UnRescueServerResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updatefirewallgrouplogic.go b/internal/logic/vm/updatefirewallgrouplogic.go new file mode 100644 index 00000000..e7ebad10 --- /dev/null +++ b/internal/logic/vm/updatefirewallgrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateFirewallGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateFirewallGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateFirewallGroupLogic { + return &UpdateFirewallGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateFirewallGroupLogic) UpdateFirewallGroup(req *types.UpdateFirewallGroupReq) (resp *types.UpdateFirewallGroupResp, err error) { + // todo: add your logic here and delete this line + UpdateFirewallGroupReq := &openstack.UpdateFirewallGroupReq{} + err = copier.CopyWithOption(UpdateFirewallGroupReq, req, copier.Option{Converters: utils.Converters}) + UpdateFirewallGroupResp, err := l.svcCtx.OpenstackRpc.UpdateFirewallGroup(l.ctx, UpdateFirewallGroupReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateFirewallGroupResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateFirewallGroupResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updatefloatingiplogic.go b/internal/logic/vm/updatefloatingiplogic.go new file mode 100644 index 00000000..c787c469 --- /dev/null +++ b/internal/logic/vm/updatefloatingiplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateFloatingIPLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateFloatingIPLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateFloatingIPLogic { + return &UpdateFloatingIPLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateFloatingIPLogic) UpdateFloatingIP(req *types.UpdateFloatingIPReq) (resp *types.UpdateFloatingIPResp, err error) { + // todo: add your logic here and delete this line + UpdateFloatingIPReq := &openstack.UpdateFloatingIPReq{} + err = copier.CopyWithOption(UpdateFloatingIPReq, req, copier.Option{Converters: utils.Converters}) + UpdateFloatingIPResp, err := l.svcCtx.OpenstackRpc.UpdateFloatingIP(l.ctx, UpdateFloatingIPReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateFloatingIPResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateFloatingIPResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updatenetworklogic.go b/internal/logic/vm/updatenetworklogic.go new file mode 100644 index 00000000..9a1b2bb0 --- /dev/null +++ b/internal/logic/vm/updatenetworklogic.go @@ -0,0 +1,63 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateNetworkLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateNetworkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateNetworkLogic { + return &UpdateNetworkLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateNetworkLogic) UpdateNetwork(req *types.UpdateNetworkReq) (resp *types.UpdateNetworkResp, err error) { + // todo: add your logic here and delete this line + UpdateNetworkReq := &openstack.UpdateNetworkReq{} + err = copier.CopyWithOption(UpdateNetworkReq, req, copier.Option{Converters: utils.Converters}) + UpdateNetworkResp, err := l.svcCtx.OpenstackRpc.UpdateNetwork(l.ctx, UpdateNetworkReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端更新失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateNetworkResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateNetworkResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updatenetworksegmentrangeslogic.go b/internal/logic/vm/updatenetworksegmentrangeslogic.go new file mode 100644 index 00000000..72db0928 --- /dev/null +++ b/internal/logic/vm/updatenetworksegmentrangeslogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateNetworkSegmentRangesLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateNetworkSegmentRangesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateNetworkSegmentRangesLogic { + return &UpdateNetworkSegmentRangesLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateNetworkSegmentRangesLogic) UpdateNetworkSegmentRanges(req *types.UpdateNetworkSegmentRangesReq) (resp *types.UpdateNetworkSegmentRangesResp, err error) { + // todo: add your logic here and delete this line + UpdateNetworkSegmentRangesReq := &openstack.UpdateNetworkSegmentRangesReq{} + err = copier.CopyWithOption(UpdateNetworkSegmentRangesReq, req, copier.Option{Converters: utils.Converters}) + UpdateNetworkSegmentRangesResp, err := l.svcCtx.OpenstackRpc.UpdateNetworkSegmentRanges(l.ctx, UpdateNetworkSegmentRangesReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateNetworkSegmentRangesResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateNetworkSegmentRangesResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updateportlogic.go b/internal/logic/vm/updateportlogic.go new file mode 100644 index 00000000..21428d66 --- /dev/null +++ b/internal/logic/vm/updateportlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdatePortLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdatePortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdatePortLogic { + return &UpdatePortLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdatePortLogic) UpdatePort(req *types.UpdatePortReq) (resp *types.UpdatePortResp, err error) { + // todo: add your logic here and delete this line + UpdatePortReq := &openstack.UpdatePortReq{} + err = copier.CopyWithOption(UpdatePortReq, req, copier.Option{Converters: utils.Converters}) + UpdatePortResp, err := l.svcCtx.OpenstackRpc.UpdatePort(l.ctx, UpdatePortReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdatePortResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdatePortResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updaterouterlogic.go b/internal/logic/vm/updaterouterlogic.go new file mode 100644 index 00000000..243d4800 --- /dev/null +++ b/internal/logic/vm/updaterouterlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateRouterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateRouterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateRouterLogic { + return &UpdateRouterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateRouterLogic) UpdateRouter(req *types.UpdateRouterReq) (resp *types.UpdateRouterResp, err error) { + // todo: add your logic here and delete this line + UpdateRouterReq := &openstack.UpdateRouterReq{} + err = copier.CopyWithOption(UpdateRouterReq, req, copier.Option{Converters: utils.Converters}) + UpdateRouterResp, err := l.svcCtx.OpenstackRpc.UpdateRouter(l.ctx, UpdateRouterReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateRouterResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateRouterResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updatesecuritygrouplogic.go b/internal/logic/vm/updatesecuritygrouplogic.go new file mode 100644 index 00000000..da694ec6 --- /dev/null +++ b/internal/logic/vm/updatesecuritygrouplogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateSecurityGroupLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateSecurityGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSecurityGroupLogic { + return &UpdateSecurityGroupLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateSecurityGroupLogic) UpdateSecurityGroup(req *types.UpdateSecurityGroupReq) (resp *types.UpdateSecurityGroupResp, err error) { + // todo: add your logic here and delete this line + UpdateSecurityGroupReq := &openstack.UpdateSecurityGroupReq{} + err = copier.CopyWithOption(UpdateSecurityGroupReq, req, copier.Option{Converters: utils.Converters}) + UpdateSecurityGroupResp, err := l.svcCtx.OpenstackRpc.UpdateSecurityGroup(l.ctx, UpdateSecurityGroupReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateSecurityGroupResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateSecurityGroupResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updateserverlogic.go b/internal/logic/vm/updateserverlogic.go new file mode 100644 index 00000000..1a571c96 --- /dev/null +++ b/internal/logic/vm/updateserverlogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateServerLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateServerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateServerLogic { + return &UpdateServerLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateServerLogic) UpdateServer(req *types.UpdateServerReq) (resp *types.UpdateServerResp, err error) { + // todo: add your logic here and delete this line + UpdateServerReq := &openstack.UpdateServerReq{} + err = copier.CopyWithOption(UpdateServerReq, req, copier.Option{Converters: tool.Converters}) + UpdateServerResp, err := l.svcCtx.OpenstackRpc.UpdateServer(l.ctx, UpdateServerReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateServerResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updatesubnetlogic.go b/internal/logic/vm/updatesubnetlogic.go new file mode 100644 index 00000000..e95f7d88 --- /dev/null +++ b/internal/logic/vm/updatesubnetlogic.go @@ -0,0 +1,48 @@ +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateSubnetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateSubnetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSubnetLogic { + return &UpdateSubnetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateSubnetLogic) UpdateSubnet(req *types.UpdateSubnetReq) (resp *types.UpdateSubnetResp, err error) { + // todo: add your logic here and delete this line + UpdateSubnetReq := &openstack.UpdateSubnetReq{} + err = copier.CopyWithOption(UpdateSubnetReq, req, copier.Option{Converters: utils.Converters}) + UpdateSubnetResp, err := l.svcCtx.OpenstackRpc.UpdateSubnet(l.ctx, UpdateSubnetReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateSubnetResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateSubnetResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/logic/vm/updatevolumelogic.go b/internal/logic/vm/updatevolumelogic.go new file mode 100644 index 00000000..6f745ad6 --- /dev/null +++ b/internal/logic/vm/updatevolumelogic.go @@ -0,0 +1,62 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + tool "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateVolumeLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateVolumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateVolumeLogic { + return &UpdateVolumeLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateVolumeLogic) UpdateVolume(req *types.UpdateVolumeReq) (resp *types.UpdateVolumeResp, err error) { + // todo: add your logic here and delete this line + UpdateVolumeReq := &openstack.UpdateVolumeReq{} + err = copier.CopyWithOption(UpdateVolumeReq, req, copier.Option{Converters: tool.Converters}) + UpdateServerResp, err := l.svcCtx.OpenstackRpc.UpdateVolume(l.ctx, UpdateVolumeReq) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrMsg("c端创建失败"), "c端创建失败 : %v ,req:%+v", err, req) + } + marshal, err := json.Marshal(&UpdateServerResp) + if err != nil { + return nil, result.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &UpdateServerResp, copier.Option{Converters: tool.Converters}) + return resp, err +} diff --git a/internal/logic/vm/uploadimagelogic.go b/internal/logic/vm/uploadimagelogic.go new file mode 100644 index 00000000..5117f3b5 --- /dev/null +++ b/internal/logic/vm/uploadimagelogic.go @@ -0,0 +1,61 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package vm + +import ( + "context" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" + error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-openstack/openstack" + "k8s.io/apimachinery/pkg/util/json" + + "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: utils.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, error2.NewDefaultError(err.Error()) + } + json.Unmarshal(marshal, &resp) + err = copier.CopyWithOption(&resp, &CreateImageResp, copier.Option{Converters: utils.Converters}) + return resp, err +} diff --git a/internal/mqs/ScheduleAi.go b/internal/mqs/ScheduleAi.go new file mode 100644 index 00000000..748c6421 --- /dev/null +++ b/internal/mqs/ScheduleAi.go @@ -0,0 +1,49 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package mqs + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +/* +* +Listening to the payment flow status change notification message queue +*/ +type AiQueue struct { + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAiMq(ctx context.Context, svcCtx *svc.ServiceContext) *AiQueue { + return &AiQueue{ + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AiQueue) Consume(val string) error { + aiSchdl, _ := schedulers.NewAiScheduler(l.ctx, val, l.svcCtx.Scheduler, nil) + + // 调度算法 + _, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl) + if err != nil { + return err + } + + return nil +} diff --git a/internal/mqs/ScheduleCloud.go b/internal/mqs/ScheduleCloud.go new file mode 100644 index 00000000..67a20b82 --- /dev/null +++ b/internal/mqs/ScheduleCloud.go @@ -0,0 +1,63 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package mqs + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +/* +* + */ +type CloudMq struct { + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCloudMq(ctx context.Context, svcCtx *svc.ServiceContext) *CloudMq { + return &CloudMq{ + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CloudMq) Consume(val string) error { + // 接受消息, 根据标签筛选过滤 + //cloudScheduler := schedulers.NewCloudScheduler() + //schdl, err := scheduler.NewScheduler(cloudScheduler, val, l.svcCtx.DbEngin, l.svcCtx.ParticipantRpc) + //if err != nil { + // return err + //} + // + ////检测是否指定了集群列表 + //schdl.SpecifyClusters() + // + ////检测是否指定了nsID + //schdl.SpecifyNsID() + // + ////通过标签匹配筛选出集群范围 + //schdl.MatchLabels() + // + ////todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度 + //schdl.TempAssign() + // + //// 存储数据 + //err = schdl.SaveToDb() + //if err != nil { + // return err + //} + return nil +} diff --git a/internal/mqs/ScheduleHpc.go b/internal/mqs/ScheduleHpc.go new file mode 100644 index 00000000..78e54976 --- /dev/null +++ b/internal/mqs/ScheduleHpc.go @@ -0,0 +1,40 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package mqs + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +/* +* +Listening to the payment flow status change notification message queue +*/ +type HpcMq struct { + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewHpcMq(ctx context.Context, svcCtx *svc.ServiceContext) *HpcMq { + return &HpcMq{ + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *HpcMq) Consume(val string) error { + return nil +} diff --git a/internal/mqs/ScheduleVm.go b/internal/mqs/ScheduleVm.go new file mode 100644 index 00000000..5c0af637 --- /dev/null +++ b/internal/mqs/ScheduleVm.go @@ -0,0 +1,49 @@ +package mqs + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +/* +* + */ +type VmMq struct { + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewVmMq(ctx context.Context, svcCtx *svc.ServiceContext) *VmMq { + return &VmMq{ + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *VmMq) Consume(val string) error { + // 接受消息, 根据标签筛选过滤 + //vmScheduler := schedulers.NewVmScheduler() + //schdl, err := scheduler.NewScheduler(vmScheduler, val, l.svcCtx.DbEngin, l.svcCtx.ParticipantRpc) + //if err != nil { + // return err + //} + // + ////检测是否指定了集群列表 + //schdl.SpecifyClusters() + // + ////检测是否指定了nsID + //schdl.SpecifyNsID() + // + ////通过标签匹配筛选出集群范围 + //schdl.MatchLabels() + // + ////todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度 + //schdl.TempAssign() + // + //// 存储数据 + //err = schdl.SaveToDb() + //if err != nil { + // return err + //} + return nil +} diff --git a/api/internal/mqs/queue.go b/internal/mqs/queue.go similarity index 100% rename from api/internal/mqs/queue.go rename to internal/mqs/queue.go diff --git a/api/internal/scheduler/algorithm/providerPricing/pricing.go b/internal/scheduler/algorithm/providerPricing/pricing.go similarity index 100% rename from api/internal/scheduler/algorithm/providerPricing/pricing.go rename to internal/scheduler/algorithm/providerPricing/pricing.go diff --git a/api/internal/scheduler/algorithm/providerPricing/provider.go b/internal/scheduler/algorithm/providerPricing/provider.go similarity index 100% rename from api/internal/scheduler/algorithm/providerPricing/provider.go rename to internal/scheduler/algorithm/providerPricing/provider.go diff --git a/api/internal/scheduler/algorithm/providerPricing/strategy.go b/internal/scheduler/algorithm/providerPricing/strategy.go similarity index 100% rename from api/internal/scheduler/algorithm/providerPricing/strategy.go rename to internal/scheduler/algorithm/providerPricing/strategy.go diff --git a/api/internal/scheduler/algorithm/providerPricing/task.go b/internal/scheduler/algorithm/providerPricing/task.go similarity index 100% rename from api/internal/scheduler/algorithm/providerPricing/task.go rename to internal/scheduler/algorithm/providerPricing/task.go diff --git a/api/internal/scheduler/algorithm/weightDistributing/weightDistributing.go b/internal/scheduler/algorithm/weightDistributing/weightDistributing.go similarity index 100% rename from api/internal/scheduler/algorithm/weightDistributing/weightDistributing.go rename to internal/scheduler/algorithm/weightDistributing/weightDistributing.go diff --git a/api/internal/scheduler/common/common.go b/internal/scheduler/common/common.go similarity index 100% rename from api/internal/scheduler/common/common.go rename to internal/scheduler/common/common.go diff --git a/internal/scheduler/database/aiStorage.go b/internal/scheduler/database/aiStorage.go new file mode 100644 index 00000000..a482e5a7 --- /dev/null +++ b/internal/scheduler/database/aiStorage.go @@ -0,0 +1,368 @@ +package database + +import ( + "github.com/zeromicro/go-zero/core/logx" + clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/client" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + "gorm.io/gorm" + "strconv" + "time" +) + +type AiStorage struct { + DbEngin *gorm.DB +} + +func (s *AiStorage) GetParticipants() (*types.ClusterListResp, error) { + var resp types.ClusterListResp + tx := s.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL ORDER BY create_time Desc").Scan(&resp.List) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return nil, tx.Error + } + return &resp, nil +} + +func (s *AiStorage) GetClustersByAdapterId(id string) (*types.ClusterListResp, error) { + var resp types.ClusterListResp + tx := s.DbEngin.Raw("select * from t_cluster where `deleted_at` IS NULL and `adapter_id` = ? ORDER BY create_time Desc", id).Scan(&resp.List) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return nil, tx.Error + } + return &resp, nil +} + +func (s *AiStorage) GetClusterNameById(id string) (string, error) { + var name string + tx := s.DbEngin.Raw("select `description` from t_cluster where `id` = ?", id).Scan(&name) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return "", tx.Error + } + return name, nil +} + +func (s *AiStorage) GetAdapterNameById(id string) (string, error) { + var name string + tx := s.DbEngin.Raw("select `name` from t_adapter where `id` = ?", id).Scan(&name) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return "", tx.Error + } + return name, nil +} + +func (s *AiStorage) GetAdapterIdsByType(adapterType string) ([]string, error) { + var list []types.AdapterInfo + var ids []string + db := s.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") + db = db.Where("type = ?", adapterType) + err := db.Order("create_time desc").Find(&list).Error + if err != nil { + return nil, err + } + for _, info := range list { + ids = append(ids, info.Id) + } + return ids, nil +} + +func (s *AiStorage) GetAdaptersByType(adapterType string) ([]*types.AdapterInfo, error) { + var list []*types.AdapterInfo + db := s.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter") + db = db.Where("type = ?", adapterType) + err := db.Order("create_time desc").Find(&list).Error + if err != nil { + return nil, err + } + return list, nil +} + +func (s *AiStorage) GetAiTasksByAdapterId(adapterId string) ([]*models.TaskAi, error) { + var resp []*models.TaskAi + db := s.DbEngin.Model(&models.TaskAi{}).Table("task_ai") + db = db.Where("adapter_id = ?", adapterId) + err := db.Order("commit_time desc").Find(&resp).Error + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *AiStorage) GetAiTaskListById(id int64) ([]*models.TaskAi, error) { + var aiTaskList []*models.TaskAi + tx := s.DbEngin.Raw("select * from task_ai where `task_id` = ? ", id).Scan(&aiTaskList) + if tx.Error != nil { + return nil, tx.Error + } + return aiTaskList, nil +} + +func (s *AiStorage) SaveTask(name string, strategyCode int64, synergyStatus int64, aiType string) (int64, error) { + startTime := time.Now() + // 构建主任务结构体 + taskModel := models.Task{ + Status: constants.Saved, + Description: "ai task", + Name: name, + SynergyStatus: synergyStatus, + Strategy: strategyCode, + AdapterTypeDict: "1", + TaskTypeDict: aiType, + StartTime: &startTime, + CommitTime: time.Now(), + } + // 保存任务数据到数据库 + tx := s.DbEngin.Create(&taskModel) + if tx.Error != nil { + return 0, tx.Error + } + return taskModel.Id, nil +} + +func (s *AiStorage) UpdateTask(task *types.TaskModel) error { + task.UpdatedTime = time.Now().Format(constants.Layout) + tx := s.DbEngin.Table("task").Model(task).Updates(task) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return tx.Error + } + return nil +} + +func (s *AiStorage) SaveAiTask(taskId int64, opt option.Option, adapterName string, clusterId string, clusterName string, jobId string, status string, msg string) error { + var aiOpt *option.AiOption + switch (opt).(type) { + case *option.AiOption: + aiOpt = (opt).(*option.AiOption) + case *option.InferOption: + inferOpt := (opt).(*option.InferOption) + aiOpt = &option.AiOption{} + aiOpt.TaskName = inferOpt.TaskName + aiOpt.Replica = inferOpt.Replica + aiOpt.AdapterId = inferOpt.AdapterId + aiOpt.TaskType = inferOpt.ModelType + aiOpt.StrategyName = inferOpt.Strategy + } + // 构建主任务结构体 + aId, err := strconv.ParseInt(aiOpt.AdapterId, 10, 64) + if err != nil { + return err + } + cId, err := strconv.ParseInt(clusterId, 10, 64) + if err != nil { + return err + } + + aiTaskModel := models.TaskAi{ + TaskId: taskId, + AdapterId: aId, + AdapterName: adapterName, + ClusterId: cId, + ClusterName: clusterName, + Name: aiOpt.TaskName, + Replica: int64(aiOpt.Replica), + JobId: jobId, + TaskType: aiOpt.TaskType, + Strategy: aiOpt.StrategyName, + Status: status, + Msg: msg, + Card: aiOpt.ComputeCard, + StartTime: time.Now().Format(time.RFC3339), + CommitTime: time.Now(), + } + // 保存任务数据到数据库 + tx := s.DbEngin.Create(&aiTaskModel) + if tx.Error != nil { + return tx.Error + } + return nil +} + +func (s *AiStorage) SaveAiTaskImageSubTask(ta *models.TaskAiSub) error { + tx := s.DbEngin.Table("task_ai_sub").Create(ta) + if tx.Error != nil { + return tx.Error + } + return nil +} + +func (s *AiStorage) SaveClusterTaskQueue(adapterId string, clusterId string, queueNum int64) error { + aId, err := strconv.ParseInt(adapterId, 10, 64) + if err != nil { + return err + } + cId, err := strconv.ParseInt(clusterId, 10, 64) + if err != nil { + return err + } + taskQueue := models.TClusterTaskQueue{ + AdapterId: aId, + ClusterId: cId, + QueueNum: queueNum, + } + tx := s.DbEngin.Create(&taskQueue) + if tx.Error != nil { + return tx.Error + } + return nil +} + +func (s *AiStorage) GetClusterTaskQueues(adapterId string, clusterId string) ([]*models.TClusterTaskQueue, error) { + var taskQueues []*models.TClusterTaskQueue + tx := s.DbEngin.Raw("select * from t_cluster_task_queue where `adapter_id` = ? and `cluster_id` = ?", adapterId, clusterId).Scan(&taskQueues) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return nil, tx.Error + } + return taskQueues, nil +} + +func (s *AiStorage) GetAiTaskIdByClusterIdAndTaskId(clusterId string, taskId string) (string, error) { + var aiTask models.TaskAi + tx := s.DbEngin.Raw("select * from task_ai where `cluster_id` = ? and `task_id` = ?", clusterId, taskId).Scan(&aiTask) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return "", tx.Error + } + return aiTask.JobId, nil +} + +func (s *AiStorage) GetClusterResourcesById(clusterId string) (*models.TClusterResource, error) { + var clusterResource models.TClusterResource + tx := s.DbEngin.Raw("select * from t_cluster_resource where `cluster_id` = ?", clusterId).Scan(&clusterResource) + if tx.Error != nil { + logx.Errorf(tx.Error.Error()) + return nil, tx.Error + } + return &clusterResource, nil +} + +func (s *AiStorage) SaveClusterResources(adapterId string, clusterId string, clusterName string, clusterType int64, cpuAvail float64, cpuTotal float64, + memAvail float64, memTotal float64, diskAvail float64, diskTotal float64, gpuAvail float64, gpuTotal float64, cardTotal int64, topsTotal float64) error { + cId, err := strconv.ParseInt(clusterId, 10, 64) + if err != nil { + return err + } + aId, err := strconv.ParseInt(adapterId, 10, 64) + if err != nil { + return err + } + clusterResource := models.TClusterResource{ + AdapterId: aId, + ClusterId: cId, + ClusterName: clusterName, + ClusterType: clusterType, + CpuAvail: cpuAvail, + CpuTotal: cpuTotal, + MemAvail: memAvail, + MemTotal: memTotal, + DiskAvail: diskAvail, + DiskTotal: diskTotal, + GpuAvail: gpuAvail, + GpuTotal: gpuTotal, + CardTotal: cardTotal, + CardTopsTotal: topsTotal, + } + tx := s.DbEngin.Create(&clusterResource) + if tx.Error != nil { + return tx.Error + } + // prometheus + param := tracker.ClusterLoadRecord{ + AdapterId: aId, + ClusterName: clusterName, + CpuAvail: cpuAvail, + CpuTotal: cpuTotal, + CpuUtilisation: clusterResource.CpuAvail / clusterResource.CpuTotal, + MemoryAvail: memAvail, + MemoryTotal: memTotal, + MemoryUtilisation: clusterResource.MemAvail / clusterResource.MemTotal, + DiskAvail: diskAvail, + DiskTotal: diskTotal, + DiskUtilisation: clusterResource.DiskAvail / clusterResource.DiskTotal, + } + tracker.SyncClusterLoad(param) + return nil +} + +func (s *AiStorage) UpdateClusterResources(clusterResource *models.TClusterResource) error { + tx := s.DbEngin.Where("cluster_id = ?", clusterResource.ClusterId).Updates(clusterResource) + + if tx.Error != nil { + return tx.Error + } + // prometheus + param := tracker.ClusterLoadRecord{ + AdapterId: clusterResource.AdapterId, + ClusterName: clusterResource.ClusterName, + CpuAvail: clusterResource.CpuAvail, + CpuTotal: clusterResource.CpuTotal, + CpuUtilisation: clusterResource.CpuAvail / clusterResource.CpuTotal, + MemoryAvail: clusterResource.MemAvail, + MemoryTotal: clusterResource.MemTotal, + MemoryUtilisation: clusterResource.MemAvail / clusterResource.MemTotal, + DiskAvail: clusterResource.DiskAvail, + DiskTotal: clusterResource.DiskTotal, + DiskUtilisation: clusterResource.DiskAvail / clusterResource.DiskTotal, + } + tracker.SyncClusterLoad(param) + return nil +} + +func (s *AiStorage) UpdateAiTask(task *models.TaskAi) error { + tx := s.DbEngin.Updates(task) + if tx.Error != nil { + return tx.Error + } + return nil +} + +func (s *AiStorage) GetStrategyCode(name string) (int64, error) { + var strategy int64 + sqlStr := `select t_dict_item.item_value + from t_dict + left join t_dict_item on t_dict.id = t_dict_item.dict_id + where item_text = ? + and t_dict.dict_code = 'schedule_Strategy'` + //查询调度策略 + err := s.DbEngin.Raw(sqlStr, name).Scan(&strategy).Error + if err != nil { + return strategy, nil + } + return strategy, nil +} + +func (s *AiStorage) AddNoticeInfo(adapterId string, adapterName string, clusterId string, clusterName string, taskName string, noticeType string, incident string) { + aId, err := strconv.ParseInt(adapterId, 10, 64) + if err != nil { + logx.Errorf("adapterId convert failure, err: %v", err) + } + var cId int64 + if clusterId != "" { + cId, err = strconv.ParseInt(clusterId, 10, 64) + if err != nil { + logx.Errorf("clusterId convert failure, err: %v", err) + } + } + + noticeInfo := clientCore.NoticeInfo{ + AdapterId: aId, + AdapterName: adapterName, + ClusterId: cId, + ClusterName: clusterName, + NoticeType: noticeType, + TaskName: taskName, + Incident: incident, + CreatedTime: time.Now(), + } + result := s.DbEngin.Table("t_notice").Create(¬iceInfo) + if result.Error != nil { + logx.Errorf("Task creation failure, err: %v", result.Error) + } +} diff --git a/internal/scheduler/database/cloudStorage.go b/internal/scheduler/database/cloudStorage.go new file mode 100644 index 00000000..f27b9f3a --- /dev/null +++ b/internal/scheduler/database/cloudStorage.go @@ -0,0 +1,34 @@ +package database + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/entity" + "gorm.io/gorm" +) + +type CloudStorage struct { + dbEngin *gorm.DB +} + +func NewCloudStorage(dbEngin *gorm.DB) *CloudStorage { + return &CloudStorage{dbEngin: dbEngin} +} + +func (c *CloudStorage) GetProviderParams() ([]entity.ProviderParams, error) { + var proParams []entity.ProviderParams + sqlstr := "SELECT SUM(a.disk_avail) as disk_avail,SUM(a.mem_avail) as mem_avail,SUM(a.cpu_total * a.cpu_usable) as cpu_avail,participant_id from (SELECT * from sc_node_avail_info where created_time in (SELECT MAX(created_time) as time from sc_node_avail_info where deleted_flag = 0 GROUP BY participant_id,node_name)) a GROUP BY a.participant_id" + c.dbEngin.Raw(sqlstr).Scan(&proParams) + if len(proParams) == 0 { + return nil, nil + } + return proParams, nil +} + +func (c *CloudStorage) FindAvailableParticipants() ([]entity.Participant, error) { + var parts []entity.Participant + sqlstr := "select id as participant_id, name as name from sc_participant_phy_info" + c.dbEngin.Raw(sqlstr).Scan(&parts) + if len(parts) == 0 { + return nil, nil + } + return parts, nil +} diff --git a/internal/scheduler/database/storage.go b/internal/scheduler/database/storage.go new file mode 100644 index 00000000..25ce0ab1 --- /dev/null +++ b/internal/scheduler/database/storage.go @@ -0,0 +1,13 @@ +package database + +import "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/entity" + +type Storage interface { + GetProviderParams() ([]entity.ProviderParams, error) + FindAvailableParticipants() ([]entity.Participant, error) +} + +type NSIDSpecified interface { + Storage + NSID() error +} diff --git a/api/internal/scheduler/entity/entity.go b/internal/scheduler/entity/entity.go similarity index 100% rename from api/internal/scheduler/entity/entity.go rename to internal/scheduler/entity/entity.go diff --git a/internal/scheduler/scheduler.go b/internal/scheduler/scheduler.go new file mode 100644 index 00000000..23111bc0 --- /dev/null +++ b/internal/scheduler/scheduler.go @@ -0,0 +1,170 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package scheduler + +import ( + "encoding/json" + "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/common" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/response" + "gorm.io/gorm" + "sigs.k8s.io/yaml" + "strings" + "sync" +) + +type Scheduler struct { + task *response.TaskInfo + participantIds []int64 + subSchedule SubSchedule + dbEngin *gorm.DB + result []string //pID:子任务yamlstring 键值对 + AiStorages *database.AiStorage + AiService *service.AiService + mu sync.RWMutex +} + +type SubSchedule interface { + GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) + PickOptimalStrategy() (strategy.Strategy, error) + AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) +} + +func NewScheduler(subSchedule SubSchedule, val string, dbEngin *gorm.DB) (*Scheduler, error) { + var task *response.TaskInfo + err := json.Unmarshal([]byte(val), &task) + if err != nil { + return nil, errors.New("create scheduler failed : " + err.Error()) + } + return &Scheduler{task: task, subSchedule: subSchedule, dbEngin: dbEngin}, nil +} + +func NewSchdlr(aiService *service.AiService, storages *database.AiStorage) *Scheduler { + return &Scheduler{AiService: aiService, AiStorages: storages} +} + +func (s *Scheduler) SpecifyClusters() { + // 如果已指定集群名,通过数据库查询后返回p端ip列表 + if len(s.task.Clusters) != 0 { + s.dbEngin.Raw("select id from sc_participant_phy_info where `name` in (?)", s.task.Clusters).Scan(&s.participantIds) + return + } +} + +func (s *Scheduler) SpecifyNsID() { + // 未指定集群名,只指定nsID + if len(s.task.Clusters) == 0 { + if len(s.task.NsID) != 0 { + var clusters string + s.dbEngin.Raw("select clusters from sc_tenant_info where `tenant_name` = ?", s.task.NsID).Scan(&clusters) + + clusterArr := strings.Split(clusters, ",") + + s.dbEngin.Raw("select id from sc_participant_phy_info where `name` in (?)", clusterArr).Scan(&s.participantIds) + } + } else { + return + } +} + +func (s *Scheduler) MatchLabels() { + + var ids []int64 + count := 0 + // 集群和nsID都未指定,则通过标签匹配 + if len(s.task.Clusters) == 0 && len(s.task.NsID) == 0 { + //如果集群列表或nsID均未指定 + for key := range s.task.MatchLabels { + var participantIds []int64 + s.dbEngin.Raw("select participant_id from sc_participant_label_info where `key` = ? and value = ?", key, s.task.MatchLabels[key]).Scan(&participantIds) + if count == 0 { + ids = participantIds + } + ids = common.Intersect(ids, participantIds) + count++ + } + s.participantIds = ids + } else { + return + } +} + +// TempAssign todo 屏蔽原调度算法 +func (s *Scheduler) TempAssign() error { + + //需要判断task中的资源类型,针对metadata中的多个kind做不同处理 + //输入副本数和集群列表,最终结果输出为pID对应副本数量列表,针对多个kind需要做拆分和重新拼接组合 + var meData []string + for _, yamlString := range s.task.Metadata { + var data map[string]interface{} + err := yaml.Unmarshal([]byte(yamlString), &data) + if err != nil { + } + + jsonData, err := json.Marshal(data) + if err != nil { + } + meData = append(meData, string(jsonData)) + } + s.task.Metadata = meData + return nil +} + +func (s *Scheduler) AssignAndSchedule(ss SubSchedule) (interface{}, error) { + //choose strategy + strategy, err := ss.PickOptimalStrategy() + if err != nil { + return nil, err + } + + //schedule + clusters, err := strategy.Schedule() + if err != nil { + return nil, err + } + + //assign tasks to clusters + resp, err := ss.AssignTask(clusters) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *Scheduler) SaveToDb() error { + + for _, participantId := range s.participantIds { + + for _, resource := range s.task.Metadata { + structForDb, err := s.subSchedule.GetNewStructForDb(s.task, resource, participantId) + if err != nil { + return err + } + + tx := s.dbEngin.Create(structForDb) + if tx.Error != nil { + logx.Error(tx.Error) + return tx.Error + } + } + + } + return nil +} diff --git a/internal/scheduler/schedulers/aiScheduler.go b/internal/scheduler/schedulers/aiScheduler.go new file mode 100644 index 00000000..64f2f550 --- /dev/null +++ b/internal/scheduler/schedulers/aiScheduler.go @@ -0,0 +1,388 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package schedulers + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/common" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy/param" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/response" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" + "sync" +) + +type AiScheduler struct { + yamlString string + task *response.TaskInfo + *scheduler.Scheduler + option *option.AiOption + ctx context.Context +} + +type AiResult struct { + AdapterId string + TaskName string + JobId string + ClusterId string + Strategy string + Replica int32 + Card string + Msg string +} + +func NewAiScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.AiOption) (*AiScheduler, error) { + return &AiScheduler{ctx: ctx, yamlString: val, Scheduler: scheduler, option: option}, nil +} + +func (as *AiScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { + ai := models.Ai{ + AdapterId: participantId, + TaskId: task.TaskId, + Status: "Saved", + YamlString: as.yamlString, + } + utils.Convert(task.Metadata, &ai) + return ai, nil +} + +func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) { + if as.option.ComputeCard != "" { + m, ok := as.AiService.AiCollectorAdapterMap[as.option.AdapterId] + if ok { + for _, id := range as.option.ClusterIds { + cm, ok := m[id] + if ok { + cards, err := cm.GetComputeCards(as.ctx) + if err != nil { + return nil, err + } + if common.Contains(cards, as.option.ComputeCard) { + return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: id, Replicas: 1}}, nil + } + } + } + } + } + + if len(as.option.ClusterIds) == 1 { + return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: as.option.ClusterIds[0], Replicas: 1}}, nil + } + + resources, err := as.findClustersWithResources() + + if err != nil { + return nil, err + } + if len(resources) == 0 { + return nil, errors.New("no cluster has resources") + } + + if len(resources) == 1 { + var cluster strategy.AssignedCluster + cluster.ClusterId = resources[0].ClusterId + cluster.Replicas = 1 + return &strategy.SingleAssignment{Cluster: &cluster}, nil + } + + params := ¶m.Params{Resources: resources} + + switch as.option.StrategyName { + case strategy.REPLICATION: + var clusterIds []string + for _, resource := range resources { + if resource == nil { + continue + } + clusterIds = append(clusterIds, resource.ClusterId) + } + strategy := strategy.NewReplicationStrategy(clusterIds, 1) + return strategy, nil + case strategy.RESOURCES_PRICING: + strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: 1}) + return strategy, nil + case strategy.DYNAMIC_RESOURCES: + strategy := strategy.NewDynamicResourcesStrategy(params.Resources, as.option, 1) + return strategy, nil + case strategy.STATIC_WEIGHT: + //todo resources should match cluster StaticWeightMap + strategy := strategy.NewStaticWeightStrategy(as.option.ClusterToStaticWeight, as.option.Replica) + return strategy, nil + case strategy.RANDOM: + strategy := strategy.NewRandomStrategy(as.option.ClusterIds, as.option.Replica) + return strategy, nil + } + + return nil, errors.New("no strategy has been chosen") +} + +func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { + if clusters == nil { + return nil, errors.New("clusters is nil") + } + + for i := len(clusters) - 1; i >= 0; i-- { + if clusters[i].Replicas == 0 { + clusters = append(clusters[:i], clusters[i+1:]...) + } + } + + if len(clusters) == 0 { + return nil, errors.New("clusters is nil") + } + + var wg sync.WaitGroup + var results []*AiResult + var mu sync.Mutex + var errs []interface{} + var taskNum int32 + for _, cluster := range clusters { + taskNum += cluster.Replicas + } + var ch = make(chan *AiResult, taskNum) + var errCh = make(chan interface{}, taskNum) + + executorMap := as.AiService.AiExecutorAdapterMap[as.option.AdapterId] + for _, cluster := range clusters { + c := cluster + for i := 0; i < int(c.Replicas); i++ { + wg.Add(1) + go func() { + opt, _ := cloneAiOption(as.option) + resp, err := executorMap[c.ClusterId].Execute(as.ctx, opt) + if err != nil { + e := struct { + err error + clusterId string + }{ + err: err, + clusterId: c.ClusterId, + } + errCh <- e + wg.Done() + return + } + + result := &AiResult{} + mu.Lock() + result, _ = convertType(resp) + mu.Unlock() + + result.AdapterId = opt.AdapterId + result.TaskName = opt.TaskName + result.Replica = c.Replicas + result.ClusterId = c.ClusterId + result.Strategy = as.option.StrategyName + result.Card = opt.ComputeCard + + ch <- result + wg.Done() + }() + } + } + wg.Wait() + close(ch) + close(errCh) + + for e := range errCh { + errs = append(errs, e) + } + + for s := range ch { + results = append(results, s) + } + + if len(errs) != 0 { + var synergystatus int64 + if len(clusters) > 1 { + synergystatus = 1 + } + strategyCode, err := as.AiStorages.GetStrategyCode(as.option.StrategyName) + taskId, err := as.AiStorages.SaveTask(as.option.TaskName, strategyCode, synergystatus, "10") + if err != nil { + return nil, errors.New("database add failed: " + err.Error()) + } + adapterName, err := as.AiStorages.GetAdapterNameById(as.option.AdapterId) + if err != nil { + return nil, err + } + + var errmsg string + for _, err := range errs { + e := (err).(struct { + err error + clusterId string + }) + msg := fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) + errmsg += msg + + clusterName, _ := as.AiStorages.GetClusterNameById(e.clusterId) + + err := as.AiStorages.SaveAiTask(taskId, as.option, adapterName, e.clusterId, clusterName, "", constants.Failed, msg) + if err != nil { + return nil, errors.New("database add failed: " + err.Error()) + } + } + for _, s := range results { + as.option.ComputeCard = s.Card //execute card + clusterName, _ := as.AiStorages.GetClusterNameById(s.ClusterId) + + if s.Msg != "" { + msg := fmt.Sprintf("clusterId: %v , error: %v \n", s.ClusterId, s.Msg) + errmsg += msg + err := as.AiStorages.SaveAiTask(taskId, as.option, adapterName, s.ClusterId, clusterName, "", constants.Failed, msg) + if err != nil { + return nil, errors.New("database add failed: " + err.Error()) + } + } else { + msg := fmt.Sprintf("clusterId: %v , submitted successfully, jobId: %v \n", s.ClusterId, s.JobId) + errmsg += msg + err := as.AiStorages.SaveAiTask(taskId, as.option, adapterName, s.ClusterId, clusterName, s.JobId, constants.Saved, msg) + if err != nil { + return nil, errors.New("database add failed: " + err.Error()) + } + } + } + logx.Errorf(errors.New(errmsg).Error()) + return nil, errors.New(errmsg) + } + + return results, nil +} + +func (as *AiScheduler) findClustersWithResources() ([]*collector.ResourceStats, error) { + var wg sync.WaitGroup + var clustersNum = len(as.AiService.AiCollectorAdapterMap[as.option.AdapterId]) + var ch = make(chan *collector.ResourceStats, clustersNum) + var errCh = make(chan interface{}, clustersNum) + + var resourceSpecs []*collector.ResourceStats + var errs []interface{} + + for s, resourceCollector := range as.AiService.AiCollectorAdapterMap[as.option.AdapterId] { + wg.Add(1) + rc := resourceCollector + id := s + go func() { + spec, err := rc.GetResourceStats(as.ctx) + if err != nil { + e := struct { + err error + clusterId string + }{ + err: err, + clusterId: id, + } + errCh <- e + wg.Done() + return + } + ch <- spec + wg.Done() + }() + } + wg.Wait() + close(ch) + close(errCh) + + for s := range ch { + resourceSpecs = append(resourceSpecs, s) + } + + for e := range errCh { + errs = append(errs, e) + } + + if len(errs) == clustersNum { + return nil, errors.New("get resources failed") + } + + if len(errs) != 0 { + var msg string + for _, err := range errs { + e := (err).(struct { + err error + clusterId string + }) + msg += fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) + } + return nil, errors.New(msg) + } + + return resourceSpecs, nil +} + +func convertType(in interface{}) (*AiResult, error) { + var result AiResult + switch (in).(type) { + case *hpcAC.SubmitTaskAiResp: + resp := (in).(*hpcAC.SubmitTaskAiResp) + if resp.Code == "0" { + result.JobId = resp.Data + } else { + result.Msg = resp.Msg + } + return &result, nil + case *octopus.CreateTrainJobResp: + resp := (in).(*octopus.CreateTrainJobResp) + + if resp.Success { + result.JobId = resp.Payload.JobId + } else { + result.Msg = resp.Error.Message + } + + return &result, nil + case *modelartsservice.CreateTrainingJobResp: + resp := (in).(*modelartsservice.CreateTrainingJobResp) + + if resp.ErrorMsg != "" { + result.Msg = resp.ErrorMsg + } else { + + result.JobId = resp.Metadata.Id + } + + return &result, nil + default: + return nil, errors.New("ai task response failed") + } +} + +func cloneAiOption(opt *option.AiOption) (*option.AiOption, error) { + origJSON, err := json.Marshal(opt) + if err != nil { + return nil, err + } + + clone := option.AiOption{} + if err = json.Unmarshal(origJSON, &clone); err != nil { + return nil, err + } + + return &clone, nil +} diff --git a/internal/scheduler/schedulers/cloudScheduler.go b/internal/scheduler/schedulers/cloudScheduler.go new file mode 100644 index 00000000..cbd862b2 --- /dev/null +++ b/internal/scheduler/schedulers/cloudScheduler.go @@ -0,0 +1,190 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package schedulers + +import ( + "context" + "errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy/param" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models/cloud" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/response" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" + "math" + "time" +) + +type CloudScheduler struct { + yamlString string + task *response.TaskInfo + *scheduler.Scheduler + option *option.CloudOption + ctx context.Context + dbEngin *gorm.DB + promClient tracker.Prometheus + svcCtx *svc.ServiceContext +} + +type CloudResult struct { + TaskId string + ClusterId string + ClusterName string + Strategy string + Replica int32 + Msg string +} + +func NewCloudScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.CloudOption, dbEngin *gorm.DB, promClient tracker.Prometheus) (*CloudScheduler, error) { + return &CloudScheduler{ctx: ctx, yamlString: val, Scheduler: scheduler, option: option, dbEngin: dbEngin, promClient: promClient}, nil +} + +func (as *CloudScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { + c := cloud.TaskCloudModel{ + AdapterId: uint(participantId), + TaskId: uint(task.TaskId), + Status: constants.Saved, + YamlString: as.yamlString, + } + utils.Convert(task.Metadata, &c) + return c, nil +} + +func (as *CloudScheduler) PickOptimalStrategy() (strategy.Strategy, error) { + if len(as.option.ClusterIds) == 1 { + return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: as.option.ClusterIds[0], Replicas: 1}}, nil + } + + resources, err := as.findClustersWithResources() + + if err != nil { + return nil, err + } + if len(resources) == 0 { + return nil, errors.New("no cluster has resources") + } + + if len(resources) == 1 { + var cluster strategy.AssignedCluster + cluster.ClusterId = resources[0].ClusterId + cluster.Replicas = 1 + return &strategy.SingleAssignment{Cluster: &cluster}, nil + } + + params := ¶m.Params{Resources: resources} + + switch as.option.Strategy { + case strategy.REPLICATION: + var clusterIds []string + for _, resource := range resources { + clusterIds = append(clusterIds, resource.ClusterId) + } + strategy := strategy.NewReplicationStrategy(clusterIds, as.option.Replica) + return strategy, nil + case strategy.RESOURCES_PRICING: + strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: as.option.Replica}) + return strategy, nil + case strategy.DYNAMIC_RESOURCES: + strategy := strategy.NewDynamicResourcesStrategy(params.Resources, as.option, 1) + return strategy, nil + case strategy.STATIC_WEIGHT: + //todo resources should match cluster StaticWeightMap + strategy := strategy.NewStaticWeightStrategy(as.option.StaticWeightMap, as.option.Replica) + return strategy, nil + } + + return nil, errors.New("no strategy has been chosen") +} + +func (as *CloudScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { + if clusters == nil { + return nil, errors.New("clusters is nil") + } + + for i := len(clusters) - 1; i >= 0; i-- { + if clusters[i].Replicas == 0 { + clusters = append(clusters[:i], clusters[i+1:]...) + } + } + + if len(clusters) == 0 { + return nil, errors.New("clusters is nil") + } + + var results []*CloudResult + + for _, cluster := range clusters { + cName := "" + as.dbEngin.Table("t_cluster").Select("name").Where("id=?", cluster.ClusterId).Find(&cName) + cr := CloudResult{ + ClusterId: cluster.ClusterId, + ClusterName: cName, + Replica: cluster.Replicas, + } + cr.ClusterId = cluster.ClusterId + cr.Replica = cluster.Replicas + + cr.ClusterName = cName + results = append(results, &cr) + } + + return results, nil +} + +func (as *CloudScheduler) findClustersWithResources() ([]*collector.ResourceStats, error) { + resp := []*collector.ResourceStats{} + //查询集群资源信息 + var rMetrics []tracker.Metric + metrics := []string{"cluster_cpu_utilisation", "cluster_cpu_avail", "cluster_cpu_total", "cluster_memory_total", "cluster_memory_avail", "cluster_memory_utilisation", "cluster_disk_utilisation", "cluster_disk_avail", "cluster_disk_total", "cluster_pod_utilisation"} + var clusterNames []string + as.dbEngin.Table("t_cluster").Select("name").Where("id in ?", as.option.ClusterIds).Find(&clusterNames) + for _, c := range clusterNames { + rMetrics = as.promClient.GetNamedMetrics(metrics, time.Now(), tracker.ClusterOption{ClusterName: c}) + r := collector.ResourceStats{} + var cid string + as.dbEngin.Table("t_cluster").Select("id").Where("name = ?", c).Find(&cid) + r.ClusterId = cid + r.Name = c + for _, metric := range rMetrics { + if metric.MetricName == "cluster_cpu_total" { + r.CpuCoreTotal = int64(metric.MetricData.MetricValues[0].Sample.Value()) + } + if metric.MetricName == "cluster_cpu_avail" { + cpuAvail := metric.MetricData.MetricValues[0].Sample.Value() + r.CpuCoreAvail = int64(math.Round(cpuAvail)) + } + if metric.MetricName == "cluster_memory_total" { + r.MemTotal = metric.MetricData.MetricValues[0].Sample.Value() + } + if metric.MetricName == "cluster_memory_avail" { + r.MemAvail = metric.MetricData.MetricValues[0].Sample.Value() + } + if metric.MetricName == "cluster_disk_total" { + r.DiskTotal = metric.MetricData.MetricValues[0].Sample.Value() + } + if metric.MetricName == "cluster_disk_avail" { + r.DiskAvail = metric.MetricData.MetricValues[0].Sample.Value() + } + } + resp = append(resp, &r) + } + return resp, nil +} diff --git a/internal/scheduler/schedulers/hpcScheduler.go b/internal/scheduler/schedulers/hpcScheduler.go new file mode 100644 index 00000000..4ca0e04a --- /dev/null +++ b/internal/scheduler/schedulers/hpcScheduler.go @@ -0,0 +1,55 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package schedulers + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/algorithm/providerPricing" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/response" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" +) + +type HpcScheduler struct { + yamlString string +} + +func NewHpcScheduler(val string) *HpcScheduler { + return &HpcScheduler{yamlString: val} +} + +func (h *HpcScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { + hpc := models.Hpc{} + utils.Convert(task.Metadata, &hpc) + hpc.Id = utils.GenSnowflakeID() + hpc.TaskId = task.TaskId + hpc.Status = constants.Saved + hpc.ParticipantId = participantId + hpc.YamlString = h.yamlString + return hpc, nil +} + +func (h *HpcScheduler) PickOptimalStrategy() (strategy.Strategy, error) { + return nil, nil +} + +func (h *HpcScheduler) genTaskAndProviders(task *response.TaskInfo) (*providerPricing.Task, []*providerPricing.Provider) { + return nil, nil +} + +func (h *HpcScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { + return nil, nil +} diff --git a/api/internal/scheduler/schedulers/option/aiOption.go b/internal/scheduler/schedulers/option/aiOption.go similarity index 100% rename from api/internal/scheduler/schedulers/option/aiOption.go rename to internal/scheduler/schedulers/option/aiOption.go diff --git a/api/internal/scheduler/schedulers/option/cloudOption.go b/internal/scheduler/schedulers/option/cloudOption.go similarity index 100% rename from api/internal/scheduler/schedulers/option/cloudOption.go rename to internal/scheduler/schedulers/option/cloudOption.go diff --git a/api/internal/scheduler/schedulers/option/inferOption.go b/internal/scheduler/schedulers/option/inferOption.go similarity index 100% rename from api/internal/scheduler/schedulers/option/inferOption.go rename to internal/scheduler/schedulers/option/inferOption.go diff --git a/api/internal/scheduler/schedulers/option/option.go b/internal/scheduler/schedulers/option/option.go similarity index 100% rename from api/internal/scheduler/schedulers/option/option.go rename to internal/scheduler/schedulers/option/option.go diff --git a/api/internal/scheduler/schedulers/option/vmOption.go b/internal/scheduler/schedulers/option/vmOption.go similarity index 100% rename from api/internal/scheduler/schedulers/option/vmOption.go rename to internal/scheduler/schedulers/option/vmOption.go diff --git a/internal/scheduler/schedulers/vmScheduler.go b/internal/scheduler/schedulers/vmScheduler.go new file mode 100644 index 00000000..0163d693 --- /dev/null +++ b/internal/scheduler/schedulers/vmScheduler.go @@ -0,0 +1,151 @@ +package schedulers + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/algorithm/providerPricing" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/response" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gorm.io/gorm" +) + +type VmScheduler struct { + yamlString string + storage database.Storage + task *response.TaskInfo + *scheduler.Scheduler + option *option.VmOption + ctx context.Context + promClient tracker.Prometheus + dbEngin *gorm.DB + svcCtx *svc.ServiceContext +} + +type VmResult struct { + TaskId string + ClusterId string + ClusterName string + Strategy string + Replica int32 + Msg string +} + +func NewVmScheduler(ctx context.Context, val string, scheduler *scheduler.Scheduler, option *option.VmOption, dbEngin *gorm.DB, promClient tracker.Prometheus) (*VmScheduler, error) { + return &VmScheduler{ctx: ctx, yamlString: val, Scheduler: scheduler, option: option, dbEngin: dbEngin, promClient: promClient}, nil +} + +func (vm *VmScheduler) PickOptimalStrategy() (strategy.Strategy, error) { + if len(vm.option.ClusterIds) == 1 { + // TODO database operation Find + return &strategy.SingleAssignment{Cluster: &strategy.AssignedCluster{ClusterId: vm.option.ClusterIds[0], Replicas: 1}}, nil + } + //resources, err := vm.findClustersWithResources() + + /* if err != nil { + return nil, err + }*/ + + //if len(resources) == 1 { + // var cluster strategy.AssignedCluster + // cluster.ClusterId = resources[0].ClusterId + // cluster.Replicas = 1 + // return &strategy.SingleAssignment{Cluster: &cluster}, nil + //} + //params := ¶m.Params{Resources: resources} + + switch vm.option.Strategy { + /* case strategy.REPLICATION: + var clusterIds []string + for _, resource := range resources { + clusterIds = append(clusterIds, resource.ClusterId) + } + strategy := strategy.NewReplicationStrategy(clusterIds, 1) + return strategy, nil + case strategy.RESOURCES_PRICING: + strategy := strategy.NewPricingStrategy(¶m.ResourcePricingParams{Params: params, Replicas: 1}) + return strategy, nil*/ + /* case strategy.DYNAMIC_RESOURCES: + strategy := strategy.NewDynamicResourcesStrategy(params.Resources, vm.option, 1) + return strategy, nil*/ + case strategy.STATIC_WEIGHT: + //todo resources should match cluster StaticWeightMap + strategy := strategy.NewStaticWeightStrategy(vm.option.StaticWeightMap, 1) + return strategy, nil + case strategy.RANDOM: + strategy := strategy.NewRandomStrategy(vm.option.ClusterIds, vm.option.Replicas) + return strategy, nil + } + return nil, errors.New("no strategy has been chosen") +} + +func (v *VmScheduler) GetNewStructForDb(task *response.TaskInfo, resource string, participantId int64) (interface{}, error) { + //TODO implement me + vm := models.Vm{} + utils.Convert(task.Metadata, &vm) + vm.Id = utils.GenSnowflakeID() + vm.TaskId = vm.TaskId + vm.Status = constants.Saved + vm.ParticipantId = participantId + return vm, nil +} + +func (vm *VmScheduler) genTaskAndProviders() (*providerPricing.Task, []*providerPricing.Provider, error) { + proParams, err := vm.storage.GetProviderParams() + if err != nil { + return nil, nil, nil + } + var providerList []*providerPricing.Provider + for _, p := range proParams { + provider := providerPricing.NewProvider(p.Participant_id, p.Cpu_avail, p.Mem_avail, p.Disk_avail, 0.0, 0.0, 0.0) + providerList = append(providerList, provider) + } + + //replicas := task.Metadata.(map[string]interface{})["spec"].(map[string]interface{})["replicas"].(float64) + //t := algorithm.NewTask(0, int(replicas), 2, 75120000, 301214500, 1200, 2, 6, 2000) + + return nil, providerList, nil +} + +func (as *VmScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interface{}, error) { + //TODO implement me + if clusters == nil { + return nil, errors.New("clusters is nil") + } + + for i := len(clusters) - 1; i >= 0; i-- { + if clusters[i].Replicas == 0 { + clusters = append(clusters[:i], clusters[i+1:]...) + } + } + + if len(clusters) == 0 { + return nil, errors.New("clusters is nil") + } + + var results []*VmResult + + for _, cluster := range clusters { + cName := "" + as.dbEngin.Table("t_cluster").Select("name").Where("id=?", cluster.ClusterId).Find(&cName) + cr := VmResult{ + ClusterId: cluster.ClusterId, + ClusterName: cName, + Replica: cluster.Replicas, + } + cr.ClusterId = cluster.ClusterId + cr.Replica = cluster.Replicas + + cr.ClusterName = cName + results = append(results, &cr) + } + + return results, nil +} diff --git a/internal/scheduler/service/aiService.go b/internal/scheduler/service/aiService.go new file mode 100644 index 00000000..d282ee04 --- /dev/null +++ b/internal/scheduler/service/aiService.go @@ -0,0 +1,110 @@ +package service + +import ( + "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/zrpc" + hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/config" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/executor" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/inference" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" + "net/http" + "strconv" + "sync" +) + +const ( + OCTOPUS = "octopus" + MODELARTS = "modelarts" + SHUGUANGAI = "shuguangAi" +) + +type AiService struct { + AiExecutorAdapterMap map[string]map[string]executor.AiExecutor + AiCollectorAdapterMap map[string]map[string]collector.AiCollector + Storage *database.AiStorage + mu sync.Mutex +} + +func NewAiService(conf *config.Config, storages *database.AiStorage) (*AiService, error) { + var aiType = "1" + adapterIds, err := storages.GetAdapterIdsByType(aiType) + if err != nil { + return nil, err + } + aiService := &AiService{ + AiExecutorAdapterMap: make(map[string]map[string]executor.AiExecutor), + AiCollectorAdapterMap: make(map[string]map[string]collector.AiCollector), + Storage: storages, + } + for _, id := range adapterIds { + clusters, err := storages.GetClustersByAdapterId(id) + if err != nil { + return nil, err + } + if len(clusters.List) == 0 { + continue + } + exeClusterMap, colClusterMap := InitAiClusterMap(conf, clusters.List) + aiService.AiExecutorAdapterMap[id] = exeClusterMap + aiService.AiCollectorAdapterMap[id] = colClusterMap + } + + return aiService, nil +} + +func InitAiClusterMap(conf *config.Config, clusters []types.ClusterInfo) (map[string]executor.AiExecutor, map[string]collector.AiCollector) { + executorMap := make(map[string]executor.AiExecutor) + collectorMap := make(map[string]collector.AiCollector) + for _, c := range clusters { + switch c.Name { + case OCTOPUS: + id, _ := strconv.ParseInt(c.Id, 10, 64) + octopusRpc := octopusclient.NewOctopus(zrpc.MustNewClient(conf.OctopusRpcConf)) + octopus := storeLink.NewOctopusLink(octopusRpc, c.Nickname, id) + collectorMap[c.Id] = octopus + executorMap[c.Id] = octopus + case MODELARTS: + id, _ := strconv.ParseInt(c.Id, 10, 64) + modelArtsRpc := modelartsservice.NewModelArtsService(zrpc.MustNewClient(conf.ModelArtsRpcConf)) + modelArtsImgRpc := imagesservice.NewImagesService(zrpc.MustNewClient(conf.ModelArtsImgRpcConf)) + modelarts := storeLink.NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, c.Name, id, c.Nickname) + collectorMap[c.Id] = modelarts + executorMap[c.Id] = modelarts + case SHUGUANGAI: + id, _ := strconv.ParseInt(c.Id, 10, 64) + aCRpc := hpcacclient.NewHpcAC(zrpc.MustNewClient(conf.ACRpcConf)) + sgai := storeLink.NewShuguangAi(aCRpc, c.Nickname, id) + collectorMap[c.Id] = sgai + executorMap[c.Id] = sgai + } + } + + return executorMap, collectorMap +} + +func (as *AiService) ImageInfer(opt *option.InferOption, id int64, adapterName string, clusters []*strategy.AssignedCluster, ts []*inference.ImageFile) { + + r := http.Request{} + _, err := inference.Infer(opt, id, adapterName, clusters, ts, as.AiCollectorAdapterMap, as.Storage, r.Context()) + if err != nil { + logx.Errorf(err.Error()) + return + } +} + +//func (a *AiService) AddCluster() error { +// +//} +// +//func (a *AiService) AddAdapter() error { +// +//} diff --git a/internal/scheduler/service/collector/collector.go b/internal/scheduler/service/collector/collector.go new file mode 100644 index 00000000..e1d1e6d8 --- /dev/null +++ b/internal/scheduler/service/collector/collector.go @@ -0,0 +1,67 @@ +package collector + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" +) + +type AiCollector interface { + GetResourceStats(ctx context.Context) (*ResourceStats, error) + GetDatasetsSpecs(ctx context.Context) ([]*DatasetsSpecs, error) + GetAlgorithms(ctx context.Context) ([]*Algorithm, error) + GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) + GetTrainingTask(ctx context.Context, taskId string) (*Task, error) + DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) + UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error + GetComputeCards(ctx context.Context) ([]string, error) + GetUserBalance(ctx context.Context) (float64, error) + GetInferUrl(ctx context.Context, option *option.InferOption) ([]*InferUrl, error) +} + +type InferUrl struct { + Url string + Card string +} + +type ResourceStats struct { + ClusterId string + Name string + CpuCoreAvail int64 + CpuCoreTotal int64 + MemAvail float64 + MemTotal float64 + DiskAvail float64 + DiskTotal float64 + GpuAvail int64 + GpuTotal int64 + CardsAvail []*Card + CpuCoreHours float64 + Balance float64 +} + +type Card struct { + Platform string + Type string + Name string + TOpsAtFp16 float64 + CardHours float64 + CardNum int32 +} + +type DatasetsSpecs struct { + Name string + Size string +} + +type Algorithm struct { + Name string + Platform string + TaskType string +} + +type Task struct { + Id string + Start string + End string + Status string +} diff --git a/internal/scheduler/service/executor/aiExecutor.go b/internal/scheduler/service/executor/aiExecutor.go new file mode 100644 index 00000000..5cdf65a9 --- /dev/null +++ b/internal/scheduler/service/executor/aiExecutor.go @@ -0,0 +1,10 @@ +package executor + +import ( + "context" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" +) + +type AiExecutor interface { + Execute(ctx context.Context, option *option.AiOption) (interface{}, error) +} diff --git a/internal/scheduler/service/inference/imageInfer.go b/internal/scheduler/service/inference/imageInfer.go new file mode 100644 index 00000000..a1480549 --- /dev/null +++ b/internal/scheduler/service/inference/imageInfer.go @@ -0,0 +1,396 @@ +package inference + +import ( + "context" + "encoding/json" + "errors" + "github.com/go-resty/resty/v2" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "log" + "math/rand" + "mime/multipart" + "sort" + "strconv" + "sync" + "time" +) + +type ImageFile struct { + ImageResult *types.ImageResult + File multipart.File +} + +func Infer(opt *option.InferOption, id int64, adapterName string, clusters []*strategy.AssignedCluster, ts []*ImageFile, aiCollectorAdapterMap map[string]map[string]collector.AiCollector, storage *database.AiStorage, ctx context.Context) ([]*types.ImageResult, error) { + + //for i := len(clusters) - 1; i >= 0; i-- { + // if clusters[i].Replicas == 0 { + // clusters = append(clusters[:i], clusters[i+1:]...) + // } + //} + + var wg sync.WaitGroup + var cluster_ch = make(chan struct { + urls []*collector.InferUrl + clusterId string + clusterName string + imageNum int32 + }, len(clusters)) + + var cs []struct { + urls []*collector.InferUrl + clusterId string + clusterName string + imageNum int32 + } + collectorMap := aiCollectorAdapterMap[opt.AdapterId] + + ////save taskai + //for _, c := range clusters { + // clusterName, _ := storage.GetClusterNameById(c.ClusterId) + // opt.Replica = c.Replicas + // err := storage.SaveAiTask(id, opt, adapterName, c.ClusterId, clusterName, "", constants.Saved, "") + // if err != nil { + // return nil, err + // } + //} + + var mutex sync.Mutex + errMap := make(map[string]string) + for _, cluster := range clusters { + wg.Add(1) + c := cluster + go func() { + imageUrls, err := collectorMap[c.ClusterId].GetInferUrl(ctx, opt) + if err != nil { + mutex.Lock() + errMap[c.ClusterId] = err.Error() + mutex.Unlock() + wg.Done() + return + } + for i, _ := range imageUrls { + imageUrls[i].Url = imageUrls[i].Url + storeLink.FORWARD_SLASH + "image" + } + clusterName, _ := storage.GetClusterNameById(c.ClusterId) + + s := struct { + urls []*collector.InferUrl + clusterId string + clusterName string + imageNum int32 + }{ + urls: imageUrls, + clusterId: c.ClusterId, + clusterName: clusterName, + imageNum: c.Replicas, + } + + cluster_ch <- s + wg.Done() + return + }() + } + wg.Wait() + close(cluster_ch) + + for s := range cluster_ch { + cs = append(cs, s) + } + + aiTaskList, err := storage.GetAiTaskListById(id) + if err != nil { + return nil, err + } + + //no cluster available + if len(cs) == 0 { + for _, t := range aiTaskList { + t.Status = constants.Failed + t.EndTime = time.Now().Format(time.RFC3339) + if _, ok := errMap[strconv.Itoa(int(t.ClusterId))]; ok { + t.Msg = errMap[strconv.Itoa(int(t.ClusterId))] + } + err := storage.UpdateAiTask(t) + if err != nil { + logx.Errorf(err.Error()) + } + } + storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") + return nil, errors.New("image infer task failed") + } + + //change cluster status + if len(clusters) != len(cs) { + var acs []*strategy.AssignedCluster + var rcs []*strategy.AssignedCluster + for _, cluster := range clusters { + if contains(cs, cluster.ClusterId) { + var ac *strategy.AssignedCluster + ac = cluster + rcs = append(rcs, ac) + } else { + var ac *strategy.AssignedCluster + ac = cluster + acs = append(acs, ac) + } + } + + // update failed cluster status + for _, ac := range acs { + for _, t := range aiTaskList { + if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) { + t.Status = constants.Failed + t.EndTime = time.Now().Format(time.RFC3339) + if _, ok := errMap[strconv.Itoa(int(t.ClusterId))]; ok { + t.Msg = errMap[strconv.Itoa(int(t.ClusterId))] + } + err := storage.UpdateAiTask(t) + if err != nil { + logx.Errorf(err.Error()) + } + } + } + } + + // update running cluster status + for _, ac := range rcs { + for _, t := range aiTaskList { + if ac.ClusterId == strconv.Itoa(int(t.ClusterId)) { + t.Status = constants.Running + err := storage.UpdateAiTask(t) + if err != nil { + logx.Errorf(err.Error()) + } + } + } + } + storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") + } else { + for _, t := range aiTaskList { + t.Status = constants.Running + err := storage.UpdateAiTask(t) + if err != nil { + logx.Errorf(err.Error()) + } + } + storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "running", "任务运行中") + } + + var result_ch = make(chan *types.ImageResult, len(ts)) + var results []*types.ImageResult + limit := make(chan bool, 7) + + var imageNumIdx int32 = 0 + var imageNumIdxEnd int32 = 0 + for _, c := range cs { + new_images := make([]*ImageFile, len(ts)) + copy(new_images, ts) + + imageNumIdxEnd = imageNumIdxEnd + c.imageNum + new_images = new_images[imageNumIdx:imageNumIdxEnd] + imageNumIdx = imageNumIdx + c.imageNum + + wg.Add(len(new_images)) + go sendInferReq(new_images, c, &wg, result_ch, limit) + } + wg.Wait() + close(result_ch) + + for s := range result_ch { + results = append(results, s) + } + + sort.Slice(results, func(p, q int) bool { + return results[p].ClusterName < results[q].ClusterName + }) + + //save ai sub tasks + for _, r := range results { + for _, task := range aiTaskList { + if r.ClusterId == strconv.Itoa(int(task.ClusterId)) { + taskAiSub := models.TaskAiSub{ + TaskId: id, + TaskName: task.Name, + TaskAiId: task.TaskId, + TaskAiName: task.Name, + ImageName: r.ImageName, + Result: r.ImageResult, + Card: r.Card, + ClusterId: task.ClusterId, + ClusterName: r.ClusterName, + } + err := storage.SaveAiTaskImageSubTask(&taskAiSub) + if err != nil { + panic(err) + } + } + } + } + + // update succeeded cluster status + var successStatusCount int + for _, c := range cs { + for _, t := range aiTaskList { + if c.clusterId == strconv.Itoa(int(t.ClusterId)) { + t.Status = constants.Completed + t.EndTime = time.Now().Format(time.RFC3339) + err := storage.UpdateAiTask(t) + if err != nil { + logx.Errorf(err.Error()) + } + successStatusCount++ + } else { + continue + } + } + } + + if len(cs) == successStatusCount { + storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "completed", "任务完成") + } else { + storage.AddNoticeInfo(opt.AdapterId, adapterName, "", "", opt.TaskName, "failed", "任务失败") + } + + return results, nil +} + +func sendInferReq(images []*ImageFile, cluster struct { + urls []*collector.InferUrl + clusterId string + clusterName string + imageNum int32 +}, wg *sync.WaitGroup, ch chan<- *types.ImageResult, limit chan bool) { + for _, image := range images { + limit <- true + go func(t *ImageFile, c struct { + urls []*collector.InferUrl + clusterId string + clusterName string + imageNum int32 + }) { + if len(c.urls) == 1 { + r, err := getInferResult(c.urls[0].Url, t.File, t.ImageResult.ImageName, c.clusterName) + if err != nil { + t.ImageResult.ImageResult = err.Error() + t.ImageResult.ClusterId = c.clusterId + t.ImageResult.ClusterName = c.clusterName + t.ImageResult.Card = c.urls[0].Card + ch <- t.ImageResult + wg.Done() + <-limit + return + } + t.ImageResult.ImageResult = r + t.ImageResult.ClusterId = c.clusterId + t.ImageResult.ClusterName = c.clusterName + t.ImageResult.Card = c.urls[0].Card + + ch <- t.ImageResult + wg.Done() + <-limit + return + } else { + idx := rand.Intn(len(c.urls)) + r, err := getInferResult(c.urls[idx].Url, t.File, t.ImageResult.ImageName, c.clusterName) + if err != nil { + t.ImageResult.ImageResult = err.Error() + t.ImageResult.ClusterId = c.clusterId + t.ImageResult.ClusterName = c.clusterName + t.ImageResult.Card = c.urls[idx].Card + ch <- t.ImageResult + wg.Done() + <-limit + return + } + t.ImageResult.ImageResult = r + t.ImageResult.ClusterId = c.clusterId + t.ImageResult.ClusterName = c.clusterName + t.ImageResult.Card = c.urls[idx].Card + + ch <- t.ImageResult + wg.Done() + <-limit + return + } + }(image, cluster) + <-limit + } +} + +func getInferResult(url string, file multipart.File, fileName string, clusterName string) (string, error) { + if clusterName == "鹏城云脑II-modelarts" { + r, err := getInferResultModelarts(url, file, fileName) + if err != nil { + return "", err + } + return r, nil + } + var res Res + req := GetRestyRequest(20) + _, err := req. + SetFileReader("file", fileName, file). + SetResult(&res). + Post(url) + if err != nil { + return "", err + } + return res.Result, nil +} + +func getInferResultModelarts(url string, file multipart.File, fileName string) (string, error) { + var res Res + /* req := GetRestyRequest(20) + _, err := req. + SetFileReader("file", fileName, file). + SetHeaders(map[string]string{ + "ak": "UNEHPHO4Z7YSNPKRXFE4", + "sk": "JWXCE9qcYbc7RjpSRIWt4WgG3ZKF6Q4lPzkJReX9", + }). + SetResult(&res). + Post(url) + if err != nil { + return "", err + }*/ + body, err := utils.SendRequest("POST", url, file, fileName) + if err != nil { + return "", err + } + errjson := json.Unmarshal([]byte(body), &res) + if errjson != nil { + log.Fatalf("Error parsing JSON: %s", errjson) + } + return res.Result, nil +} + +func GetRestyRequest(timeoutSeconds int64) *resty.Request { + client := resty.New().SetTimeout(time.Duration(timeoutSeconds) * time.Second) + request := client.R() + return request +} + +type Res struct { + Result string `json:"result"` +} + +func contains(cs []struct { + urls []*collector.InferUrl + clusterId string + clusterName string + imageNum int32 +}, e string) bool { + for _, c := range cs { + if c.clusterId == e { + return true + } + } + return false +} diff --git a/internal/scheduler/service/status/taskStatusSync.go b/internal/scheduler/service/status/taskStatusSync.go new file mode 100644 index 00000000..7a48d9f9 --- /dev/null +++ b/internal/scheduler/service/status/taskStatusSync.go @@ -0,0 +1,337 @@ +package status + +import ( + "errors" + "fmt" + "github.com/zeromicro/go-zero/core/logx" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "net/http" + "strconv" + "sync" + "time" +) + +func UpdateTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { + list := make([]*types.TaskModel, len(tasklist)) + copy(list, tasklist) + for i := len(list) - 1; i >= 0; i-- { + if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed { + list = append(list[:i], list[i+1:]...) + } + } + + if len(list) == 0 { + return + } + + task := list[0] + for i := range list { + earliest, _ := time.Parse(time.RFC3339, task.UpdatedTime) + latest, _ := time.Parse(time.RFC3339, list[i].UpdatedTime) + if latest.Before(earliest) { + task = list[i] + } + } + + // Update Infer Task Status + if task.TaskTypeDict == "11" || task.TaskTypeDict == "12" { + updateInferTaskStatus(svc, *task) + return + } + + aiTask, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) + if err != nil { + logx.Errorf(err.Error()) + return + } + + if len(aiTask) == 0 { + err := svc.Scheduler.AiStorages.UpdateTask(task) + if err != nil { + return + } + return + } + + if len(aiTask) == 1 { + if aiTask[0].Status == constants.Completed { + task.Status = constants.Succeeded + } else { + task.Status = aiTask[0].Status + } + task.StartTime = aiTask[0].StartTime + task.EndTime = aiTask[0].EndTime + err := svc.Scheduler.AiStorages.UpdateTask(task) + if err != nil { + return + } + return + } + + for i := len(aiTask) - 1; i >= 0; i-- { + if aiTask[i].StartTime == "" { + task.Status = aiTask[i].Status + aiTask = append(aiTask[:i], aiTask[i+1:]...) + } + } + + if len(aiTask) == 0 { + err := svc.Scheduler.AiStorages.UpdateTask(task) + if err != nil { + return + } + return + } + + start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local) + end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local) + + var status string + var count int + for _, a := range aiTask { + s, _ := time.ParseInLocation(constants.Layout, a.StartTime, time.Local) + e, _ := time.ParseInLocation(constants.Layout, a.EndTime, time.Local) + + if s.Before(start) { + start = s + } + + if e.After(end) { + end = e + } + + if a.Status == constants.Failed { + status = a.Status + break + } + + if a.Status == constants.Pending { + status = a.Status + continue + } + + if a.Status == constants.Running { + status = a.Status + continue + } + + if a.Status == constants.Completed { + count++ + continue + } + } + + if count == len(aiTask) { + status = constants.Succeeded + } + + if status != "" { + task.Status = status + task.StartTime = start.Format(constants.Layout) + task.EndTime = end.Format(constants.Layout) + } + + err = svc.Scheduler.AiStorages.UpdateTask(task) + if err != nil { + return + } +} + +func updateInferTaskStatus(svc *svc.ServiceContext, task types.TaskModel) { + aiTask, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) + if err != nil { + logx.Errorf(err.Error()) + return + } + + if len(aiTask) == 0 { + task.Status = constants.Failed + err = svc.Scheduler.AiStorages.UpdateTask(&task) + if err != nil { + return + } + return + } + + if len(aiTask) == 1 { + if aiTask[0].Status == constants.Completed { + task.StartTime = aiTask[0].StartTime + task.EndTime = aiTask[0].EndTime + task.Status = constants.Succeeded + } else { + task.StartTime = aiTask[0].StartTime + task.Status = aiTask[0].Status + } + + err = svc.Scheduler.AiStorages.UpdateTask(&task) + if err != nil { + return + } + return + } + + //for i := len(aiTask) - 1; i >= 0; i-- { + // if aiTask[i].StartTime == "" { + // task.Status = aiTask[i].Status + // aiTask = append(aiTask[:i], aiTask[i+1:]...) + // } + //} + // + //if len(aiTask) == 0 { + // task.UpdatedTime = time.Now().Format(constants.Layout) + // tx = svc.DbEngin.Table("task").Model(task).Updates(task) + // if tx.Error != nil { + // logx.Errorf(tx.Error.Error()) + // return + // } + // return + //} + + if aiTask[0].StartTime == "" { + return + } + + start, _ := time.ParseInLocation(time.RFC3339, aiTask[0].StartTime, time.Local) + end, _ := time.ParseInLocation(time.RFC3339, aiTask[0].EndTime, time.Local) + var status string + var count int + for _, a := range aiTask { + if a.Status == constants.Failed { + status = a.Status + break + } + + if a.Status == constants.Pending { + status = a.Status + continue + } + + if a.Status == constants.Running { + status = a.Status + continue + } + + if a.Status == constants.Completed { + count++ + continue + } + } + + if count == len(aiTask) { + status = constants.Succeeded + } + + if status == constants.Succeeded { + task.Status = status + task.StartTime = start.Format(time.RFC3339) + task.EndTime = end.Format(time.RFC3339) + } else { + task.Status = status + task.StartTime = start.Format(time.RFC3339) + } + + err = svc.Scheduler.AiStorages.UpdateTask(&task) + if err != nil { + return + } +} + +func UpdateAiTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { + list := make([]*types.TaskModel, len(tasklist)) + copy(list, tasklist) + for i := len(list) - 1; i >= 0; i-- { + if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed { + list = append(list[:i], list[i+1:]...) + } + } + + if len(list) == 0 { + return + } + + task := list[0] + for i := range list { + earliest, _ := time.Parse(constants.Layout, task.UpdatedTime) + latest, _ := time.Parse(constants.Layout, list[i].UpdatedTime) + if latest.Before(earliest) { + task = list[i] + } + } + + aiTaskList, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) + if err != nil { + logx.Errorf(err.Error()) + return + } + + if len(aiTaskList) == 0 { + return + } + + var wg sync.WaitGroup + for _, aitask := range aiTaskList { + t := aitask + if t.Status == constants.Completed || t.Status == constants.Failed || t.JobId == "" { + continue + } + wg.Add(1) + go func() { + h := http.Request{} + trainingTask, err := svc.Scheduler.AiService.AiCollectorAdapterMap[strconv.FormatInt(t.AdapterId, 10)][strconv.FormatInt(t.ClusterId, 10)].GetTrainingTask(h.Context(), t.JobId) + if err != nil { + if status.Code(err) == codes.DeadlineExceeded { + msg := fmt.Sprintf("###UpdateAiTaskStatus###, AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) + logx.Errorf(errors.New(msg).Error()) + wg.Done() + return + } + + msg := fmt.Sprintf("###UpdateAiTaskStatus###, AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) + logx.Errorf(errors.New(msg).Error()) + wg.Done() + return + } + if trainingTask == nil { + wg.Done() + return + } + switch trainingTask.Status { + case constants.Running: + if t.Status != trainingTask.Status { + svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "running", "任务运行中") + t.Status = trainingTask.Status + } + case constants.Failed: + if t.Status != trainingTask.Status { + svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "failed", "任务失败") + t.Status = trainingTask.Status + } + case constants.Completed: + if t.Status != trainingTask.Status { + svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "completed", "任务完成") + t.Status = trainingTask.Status + } + default: + if t.Status != trainingTask.Status { + svc.Scheduler.AiStorages.AddNoticeInfo(strconv.FormatInt(t.AdapterId, 10), t.AdapterName, strconv.FormatInt(t.ClusterId, 10), t.ClusterName, t.Name, "pending", "任务pending") + t.Status = trainingTask.Status + } + } + t.StartTime = trainingTask.Start + t.EndTime = trainingTask.End + err = svc.Scheduler.AiStorages.UpdateAiTask(t) + if err != nil { + msg := fmt.Sprintf("###UpdateAiTaskStatus###, AiTaskId: %v, clusterId: %v , JobId: %v, error: %v \n", t.Id, t.ClusterId, t.JobId, err.Error()) + logx.Errorf(errors.New(msg).Error()) + wg.Done() + return + } + wg.Done() + }() + } + wg.Wait() +} diff --git a/internal/scheduler/strategy/dynamicResources.go b/internal/scheduler/strategy/dynamicResources.go new file mode 100644 index 00000000..ff7f4109 --- /dev/null +++ b/internal/scheduler/strategy/dynamicResources.go @@ -0,0 +1,75 @@ +package strategy + +import ( + "errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/common" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" +) + +type DynamicResourcesStrategy struct { + replicas int32 + resources []*collector.ResourceStats + opt option.Option +} + +func NewDynamicResourcesStrategy(resources []*collector.ResourceStats, opt option.Option, replica int32) *DynamicResourcesStrategy { + return &DynamicResourcesStrategy{resources: resources, opt: opt, replicas: replica} +} + +func (ps *DynamicResourcesStrategy) Schedule() ([]*AssignedCluster, error) { + if ps.replicas < 1 { + return nil, errors.New("replicas must be greater than 0") + } + + switch ps.opt.GetOptionType() { + case option.AI: + opt := (interface{})(ps.opt).(*option.AiOption) + + var maxCardHoursAvailable float64 + var maxCpuCoreHoursAvailable float64 + var assignedCluster AssignedCluster + var results []*AssignedCluster + for _, res := range ps.resources { + + if res == nil { + continue + } + + if opt.ResourceType == "cpu" { + if res.CpuCoreHours <= 0 { + cluster := &AssignedCluster{ClusterId: res.ClusterId, Replicas: ps.replicas} + results = append(results, cluster) + return results, nil + } + + if res.CpuCoreHours > maxCpuCoreHoursAvailable { + maxCpuCoreHoursAvailable = res.CpuCoreHours + assignedCluster.ClusterId = res.ClusterId + assignedCluster.Replicas = ps.replicas + } + } + + if opt.ResourceType == "computeCard" { + var maxCurrentCardHours float64 + for _, card := range res.CardsAvail { + cardHours := common.RoundFloat( /*card.TOpsAtFp16**/ card.CardHours, 3) + if cardHours > maxCurrentCardHours { + maxCurrentCardHours = cardHours + } + } + if maxCurrentCardHours > maxCardHoursAvailable { + maxCardHoursAvailable = maxCurrentCardHours + assignedCluster.ClusterId = res.ClusterId + assignedCluster.Replicas = ps.replicas + } + } + } + results = append(results, &assignedCluster) + return results, nil + case option.CLOUD: + + } + + return nil, errors.New("failed to apply DynamicResourcesStrategy") +} diff --git a/internal/scheduler/strategy/param/params.go b/internal/scheduler/strategy/param/params.go new file mode 100644 index 00000000..69c7e2c4 --- /dev/null +++ b/internal/scheduler/strategy/param/params.go @@ -0,0 +1,9 @@ +package param + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" +) + +type Params struct { + Resources []*collector.ResourceStats +} diff --git a/internal/scheduler/strategy/param/resourcePricing.go b/internal/scheduler/strategy/param/resourcePricing.go new file mode 100644 index 00000000..b6e1aa1b --- /dev/null +++ b/internal/scheduler/strategy/param/resourcePricing.go @@ -0,0 +1,34 @@ +package param + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/algorithm/providerPricing" + "strconv" +) + +type ResourcePricingParams struct { + Replicas int32 + task *providerPricing.Task + *Params +} + +func (r *ResourcePricingParams) GetReplicas() int32 { + return r.Replicas +} + +func (r *ResourcePricingParams) GetTask() *providerPricing.Task { + return r.task +} + +func (r *ResourcePricingParams) GetProviders() []*providerPricing.Provider { + var providerList []*providerPricing.Provider + for _, resource := range r.Resources { + id, _ := strconv.ParseInt(resource.ClusterId, 10, 64) + provider := providerPricing.NewProvider( + id, + float64(resource.CpuCoreAvail), + resource.MemAvail, + resource.DiskAvail, 0.0, 0.0, 0.0) + providerList = append(providerList, provider) + } + return providerList +} diff --git a/api/internal/scheduler/strategy/random.go b/internal/scheduler/strategy/random.go similarity index 100% rename from api/internal/scheduler/strategy/random.go rename to internal/scheduler/strategy/random.go diff --git a/api/internal/scheduler/strategy/replication.go b/internal/scheduler/strategy/replication.go similarity index 100% rename from api/internal/scheduler/strategy/replication.go rename to internal/scheduler/strategy/replication.go diff --git a/internal/scheduler/strategy/resourcePricing.go b/internal/scheduler/strategy/resourcePricing.go new file mode 100644 index 00000000..d24bf2b1 --- /dev/null +++ b/internal/scheduler/strategy/resourcePricing.go @@ -0,0 +1,167 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package strategy + +import ( + "errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/algorithm/providerPricing" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy/param" + "strconv" +) + +type PricingStrategy struct { + ProviderList []*providerPricing.Provider + Task *providerPricing.Task + StrategyList []*providerPricing.Strategy +} + +func NewPricingStrategy(params *param.ResourcePricingParams) *PricingStrategy { + providers := params.GetProviders() + task := params.GetTask() + var providerList []*providerPricing.Provider + var res [][]int + + for _, p := range providers { + p.GenMaxResourceNum(task) + providerList = append(providerList, p) + } + + providerPricing.Back_trace_task(task.Replicas, 0, providerList, 0, &res, 0) + + var strategyList []*providerPricing.Strategy + for _, r := range res { + var path []int + var pathlist [][]int + + var resourcePerProvider []int + for j, p := range providerList { + if r[j] > p.MaxReplicas { + resourcePerProvider = append(resourcePerProvider, p.MaxReplicas) + } else { + resourcePerProvider = append(resourcePerProvider, r[j]) + } + } + providerPricing.Back_trace_resource(resourcePerProvider, 0, path, &pathlist) + strategy := providerPricing.NewStrategy() + strategy.Tasksolution = r + strategy.Resourcesolution = pathlist + strategyList = append(strategyList, strategy) + } + + return &PricingStrategy{ProviderList: providerList, Task: task, StrategyList: strategyList} +} + +func (ps *PricingStrategy) computeMaxScore() (*providerPricing.Task, error) { + maxStrategy := providerPricing.NewStrategy() + var maxprofit float64 + + //先计算出最大的利润值 + for _, strategy := range ps.StrategyList { + for _, resourceSolu := range strategy.Resourcesolution { + profit := providerPricing.ComputeProfit(ps.Task, strategy.Tasksolution, resourceSolu, ps.ProviderList) + if profit > maxprofit { + maxprofit = profit + } + } + } + + for _, strategy := range ps.StrategyList { + for _, resourceSolu := range strategy.Resourcesolution { + profit := providerPricing.ComputeProfit(ps.Task, strategy.Tasksolution, resourceSolu, ps.ProviderList) + highDegree := providerPricing.ComputeHighDegree(ps.Task, resourceSolu, ps.ProviderList) + + valueSum := profit/maxprofit + highDegree + + //将每个确定任务分配策略的最高的策略得分存储到里面 + if valueSum > maxStrategy.ValueSum { + strategy.Profit = profit + strategy.HighDegree = highDegree + } + + if valueSum > maxStrategy.ValueSum { + maxStrategy.ValueSum = valueSum + maxStrategy.Tasksolution = strategy.Tasksolution + newResourceSolu := [][]int{} + newResourceSolu = append(newResourceSolu, resourceSolu) + maxStrategy.Resourcesolution = newResourceSolu + maxStrategy.Profit = profit + maxStrategy.HighDegree = highDegree + } + } + } + + if len(ps.ProviderList) == 0 { + return nil, errors.New("empty providers") + } + + ps.Task.MaxscoreStrategy = maxStrategy // 记录该任务的最终分配策略 + return ps.Task, nil +} + +func (ps *PricingStrategy) produceMaxScoreStrategy() (*providerPricing.Strategy, error) { + task, err := ps.computeMaxScore() + if err != nil { + return nil, err + } + + //计算任务i的resourcePerTask属性 + for i, _ := range ps.ProviderList { + tasksolu := task.MaxscoreStrategy.Tasksolution[i] // 第j个提供商分到的任务数 + resourcesolu := task.MaxscoreStrategy.Resourcesolution[0][i] // 第j个提供商分到的资源数 + + // 在第j个云提供商处声明一个长度为资源数的链表 + resourcePerTaskPerProviders := make([]int, resourcesolu) + if tasksolu > 0 { + for tasksolu > 0 { + for j := 0; j < resourcesolu; j++ { + resourcePerTaskPerProviders[j] += 1 + tasksolu -= 1 + } + } + } else if tasksolu == 0 { + resourcePerTaskPerProviders = []int{0} + } + + task.ResourcePerTask = append(task.ResourcePerTask, resourcePerTaskPerProviders) + } + + return task.MaxscoreStrategy, nil +} + +func (ps *PricingStrategy) Schedule() ([]*AssignedCluster, error) { + strategy, err := ps.produceMaxScoreStrategy() + if err != nil { + return nil, err + } + + if len(strategy.Tasksolution) == 0 { + return nil, errors.New("调度失败, 未能获取调度结果") + } + + var results []*AssignedCluster + for i, e := range strategy.Tasksolution { + if e == 0 { + continue + } + cluster := &AssignedCluster{ClusterId: strconv.FormatInt(ps.ProviderList[i].Pid, 10), Replicas: int32(e)} + results = append(results, cluster) + } + + if len(results) == 0 { + return nil, errors.New("可用集群为空") + } + + return results, nil +} diff --git a/api/internal/scheduler/strategy/singleAssignment.go b/internal/scheduler/strategy/singleAssignment.go similarity index 100% rename from api/internal/scheduler/strategy/singleAssignment.go rename to internal/scheduler/strategy/singleAssignment.go diff --git a/internal/scheduler/strategy/staticWeight.go b/internal/scheduler/strategy/staticWeight.go new file mode 100644 index 00000000..da5ab621 --- /dev/null +++ b/internal/scheduler/strategy/staticWeight.go @@ -0,0 +1,50 @@ +package strategy + +import ( + "errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/algorithm/weightDistributing" +) + +type StaticWeightStrategy struct { + staticWeightMap map[string]int32 + replicas int32 +} + +func NewStaticWeightStrategy(staticWeightMap map[string]int32, replicas int32) *StaticWeightStrategy { + return &StaticWeightStrategy{staticWeightMap: staticWeightMap, + replicas: replicas, + } +} + +func (s *StaticWeightStrategy) Schedule() ([]*AssignedCluster, error) { + + if s.replicas < 1 { + return nil, errors.New("replicas must be greater than 0") + } + + if len(s.staticWeightMap) == 0 || s.staticWeightMap == nil { + return nil, errors.New("weight must be set") + } + + weights := make([]*weightDistributing.Weight, 0) + for k, v := range s.staticWeightMap { + weight := &weightDistributing.Weight{ + Id: k, + Weight: v, + } + weights = append(weights, weight) + } + + err := weightDistributing.DistributeReplicas(weights, s.replicas) + if err != nil { + return nil, err + } + + var results []*AssignedCluster + for _, weight := range weights { + cluster := &AssignedCluster{ClusterId: weight.Id, Replicas: weight.Replica} + results = append(results, cluster) + } + + return results, nil +} diff --git a/api/internal/scheduler/strategy/strategy.go b/internal/scheduler/strategy/strategy.go similarity index 100% rename from api/internal/scheduler/strategy/strategy.go rename to internal/scheduler/strategy/strategy.go diff --git a/internal/scheduler/strategy/test/strategy_test.go b/internal/scheduler/strategy/test/strategy_test.go new file mode 100644 index 00000000..0850cd07 --- /dev/null +++ b/internal/scheduler/strategy/test/strategy_test.go @@ -0,0 +1,251 @@ +package test + +import ( + "fmt" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/entity" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy" + "math/rand" + "testing" + "time" +) + +func TestReplication(t *testing.T) { + parts := []entity.Participant{ + {Name: "test1", Participant_id: 1}, + {Name: "test2", Participant_id: 2}, + {Name: "test3", Participant_id: 3}, + } + rsc := []*collector.ResourceStats{ + { + ClusterId: "1", + Name: "test1", + }, + { + ClusterId: "2", + Name: "test2"}, + { + ClusterId: "3", + Name: "test3"}, + } + tests := []struct { + name string + replica int32 + ps []entity.Participant + res []*collector.ResourceStats + }{ + { + name: "test1", + replica: 1, + ps: parts, + }, + { + name: "test2", + replica: 2, + ps: parts, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var clusterIds []string + for _, stats := range rsc { + clusterIds = append(clusterIds, stats.ClusterId) + } + repl := strategy.NewReplicationStrategy(clusterIds, 0) + schedule, err := repl.Schedule() + if err != nil { + return + } + for _, cluster := range schedule { + fmt.Println(cluster) + } + + }) + } + +} + +func TestStaticWeight(t *testing.T) { + parts := map[string]int32{ + "test1": 6, + "test2": 5, + "test3": 2, + } + tests := []struct { + name string + replica int32 + ps map[string]int32 + }{ + { + name: "test1", + replica: 1, + ps: parts, + }, + { + name: "test2", + replica: 5, + ps: parts, + }, + { + name: "test2", + replica: 6, + ps: parts, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + repl := strategy.NewStaticWeightStrategy(tt.ps, tt.replica) + schedule, err := repl.Schedule() + if err != nil { + return + } + for _, cluster := range schedule { + fmt.Println(cluster) + } + + }) + } +} + +func TestRandom(t *testing.T) { + // 使用当前时间作为随机数种子,确保每次程序运行产生的随机数序列都不同 + rand.Seed(time.Now().UnixNano()) + + /*randomNum := randInt(1, 100) + fmt.Println("Random number:", randomNum)*/ + total := 5 // 假设总数是5 + first, second := splitIntoTwoRandomParts(total) + fmt.Printf("第一部分的数量: %d, 第二部分的数量: %d\n", first, second) +} + +// randInt 生成一个指定范围内的随机整数,包括min但不包括max +func randInt(min, max int) int { + return min + rand.Intn(max-min) +} + +func splitIntoTwoRandomParts(total int) (int, int) { + if total < 2 { + // 如果总数小于2,则无法分成两部分 + return 0, 0 + } + // 生成一个随机数作为第一部分的数量(范围在[1, total-1]之间) + firstPart := rand.Intn(total-1) + 1 + // 第二部分的数量就是总数减去第一部分的数量 + secondPart := total - firstPart + return firstPart, secondPart +} + +func splitIntoRandomParts(total int) (int, int) { + if total < 2 { + // 如果总数小于2,则无法分成两部分 + return 0, 0 + } + // 生成一个随机数作为第一部分的数量(范围在[1, total-1]之间) + firstPart := rand.Intn(total-1) + 1 + // 第二部分的数量就是总数减去第一部分的数量 + secondPart := total - firstPart + return firstPart, secondPart +} + +func TestRandoms(t *testing.T) { + // 使用当前时间作为随机数种子,确保每次程序运行产生的随机数序列都不同 + rand.Seed(time.Now().UnixNano()) + + /*randomNum := randInt(1, 100) + fmt.Println("Random number:", randomNum)*/ + total := 10 // 假设总数是5 + parts := splitRandomParts(total) + fmt.Println("分配结果:", parts) +} + +// splitIntoRandomParts 将总数total随机分成多个部分,并返回这些部分的切片 +func splitRandomParts(total int) []int { + if total < 2 { + // 如果总数小于2,则无法分成多个部分 + return []int{total} + } + + // 创建一个切片来保存每个部分的数量 + var parts []int + + // 剩余要分配的副本数 + remaining := total + + // 随机决定要分成的部分数量(至少2个部分) + numParts := rand.Intn(total-1) + 2 + + // 确保每个部分至少获得1个副本 + for i := 0; i < numParts-1; i++ { + // 生成一个随机数(1到剩余副本数之间) + // 为了避免最后一个部分太小,我们可能需要调整随机数范围 + minPartSize := 1 + if remaining <= numParts-i { + // 如果剩余副本数不足以让每个部分都至少获得1个,则调整最小部分大小 + minPartSize = remaining / (numParts - i) + if remaining%(numParts-i) > 0 { + minPartSize++ + } + } + // 生成一个大于等于minPartSize且小于等于remaining的随机数 + partSize := minPartSize + rand.Intn(remaining-minPartSize+1) + parts = append(parts, partSize) + remaining -= partSize + } + + // 最后一个部分的数量就是剩余的副本数 + parts = append(parts, remaining) + + return parts +} + +func TestNumRandom(t *testing.T) { + total := 10 // 假设副本数是10 + numParts := 2 // 假设要分成5个集群 + + parts, err := splitIntoParts(total, numParts) + if err != nil { + fmt.Println("Error:", err) + return + } + fmt.Println("分配结果:", parts) +} + +// splitIntoParts 将总数total随机分成numParts个部分,并返回这些部分的切片 +func splitIntoParts(total int, numParts int) ([]int, error) { + if total < 1 || numParts < 1 { + // 总数或部分数量不能小于1 + return nil, fmt.Errorf("total and numParts must be greater than 0") + } + if numParts > total { + // 部分数量不能大于总数 + return nil, fmt.Errorf("numParts cannot be greater than total") + } + + // 创建一个切片来保存每个部分的数量 + parts := make([]int, numParts) + + // 首先将每个部分都分配至少一个副本 + for i := range parts { + parts[i] = 1 + total-- + } + + // 剩余要分配的副本数 + remaining := total + + // 随机分配剩余的副本 + for remaining > 0 { + // 随机选择一个部分(索引从0到numParts-1) + partIndex := rand.Intn(numParts) + + // 如果该部分加上一个副本后不会超过总数,则分配一个副本 + if parts[partIndex]+1 <= total { + parts[partIndex]++ + remaining-- + } + } + + return parts, nil +} diff --git a/internal/storeLink/modelarts.go b/internal/storeLink/modelarts.go new file mode 100644 index 00000000..caa8ec24 --- /dev/null +++ b/internal/storeLink/modelarts.go @@ -0,0 +1,399 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storeLink + +import ( + "context" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + modelartsclient "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "strconv" + "strings" + "time" +) + +const ( + Ascend = "Ascend" +) + +type ModelArtsLink struct { + modelArtsRpc modelartsservice.ModelArtsService + modelArtsImgRpc imagesservice.ImagesService + platform string + participantId int64 + pageIndex int32 + pageSize int32 +} + +func NewModelArtsLink(modelArtsRpc modelartsservice.ModelArtsService, modelArtsImgRpc imagesservice.ImagesService, name string, id int64, nickname string) *ModelArtsLink { + return &ModelArtsLink{modelArtsRpc: modelArtsRpc, modelArtsImgRpc: modelArtsImgRpc, platform: nickname, participantId: id, pageIndex: 0, pageSize: 50} +} + +func (m *ModelArtsLink) UploadImage(ctx context.Context, path string) (interface{}, error) { + //TODO modelArts上传镜像 + return nil, nil +} + +func (m *ModelArtsLink) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { + // TODO modelArts删除镜像 + return nil, nil +} + +func (m *ModelArtsLink) QueryImageList(ctx context.Context) (interface{}, error) { + // modelArts获取镜像列表 + req := &modelarts.ListRepoReq{ + Offset: "0", + Limit: strconv.Itoa(int(m.pageSize)), + Platform: m.platform, + } + resp, err := m.modelArtsImgRpc.ListReposDetails(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ModelArtsLink) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { + // modelArts提交任务 + environments := make(map[string]string) + parameters := make([]*modelarts.ParametersTrainJob, 0) + for _, env := range envs { + s := strings.Split(env, COMMA) + environments[s[0]] = s[1] + } + for _, param := range params { + s := strings.Split(param, COMMA) + parameters = append(parameters, &modelarts.ParametersTrainJob{ + Name: s[0], + Value: s[1], + }) + } + req := &modelarts.CreateTrainingJobReq{ + Kind: "job", + Metadata: &modelarts.MetadataS{ + Name: TASK_NAME_PREFIX + utils.RandomString(10), + WorkspaceId: "0", + }, + Algorithm: &modelarts.Algorithms{ + Id: algorithmId, + Engine: &modelarts.EngineCreateTraining{ + ImageUrl: imageId, + }, + Command: cmd, + Environments: environments, + Parameters: parameters, + }, + Spec: &modelarts.SpecsC{ + Resource: &modelarts.ResourceCreateTraining{ + FlavorId: resourceId, + NodeCount: 1, + }, + }, + Platform: m.platform, + } + resp, err := m.modelArtsRpc.CreateTrainingJob(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ModelArtsLink) QueryTask(ctx context.Context, taskId string) (interface{}, error) { + // 获取任务 + req := &modelarts.DetailTrainingJobsReq{ + TrainingJobId: taskId, + Platform: m.platform, + } + resp, err := m.modelArtsRpc.GetTrainingJobs(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ModelArtsLink) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { + // 删除任务 + req := &modelarts.DeleteTrainingJobReq{ + TrainingJobId: taskId, + Platform: m.platform, + } + resp, err := m.modelArtsRpc.DeleteTrainingJob(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ModelArtsLink) QuerySpecs(ctx context.Context) (interface{}, error) { + // octopus查询资源规格 + req := &modelarts.TrainingJobFlavorsReq{ + Platform: m.platform, + } + resp, err := m.modelArtsRpc.GetTrainingJobFlavors(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ModelArtsLink) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { + return nil, nil +} + +func (m *ModelArtsLink) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) { + return nil, nil +} + +func (m *ModelArtsLink) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) { + var algorithms []*collector.Algorithm + + req := &modelarts.ListAlgorithmsReq{ + Platform: m.platform, + Offset: m.pageIndex, + Limit: m.pageSize, + } + resp, err := m.modelArtsRpc.ListAlgorithms(ctx, req) + if err != nil { + return nil, err + } + if resp.ErrorMsg != "" { + return nil, errors.New("failed to get algorithms") + } + + for _, a := range resp.Items { + //TODO The value of taskType is temporarily fixed to "pytorch" + algorithm := &collector.Algorithm{Name: a.Metadata.Name, Platform: MODELARTS, TaskType: "pytorch"} + algorithms = append(algorithms, algorithm) + } + return algorithms, nil +} + +func (m *ModelArtsLink) GetComputeCards(ctx context.Context) ([]string, error) { + var cards []string + cards = append(cards, Ascend) + return cards, nil +} + +func (m *ModelArtsLink) GetUserBalance(ctx context.Context) (float64, error) { + return 0, nil +} + +func (m *ModelArtsLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) { + return "", nil +} + +func (m *ModelArtsLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error { + return nil +} + +func (m *ModelArtsLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { + req := &modelartsservice.GetTrainingJobLogsPreviewReq{ + Platform: m.platform, + TaskId: "worker-0", + TrainingJobId: taskId, + } + resp, err := m.modelArtsRpc.GetTrainingJobLogsPreview(ctx, req) + if err != nil { + return "", err + } + + if strings.Contains(resp.Content, "404 Not Found") { + resp.Content = "waiting for logs..." + } + return resp.Content, nil +} + +func (m *ModelArtsLink) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { + resp, err := m.QueryTask(ctx, taskId) + if err != nil { + return nil, err + } + jobresp, ok := (resp).(*modelartsservice.JobResponse) + if jobresp.ErrorMsg != "" || !ok { + if jobresp.ErrorMsg != "" { + return nil, errors.New(jobresp.ErrorMsg) + } else { + return nil, errors.New("get training task failed, empty error returned") + } + } + var task collector.Task + task.Id = jobresp.Metadata.Id + + switch strings.ToLower(jobresp.Status.Phase) { + case "completed": + milliTimestamp := int64(jobresp.Status.StartTime) + task.Start = timeutils.MillisecondsToUTCString(milliTimestamp, time.DateTime) + duration := int64(jobresp.Status.Duration) + task.End = timeutils.MillisecondsToAddDurationToUTCString(milliTimestamp, duration, time.DateTime) + task.Status = constants.Completed + case "failed": + milliTimestamp := int64(jobresp.Status.StartTime) + task.Start = timeutils.MillisecondsToUTCString(milliTimestamp, time.DateTime) + duration := int64(jobresp.Status.Duration) + task.End = timeutils.MillisecondsToAddDurationToUTCString(milliTimestamp, duration, time.DateTime) + task.Status = constants.Failed + case "running": + milliTimestamp := int64(jobresp.Status.StartTime) + task.Start = timeutils.MillisecondsToUTCString(milliTimestamp, time.DateTime) + task.Status = constants.Running + case "stopped": + task.Status = constants.Stopped + case "pending": + task.Status = constants.Pending + case "terminated": + //TODO Failed + task.Status = constants.Failed + default: + task.Status = "undefined" + } + + return &task, nil +} + +func (m *ModelArtsLink) Execute(ctx context.Context, option *option.AiOption) (interface{}, error) { + err := m.GenerateSubmitParams(ctx, option) + if err != nil { + return nil, err + } + task, err := m.SubmitTask(ctx, option.ImageId, option.Cmd, option.Envs, option.Params, option.ResourceId, option.DatasetsId, option.AlgorithmId, option.TaskType) + if err != nil { + return nil, err + } + return task, nil +} + +func (m *ModelArtsLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error { + err := m.generateResourceId(ctx, option) + if err != nil { + return err + } + err = m.generateAlgorithmId(ctx, option) + if err != nil { + return err + } + err = m.generateImageId(option) + if err != nil { + return err + } + err = m.generateCmd(option) + if err != nil { + return err + } + err = m.generateEnv(option) + if err != nil { + return err + } + err = m.generateParams(option) + if err != nil { + return err + } + return nil +} + +func (m *ModelArtsLink) generateResourceId(ctx context.Context, option *option.AiOption) error { + option.ResourceId = "modelarts.kat1.xlarge" + return nil +} + +func (m *ModelArtsLink) generateImageId(option *option.AiOption) error { + + return nil +} + +func (m *ModelArtsLink) generateCmd(option *option.AiOption) error { + + return nil +} + +func (m *ModelArtsLink) generateEnv(option *option.AiOption) error { + + return nil +} + +func (m *ModelArtsLink) generateParams(option *option.AiOption) error { + + return nil +} + +func (m *ModelArtsLink) generateAlgorithmId(ctx context.Context, option *option.AiOption) error { + req := &modelarts.ListAlgorithmsReq{ + Platform: m.platform, + Offset: m.pageIndex, + Limit: m.pageSize, + } + resp, err := m.modelArtsRpc.ListAlgorithms(ctx, req) + if err != nil { + return err + } + if resp.ErrorMsg != "" { + return errors.New("failed to get algorithmId") + } + + for _, algorithm := range resp.Items { + engVersion := algorithm.JobConfig.Engine.EngineVersion + if strings.Contains(engVersion, option.TaskType) { + ns := strings.Split(algorithm.Metadata.Name, DASH) + if ns[0] != option.TaskType { + continue + } + if ns[1] != option.DatasetsName { + continue + } + if ns[2] != option.AlgorithmName { + continue + } + option.AlgorithmId = algorithm.Metadata.Id + return nil + } + } + + if option.AlgorithmId == "" { + return errors.New("Algorithm does not exist") + } + + return errors.New("failed to get AlgorithmId") +} + +func (m *ModelArtsLink) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*collector.InferUrl, error) { + var imageUrls []*collector.InferUrl + urlReq := &modelartsclient.ImageReasoningUrlReq{ + ModelName: option.ModelName, + Type: option.ModelType, + Card: "npu", + } + urlResp, err := m.modelArtsRpc.ImageReasoningUrl(ctx, urlReq) + if err != nil { + return nil, err + } + imageUrl := &collector.InferUrl{ + Url: urlResp.Url, + Card: "npu", + } + imageUrls = append(imageUrls, imageUrl) + + return imageUrls, nil +} diff --git a/internal/storeLink/octopus.go b/internal/storeLink/octopus.go new file mode 100644 index 00000000..2813d048 --- /dev/null +++ b/internal/storeLink/octopus.go @@ -0,0 +1,904 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storeLink + +import ( + "context" + "errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" + "math" + "strconv" + "strings" + "time" +) + +type OctopusLink struct { + octopusRpc octopusclient.Octopus + pageIndex int32 + pageSize int32 + platform string + participantId int64 +} + +const ( + IMG_NAME_PREFIX = "oct_" + IMG_VERSION_PREFIX = "version_" + TASK_NAME_PREFIX = "trainJob" + RESOURCE_POOL = "common-pool" + HANWUJI = "hanwuji" + SUIYUAN = "suiyuan" + SAILINGSI = "sailingsi" + MLU = "MLU" + BIV100 = "BI-V100" + CAMBRICONMLU290 = 256 + GCU = "GCU" + ENFLAME = "enflame" + EnflameT20 = 128 + BASE_TOPS = 128 + CAMBRICON = "cambricon" + ILUVATAR = "iluvatar" + TRAIN_CMD = "cd /code; python train.py" + VERSION = "V1" + DOMAIN = "http://192.168.242.41:8001/" + CAMBRICON_CN = "寒武纪290" + ENFLAME_CN = "燧原T20" + ILUVATAR_CN = "天数BI-V100" +) + +var ( + cardAliasMap = map[string]string{ + MLU: CAMBRICON, + GCU: ENFLAME, + BIV100: ILUVATAR, + } + cardCnMap = map[string]string{ + MLU: CAMBRICON_CN, + GCU: ENFLAME_CN, + BIV100: ILUVATAR_CN, + } + cardTopsMap = map[string]float64{ + MLU: CAMBRICONMLU290, + GCU: EnflameT20, + } +) + +func NewOctopusLink(octopusRpc octopusclient.Octopus, name string, id int64) *OctopusLink { + return &OctopusLink{octopusRpc: octopusRpc, platform: name, participantId: id, pageIndex: 1, pageSize: 100} +} + +func (o *OctopusLink) UploadImage(ctx context.Context, path string) (interface{}, error) { + // octopus创建镜像 + createReq := &octopus.CreateImageReq{ + Platform: o.platform, + CreateImage: &octopus.CreateImage{ + SourceType: 1, + ImageName: IMG_NAME_PREFIX + utils.RandomString(7), + ImageVersion: IMG_VERSION_PREFIX + utils.RandomString(7), + }, + } + createResp, err := o.octopusRpc.CreateImage(ctx, createReq) + if err != nil { + return nil, err + } + + // octopus上传镜像 + uploadReq := &octopus.UploadImageReq{ + Platform: o.platform, + ImageId: createResp.Payload.ImageId, + Params: &octopus.UploadImageParam{ + Domain: "", + FileName: "", + }, + } + uploadResp, err := o.octopusRpc.UploadImage(ctx, uploadReq) + if err != nil { + return nil, err + } + + // Todo 实际上传 + + return uploadResp, nil +} + +func (o *OctopusLink) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { + // octopus删除镜像 + req := &octopus.DeleteImageReq{ + Platform: o.platform, + ImageId: imageId, + } + resp, err := o.octopusRpc.DeleteImage(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OctopusLink) QueryImageList(ctx context.Context) (interface{}, error) { + // octopus获取镜像列表 + req := &octopus.GetUserImageListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.octopusRpc.GetUserImageList(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OctopusLink) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { + // octopus提交任务 + + // python参数 + var prms []*octopus.Parameters + for _, param := range params { + var p octopus.Parameters + s := strings.Split(param, COMMA) + p.Key = s[0] + p.Value = s[1] + prms = append(prms, &p) + } + + //环境变量 + envMap := make(map[string]string) + for _, env := range envs { + s := strings.Split(env, COMMA) + envMap[s[0]] = s[1] + } + + req := &octopus.CreateTrainJobReq{ + Platform: o.platform, + Params: &octopus.CreateTrainJobParam{ + ImageId: imageId, + Name: TASK_NAME_PREFIX + UNDERSCORE + utils.RandomString(10), + ResourcePool: RESOURCE_POOL, + Config: []*octopus.Config{ + { + Command: cmd, + ResourceSpecId: resourceId, + MinFailedTaskCount: 1, + MinSucceededTaskCount: 1, + TaskNumber: 1, + Parameters: prms, + Envs: envMap, + }, + }, + DataSetId: datasetsId, + DataSetVersion: VERSION, + AlgorithmId: algorithmId, + AlgorithmVersion: VERSION, + }, + } + resp, err := o.octopusRpc.CreateTrainJob(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OctopusLink) QueryTask(ctx context.Context, taskId string) (interface{}, error) { + // octopus获取任务 + req := &octopus.GetTrainJobReq{ + Platform: o.platform, + Id: taskId, + } + resp, err := o.octopusRpc.GetTrainJob(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OctopusLink) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { + // octopus删除任务 + req := &octopus.DeleteTrainJobReq{ + Platform: o.platform, + JobIds: []string{taskId}, + } + resp, err := o.octopusRpc.DeleteTrainJob(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OctopusLink) QuerySpecs(ctx context.Context) (interface{}, error) { + // octopus查询资源规格 + req := &octopus.GetResourceSpecsReq{ + Platform: o.platform, + ResourcePool: RESOURCE_POOL, + } + resp, err := o.octopusRpc.GetResourceSpecs(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OctopusLink) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { + req := &octopus.GetResourceSpecsReq{ + Platform: o.platform, + ResourcePool: RESOURCE_POOL, + } + specResp, err := o.octopusRpc.GetResourceSpecs(ctx, req) + if err != nil { + return nil, err + } + if !specResp.Success { + return nil, errors.New(specResp.Error.Message) + } + balanceReq := &octopus.GetUserBalanceReq{ + Platform: o.platform, + } + balanceResp, err := o.octopusRpc.GetUserBalance(ctx, balanceReq) + if err != nil { + return nil, err + } + if !balanceResp.Success { + return nil, errors.New(balanceResp.Error.Message) + } + + var cards []*collector.Card + balance := float64(balanceResp.Payload.BillingUser.Amount) + var cpuHours float64 + for _, spec := range specResp.TrainResourceSpecs { + if spec.Price == 0 { + ns := strings.Split(spec.Name, COMMA) + if len(ns) == 2 { + nss := strings.Split(ns[0], COLON) + if nss[0] == CPU { + cpuHours = -1 + } + } + } + + if spec.Price == 1 { + ns := strings.Split(spec.Name, COMMA) + cardSpecs := strings.Split(ns[0], STAR) + + cardTops, isMapContainsKey := cardTopsMap[cardSpecs[1]] + if !isMapContainsKey { + continue + } + + card := &collector.Card{ + Platform: OCTOPUS, + Type: CARD, + Name: cardSpecs[1], + TOpsAtFp16: cardTops, + CardHours: balance / spec.Price, + } + cards = append(cards, card) + } + } + + resourceStats := &collector.ResourceStats{ + ClusterId: strconv.FormatInt(o.participantId, 10), + Name: o.platform, + Balance: balance, + CardsAvail: cards, + CpuCoreHours: cpuHours, + } + + return resourceStats, nil +} + +func (o *OctopusLink) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) { + req := &octopus.GetMyDatasetListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.octopusRpc.GetMyDatasetList(ctx, req) + if err != nil { + return nil, err + } + if !resp.Success { + return nil, errors.New(resp.Error.Message) + } + specs := []*collector.DatasetsSpecs{} + for _, dataset := range resp.Payload.Datasets { + spec := &collector.DatasetsSpecs{Name: dataset.Name} + specs = append(specs, spec) + } + return specs, nil +} + +func (o *OctopusLink) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) { + var algorithms []*collector.Algorithm + + req := &octopus.GetMyAlgorithmListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.octopusRpc.GetMyAlgorithmList(ctx, req) + if err != nil { + return nil, err + } + if !resp.Success { + return nil, errors.New("failed to get algorithms") + } + + for _, a := range resp.Payload.Algorithms { + algorithm := &collector.Algorithm{Name: a.AlgorithmName, Platform: OCTOPUS, TaskType: strings.ToLower(a.FrameworkName)} + algorithms = append(algorithms, algorithm) + } + return algorithms, nil +} + +func (o *OctopusLink) GetComputeCards(ctx context.Context) ([]string, error) { + var cards []string + for s, _ := range cardAliasMap { + cards = append(cards, s) + } + return cards, nil +} + +func (o *OctopusLink) GetUserBalance(ctx context.Context) (float64, error) { + balanceReq := &octopus.GetUserBalanceReq{ + Platform: o.platform, + } + balanceResp, err := o.octopusRpc.GetUserBalance(ctx, balanceReq) + if err != nil { + return 0, err + } + if !balanceResp.Success { + if balanceResp.Error != nil { + return 0, errors.New(balanceResp.Error.Message) + } else { + return 0, errors.New("failed to get user balance") + } + } + balance := float64(balanceResp.Payload.BillingUser.Amount) + return balance, nil +} + +func (o *OctopusLink) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) { + var name string + if resourceType == CARD { + name = dataset + UNDERSCORE + algorithm + UNDERSCORE + card + } else { + name = dataset + UNDERSCORE + algorithm + UNDERSCORE + CPU + } + + req := &octopus.GetMyAlgorithmListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.octopusRpc.GetMyAlgorithmList(ctx, req) + if err != nil { + return "", err + } + if !resp.Success { + return "", errors.New("failed to get algorithmList") + } + + var algorithmId string + var algorithms []*octopus.Algorithms + for _, a := range resp.Payload.Algorithms { + if strings.ToLower(a.FrameworkName) != taskType { + continue + } + + if a.AlgorithmDescript == name { + algorithms = append(algorithms, a) + } + } + + if len(algorithms) == 0 { + return "", errors.New("algorithmId not found") + } + + if len(algorithms) == 1 { + algorithmId = algorithms[0].AlgorithmId + } + + aLatest := &octopus.Algorithms{} + for i, _ := range algorithms { + if time.Unix(algorithms[i].CreatedAt, 0).After(time.Unix(aLatest.CreatedAt, 0)) { + aLatest = algorithms[i] + } + } + if aLatest.AlgorithmId == "" { + return "", errors.New("algorithmId not found") + } + + algorithmId = aLatest.AlgorithmId + + dcReq := &octopus.DownloadCompressReq{ + Platform: o.platform, + Version: VERSION, + AlgorithmId: algorithmId, + } + dcResp, err := o.octopusRpc.DownloadCompress(ctx, dcReq) + if err != nil { + return "", err + } + + if !dcResp.Success { + return "", errors.New(dcResp.Error.Message) + } + + daReq := &octopus.DownloadAlgorithmReq{ + Platform: o.platform, + Version: VERSION, + AlgorithmId: algorithmId, + CompressAt: dcResp.Payload.CompressAt, + Domain: DOMAIN, + } + daResp, err := o.octopusRpc.DownloadAlgorithm(ctx, daReq) + if err != nil { + return "", err + } + if !daResp.Success { + return "", errors.New(dcResp.Error.Message) + } + urlReq := &octopus.AlgorithmUrlReq{ + Platform: o.platform, + Url: daResp.Payload.DownloadUrl, + } + urlResp, err := o.octopusRpc.DownloadAlgorithmUrl(ctx, urlReq) + if err != nil { + return "", err + } + + return urlResp.Algorithm, nil +} + +func (o *OctopusLink) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error { + //var name string + //if resourceType == CARD { + // name = dataset + UNDERSCORE + algorithm + UNDERSCORE + card + //} else { + // name = dataset + UNDERSCORE + algorithm + UNDERSCORE + CPU + //} + //uploadReq := &octopus.UploadAlgorithmReq{} + return nil +} + +func (o *OctopusLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { + instance, err := strconv.ParseInt(instanceNum, 10, 32) + if err != nil { + return "", err + } + req := &octopus.GetTrainJobLogReq{ + Platform: o.platform, + TaskId: taskId, + TaskNum: "task0", + Num: int32(instance), + } + resp, err := o.octopusRpc.GetTrainJobLog(ctx, req) + if err != nil { + return "", err + } + + if strings.Contains(resp.Content, "404 Not Found") { + resp.Content = "waiting for logs..." + } + + return resp.Content, nil +} + +func (o *OctopusLink) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { + resp, err := o.QueryTask(ctx, taskId) + if err != nil { + return nil, err + } + jobresp, ok := (resp).(*octopus.GetTrainJobResp) + if !jobresp.Success || !ok { + if jobresp.Error != nil { + return nil, errors.New(jobresp.Error.Message) + } else { + return nil, errors.New("get training task failed, empty error returned") + } + } + var task collector.Task + task.Id = jobresp.Payload.TrainJob.Id + if jobresp.Payload.TrainJob.StartedAt != 0 { + task.Start = time.Unix(jobresp.Payload.TrainJob.StartedAt, 0).Format(constants.Layout) + } + if jobresp.Payload.TrainJob.CompletedAt != 0 { + task.End = time.Unix(jobresp.Payload.TrainJob.CompletedAt, 0).Format(constants.Layout) + } + switch jobresp.Payload.TrainJob.Status { + case "succeeded": + task.Status = constants.Completed + case "failed": + task.Status = constants.Failed + case "running": + task.Status = constants.Running + case "stopped": + task.Status = constants.Stopped + case "pending": + task.Status = constants.Pending + default: + task.Status = "undefined" + } + + return &task, nil +} + +func (o *OctopusLink) Execute(ctx context.Context, option *option.AiOption) (interface{}, error) { + err := o.GenerateSubmitParams(ctx, option) + if err != nil { + return nil, err + } + task, err := o.SubmitTask(ctx, option.ImageId, option.Cmd, option.Envs, option.Params, option.ResourceId, option.DatasetsId, option.AlgorithmId, option.TaskType) + if err != nil { + return nil, err + } + return task, nil +} + +func (o *OctopusLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error { + err := o.generateResourceId(ctx, option) + if err != nil { + return err + } + err = o.generateDatasetsId(ctx, option) + if err != nil { + return err + } + err = o.generateImageId(ctx, option) + if err != nil { + return err + } + err = o.generateAlgorithmId(ctx, option) + if err != nil { + return err + } + err = o.generateCmd(option) + if err != nil { + return err + } + err = o.generateEnv(option) + if err != nil { + return err + } + err = o.generateParams(option) + if err != nil { + return err + } + return nil +} + +func (o *OctopusLink) generateResourceId(ctx context.Context, option *option.AiOption) error { + if option.ResourceType == "" { + return errors.New("ResourceType not set") + } + req := &octopus.GetResourceSpecsReq{ + Platform: o.platform, + ResourcePool: RESOURCE_POOL, + } + specResp, err := o.octopusRpc.GetResourceSpecs(ctx, req) + if err != nil { + return err + } + if !specResp.Success { + return errors.New(specResp.Error.Message) + } + + if option.ResourceType == CPU { + for _, spec := range specResp.TrainResourceSpecs { + if spec.Price == 0 { + option.ResourceId = spec.Id + return nil + } + } + } + + if option.ResourceType == CARD { + if option.ComputeCard == "" { + option.ComputeCard = GCU + } + err = setResourceIdByCard(option, specResp, option.ComputeCard) + if err != nil { + return err + } + return nil + } + + return errors.New("failed to get ResourceId") +} + +func (o *OctopusLink) generateDatasetsId(ctx context.Context, option *option.AiOption) error { + if option.DatasetsName == "" { + return errors.New("DatasetsName not set") + } + req := &octopus.GetMyDatasetListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.octopusRpc.GetMyDatasetList(ctx, req) + if err != nil { + return err + } + if !resp.Success { + return errors.New("failed to get DatasetsId") + } + for _, dataset := range resp.Payload.Datasets { + if dataset.Name == option.DatasetsName { + option.DatasetsId = dataset.Id + return nil + } + } + return errors.New("failed to get DatasetsId") +} + +func (o *OctopusLink) generateImageId(ctx context.Context, option *option.AiOption) error { + if option.TaskType == "" { + return errors.New("TaskType not set") + } + + req := &octopus.GetUserImageListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.octopusRpc.GetUserImageList(ctx, req) + if err != nil { + return err + } + if !resp.Success { + return errors.New("failed to get imageId") + } + + if option.ResourceType == CPU { + for _, img := range resp.Payload.Images { + if img.Image.ImageName == "test-image" { + option.ImageId = img.Image.Id + return nil + } + } + } + + preImgReq := &octopus.GetPresetImageListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + preImgResp, err := o.octopusRpc.GetPresetImageList(ctx, preImgReq) + if err != nil { + return err + } + if !preImgResp.Success { + return errors.New("failed to get PresetImages") + } + + if option.ResourceType == CARD { + for _, image := range preImgResp.Payload.Images { + if strings.Contains(image.ImageName, cardAliasMap[strings.ToUpper(option.ComputeCard)]) { + switch strings.ToUpper(option.ComputeCard) { + case GCU: + if strings.HasPrefix(image.ImageVersion, "t20_") { + option.ImageId = image.Id + return nil + } + case BIV100: + if strings.HasPrefix(image.ImageVersion, "bi_") { + option.ImageId = image.Id + return nil + } + case MLU: + option.ImageId = image.Id + return nil + } + } + } + } + + return errors.New("failed to get ImageId") +} + +func (o *OctopusLink) generateAlgorithmId(ctx context.Context, option *option.AiOption) error { + req := &octopus.GetMyAlgorithmListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.octopusRpc.GetMyAlgorithmList(ctx, req) + if err != nil { + return err + } + if !resp.Success { + return errors.New("failed to get algorithmId") + } + + for _, algorithm := range resp.Payload.Algorithms { + if algorithm.FrameworkName == strings.Title(option.TaskType) { + ns := strings.Split(algorithm.AlgorithmName, UNDERSCORE) + if ns[0] != option.DatasetsName { + continue + } + if ns[1] != option.AlgorithmName { + continue + } + switch option.ResourceType { + case CPU: + if ns[2] != CPU { + continue + } + case CARD: + if ns[2] != strings.ToLower(option.ComputeCard) { + continue + } + } + + option.AlgorithmId = algorithm.AlgorithmId + return nil + } + } + + if option.AlgorithmId == "" { + return errors.New("Algorithm does not exist") + } + + return errors.New("failed to get AlgorithmId") +} + +func (o *OctopusLink) generateCmd(option *option.AiOption) error { + if option.Cmd == "" { + switch option.ComputeCard { + case GCU: + option.Cmd = "cd /code; python3 train.py" + case MLU: + option.Cmd = ". /torch/venv3/pytorch/bin/activate; cd /code; python train.py" + default: + option.Cmd = TRAIN_CMD + } + } + + return nil +} + +func (o *OctopusLink) generateEnv(option *option.AiOption) error { + + return nil +} + +func (o *OctopusLink) generateParams(option *option.AiOption) error { + if len(option.Params) == 0 { + epoch := "epoch" + COMMA + "1" + option.Params = append(option.Params, epoch) + } + return nil +} + +func setResourceIdByCard(option *option.AiOption, specs *octopus.GetResourceSpecsResp, computeCard string) error { + if option.Tops == 0 { + for _, spec := range specs.TrainResourceSpecs { + if spec.Price == 1 { + ns := strings.Split(spec.Name, COMMA) + cardSpecs := strings.Split(ns[0], STAR) + if cardSpecs[1] == cardCnMap[strings.ToUpper(computeCard)] { + option.ResourceId = spec.Id + option.ComputeCard = computeCard + return nil + } + } else { + continue + } + } + } else { + cardNum := math.Ceil(option.Tops / float64(BASE_TOPS)) + for _, spec := range specs.TrainResourceSpecs { + if option.Tops < BASE_TOPS { + if spec.Price == 1 { + ns := strings.Split(spec.Name, COMMA) + cardSpecs := strings.Split(ns[0], STAR) + if cardSpecs[1] == cardCnMap[strings.ToUpper(computeCard)] { + option.ResourceId = spec.Id + option.ComputeCard = computeCard + return nil + } + } else { + continue + } + } else { + ns := strings.Split(spec.Name, COMMA) + if len(ns) != 4 { + continue + } + cardSpecs := strings.Split(ns[0], STAR) + if cardSpecs[1] != cardCnMap[strings.ToUpper(computeCard)] { + continue + } + s, err := strconv.ParseFloat(cardSpecs[0], 64) + if err != nil { + return err + } + switch computeCard { + case GCU: + option.ComputeCard = computeCard + if cardNum == s { // 1, 4, 8 + option.ResourceId = spec.Id + return nil + } + if 1 < cardNum && cardNum <= 4 && s == 4 { + option.ResourceId = spec.Id + return nil + } + if 4 < cardNum && s == 8 { + option.ResourceId = spec.Id + return nil + } + + case MLU: // 1, 2, 4 + option.ComputeCard = computeCard + if cardNum/2 == s { + option.ResourceId = spec.Id + return nil + } + if 1 < cardNum/2 && cardNum/2 <= 2 && s == 2 { + option.ResourceId = spec.Id + return nil + } + if 2 < cardNum/2 && s == 4 { + option.ResourceId = spec.Id + return nil + } + } + } + } + } + return errors.New("set ResourceId error") +} + +func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*collector.InferUrl, error) { + req := &octopus.GetNotebookListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + list, err := o.octopusRpc.GetNotebookList(ctx, req) + if err != nil { + return nil, err + } + + var imageUrls []*collector.InferUrl + for _, notebook := range list.Payload.GetNotebooks() { + if strings.Contains(notebook.AlgorithmName, option.ModelName) && notebook.Status == "running" { + url := strings.Replace(notebook.Tasks[0].Url, FORWARD_SLASH, "", -1) + names := strings.Split(notebook.AlgorithmName, UNDERSCORE) + imageUrl := &collector.InferUrl{ + Url: DOMAIN + url, + Card: names[2], + } + imageUrls = append(imageUrls, imageUrl) + } else { + continue + } + } + + if len(imageUrls) == 0 { + return nil, errors.New("no infer url available") + } + return imageUrls, nil +} diff --git a/internal/storeLink/shuguangHpc.go b/internal/storeLink/shuguangHpc.go new file mode 100644 index 00000000..52e4823e --- /dev/null +++ b/internal/storeLink/shuguangHpc.go @@ -0,0 +1,268 @@ +package storeLink + +import ( + "context" + "errors" + "fmt" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "strconv" + "strings" +) + +type ShuguangHpc struct { + aCRpc hpcacclient.HpcAC + platform string + participantId int64 +} + +const ( + GAP_WALL_TIME_24H = "24:00:00" + TASK_SHUGUANG_PREFIX = "ShuguangHPC" + NEWLINE = "\n" + JOBNAME = "JOBNAME" + GAP_CMD_FILE = "cmd" + GAP_NNODE = "1" // 节点个数 + GAP_NODE_STRING = "" + GAP_APPNAME = "BASE" + GAP_QUEUE = "wzhdtest" + GAP_WORK_DIR = "/work/home/acgnnmfbwo/BASE/JOBNAME" + GAP_STD_OUT_FILE = "/work/home/acgnnmfbwo/BASE/JOBNAME/std.out.%j" + GAP_STD_ERR_FILE = "/work/home/acgnnmfbwo/BASE/JOBNAME/std.err.%j" + StrJobManagerID = 1637920656 + Apptype = "BASIC" + EXPORT = "export" + GAP_NPROC = "1" + GAP_NDCU = "1" + GAP_EXCLUSIVE = "" + GAP_PPN = "" + GAP_NGPU = "" + GAP_MULTI_SUB = "" + StrJobInfoMap = "%d,%s:%s:" + Username = "acgnnmfbwo" +) + +var RESOURCEMAP = map[string]ResourceSpecHpc{ + "FPOqD5Cx8iNYqawEgDrAxLdrszp4Tmhl": { + GAP_NNODE: "1", + GAP_NPROC: "1", + GAP_NDCU: "1", + }, + "Nd99eGNoBFC2ZTycKDlqD37heWTOmrMS": { + GAP_NNODE: "1", + GAP_NPROC: "2", + GAP_NDCU: "1", + }, + "uAmLkz6jgSZkC6o8JywG7Yo2aiFPPOBO": { + GAP_NNODE: "1", + GAP_NPROC: "4", + GAP_NDCU: "2", + }, + "D71OZQYrRabJc2nfL2GDWOdLEfbiMzYH": { + GAP_NNODE: "1", + GAP_NPROC: "8", + GAP_NDCU: "4", + }, + "sXUMrGmgMDFJaLi6dPiB9LkHjFb3lvL5": { + GAP_NNODE: "1", + GAP_NPROC: "16", + GAP_NDCU: "4", + }, + "ZfCKQKbNbQl9RPwlSyWLah1Gf7Ti7uJA": { + GAP_NNODE: "1", + GAP_NPROC: "32", + GAP_NDCU: "4", + }, + "cfEI4ulTNo2gYUozzdG59URByUjwLl3x": { + GAP_NNODE: "2", + GAP_NPROC: "4", + GAP_NDCU: "2", + }, + "vtbkaks8bErhpLRkUDiPDUHq6ssotFpD": { + GAP_NNODE: "2", + GAP_NPROC: "8", + GAP_NDCU: "4", + }, + "QJXZFJSReVWWQfkvQjGyEq1JpDHN55Oh": { + GAP_NNODE: "2", + GAP_NPROC: "16", + GAP_NDCU: "4", + }, + "79xSdy48yLbVLl9DqEV6tQ2J6jaHe5KO": { + GAP_NNODE: "2", + GAP_NPROC: "32", + GAP_NDCU: "8", + }, +} + +var RESOURCESPECSHPC = map[string]string{ + "FPOqD5Cx8iNYqawEgDrAxLdrszp4Tmhl": "1*NODE, CPU:1, 1*DCU", + "Nd99eGNoBFC2ZTycKDlqD37heWTOmrMS": "1*NODE, CPU:2, 1*DCU", + "uAmLkz6jgSZkC6o8JywG7Yo2aiFPPOBO": "1*NODE, CPU:4, 2*DCU", + "D71OZQYrRabJc2nfL2GDWOdLEfbiMzYH": "1*NODE, CPU:8, 4*DCU", + "sXUMrGmgMDFJaLi6dPiB9LkHjFb3lvL5": "1*NODE, CPU:16, 4*DCU", + "ZfCKQKbNbQl9RPwlSyWLah1Gf7Ti7uJA": "1*NODE, CPU:32, 4*DCU", + "cfEI4ulTNo2gYUozzdG59URByUjwLl3x": "2*NODE, CPU:4, 2*DCU", + "vtbkaks8bErhpLRkUDiPDUHq6ssotFpD": "2*NODE, CPU:8, 4*DCU", + "QJXZFJSReVWWQfkvQjGyEq1JpDHN55Oh": "2*NODE, CPU:16, 4*DCU", + "79xSdy48yLbVLl9DqEV6tQ2J6jaHe5KO": "2*NODE, CPU:32, 8*DCU", +} + +var AcStatus = map[string]string{ + "statQ": "Pending", + "statR": "Running", + "statE": "Pending", + "statC": "Completed", + "statH": "Pending", + "statS": "Pending", + "statW": "Pending", + "statX": "Other", +} + +type ResourceSpecHpc struct { + GAP_NNODE string + GAP_NPROC string + GAP_NDCU string +} + +func NewShuguangHpc(aCRpc hpcacclient.HpcAC, name string, id int64) *ShuguangHpc { + return &ShuguangHpc{aCRpc: aCRpc, platform: name, participantId: id} +} + +func (s ShuguangHpc) UploadImage(ctx context.Context, path string) (interface{}, error) { + return nil, nil +} + +func (s ShuguangHpc) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { + return nil, nil +} + +func (s ShuguangHpc) QueryImageList(ctx context.Context) (interface{}, error) { + return nil, nil +} + +func (s ShuguangHpc) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { + // shuguangHpc提交任务 + + //判断是否resourceId匹配自定义资源Id + _, isMapContainsKey := RESOURCESPECSHPC[resourceId] + if !isMapContainsKey { + return nil, errors.New("shuguangHpc资源Id不存在") + } + + //环境变量 + var env string + for _, e := range envs { + s := strings.Split(e, COMMA) + env += EXPORT + SPACE + s[0] + EQUAL + s[1] + NEWLINE + } + + //请求 + taskName := TASK_SHUGUANG_PREFIX + UNDERSCORE + utils.RandomString(10) + GAP_WORK_DIR := strings.Replace(GAP_WORK_DIR, JOBNAME, taskName, -1) + GAP_STD_OUT_FILE := strings.Replace(GAP_STD_OUT_FILE, JOBNAME, taskName, -1) + GAP_STD_ERR_FILE := strings.Replace(GAP_STD_ERR_FILE, JOBNAME, taskName, -1) + + req := &hpcAC.SubmitJobReq{ + Apptype: Apptype, + Appname: GAP_APPNAME, + StrJobManagerID: StrJobManagerID, + MapAppJobInfo: &hpcAC.MapAppJobInfo{ + GAP_CMD_FILE: cmd, + GAP_NNODE: GAP_NNODE, + GAP_NODE_STRING: GAP_NODE_STRING, + GAP_SUBMIT_TYPE: GAP_CMD_FILE, + GAP_JOB_NAME: taskName, + GAP_WORK_DIR: GAP_WORK_DIR, + GAP_QUEUE: GAP_QUEUE, + GAP_NPROC: GAP_NPROC, + GAP_PPN: GAP_PPN, + GAP_NGPU: GAP_NGPU, + GAP_NDCU: GAP_NDCU, + GAP_WALL_TIME: GAP_WALL_TIME_24H, + GAP_EXCLUSIVE: GAP_EXCLUSIVE, + GAP_APPNAME: GAP_APPNAME, + GAP_MULTI_SUB: GAP_MULTI_SUB, + GAP_STD_OUT_FILE: GAP_STD_OUT_FILE, + GAP_STD_ERR_FILE: GAP_STD_ERR_FILE, + GAP_SCHEDULER_OPT_WEB: env, + }, + } + + updateSGHpcRequestByResourceId(resourceId, req) + + resp, err := s.aCRpc.SubmitJob(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil + +} + +func (s ShuguangHpc) QueryTask(ctx context.Context, taskId string) (interface{}, error) { + //实时作业 + reqC := &hpcAC.JobDetailReq{ + JobId: taskId, + } + respC, err := s.aCRpc.GetJobDetail(ctx, reqC) + if err != nil { + return nil, err + } + + //实时作业检查是否成功 + if respC.Data != nil && respC.Data.JobEndTime != "" { + return respC, nil + } else { + //历史作业 + reqH := &hpcAC.HistoryJobDetailReq{ + JobId: taskId, + JobmanagerId: strconv.Itoa(StrJobManagerID), + } + + respH, err := s.aCRpc.HistoryJobDetail(ctx, reqH) + if err != nil { + return nil, err + } + + return respH, nil + } +} + +func (s ShuguangHpc) QuerySpecs(ctx context.Context) (interface{}, error) { + resp := &types.GetResourceSpecsResp{} + + for k, v := range RESOURCESPECSHPC { + var respec types.ResourceSpecSl + respec.SpecId = k + respec.SpecName = v + respec.ParticipantId = s.participantId + respec.ParticipantName = s.platform + resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) + } + + resp.Success = true + return resp, nil +} + +func (s ShuguangHpc) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { + strJobInfoMap := fmt.Sprintf(StrJobInfoMap, StrJobManagerID, Username, taskId) + req := &hpcAC.DeleteJobReq{ + StrJobInfoMap: strJobInfoMap, + } + resp, err := s.aCRpc.DeleteJob(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func updateSGHpcRequestByResourceId(resourceId string, req *hpcAC.SubmitJobReq) { + spec := RESOURCEMAP[resourceId] + req.MapAppJobInfo.GAP_NNODE = spec.GAP_NNODE + req.MapAppJobInfo.GAP_NPROC = spec.GAP_NPROC + req.MapAppJobInfo.GAP_NDCU = spec.GAP_NDCU +} diff --git a/internal/storeLink/shuguangai.go b/internal/storeLink/shuguangai.go new file mode 100644 index 00000000..b44a0c1b --- /dev/null +++ b/internal/storeLink/shuguangai.go @@ -0,0 +1,753 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storeLink + +import ( + "context" + "errors" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/common" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "strconv" + "strings" + "sync" + "time" +) + +const ( + RAM_SIZE_1G = 1024 // 1G + WORKER_NUMBER = 1 + DCU = "DCU" + DCU_TOPS = 24.5 + PYTORCH = "Pytorch" + TASK_PYTORCH_PREFIX = "PytorchTask" + TENSORFLOW = "Tensorflow" + RESOURCE_GROUP = "wzhdtest" + WorkPath = "/work/home/acgnnmfbwo/pcmv1/" + TimeoutLimit = "10:00:00" + PythonCodePath = "/work/home/acgnnmfbwo/111111/py/test.py" + DATASETS_DIR = "/work/home/acgnnmfbwo/pcmv1/dataset" + ALGORITHM_DIR = "/work/home/acgnnmfbwo/pcmv1/algorithm" + TRAIN_FILE = "train.py" + CPUCOREPRICEPERHOUR = 0.09 + DCUPRICEPERHOUR = 2.0 + KB = 1024 +) + +var RESOURCESGAIMAP = map[string]ResourceSpecSGAI{ + "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": { + CPU: 1, + GPU: 1, + RAM: 2 * RAM_SIZE_1G, + }, + "6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": { + CPU: 1, + GPU: 2, + RAM: 2 * RAM_SIZE_1G, + }, + "OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": { + CPU: 2, + GPU: 3, + RAM: 4 * RAM_SIZE_1G, + }, + "sBWfpkntUzsWYly11kdwEHZOYYIsFmve": { + CPU: 4, + GPU: 4, + RAM: 8 * RAM_SIZE_1G, + }, + "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": { + CPU: 5, + GPU: 5, + RAM: 10 * RAM_SIZE_1G, + }, +} + +var RESOURCESPECSAI = map[string]string{ + "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": "CPU:1, DCU:1, RAM:2G", + "6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": "CPU:1, DCU:2, RAM:2G", + "OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": "CPU:2, DCU:3, RAM:4G", + "sBWfpkntUzsWYly11kdwEHZOYYIsFmve": "CPU:4, DCU:4, RAM:8G", + "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": "CPU:5, DCU:5, RAM:10G", +} + +type ResourceSpecSGAI struct { + CPU int64 + GPU int64 + RAM int64 +} + +type ShuguangAi struct { + aCRpc hpcacclient.HpcAC + platform string + participantId int64 +} + +func NewShuguangAi(aCRpc hpcAC.HpcACClient, name string, id int64) *ShuguangAi { + return &ShuguangAi{aCRpc: aCRpc, platform: name, participantId: id} +} + +func (s *ShuguangAi) UploadImage(ctx context.Context, path string) (interface{}, error) { + return nil, nil +} + +func (s *ShuguangAi) DeleteImage(ctx context.Context, imageId string) (interface{}, error) { + return nil, nil +} + +func (s *ShuguangAi) QueryImageList(ctx context.Context) (interface{}, error) { + // shuguangAi获取镜像列表 + req := &hpcAC.GetImageListAiReq{ + AcceleratorType: DCU, + TaskType: PYTORCH, + } + resp, err := s.aCRpc.GetImageListAi(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ShuguangAi) SubmitPytorchTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string) (interface{}, error) { + //判断是否resourceId匹配自定义资源Id + _, isMapContainsKey := RESOURCESPECSAI[resourceId] + if !isMapContainsKey { + return nil, errors.New("shuguangAi资源Id不存在") + } + + //根据imageId获取imagePath, version + imageReq := &hpcAC.GetImageAiByIdReq{ImageId: imageId} + imageResp, err := s.aCRpc.GetImageAiById(ctx, imageReq) + if err != nil { + return nil, err + } + + //python参数 + var pythonArg string + for _, param := range params { + s := strings.Split(param, COMMA) + pythonArg += PY_PARAM_PREFIX + s[0] + "=" + s[1] + SPACE + } + + //环境变量 + var env string + for _, e := range envs { + s := strings.Split(e, COMMA) + env += s[0] + "=" + s[1] + SPACE + } + + //set paths + paths := strings.Split(algorithmId, DASH) + workPath := ALGORITHM_DIR + FORWARD_SLASH + paths[0] + FORWARD_SLASH + paths[1] + DASH + paths[2] + codePath := workPath + FORWARD_SLASH + TRAIN_FILE + + req := &hpcAC.SubmitPytorchTaskReq{ + Params: &hpcAC.SubmitPytorchTaskParams{ + TaskName: TASK_PYTORCH_PREFIX + UNDERSCORE + utils.RandomString(10), + WorkPath: workPath, + IsDistributed: false, + IsHvd: false, + Env: env, + AcceleratorType: DCU, + Version: imageResp.Image.Version, + ImagePath: imageResp.Image.Path, + WorkerNumber: WORKER_NUMBER, + ResourceGroup: RESOURCE_GROUP, + TimeoutLimit: TimeoutLimit, + PythonCodePath: codePath, + PythonArg: pythonArg, + }, + } + + updateSGAIRequestByResourceId(resourceId, req) + + resp, err := s.aCRpc.SubmitPytorchTask(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func updateSGAIRequestByResourceId(resourceId string, req *hpcAC.SubmitPytorchTaskReq) { + spec := RESOURCESGAIMAP[resourceId] + req.Params.WorkerCpuNumber = spec.CPU + req.Params.WorkerGpuNumber = spec.GPU + req.Params.WorkerRamSize = spec.RAM +} + +func (s *ShuguangAi) SubmitTensorflowTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string) (interface{}, error) { + //req := &hpcAC.SubmitTensorflowTaskReq{ + // Params: &hpcAC.SubmitTensorflowTaskParams{ + // + // } + //} + return nil, nil +} + +func (s *ShuguangAi) SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) { + // set algorithmId temporarily for storelink submit + if algorithmId == "" { + algorithmId = "pytorch-mnist-fcn" + } + + // shuguangAi提交任务 + switch aiType { + case PYTORCH_TASK: + task, err := s.SubmitPytorchTask(ctx, imageId, cmd, envs, params, resourceId, datasetsId, algorithmId) + if err != nil { + return nil, err + } + return task, nil + case TENSORFLOW_TASK: + task, err := s.SubmitTensorflowTask(ctx, imageId, cmd, envs, params, resourceId, datasetsId, algorithmId) + if err != nil { + return nil, err + } + return task, nil + } + return nil, errors.New("shuguangAi不支持的任务类型") +} + +func (s *ShuguangAi) QueryTask(ctx context.Context, taskId string) (interface{}, error) { + // shuguangAi获取任务 + req := &hpcAC.GetPytorchTaskReq{ + Id: taskId, + } + resp, err := s.aCRpc.GetPytorchTask(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ShuguangAi) DeleteTask(ctx context.Context, taskId string) (interface{}, error) { + // shuguangAi删除任务 + req := &hpcAC.DeleteTaskAiReq{ + Ids: taskId, + } + resp, err := s.aCRpc.DeleteTaskAi(ctx, req) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ShuguangAi) QuerySpecs(ctx context.Context) (interface{}, error) { + resp := &types.GetResourceSpecsResp{} + + for k, v := range RESOURCESPECSAI { + var respec types.ResourceSpecSl + respec.SpecId = k + respec.SpecName = v + respec.ParticipantId = s.participantId + respec.ParticipantName = s.platform + resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) + } + + resp.Success = true + return resp, nil +} + +func (s *ShuguangAi) GetResourceStats(ctx context.Context) (*collector.ResourceStats, error) { + var wg sync.WaitGroup + wg.Add(4) + var cBalance = make(chan float64) + var cMemTotal = make(chan float64) + var cTotalCpu = make(chan int64) + + resourceStats := &collector.ResourceStats{ + ClusterId: strconv.FormatInt(s.participantId, 10), + Name: s.platform, + } + + dcu := &collector.Card{ + Platform: SHUGUANGAI, + Type: CARD, + Name: DCU, + TOpsAtFp16: DCU_TOPS, + } + + //balance + go func() { + userReq := &hpcAC.GetUserInfoReq{} + userinfo, err := s.aCRpc.GetUserInfo(ctx, userReq) + if err != nil { + return + } + balance, _ := strconv.ParseFloat(userinfo.Data.AccountBalance, 64) + resourceStats.Balance = balance + + cBalance <- balance + }() + + //resource limit + go func() { + limitReq := &hpcAC.QueueReq{} + limitResp, err := s.aCRpc.QueryUserQuotasLimit(ctx, limitReq) + if err != nil { + wg.Done() + return + } + totalCpu := limitResp.Data.AccountMaxCpu + totalDcu := limitResp.Data.AccountMaxDcu + + dcu.CardNum = int32(totalDcu) + resourceStats.CpuCoreTotal = totalCpu + + cTotalCpu <- totalCpu + wg.Done() + }() + + //disk + go func() { + diskReq := &hpcAC.ParaStorQuotaReq{} + diskResp, err := s.aCRpc.ParaStorQuota(ctx, diskReq) + if err != nil { + wg.Done() + return + } + + totalDisk := common.RoundFloat(diskResp.Data[0].Threshold*KB*KB*KB, 3) + availDisk := common.RoundFloat((diskResp.Data[0].Threshold-diskResp.Data[0].Usage)*KB*KB*KB, 3) + + resourceStats.DiskTotal = totalDisk + resourceStats.DiskAvail = availDisk + wg.Done() + }() + + //memory + go func() { + nodeResp, err := s.aCRpc.GetNodeResources(ctx, nil) + if err != nil { + wg.Done() + return + } + memSize := common.RoundFloat(float64(nodeResp.Data.MemorySize)*KB*KB, 3) // MB to BYTES + + resourceStats.MemTotal = memSize + cMemTotal <- memSize + wg.Done() + }() + + //resources being occupied + go func() { + memSize := <-cMemTotal + totalCpu := <-cTotalCpu + memberJobResp, err := s.aCRpc.GetMemberJobs(ctx, nil) + if err != nil { + wg.Done() + return + } + var cpuCoreAvail int64 + var memAvail float64 + if len(memberJobResp.Data) != 0 { + cpuCoreAvail = totalCpu + memAvail = memSize + } else { + var cpuCoreUsed int64 + var memUsed float64 + for _, datum := range memberJobResp.Data { + cpuCoreUsed += datum.CpuCore + } + memUsed = float64(cpuCoreUsed * 2 * KB * KB * KB) // 2 GB per cpu core + if cpuCoreUsed > totalCpu { + cpuCoreAvail = 0 + } else { + cpuCoreAvail = totalCpu - cpuCoreUsed + } + if memUsed > memSize { + memAvail = 0 + } else { + memAvail = memSize - memUsed + } + } + resourceStats.CpuCoreAvail = cpuCoreAvail + resourceStats.MemAvail = memAvail + wg.Done() + }() + + //usable hours + var balance float64 + + select { + case v := <-cBalance: + balance = v + case <-time.After(2 * time.Second): + return nil, errors.New("get balance rpc call failed") + } + + var cards []*collector.Card + cardHours := common.RoundFloat(balance/DCUPRICEPERHOUR, 3) + cpuHours := common.RoundFloat(balance/CPUCOREPRICEPERHOUR, 3) + + dcu.CardHours = cardHours + resourceStats.CpuCoreHours = cpuHours + + wg.Wait() + + cards = append(cards, dcu) + resourceStats.CardsAvail = cards + + return resourceStats, nil +} + +func (s *ShuguangAi) GetDatasetsSpecs(ctx context.Context) ([]*collector.DatasetsSpecs, error) { + req := &hpcAC.GetFileListReq{Limit: 100, Path: DATASETS_DIR, Start: 0} + list, err := s.aCRpc.GetFileList(ctx, req) + if err != nil { + return nil, err + } + if list.Code != "0" { + return nil, errors.New(list.Msg) + } + specs := []*collector.DatasetsSpecs{} + for _, file := range list.Data.FileList { + spec := &collector.DatasetsSpecs{Name: file.Name, Size: strconv.FormatInt(file.Size, 10)} + specs = append(specs, spec) + } + return specs, nil +} + +func (s *ShuguangAi) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm, error) { + var algorithms []*collector.Algorithm + for _, t := range GetTaskTypes() { + taskType := t + req := &hpcAC.GetFileListReq{Limit: 100, Path: ALGORITHM_DIR + FORWARD_SLASH + taskType, Start: 0, Order: "asc", OrderBy: "name", KeyWord: ""} + list, err := s.aCRpc.GetFileList(ctx, req) + if err != nil { + return nil, err + } + if list.Code != "0" { + return nil, errors.New(list.Msg) + } + for _, file := range list.Data.FileList { + algorithm := &collector.Algorithm{Name: file.Name, Platform: SHUGUANGAI, TaskType: taskType} + algorithms = append(algorithms, algorithm) + } + } + return algorithms, nil +} + +func (s *ShuguangAi) GetComputeCards(ctx context.Context) ([]string, error) { + var cards []string + cards = append(cards, DCU) + return cards, nil +} + +func (s *ShuguangAi) GetUserBalance(ctx context.Context) (float64, error) { + userReq := &hpcAC.GetUserInfoReq{} + userinfo, err := s.aCRpc.GetUserInfo(ctx, userReq) + if err != nil { + return 0, err + } + balance, _ := strconv.ParseFloat(userinfo.Data.AccountBalance, 64) + return balance, nil +} + +func (s *ShuguangAi) DownloadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string) (string, error) { + algoName := dataset + DASH + algorithm + req := &hpcAC.GetFileReq{ + Path: ALGORITHM_DIR + FORWARD_SLASH + taskType + FORWARD_SLASH + algoName + FORWARD_SLASH + TRAIN_FILE, + } + resp, err := s.aCRpc.GetFile(ctx, req) + if err != nil { + return "", err + } + + return resp.Content, nil +} + +func (s *ShuguangAi) UploadAlgorithmCode(ctx context.Context, resourceType string, card string, taskType string, dataset string, algorithm string, code string) error { + algoName := dataset + DASH + algorithm + req := &hpcAC.UploadFileReq{ + Path: ALGORITHM_DIR + FORWARD_SLASH + taskType + FORWARD_SLASH + algoName + FORWARD_SLASH, + Cover: "cover", + File: code, + } + + _, err := s.aCRpc.UploadFile(ctx, req) + if err != nil { + return err + } + + return nil +} + +func (s *ShuguangAi) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { + req := &hpcAC.GetInstanceLogReq{ + TaskId: taskId, + InstanceNum: instanceNum, + LineCount: 1000, + StartLineNum: -1, + } + resp, err := s.aCRpc.GetInstanceLog(ctx, req) + if err != nil { + return "", err + } + + if resp.Code != "0" { + resp.Data.Content = "waiting for logs..." + } + + return resp.Data.Content, nil +} + +func (s *ShuguangAi) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { + resp, err := s.QueryTask(ctx, taskId) + if err != nil { + return nil, err + } + jobresp := (resp).(*hpcAC.GetPytorchTaskResp) + if jobresp.Code != "0" { + return nil, errors.New(jobresp.Msg) + } + var task collector.Task + task.Id = jobresp.Data.Id + if jobresp.Data.StartTime != "" { + task.Start = jobresp.Data.StartTime + } + if jobresp.Data.EndTime != "" { + task.End = jobresp.Data.EndTime + } + task.Status = jobresp.Data.Status + + return &task, nil +} + +func (s *ShuguangAi) Execute(ctx context.Context, option *option.AiOption) (interface{}, error) { + err := s.GenerateSubmitParams(ctx, option) + if err != nil { + return nil, err + } + task, err := s.SubmitTask(ctx, option.ImageId, option.Cmd, option.Envs, option.Params, option.ResourceId, option.DatasetsId, option.AlgorithmId, option.TaskType) + if err != nil { + return nil, err + } + return task, nil +} + +func (s *ShuguangAi) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error { + err := s.generateResourceId(option) + if err != nil { + return err + } + err = s.generateImageId(ctx, option) + if err != nil { + return err + } + err = s.generateAlgorithmId(ctx, option) + if err != nil { + return err + } + err = s.generateCmd(option) + if err != nil { + return err + } + err = s.generateEnv(option) + if err != nil { + return err + } + err = s.generateParams(option) + if err != nil { + return err + } + return nil +} + +func (s *ShuguangAi) generateResourceId(option *option.AiOption) error { + if option.ResourceType == "" { + return errors.New("ResourceType not set") + } + + if option.ResourceType == CPU { + option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi" + option.ComputeCard = CPU + return nil + } + + if option.ResourceType == CARD { + if option.ComputeCard == "" { + option.ComputeCard = DCU + } + + if strings.ToUpper(option.ComputeCard) != DCU { + return errors.New("computeCard not found") + } + option.ComputeCard = DCU + + if 0 <= option.Tops && option.Tops <= DCU_TOPS { + option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi" + return nil + } + + cardNum := 5 + for k, v := range RESOURCESGAIMAP { + for i := 1; i <= cardNum; i++ { + if float64(i)*DCU_TOPS <= option.Tops && option.Tops <= float64(v.GPU)*DCU_TOPS { + option.ResourceId = k + return nil + } + } + } + + if option.Tops > float64(cardNum)*DCU_TOPS { + option.ResourceId = "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2" + return nil + } + } + + return errors.New("failed to get ResourceId") +} + +func (s *ShuguangAi) generateImageId(ctx context.Context, option *option.AiOption) error { + if option.TaskType == "" { + return errors.New("TaskType not set") + } + taskType := strings.Title(option.TaskType) + req := &hpcAC.GetImageListAiReq{ + AcceleratorType: DCU, + TaskType: taskType, + } + resp, err := s.aCRpc.GetImageListAi(ctx, req) + if err != nil { + return err + } + if resp.Code != "0" { + return errors.New("failed to get imageId") + } + + for _, datum := range resp.Data { + ns := strings.Split(datum.Version, COLON) + if ns[0] == "jupyterlab-pytorch" { + option.ImageId = datum.ImageId + return nil + } + + } + + return errors.New("failed to get ImageId") +} + +func (s *ShuguangAi) generateAlgorithmId(ctx context.Context, option *option.AiOption) error { + if option.DatasetsName == "" { + return errors.New("DatasetsName not set") + } + + req := &hpcAC.GetFileListReq{Limit: 100, Path: ALGORITHM_DIR + FORWARD_SLASH + option.TaskType, Start: 0} + list, err := s.aCRpc.GetFileList(ctx, req) + if err != nil { + return err + } + if list.Code != "0" { + return errors.New(list.Msg) + } + + var algorithmId string + for _, file := range list.Data.FileList { + ns := strings.Split(file.Name, DASH) + if ns[0] == option.DatasetsName { + algoName := ns[1] + if option.AlgorithmName == "" { + switch option.DatasetsName { + case "cifar10": + algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + "cnn" + option.AlgorithmId = algorithmId + option.AlgorithmName = algoName + return nil + case "mnist": + algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + "fcn" + option.AlgorithmId = algorithmId + option.AlgorithmName = algoName + return nil + } + } else { + if algoName == option.AlgorithmName { + algorithmId = option.TaskType + DASH + option.DatasetsName + DASH + algoName + option.AlgorithmId = algorithmId + return nil + } + } + } + } + + if algorithmId == "" { + return errors.New("Algorithm does not exist") + } + + return errors.New("failed to get AlgorithmId") +} + +func (s *ShuguangAi) generateCmd(option *option.AiOption) error { + + return nil +} + +func (s *ShuguangAi) generateEnv(option *option.AiOption) error { + + return nil +} + +func (s *ShuguangAi) generateParams(option *option.AiOption) error { + if option.ResourceType == "" { + return errors.New("ResourceType not set") + } + + if len(option.Params) == 0 { + epoch := "epoch" + COMMA + "1" + option.Params = append(option.Params, epoch) + } + + switch option.ResourceType { + case CPU: + card := "card" + COMMA + CPU + option.Params = append(option.Params, card) + return nil + case CARD: + card := "card" + COMMA + "cuda:0" + option.Params = append(option.Params, card) + return nil + } + + return errors.New("failed to set params") +} + +func (s *ShuguangAi) GetInferUrl(ctx context.Context, option *option.InferOption) ([]*collector.InferUrl, error) { + var imageUrls []*collector.InferUrl + + urlReq := &hpcAC.GetInferUrlReq{ + ModelName: option.ModelName, + Type: option.ModelType, + Card: "dcu", + } + + urlResp, err := s.aCRpc.GetInferUrl(ctx, urlReq) + if err != nil { + return nil, err + } + imageUrl := &collector.InferUrl{ + Url: urlResp.Url, + Card: "dcu", + } + imageUrls = append(imageUrls, imageUrl) + + return imageUrls, nil +} diff --git a/internal/storeLink/storeLink.go b/internal/storeLink/storeLink.go new file mode 100644 index 00000000..9dcf782a --- /dev/null +++ b/internal/storeLink/storeLink.go @@ -0,0 +1,1035 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package storeLink + +import ( + "context" + "fmt" + "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-ac/hpcAC" + hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/common" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/timeutils" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" + "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts" + "gitlink.org.cn/JointCloud/pcm-octopus/octopus" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" + "gorm.io/gorm" + "strings" + "sync" +) + +type Linkage interface { + UploadImage(ctx context.Context, path string) (interface{}, error) + DeleteImage(ctx context.Context, imageId string) (interface{}, error) + QueryImageList(ctx context.Context) (interface{}, error) + SubmitTask(ctx context.Context, imageId string, cmd string, envs []string, params []string, resourceId string, datasetsId string, algorithmId string, aiType string) (interface{}, error) + QueryTask(ctx context.Context, taskId string) (interface{}, error) + QuerySpecs(ctx context.Context) (interface{}, error) + DeleteTask(ctx context.Context, taskId string) (interface{}, error) +} + +const ( + COLON = ":" + PY_PARAM_PREFIX = "--" + SPACE = " " + UNDERSCORE = "_" + EQUAL = "=" + DASH = "-" + FORWARD_SLASH = "/" + COMMA = "," + STAR = "*" + TYPE_OCTOPUS = "1" + TYPE_MODELARTS = "2" + TYPE_SHUGUANGAI = "3" + TYPE_SHUGUANGHPC = "4" + OCTOPUS = "Octopus" + MODELARTS = "Modelarts" + SHUGUANGAI = "ShuguangAi" + SHUGUANGHPC = "ShuguangHpc" + CPU = "cpu" + GPU = "gpu" + CARD = "computeCard" + PYTORCH_TASK = "pytorch" + TENSORFLOW_TASK = "tensorflow" +) + +var ( + OctImgStatus = map[int32]string{ + 1: "未上传", + 3: "制作完成", + 4: "制作失败", + } + ModelTypeMap = map[string][]string{ + "image_recognition": {"imagenet_resnet50"}, + "text_to_text": {"chatGLM_6B"}, + } + AITYPE = map[string]string{ + "1": OCTOPUS, + "2": MODELARTS, + "3": SHUGUANGAI, + "4": SHUGUANGHPC, + } + resourceTypes = []string{CARD} + taskTypes = []string{PYTORCH_TASK} + + ERROR_RESP_EMPTY = errors.New("resp empty error") + ERROR_CONVERT_EMPTY = errors.New("convert empty error") +) + +type StoreLink struct { + ILinkage Linkage +} + +func NewStoreLink(octopusRpc octopusclient.Octopus, modelArtsRpc modelartsservice.ModelArtsService, modelArtsImgRpc imagesservice.ImagesService, aCRpc hpcacclient.HpcAC, participant *models.StorelinkCenter) *StoreLink { + switch participant.Type { + case TYPE_OCTOPUS: + linkStruct := NewOctopusLink(octopusRpc, participant.Name, participant.Id) + return &StoreLink{ILinkage: linkStruct} + case TYPE_MODELARTS: + linkStruct := NewModelArtsLink(modelArtsRpc, modelArtsImgRpc, participant.Name, participant.Id, "") + return &StoreLink{ILinkage: linkStruct} + case TYPE_SHUGUANGAI: + linkStruct := NewShuguangAi(aCRpc, participant.Name, participant.Id) + return &StoreLink{ILinkage: linkStruct} + case TYPE_SHUGUANGHPC: + linkStruct := NewShuguangHpc(aCRpc, participant.Name, participant.Id) + return &StoreLink{ILinkage: linkStruct} + default: + return nil + } +} + +func GetParticipants(dbEngin *gorm.DB) []*models.StorelinkCenter { + var participants []*models.StorelinkCenter + dbEngin.Raw("select * from storelink_center").Scan(&participants) + return participants +} + +func GetParticipantById(partId int64, dbEngin *gorm.DB) *models.StorelinkCenter { + var participant models.StorelinkCenter + dbEngin.Raw("select * from storelink_center where id = ?", partId).Scan(&participant) + return &participant +} + +func GetResourceTypes() []string { + return resourceTypes +} + +func GetModelTypes() []string { + var mTypes []string + for k, _ := range ModelTypeMap { + mTypes = append(mTypes, k) + } + return mTypes +} + +func GetModelNamesByType(t string) ([]string, error) { + _, ok := ModelTypeMap[t] + if !ok { + return nil, errors.New("model type does not exist") + } + return ModelTypeMap[t], nil +} + +func GetDatasetsNames(ctx context.Context, collectorMap map[string]collector.AiCollector) ([]string, error) { + var wg sync.WaitGroup + var errCh = make(chan interface{}, len(collectorMap)) + var errs []interface{} + var names []string + var mu sync.Mutex + colMap := collectorMap + for s, col := range colMap { + wg.Add(1) + c := col + id := s + go func() { + var ns []string + specs, err := c.GetDatasetsSpecs(ctx) + if err != nil { + e := struct { + err error + clusterId string + }{ + err: err, + clusterId: id, + } + errCh <- e + wg.Done() + return + } + for _, spec := range specs { + ns = append(ns, spec.Name) + } + if len(ns) == 0 { + wg.Done() + return + } + mu.Lock() + if len(names) == 0 { + names = ns + wg.Done() + mu.Unlock() + return + } + names = common.IntersectString(names, ns) + wg.Done() + mu.Unlock() + }() + } + wg.Wait() + close(errCh) + + if len(errs) == len(colMap) { + return nil, errors.New("get DatasetsNames failed") + } + + for e := range errCh { + errs = append(errs, e) + } + + if len(errs) != 0 { + var msg string + for _, err := range errs { + e := (err).(struct { + err error + clusterId string + }) + msg += fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) + } + return nil, errors.New(msg) + } + + names = common.RemoveDuplicates(names) + return names, nil +} + +func GetAlgorithms(ctx context.Context, collectorMap map[string]collector.AiCollector, resourceType string, taskType string, dataset string) ([]string, error) { + var names []string + var wg sync.WaitGroup + var errCh = make(chan interface{}, len(collectorMap)) + var errs []interface{} + var mu sync.Mutex + + colMap := collectorMap + for s, col := range colMap { + wg.Add(1) + c := col + id := s + go func() { + var ns []string + algorithms, err := c.GetAlgorithms(ctx) + if err != nil { + e := struct { + err error + clusterId string + }{ + err: err, + clusterId: id, + } + errCh <- e + wg.Done() + return + } + for _, algorithm := range algorithms { + if algorithm.TaskType != taskType { + continue + } + switch algorithm.Platform { + case OCTOPUS: + splitns := strings.Split(algorithm.Name, UNDERSCORE) + if dataset != splitns[0] || len(splitns) == 1 { + continue + } + ns = append(ns, splitns[1]) + case SHUGUANGAI: + splitns := strings.Split(algorithm.Name, DASH) + if dataset != splitns[0] || len(splitns) == 1 { + continue + } + ns = append(ns, splitns[1]) + } + } + if len(ns) == 0 { + wg.Done() + return + } + mu.Lock() + if len(names) == 0 { + names = ns + wg.Done() + mu.Unlock() + return + } + names = common.IntersectString(names, ns) + wg.Done() + mu.Unlock() + }() + } + wg.Wait() + close(errCh) + + for e := range errCh { + errs = append(errs, e) + } + + if len(errs) == len(colMap) { + return nil, errors.New("get Algorithms failed") + } + + if len(errs) != 0 { + var msg string + for _, err := range errs { + e := (err).(struct { + err error + clusterId string + }) + msg += fmt.Sprintf("clusterId: %v , error: %v \n", e.clusterId, e.err.Error()) + } + return nil, errors.New(msg) + } + + names = common.RemoveDuplicates(names) + return names, nil +} + +func GetTaskTypes() []string { + return taskTypes +} + +func ConvertType(in interface{}, out interface{}, participant *models.StorelinkCenter) (interface{}, error) { + + switch (interface{})(in).(type) { + case *types.GetResourceSpecsResp: + return in, nil + case *octopus.UploadImageResp: + inresp := (interface{})(in).(*octopus.UploadImageResp) + switch (interface{})(out).(type) { + case *types.UploadLinkImageResp: + resp := (interface{})(out).(*types.UploadLinkImageResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + return resp, nil + } + return nil, nil + + case *octopus.DeleteImageResp: + inresp := (interface{})(in).(*octopus.DeleteImageResp) + switch (interface{})(out).(type) { + case *types.DeleteLinkImageResp: + resp := (interface{})(out).(*types.DeleteLinkImageResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + return resp, nil + } + return nil, nil + + case *octopus.GetUserImageListResp: + inresp := (interface{})(in).(*octopus.GetUserImageListResp) + switch (interface{})(out).(type) { + case *types.GetLinkImageListResp: + resp := (interface{})(out).(*types.GetLinkImageListResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + resp.Images = nil + return resp, nil + } + + for _, v := range inresp.Payload.Images { + var image types.ImageSl + image.ImageId = v.Image.Id + image.ImageName = v.Image.ImageName + image.ImageStatus = OctImgStatus[v.Image.ImageStatus] + resp.Images = append(resp.Images, &image) + } + return resp, nil + } + return nil, nil + + case *modelarts.ListReposDetailsResp: + inresp := (interface{})(in).(*modelarts.ListReposDetailsResp) + switch (interface{})(out).(type) { + case *types.GetLinkImageListResp: + resp := (interface{})(out).(*types.GetLinkImageListResp) + if inresp.Errors != nil { + resp.Success = false + resp.ErrorMsg = inresp.Errors[0].ErrorMessage + resp.Images = nil + return resp, nil + } + + resp.Success = true + for _, v := range inresp.Items { + for _, r := range v.Tags { + var image types.ImageSl + image.ImageId = v.Namespace + "/" + v.Name + ":" + r + image.ImageName = v.Name + image.ImageStatus = "created" + resp.Images = append(resp.Images, &image) + } + } + return resp, nil + } + return nil, nil + + case *hpcAC.GetImageListAiResp: + inresp := (interface{})(in).(*hpcAC.GetImageListAiResp) + switch (interface{})(out).(type) { + case *types.GetLinkImageListResp: + resp := (interface{})(out).(*types.GetLinkImageListResp) + if inresp.Code == "0" { + resp.Success = true + for _, img := range inresp.Data { + var image types.ImageSl + image.ImageId = img.ImageId + image.ImageName = img.Version + image.ImageStatus = "created" + resp.Images = append(resp.Images, &image) + } + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Images = nil + } + return resp, nil + } + return nil, nil + + case *octopus.CreateTrainJobResp: + inresp := (interface{})(in).(*octopus.CreateTrainJobResp) + switch (interface{})(out).(type) { + case *types.SubmitLinkTaskResp: + resp := (interface{})(out).(*types.SubmitLinkTaskResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + resp.TaskId = inresp.Payload.JobId + + return resp, nil + case *types.ScheduleResp: + resp := (interface{})(out).(*types.ScheduleResp) + return resp, nil + } + return nil, nil + + case *modelarts.CreateTrainingJobResp: + inresp := (interface{})(in).(*modelarts.CreateTrainingJobResp) + switch (interface{})(out).(type) { + case *types.SubmitLinkTaskResp: + resp := (interface{})(out).(*types.SubmitLinkTaskResp) + if inresp.ErrorMsg != "" { + resp.ErrorMsg = inresp.ErrorMsg + resp.Success = false + return resp, nil + } + resp.Success = true + resp.TaskId = inresp.Metadata.Id + + return resp, nil + } + return nil, nil + + case *hpcAC.SubmitTaskAiResp: + inresp := (interface{})(in).(*hpcAC.SubmitTaskAiResp) + switch (interface{})(out).(type) { + case *types.SubmitLinkTaskResp: + resp := (interface{})(out).(*types.SubmitLinkTaskResp) + if inresp.Code == "0" { + resp.Success = true + resp.TaskId = inresp.Data + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + case *types.ScheduleResp: + resp := (interface{})(out).(*types.ScheduleResp) + return resp, nil + } + return nil, nil + + case *hpcAC.SubmitJobResp: + inresp := (interface{})(in).(*hpcAC.SubmitJobResp) + switch (interface{})(out).(type) { + case *types.SubmitLinkTaskResp: + resp := (interface{})(out).(*types.SubmitLinkTaskResp) + if inresp.Code == "0" { + resp.Success = true + resp.TaskId = inresp.Data + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + } + return nil, nil + + case *octopus.GetTrainJobResp: + inresp := (interface{})(in).(*octopus.GetTrainJobResp) + switch (interface{})(out).(type) { + case *types.GetLinkTaskResp: + resp := (interface{})(out).(*types.GetLinkTaskResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + var task types.TaskSl + task.TaskId = inresp.Payload.TrainJob.Id + task.TaskName = inresp.Payload.TrainJob.Name + task.StartedAt = inresp.Payload.TrainJob.StartedAt + task.CompletedAt = inresp.Payload.TrainJob.CompletedAt + task.TaskStatus = inresp.Payload.TrainJob.Status + + resp.Task = &task + return resp, nil + } + return nil, nil + + case *modelarts.JobResponse: + inresp := (interface{})(in).(*modelarts.JobResponse) + switch (interface{})(out).(type) { + case *types.GetLinkTaskResp: + resp := (interface{})(out).(*types.GetLinkTaskResp) + if inresp.ErrorMsg != "" { + resp.ErrorMsg = inresp.ErrorMsg + resp.Success = false + return resp, nil + } + resp.Success = true + resp.Task = &types.TaskSl{} + resp.Task.TaskId = inresp.Metadata.Id + resp.Task.TaskName = inresp.Metadata.Name + resp.Task.StartedAt = int64(inresp.Status.StartTime) + resp.Task.CompletedAt = int64(inresp.Status.Duration) + resp.Task.TaskStatus = inresp.Status.Phase + + return resp, nil + } + return nil, nil + + case *hpcAC.GetPytorchTaskResp: + inresp := (interface{})(in).(*hpcAC.GetPytorchTaskResp) + switch (interface{})(out).(type) { + case *types.GetLinkTaskResp: + resp := (interface{})(out).(*types.GetLinkTaskResp) + if inresp.Code == "0" { + resp.Success = true + var task types.TaskSl + task.TaskId = inresp.Data.Id + task.TaskName = inresp.Data.TaskName + task.TaskStatus = inresp.Data.Status + task.StartedAt = timeutils.StringToUnixTime(inresp.Data.StartTime) + task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.EndTime) + resp.Task = &task + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Task = nil + } + + return resp, nil + } + return nil, nil + + case *hpcAC.GetJobDetailResp: + inresp := (interface{})(in).(*hpcAC.GetJobDetailResp) + switch (interface{})(out).(type) { + case *types.GetLinkTaskResp: + resp := (interface{})(out).(*types.GetLinkTaskResp) + if inresp.Code == "0" { + resp.Success = true + var task types.TaskSl + task.TaskId = inresp.Data.JobId + task.TaskName = inresp.Data.JobName + task.TaskStatus = AcStatus[inresp.Data.JobStatus] + task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) + task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) + resp.Task = &task + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Task = nil + } + + return resp, nil + } + return nil, nil + + case *hpcAC.HistoryJobDetailResp: + inresp := (interface{})(in).(*hpcAC.HistoryJobDetailResp) + switch (interface{})(out).(type) { + case *types.GetLinkTaskResp: + resp := (interface{})(out).(*types.GetLinkTaskResp) + if inresp.Code == "0" { + resp.Success = true + var task types.TaskSl + task.TaskId = inresp.Data.JobId + task.TaskName = inresp.Data.JobName + task.TaskStatus = AcStatus[inresp.Data.JobState] + task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) + task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) + resp.Task = &task + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Task = nil + } + + return resp, nil + } + return nil, nil + + case *octopus.DeleteTrainJobResp: + inresp := (interface{})(in).(*octopus.DeleteTrainJobResp) + switch (interface{})(out).(type) { + case *types.DeleteLinkTaskResp: + resp := (interface{})(out).(*types.DeleteLinkTaskResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + return resp, nil + } + return nil, nil + + case *modelarts.DeleteTrainingJobResp: + inresp := (interface{})(in).(*modelarts.DeleteTrainingJobResp) + switch (interface{})(out).(type) { + case *types.DeleteLinkTaskResp: + resp := (interface{})(out).(*types.DeleteLinkTaskResp) + if inresp.ErrorMsg != "" { + resp.ErrorMsg = inresp.ErrorMsg + resp.Success = false + return resp, nil + } + resp.Success = true + return resp, nil + } + return nil, nil + + case *hpcAC.DeleteTaskAiResp: + inresp := (interface{})(in).(*hpcAC.DeleteTaskAiResp) + switch (interface{})(out).(type) { + case *types.DeleteLinkTaskResp: + resp := (interface{})(out).(*types.DeleteLinkTaskResp) + if inresp.Code == "0" { + resp.Success = true + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + } + return nil, nil + + case *hpcAC.DeleteJobResp: + inresp := (interface{})(in).(*hpcAC.DeleteJobResp) + switch (interface{})(out).(type) { + case *types.DeleteLinkTaskResp: + resp := (interface{})(out).(*types.DeleteLinkTaskResp) + if inresp.Code == "0" { + resp.Success = true + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + } + return nil, nil + + case *octopus.GetResourceSpecsResp: + inresp := (interface{})(in).(*octopus.GetResourceSpecsResp) + switch (interface{})(out).(type) { + case *types.GetResourceSpecsResp: + resp := (interface{})(out).(*types.GetResourceSpecsResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ResourceSpecs = nil + return resp, nil + } + + for _, spec := range inresp.TrainResourceSpecs { + var respec types.ResourceSpecSl + respec.SpecId = spec.Id + respec.SpecName = spec.Name + respec.ParticipantId = participant.Id + respec.ParticipantName = participant.Name + respec.SpecPrice = spec.Price + resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) + } + + return resp, nil + } + return nil, nil + + case *modelarts.TrainingJobFlavorsResp: + inresp := (interface{})(in).(*modelarts.TrainingJobFlavorsResp) + switch (interface{})(out).(type) { + case *types.GetResourceSpecsResp: + resp := (interface{})(out).(*types.GetResourceSpecsResp) + resp.Success = true + + if inresp.Flavors == nil { + resp.Success = false + resp.ResourceSpecs = nil + return resp, nil + } + + for _, spec := range inresp.Flavors { + var respec types.ResourceSpecSl + respec.SpecId = spec.FlavorId + respec.SpecName = spec.FlavorName + respec.ParticipantId = participant.Id + respec.ParticipantName = participant.Name + respec.SpecPrice = 0 + resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) + } + + return resp, nil + } + return nil, nil + + default: + return nil, errors.New("type convert fail") + } +} + +func ConvertTypeOld[T any](in *T, participant *models.StorelinkCenter) (interface{}, error) { + + switch (interface{})(in).(type) { + case *octopus.UploadImageResp: + var resp types.UploadLinkImageResp + inresp := (interface{})(in).(*octopus.UploadImageResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + return resp, nil + case *octopus.DeleteImageResp: + var resp types.DeleteLinkImageResp + inresp := (interface{})(in).(*octopus.DeleteImageResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + return resp, nil + + case *octopus.GetUserImageListResp: + var resp types.GetLinkImageListResp + inresp := (interface{})(in).(*octopus.GetUserImageListResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + resp.Images = nil + return resp, nil + } + + for _, v := range inresp.Payload.Images { + var image types.ImageSl + image.ImageId = v.Image.Id + image.ImageName = v.Image.ImageName + image.ImageStatus = OctImgStatus[v.Image.ImageStatus] + resp.Images = append(resp.Images, &image) + } + return resp, nil + case *modelarts.ListReposDetailsResp: + var resp types.GetLinkImageListResp + inresp := (interface{})(in).(*modelarts.ListReposDetailsResp) + + if inresp.Errors != nil { + resp.Success = false + resp.ErrorMsg = inresp.Errors[0].ErrorMessage + resp.Images = nil + return resp, nil + } + + resp.Success = true + for _, v := range inresp.Items { + for _, r := range v.Tags { + var image types.ImageSl + image.ImageId = v.Namespace + "/" + v.Name + ":" + r + image.ImageName = v.Name + image.ImageStatus = "created" + resp.Images = append(resp.Images, &image) + } + } + return resp, nil + case *hpcAC.GetImageListAiResp: + var resp types.GetLinkImageListResp + inresp := (interface{})(in).(*hpcAC.GetImageListAiResp) + + if inresp.Code == "0" { + resp.Success = true + for _, img := range inresp.Data { + var image types.ImageSl + image.ImageId = img.ImageId + image.ImageName = img.Version + image.ImageStatus = "created" + resp.Images = append(resp.Images, &image) + } + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Images = nil + } + return resp, nil + + case *octopus.CreateTrainJobResp: + var resp types.SubmitLinkTaskResp + inresp := (interface{})(in).(*octopus.CreateTrainJobResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + resp.TaskId = inresp.Payload.JobId + + return resp, nil + case *modelarts.CreateTrainingJobResp: + var resp types.SubmitLinkTaskResp + inresp := (interface{})(in).(*modelarts.CreateTrainingJobResp) + + if inresp.ErrorMsg != "" { + resp.ErrorMsg = inresp.ErrorMsg + resp.Success = false + return resp, nil + } + resp.Success = true + resp.TaskId = inresp.Metadata.Id + + return resp, nil + case *hpcAC.SubmitTaskAiResp: + var resp types.SubmitLinkTaskResp + inresp := (interface{})(in).(*hpcAC.SubmitTaskAiResp) + + if inresp.Code == "0" { + resp.Success = true + resp.TaskId = inresp.Data + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + case *hpcAC.SubmitJobResp: + var resp types.SubmitLinkTaskResp + inresp := (interface{})(in).(*hpcAC.SubmitJobResp) + if inresp.Code == "0" { + resp.Success = true + resp.TaskId = inresp.Data + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + case *octopus.GetTrainJobResp: + var resp types.GetLinkTaskResp + inresp := (interface{})(in).(*octopus.GetTrainJobResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + var task types.TaskSl + task.TaskId = inresp.Payload.TrainJob.Id + task.TaskName = inresp.Payload.TrainJob.Name + task.StartedAt = inresp.Payload.TrainJob.StartedAt + task.CompletedAt = inresp.Payload.TrainJob.CompletedAt + task.TaskStatus = inresp.Payload.TrainJob.Status + + resp.Task = &task + return resp, nil + case *modelarts.JobResponse: + var resp types.GetLinkTaskResp + inresp := (interface{})(in).(*modelarts.JobResponse) + if inresp.ErrorMsg != "" { + resp.ErrorMsg = inresp.ErrorMsg + resp.Success = false + return resp, nil + } + resp.Success = true + resp.Task = &types.TaskSl{} + resp.Task.TaskId = inresp.Metadata.Id + resp.Task.TaskName = inresp.Metadata.Name + resp.Task.StartedAt = int64(inresp.Status.StartTime) + resp.Task.CompletedAt = int64(inresp.Status.Duration) + resp.Task.TaskStatus = inresp.Status.Phase + + return resp, nil + case *hpcAC.GetPytorchTaskResp: + var resp types.GetLinkTaskResp + inresp := (interface{})(in).(*hpcAC.GetPytorchTaskResp) + if inresp.Code == "0" { + resp.Success = true + var task types.TaskSl + task.TaskId = inresp.Data.Id + task.TaskName = inresp.Data.TaskName + task.TaskStatus = inresp.Data.Status + task.StartedAt = timeutils.StringToUnixTime(inresp.Data.StartTime) + task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.EndTime) + resp.Task = &task + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Task = nil + } + + return resp, nil + case *hpcAC.GetJobDetailResp: + var resp types.GetLinkTaskResp + inresp := (interface{})(in).(*hpcAC.GetJobDetailResp) + if inresp.Code == "0" { + resp.Success = true + var task types.TaskSl + task.TaskId = inresp.Data.JobId + task.TaskName = inresp.Data.JobName + task.TaskStatus = AcStatus[inresp.Data.JobStatus] + task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) + task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) + resp.Task = &task + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Task = nil + } + + return resp, nil + case *hpcAC.HistoryJobDetailResp: + var resp types.GetLinkTaskResp + inresp := (interface{})(in).(*hpcAC.HistoryJobDetailResp) + if inresp.Code == "0" { + resp.Success = true + var task types.TaskSl + task.TaskId = inresp.Data.JobId + task.TaskName = inresp.Data.JobName + task.TaskStatus = AcStatus[inresp.Data.JobState] + task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime) + task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime) + resp.Task = &task + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + resp.Task = nil + } + + return resp, nil + case *octopus.DeleteTrainJobResp: + var resp types.DeleteLinkTaskResp + inresp := (interface{})(in).(*octopus.DeleteTrainJobResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ErrorMsg = inresp.Error.Message + return resp, nil + } + + return resp, nil + case *modelarts.DeleteTrainingJobResp: + var resp types.DeleteLinkTaskResp + inresp := (interface{})(in).(*modelarts.DeleteTrainingJobResp) + if inresp.ErrorMsg != "" { + resp.ErrorMsg = inresp.ErrorMsg + resp.Success = false + return resp, nil + } + resp.Success = true + return resp, nil + case *hpcAC.DeleteTaskAiResp: + var resp types.DeleteLinkTaskResp + inresp := (interface{})(in).(*hpcAC.DeleteTaskAiResp) + if inresp.Code == "0" { + resp.Success = true + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + case *hpcAC.DeleteJobResp: + var resp types.DeleteLinkTaskResp + inresp := (interface{})(in).(*hpcAC.DeleteJobResp) + if inresp.Code == "0" { + resp.Success = true + } else { + resp.Success = false + resp.ErrorMsg = inresp.Msg + } + return resp, nil + case *octopus.GetResourceSpecsResp: + var resp types.GetResourceSpecsResp + inresp := (interface{})(in).(*octopus.GetResourceSpecsResp) + resp.Success = inresp.Success + if !resp.Success { + resp.ResourceSpecs = nil + return resp, nil + } + + for _, spec := range inresp.TrainResourceSpecs { + var respec types.ResourceSpecSl + respec.SpecId = spec.Id + respec.SpecName = spec.Name + respec.ParticipantId = participant.Id + respec.ParticipantName = participant.Name + respec.SpecPrice = spec.Price + resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) + } + + return resp, nil + case *modelarts.TrainingJobFlavorsResp: + var resp types.GetResourceSpecsResp + resp.Success = true + inresp := (interface{})(in).(*modelarts.TrainingJobFlavorsResp) + if inresp.Flavors == nil { + resp.Success = false + resp.ResourceSpecs = nil + return resp, nil + } + + for _, spec := range inresp.Flavors { + var respec types.ResourceSpecSl + respec.SpecId = spec.FlavorId + respec.SpecName = spec.FlavorName + respec.ParticipantId = participant.Id + respec.ParticipantName = participant.Name + respec.SpecPrice = 0 + resp.ResourceSpecs = append(resp.ResourceSpecs, &respec) + } + + return resp, nil + default: + return nil, errors.New("type convert fail") + } +} diff --git a/internal/svc/servicecontext.go b/internal/svc/servicecontext.go new file mode 100644 index 00000000..1fa35295 --- /dev/null +++ b/internal/svc/servicecontext.go @@ -0,0 +1,141 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package svc + +import ( + "github.com/go-redis/redis/v8" + "github.com/go-resty/resty/v2" + alert "github.com/prometheus/alertmanager/api/v2/client" + "github.com/robfig/cron/v3" + "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/zrpc" + hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/config" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/database" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice" + "gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice" + "gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" + "gitlink.org.cn/JointCloud/pcm-openstack/openstackclient" + slurmClient "gitlink.org.cn/JointCloud/pcm-slurm/slurmclient" + "gitlink.org.cn/jcce-pcm/pcm-participant-ceph/cephclient" + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "gorm.io/gorm/schema" + "time" +) + +type ServiceContext struct { + Config config.Config + RedisClient *redis.Client + Cron *cron.Cron + ModelArtsRpc modelartsservice.ModelArtsService + ModelArtsImgRpc imagesservice.ImagesService + DbEngin *gorm.DB + ACRpc hpcacclient.HpcAC + THRpc slurmClient.Slurm + OctopusRpc octopusclient.Octopus + CephRpc cephclient.Ceph + OpenstackRpc openstackclient.Openstack + MonitorClient map[int64]tracker.Prometheus + PromClient tracker.Prometheus + AlertClient *alert.AlertmanagerAPI + HttpClient *resty.Client + Scheduler *scheduler.Scheduler +} + +func NewServiceContext(c config.Config) *ServiceContext { + promClient, err := tracker.NewPrometheus(c.Monitoring.PromUrl) + + if err != nil { + logx.Errorf("InitPrometheus err: %v", err) + panic("InitSnowflake err") + } + httpClient := resty.New() + httpClient.SetTimeout(1 * time.Second) + alertClient := tracker.NewAlertClient(c.Monitoring.AlertUrl) + if err != nil { + logx.Errorf("InitPrometheus err: %v", err) + panic("InitSnowflake err") + } + + //添加snowflake支持 + err = utils.InitSnowflake(c.SnowflakeConf.MachineId) + if err != nil { + logx.Errorf("InitSnowflake err: %v", err) + panic("InitSnowflake err") + } + + //启动Gorm支持 + dbEngin, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{ + NamingStrategy: schema.NamingStrategy{ + SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user` + }, + Logger: logger.Default.LogMode(logger.Warn), + }) + if err != nil { + logx.Errorf("数据库连接失败, err%v", err) + panic(err) + } + sqlDB, err := dbEngin.DB() + // SetMaxIdleConns 设置空闲连接池中连接的最大数量 + sqlDB.SetMaxIdleConns(10) + + // SetMaxOpenConns 设置打开数据库连接的最大数量。 + sqlDB.SetMaxOpenConns(50) + + // SetConnMaxLifetime 设置了连接可复用的最大时间。 + sqlDB.SetConnMaxLifetime(time.Hour) + + if err != nil { + logx.Error(err.Error()) + return nil + } + redisClient := redis.NewClient(&redis.Options{ + Addr: c.Redis.Host, + Password: c.Redis.Pass, + }) + + // scheduler + storage := &database.AiStorage{DbEngin: dbEngin} + aiService, err := service.NewAiService(&c, storage) + if err != nil { + logx.Error(err.Error()) + return nil + } + scheduler := scheduler.NewSchdlr(aiService, storage) + + return &ServiceContext{ + DbEngin: dbEngin, + Cron: cron.New(cron.WithSeconds()), + Config: c, + RedisClient: redisClient, + ModelArtsRpc: modelartsservice.NewModelArtsService(zrpc.MustNewClient(c.ModelArtsRpcConf)), + ModelArtsImgRpc: imagesservice.NewImagesService(zrpc.MustNewClient(c.ModelArtsImgRpcConf)), + CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)), + ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)), + OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)), + OpenstackRpc: openstackclient.NewOpenstack(zrpc.MustNewClient(c.OpenstackRpcConf)), + MonitorClient: make(map[int64]tracker.Prometheus), + PromClient: promClient, + AlertClient: alertClient, + HttpClient: httpClient, + Scheduler: scheduler, + } +} diff --git a/api/internal/types/types.go b/internal/types/types.go similarity index 100% rename from api/internal/types/types.go rename to internal/types/types.go diff --git a/pcm.go b/pcm.go new file mode 100644 index 00000000..95215948 --- /dev/null +++ b/pcm.go @@ -0,0 +1,63 @@ +/* + + Copyright (c) [2023] [pcm] + [pcm-coordinator] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + +*/ + +package main + +import ( + "context" + "flag" + "github.com/zeromicro/go-zero/core/conf" + "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/core/service" + "github.com/zeromicro/go-zero/rest" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/config" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/cron" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/handler" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/mqs" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" +) + +var configFile = flag.String("f", "etc/pcm.yaml", "the config file") + +func main() { + flag.Parse() + + var c config.Config + conf.MustLoad(*configFile, &c) + + serviceGroup := service.NewServiceGroup() + defer serviceGroup.Stop() + + server := rest.MustNewServer(c.RestConf, rest.WithCors()) + + ctx := svc.NewServiceContext(c) + // start log component + logx.MustSetup(c.LogConf) + ctx.Cron.Start() + cron.AddCronGroup(ctx) + handler.RegisterHandlers(server, ctx) + + serviceGroup.Add(server) + services := []service.Service{ + //mqs.MustNewQueue("ai", mqs.NewAiMq(context.Background(), ctx)), + mqs.MustNewQueue("cloud", mqs.NewCloudMq(context.Background(), ctx)), + //mqs.MustNewQueue("hpc", mqs.NewHpcMq(context.Background(), ctx)), + } + for _, mq := range services { + serviceGroup.Add(mq) + } + logx.Infof("Starting server at %s:%d...\n", c.Host, c.Port) + serviceGroup.Start() + +} diff --git a/api/pkg/response/TaskInfo.go b/pkg/response/TaskInfo.go similarity index 100% rename from api/pkg/response/TaskInfo.go rename to pkg/response/TaskInfo.go diff --git a/rpc/Dockerfile b/rpc/Dockerfile deleted file mode 100644 index fb0fb43a..00000000 --- a/rpc/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM golang:1.21.2-alpine3.18 AS builder - -WORKDIR /app - -COPY . . - -RUN go env -w GO111MODULE=on \ -&& go env -w GOPROXY=https://goproxy.cn,direct \ -&& go env -w CGO_ENABLED=0 \ -&& go mod download -RUN go build -o pcm-coordinator-rpc /app/rpc/pcmcore.go - - -FROM alpine:3.18 - -WORKDIR /app - -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/g' /etc/apk/repositories && \ - apk add --no-cache ca-certificates tzdata && \ - update-ca-certificates && \ - rm -rf /var/cache/apk/* - -COPY --from=builder /app/pcm-coordinator-api /app/ -COPY --from=builder /app/api/etc/pcm.yaml /app/ - -ENV TZ=Asia/Shanghai - -EXPOSE 2004 - -ENTRYPOINT ./pcm-coordinator-rpc -f pcmcore.yaml \ No newline at end of file diff --git a/rpc/Makefile b/rpc/Makefile deleted file mode 100644 index 7f152f2f..00000000 --- a/rpc/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -Generate-AMD64: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-coordinator-rpc pcmcore.go - -Generate-ARM64: - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -o pcm-coordinator-rpc pcmcore.go - -rpc-gen: - goctl rpc protoc pb/*.proto --go_out=. --go-grpc_out=. --zrpc_out=. -m - protoc-go-inject-tag -input="pcmCore/*.pb.go" -remove_tag_comment \ No newline at end of file diff --git a/rpc/client/participantservice/participantservice.go b/rpc/client/participantservice/participantservice.go deleted file mode 100644 index 564c3d19..00000000 --- a/rpc/client/participantservice/participantservice.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// Source: pcmCore.proto - -package participantservice - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/zrpc" - "google.golang.org/grpc" -) - -type ( - AiInfo = pcmCore.AiInfo - ApplyInfo = pcmCore.ApplyInfo - ApplyListReq = pcmCore.ApplyListReq - ApplyListResp = pcmCore.ApplyListResp - ClientInfo = pcmCore.ClientInfo - CloudInfo = pcmCore.CloudInfo - HealthCheckResp = pcmCore.HealthCheckResp - HpcInfo = pcmCore.HpcInfo - InfoListReq = pcmCore.InfoListReq - InfoListResp = pcmCore.InfoListResp - ListParticipantAvailResp = pcmCore.ListParticipantAvailResp - ListParticipantPhyResp = pcmCore.ListParticipantPhyResp - ListTenantResp = pcmCore.ListTenantResp - NodeAvailInfo = pcmCore.NodeAvailInfo - NodePhyInfo = pcmCore.NodePhyInfo - ParticipantAvailReq = pcmCore.ParticipantAvailReq - ParticipantHeartbeatReq = pcmCore.ParticipantHeartbeatReq - ParticipantLabel = pcmCore.ParticipantLabel - ParticipantPhyReq = pcmCore.ParticipantPhyReq - ParticipantPhyResp = pcmCore.ParticipantPhyResp - ParticipantResp = pcmCore.ParticipantResp - ParticipantServiceResp = pcmCore.ParticipantServiceResp - ParticipantTenant = pcmCore.ParticipantTenant - QueuePhyInfo = pcmCore.QueuePhyInfo - SyncInfoReq = pcmCore.SyncInfoReq - SyncInfoResp = pcmCore.SyncInfoResp - TenantInfo = pcmCore.TenantInfo - TenantResp = pcmCore.TenantResp - VmInfo = pcmCore.VmInfo - - ParticipantService interface { - // registerParticipant Participant注册接口 - RegisterParticipant(ctx context.Context, in *ParticipantPhyReq, opts ...grpc.CallOption) (*ParticipantPhyResp, error) - // reportHeartbeat 心跳请求 - ReportHeartbeat(ctx context.Context, in *ParticipantHeartbeatReq, opts ...grpc.CallOption) (*HealthCheckResp, error) - // reportAvailable 监控数据上报 - ReportAvailable(ctx context.Context, in *ParticipantAvailReq, opts ...grpc.CallOption) (*ParticipantResp, error) - // listParticipant 服务列表 - ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantServiceResp, error) - // listAvailable 集群动态信息列表 - ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error) - // listPhyInformation 集群静态信息列表 - ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error) - // registerTenant 注册租户信息 - RegisterTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*TenantResp, error) - // listTenant 租户列表信息 - ListTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*ListTenantResp, error) - // applyList 执行任务列表 - ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // DeleteList 删除任务列表 - DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // RestartList 重启任务列表 - RestartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // PauseList 暂停任务列表 - PauseList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // StartList 启动任务列表 - StartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - } - - defaultParticipantService struct { - cli zrpc.Client - } -) - -func NewParticipantService(cli zrpc.Client) ParticipantService { - return &defaultParticipantService{ - cli: cli, - } -} - -// registerParticipant Participant注册接口 -func (m *defaultParticipantService) RegisterParticipant(ctx context.Context, in *ParticipantPhyReq, opts ...grpc.CallOption) (*ParticipantPhyResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.RegisterParticipant(ctx, in, opts...) -} - -// reportHeartbeat 心跳请求 -func (m *defaultParticipantService) ReportHeartbeat(ctx context.Context, in *ParticipantHeartbeatReq, opts ...grpc.CallOption) (*HealthCheckResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.ReportHeartbeat(ctx, in, opts...) -} - -// reportAvailable 监控数据上报 -func (m *defaultParticipantService) ReportAvailable(ctx context.Context, in *ParticipantAvailReq, opts ...grpc.CallOption) (*ParticipantResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.ReportAvailable(ctx, in, opts...) -} - -// listParticipant 服务列表 -func (m *defaultParticipantService) ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantServiceResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.ListParticipant(ctx, in, opts...) -} - -// listAvailable 集群动态信息列表 -func (m *defaultParticipantService) ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.ListPhyAvailable(ctx, in, opts...) -} - -// listPhyInformation 集群静态信息列表 -func (m *defaultParticipantService) ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.ListPhyInformation(ctx, in, opts...) -} - -// registerTenant 注册租户信息 -func (m *defaultParticipantService) RegisterTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*TenantResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.RegisterTenant(ctx, in, opts...) -} - -// listTenant 租户列表信息 -func (m *defaultParticipantService) ListTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*ListTenantResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.ListTenant(ctx, in, opts...) -} - -// applyList 执行任务列表 -func (m *defaultParticipantService) ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.ApplyList(ctx, in, opts...) -} - -// DeleteList 删除任务列表 -func (m *defaultParticipantService) DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.DeleteList(ctx, in, opts...) -} - -// RestartList 重启任务列表 -func (m *defaultParticipantService) RestartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.RestartList(ctx, in, opts...) -} - -// PauseList 暂停任务列表 -func (m *defaultParticipantService) PauseList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.PauseList(ctx, in, opts...) -} - -// StartList 启动任务列表 -func (m *defaultParticipantService) StartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - client := pcmCore.NewParticipantServiceClient(m.cli.Conn()) - return client.StartList(ctx, in, opts...) -} diff --git a/rpc/client/pcmcore/pcmcore.go b/rpc/client/pcmcore/pcmcore.go deleted file mode 100644 index bdb5083f..00000000 --- a/rpc/client/pcmcore/pcmcore.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// Source: pcmCore.proto - -package pcmcore - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/zrpc" - "google.golang.org/grpc" -) - -type ( - AiInfo = pcmCore.AiInfo - ApplyInfo = pcmCore.ApplyInfo - ApplyListReq = pcmCore.ApplyListReq - ApplyListResp = pcmCore.ApplyListResp - ClientInfo = pcmCore.ClientInfo - CloudInfo = pcmCore.CloudInfo - HealthCheckResp = pcmCore.HealthCheckResp - HpcInfo = pcmCore.HpcInfo - InfoListReq = pcmCore.InfoListReq - InfoListResp = pcmCore.InfoListResp - ListParticipantAvailResp = pcmCore.ListParticipantAvailResp - ListParticipantPhyResp = pcmCore.ListParticipantPhyResp - ListTenantResp = pcmCore.ListTenantResp - NodeAvailInfo = pcmCore.NodeAvailInfo - NodePhyInfo = pcmCore.NodePhyInfo - ParticipantAvailReq = pcmCore.ParticipantAvailReq - ParticipantHeartbeatReq = pcmCore.ParticipantHeartbeatReq - ParticipantLabel = pcmCore.ParticipantLabel - ParticipantPhyReq = pcmCore.ParticipantPhyReq - ParticipantPhyResp = pcmCore.ParticipantPhyResp - ParticipantResp = pcmCore.ParticipantResp - ParticipantServiceResp = pcmCore.ParticipantServiceResp - ParticipantTenant = pcmCore.ParticipantTenant - QueuePhyInfo = pcmCore.QueuePhyInfo - SyncInfoReq = pcmCore.SyncInfoReq - SyncInfoResp = pcmCore.SyncInfoResp - TenantInfo = pcmCore.TenantInfo - TenantResp = pcmCore.TenantResp - VmInfo = pcmCore.VmInfo - - PcmCore interface { - // SyncInfo Synchronous data information - SyncInfo(ctx context.Context, in *SyncInfoReq, opts ...grpc.CallOption) (*SyncInfoResp, error) - // InfoList - InfoList(ctx context.Context, in *InfoListReq, opts ...grpc.CallOption) (*InfoListResp, error) - } - - defaultPcmCore struct { - cli zrpc.Client - } -) - -func NewPcmCore(cli zrpc.Client) PcmCore { - return &defaultPcmCore{ - cli: cli, - } -} - -// SyncInfo Synchronous data information -func (m *defaultPcmCore) SyncInfo(ctx context.Context, in *SyncInfoReq, opts ...grpc.CallOption) (*SyncInfoResp, error) { - client := pcmCore.NewPcmCoreClient(m.cli.Conn()) - return client.SyncInfo(ctx, in, opts...) -} - -// InfoList -func (m *defaultPcmCore) InfoList(ctx context.Context, in *InfoListReq, opts ...grpc.CallOption) (*InfoListResp, error) { - client := pcmCore.NewPcmCoreClient(m.cli.Conn()) - return client.InfoList(ctx, in, opts...) -} diff --git a/rpc/etc/pcmcore.yaml b/rpc/etc/pcmcore.yaml deleted file mode 100644 index 70902acf..00000000 --- a/rpc/etc/pcmcore.yaml +++ /dev/null @@ -1,24 +0,0 @@ -Name: pcm.core.rpc -ListenOn: 0.0.0.0:2004 - -Timeout: 15000 # 15s,设置rpc服务的响应的超时时间,若超过15s还未返回则结束请求 - -DB: - # DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true - DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true - -#链路追踪 -# Telemetry: -# Name: pcm-core-rpc -# Endpoint: http://jaeger-collector.observability:14268/api/traces -# Sampler: 1.0 -# Batcher: jaeger - -SnowflakeConf: - MachineId: 1 - -RedisConf: - Host: 10.206.0.7:6379 - Pass: redisPW123 - Type: node - Tls: false \ No newline at end of file diff --git a/rpc/internal/config/config.go b/rpc/internal/config/config.go deleted file mode 100644 index 56cf8fdf..00000000 --- a/rpc/internal/config/config.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package config - -import ( - "github.com/zeromicro/go-zero/core/logx" - "github.com/zeromicro/go-zero/core/stores/redis" - "github.com/zeromicro/go-zero/zrpc" -) - -type Config struct { - zrpc.RpcServerConf - DB struct { - DataSource string - } - LogConf logx.LogConf - SnowflakeConf SnowflakeConf - RedisConf redis.RedisConf -} - -// SnowflakeConf 雪花算法机器id配置 -type SnowflakeConf struct { - MachineId int64 `json:"machineId"` -} diff --git a/rpc/internal/logic/participantservice/applylistlogic.go b/rpc/internal/logic/participantservice/applylistlogic.go deleted file mode 100644 index 606c9d80..00000000 --- a/rpc/internal/logic/participantservice/applylistlogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package participantservicelogic - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ApplyListLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewApplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplyListLogic { - return &ApplyListLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// applyList 执行任务列表 -func (l *ApplyListLogic) ApplyList(in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - result := pcmCore.ApplyListResp{ - InfoList: make([]*pcmCore.ApplyInfo, 0), - } - l.svcCtx.DbEngin.Raw("SELECT sppi.`name` as ParticipantName,c.yaml_string as YamlString FROM cloud c,sc_participant_phy_info sppi where c.`status` = 'Saved' and sppi.id = c.participant_id").Scan(&result.InfoList) - if len(result.InfoList) != 0 { - l.svcCtx.DbEngin.Exec("update cloud set status = ? where status = ?", "Issued", "Saved") - } - return &result, nil -} diff --git a/rpc/internal/logic/participantservice/deletelistlogic.go b/rpc/internal/logic/participantservice/deletelistlogic.go deleted file mode 100644 index 774ed8e5..00000000 --- a/rpc/internal/logic/participantservice/deletelistlogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package participantservicelogic - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type DeleteListLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewDeleteListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteListLogic { - return &DeleteListLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// DeleteList 删除任务列表 -func (l *DeleteListLogic) DeleteList(in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - result := pcmCore.ApplyListResp{ - InfoList: make([]*pcmCore.ApplyInfo, 0), - } - l.svcCtx.DbEngin.Raw("SELECT sppi.`name` as ParticipantName,c.yaml_string as YamlString FROM cloud c,sc_participant_phy_info sppi where c.`status` = 'WaitDelete' and sppi.id = c.participant_id").Scan(&result.InfoList) - if len(result.InfoList) != 0 { - l.svcCtx.DbEngin.Exec("update cloud set status = ? where status = ?", "Deleted", "WaitDelete") - } - return &result, nil -} diff --git a/rpc/internal/logic/participantservice/listparticipantlogic.go b/rpc/internal/logic/participantservice/listparticipantlogic.go deleted file mode 100644 index f67d1c6f..00000000 --- a/rpc/internal/logic/participantservice/listparticipantlogic.go +++ /dev/null @@ -1,73 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "fmt" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - "time" -) - -type ListParticipantLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewListParticipantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListParticipantLogic { - return &ListParticipantLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// listParticipant 服务列表 -func (l *ListParticipantLogic) ListParticipant(in *pcmCore.ParticipantTenant) (*pcmCore.ParticipantServiceResp, error) { - // todo: add your logic here and delete this line - rdb := l.svcCtx.RedisClient - resp := pcmCore.ParticipantServiceResp{} - clientInfo := pcmCore.ClientInfo{} - //获取所有Participant的key值 - keys, err := l.svcCtx.RedisClient.Keys(context.Background(), "ps_*").Result() - if err != nil { - logx.Errorf("Error getting keys from Redis err: %v", err) - return &pcmCore.ParticipantServiceResp{ - Code: 500, - Msg: fmt.Sprintf("get service list error %s", err), - }, nil - } - for _, key := range keys { - if err := rdb.HGetAll(l.ctx, key).Scan(&clientInfo); err != nil { - logx.Errorf("get service err:", err) - return &pcmCore.ParticipantServiceResp{ - Code: 500, - Msg: fmt.Sprintf("get service list error %s", err), - }, nil - } - - //最后心跳时间差值大于15s则标记服务为不健康 - if time.Now().Unix()-clientInfo.LastHeartbeat > 15 { - clientInfo.ClientState = "UNKNOWN" - } - resp.Data = append(resp.Data, &clientInfo) - } - resp.Code = 200 - resp.Msg = "ok" - return &resp, nil -} diff --git a/rpc/internal/logic/participantservice/listphyavailablelogic.go b/rpc/internal/logic/participantservice/listphyavailablelogic.go deleted file mode 100644 index 9dbe8f40..00000000 --- a/rpc/internal/logic/participantservice/listphyavailablelogic.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" -) - -type ListPhyAvailableLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewListPhyAvailableLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPhyAvailableLogic { - return &ListPhyAvailableLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// listAvailable 集群动态信息列表 -func (l *ListPhyAvailableLogic) ListPhyAvailable(in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantAvailResp, error) { - // todo: add your logic here and delete this line - resp := &pcmCore.ListParticipantAvailResp{} - var scParticipantPhyInfoS []models.ScParticipantAvailInfo - //查询集群静态信息列表 - l.svcCtx.DbEngin.Find(&scParticipantPhyInfoS) - utils.Convert(scParticipantPhyInfoS, &resp.ParticipantAvails) - return resp, nil -} diff --git a/rpc/internal/logic/participantservice/listphyinformationlogic.go b/rpc/internal/logic/participantservice/listphyinformationlogic.go deleted file mode 100644 index 02a45591..00000000 --- a/rpc/internal/logic/participantservice/listphyinformationlogic.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListPhyInformationLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewListPhyInformationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPhyInformationLogic { - return &ListPhyInformationLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// listPhyInformation 集群静态信息列表 -func (l *ListPhyInformationLogic) ListPhyInformation(in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantPhyResp, error) { - // todo: add your logic here and delete this line - resp := &pcmCore.ListParticipantPhyResp{} - var scParticipantPhyInfoS []models.ScParticipantPhyInfo - //查询集群静态信息列表 - l.svcCtx.DbEngin.Find(&scParticipantPhyInfoS) - utils.Convert(scParticipantPhyInfoS, &resp.ParticipantPhys) - return resp, nil -} diff --git a/rpc/internal/logic/participantservice/listtenantlogic.go b/rpc/internal/logic/participantservice/listtenantlogic.go deleted file mode 100644 index d2bd2b71..00000000 --- a/rpc/internal/logic/participantservice/listtenantlogic.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ListTenantLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewListTenantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTenantLogic { - return &ListTenantLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// listTenant 租户列表信息 -func (l *ListTenantLogic) ListTenant(in *pcmCore.TenantInfo) (*pcmCore.ListTenantResp, error) { - resp := &pcmCore.ListTenantResp{} - var scTenantInfos []models.ScTenantInfo - //查询集群静态信息列表 - l.svcCtx.DbEngin.Find(&scTenantInfos) - utils.Convert(scTenantInfos, &resp.TenantInfos) - resp.Code = 200 - resp.Msg = "success" - return resp, nil -} diff --git a/rpc/internal/logic/participantservice/pauselistlogic.go b/rpc/internal/logic/participantservice/pauselistlogic.go deleted file mode 100644 index ee7a4656..00000000 --- a/rpc/internal/logic/participantservice/pauselistlogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package participantservicelogic - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type PauseListLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewPauseListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PauseListLogic { - return &PauseListLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// PauseList 暂停任务列表 -func (l *PauseListLogic) PauseList(in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - result := pcmCore.ApplyListResp{ - InfoList: make([]*pcmCore.ApplyInfo, 0), - } - l.svcCtx.DbEngin.Raw("SELECT sppi.`name` as ParticipantName, c.ns_id as namespace,c.name as name , c.kind as kind FROM cloud c,sc_participant_phy_info sppi where c.`status` = 'WaitPause' and sppi.id = c.participant_id and deleted_at is null").Scan(&result.InfoList) - if len(result.InfoList) != 0 { - l.svcCtx.DbEngin.Exec("update cloud set status = ? where status = ?", "Paused", "WaitPause") - } - return &result, nil -} diff --git a/rpc/internal/logic/participantservice/registerparticipantlogic.go b/rpc/internal/logic/participantservice/registerparticipantlogic.go deleted file mode 100644 index 87f15483..00000000 --- a/rpc/internal/logic/participantservice/registerparticipantlogic.go +++ /dev/null @@ -1,125 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "github.com/pkg/errors" - models2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gorm.io/gorm" - "time" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type RegisterParticipantLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewRegisterParticipantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterParticipantLogic { - return &RegisterParticipantLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// RegisterParticipant Participant注册接口 -func (l *RegisterParticipantLogic) RegisterParticipant(in *pcmCore.ParticipantPhyReq) (*pcmCore.ParticipantPhyResp, error) { - //判断ParticipantId是否存在 - db := l.svcCtx.DbEngin.Begin() - // 执行回滚或者提交操作 - defer func() { - if p := recover(); p != nil { - db.Rollback() - logx.Error(p) - } else if db.Error != nil { - logx.Info("rollback") - db.Rollback() - } else { - db = db.Commit() - logx.Info("commit success") - } - }() - participantInfo := &models2.ScParticipantPhyInfo{} - utils.Convert(in, participantInfo) - if in.ParticipantId == 0 { - participantInfo.Id = utils.GenSnowflakeID() - } else { - participantInfo.Id = in.ParticipantId - } - //保存participant静态信息 - result := db.Save(&participantInfo) - //保存节点信息 - nodeList := make([]*models2.ScNodePhyInfo, 0) - for _, info := range in.NodeInfo { - nodeInfo := &models2.ScNodePhyInfo{} - utils.Convert(info, nodeInfo) - nodeInfo.CreatedTime = time.Now() - nodeInfo.ParticipantId = participantInfo.Id - //查询节点name与ParticipantId是否存在 - nodeErr := db.Where(&models2.ScNodePhyInfo{NodeName: nodeInfo.NodeName, ParticipantId: in.ParticipantId}).Take(nodeInfo) - if errors.Is(nodeErr.Error, gorm.ErrRecordNotFound) { - nodeInfo.Id = utils.GenSnowflakeID() - } - nodeList = append(nodeList, nodeInfo) - } - result = db.Save(&nodeList) - //保存队列信息 - queueList := make([]*models2.ScQueuePhyInfo, 0) - for _, info := range in.QueueInfo { - queueInfo := &models2.ScQueuePhyInfo{} - utils.Convert(info, queueInfo) - queueInfo.CreatedTime = time.Now() - queueInfo.ParticipantId = participantInfo.Id - //查询队列name与ParticipantId是否存在 - queueErr := db.Where(&models2.ScQueuePhyInfo{QueueName: queueInfo.QueueName, ParticipantId: in.ParticipantId}).Take(queueInfo) - if errors.Is(queueErr.Error, gorm.ErrRecordNotFound) { - queueInfo.Id = utils.GenSnowflakeID() - } - queueList = append(queueList, queueInfo) - } - result = db.Save(&queueList) - //保存标签信息 - labelList := make([]*models2.ScParticipantLabelInfo, 0) - for _, label := range in.LabelInfo { - labelInfo := &models2.ScParticipantLabelInfo{} - utils.Convert(label, labelInfo) - labelInfo.CreatedTime = time.Now() - labelInfo.ParticipantId = participantInfo.Id - //查询标签key value与ParticipantId是否存在 - labelErr := db.Where(&models2.ScParticipantLabelInfo{Key: labelInfo.Key, Value: labelInfo.Value, ParticipantId: in.ParticipantId}).Take(labelInfo) - if errors.Is(labelErr.Error, gorm.ErrRecordNotFound) { - labelInfo.Id = utils.GenSnowflakeID() - } - labelList = append(labelList, labelInfo) - } - result = db.Save(&labelList) - if result.Error != nil { - logx.Errorf("orm err:", result.Error) - return &pcmCore.ParticipantPhyResp{}, nil - } - return &pcmCore.ParticipantPhyResp{ - Code: 200, - Msg: "ok", - ParticipantId: participantInfo.Id, - }, nil -} diff --git a/rpc/internal/logic/participantservice/registertenantlogic.go b/rpc/internal/logic/participantservice/registertenantlogic.go deleted file mode 100644 index c9e03d36..00000000 --- a/rpc/internal/logic/participantservice/registertenantlogic.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" -) - -type RegisterTenantLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewRegisterTenantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterTenantLogic { - return &RegisterTenantLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// registerTenant 注册租户信息 -func (l *RegisterTenantLogic) RegisterTenant(in *pcmCore.TenantInfo) (*pcmCore.TenantResp, error) { - // todo: add your logic here and delete this line - tenantInfo := &models.ScTenantInfo{} - utils.Convert(in, tenantInfo) - tenantInfo.Id = utils.GenSnowflakeID() - tx := l.svcCtx.DbEngin.Save(&tenantInfo) - if tx.Error != nil { - logx.Errorf("orm err:", tx.Error) - return &pcmCore.TenantResp{ - Code: 500, - Msg: "save Tenant error " + tx.Error.Error(), - }, nil - } - return &pcmCore.TenantResp{ - Code: 200, - Msg: "success", - }, nil -} diff --git a/rpc/internal/logic/participantservice/reportavailablelogic.go b/rpc/internal/logic/participantservice/reportavailablelogic.go deleted file mode 100644 index a43443e6..00000000 --- a/rpc/internal/logic/participantservice/reportavailablelogic.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "fmt" - "github.com/pkg/errors" - models2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - "gorm.io/gorm" - "time" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ReportAvailableLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewReportAvailableLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReportAvailableLogic { - return &ReportAvailableLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// ReportAvailable 监控数据上报 -func (l *ReportAvailableLogic) ReportAvailable(in *pcmCore.ParticipantAvailReq) (*pcmCore.ParticipantResp, error) { - db := l.svcCtx.DbEngin.Begin() - // 执行回滚或者提交操作 - defer func() { - if p := recover(); p != nil { - db.Rollback() - logx.Error(p) - } else if db.Error != nil { - logx.Info("rollback") - db.Rollback() - } else { - db = db.Commit() - logx.Info("commit success") - } - }() - //判断Participant静态信息是否存在 - participantPhyInfo := &models2.ScParticipantPhyInfo{} - participantPhyInfo.Id = in.ParticipantId - if in.ParticipantId == 0 { - return &pcmCore.ParticipantResp{ - Code: 500, - Msg: fmt.Sprintf("ParticipantInfo Does not exist, please check participantPhyId: %d", in.ParticipantId), - }, nil - } - if errors.Is(db.Take(&participantPhyInfo).Error, gorm.ErrRecordNotFound) { - return &pcmCore.ParticipantResp{ - Code: 500, - Msg: fmt.Sprintf("ParticipantInfo Does not exist, please check participantPhyId: %d", in.ParticipantId), - }, nil - } - - participantAvailInfo := &models2.ScParticipantAvailInfo{} - utils.Convert(in, participantAvailInfo) - if in.Id == 0 { - participantAvailInfo.Id = utils.GenSnowflakeID() - } - participantAvailInfo.CreatedTime = time.Now() - //保存participant动态信息 - result := db.Save(&participantAvailInfo) - //保存节点信息 - nodeList := make([]*models2.ScNodeAvailInfo, 0) - for _, info := range in.NodeAvailInfo { - nodeInfo := &models2.ScNodeAvailInfo{} - utils.Convert(info, nodeInfo) - nodeInfo.CreatedTime = time.Now() - nodeInfo.ParticipantId = participantAvailInfo.ParticipantId - if nodeInfo.Id == 0 { - nodeInfo.Id = utils.GenSnowflakeID() - } - nodeList = append(nodeList, nodeInfo) - } - result = db.Save(&nodeList) - if result.Error != nil { - logx.Errorf("orm err:", result.Error) - return &pcmCore.ParticipantResp{ - Code: 500, - Msg: fmt.Sprintf("Save participantAvailInfo error %s", result.Error), - }, nil - } - - return &pcmCore.ParticipantResp{ - Code: 200, - Msg: "ok", - }, nil -} diff --git a/rpc/internal/logic/participantservice/reportheartbeatlogic.go b/rpc/internal/logic/participantservice/reportheartbeatlogic.go deleted file mode 100644 index 9e17c384..00000000 --- a/rpc/internal/logic/participantservice/reportheartbeatlogic.go +++ /dev/null @@ -1,64 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package participantservicelogic - -import ( - "context" - "fmt" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - "sync" - "time" -) - -var clientsMutex sync.Mutex - -type ReportHeartbeatLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewReportHeartbeatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReportHeartbeatLogic { - return &ReportHeartbeatLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// ReportHeartbeat 心跳请求 -func (l *ReportHeartbeatLogic) ReportHeartbeat(in *pcmCore.ParticipantHeartbeatReq) (*pcmCore.HealthCheckResp, error) { - //Participant服务key值以ps_开头 - key := fmt.Sprintf("ps_%s-%d", in.Address, in.ParticipantId) - clientsMutex.Lock() - defer clientsMutex.Unlock() - setResult := l.svcCtx.RedisClient.HSet(context.Background(), key, - map[string]interface{}{ - "address": in.Address, - "participantId": in.ParticipantId, - "lastHeartbeat": time.Now().Unix(), - "clientState": "TRUE", - }) - if setResult.Err() != nil { - return nil, setResult.Err() - } - l.svcCtx.RedisClient.Expire(context.Background(), key, 30*time.Second) - return &pcmCore.HealthCheckResp{ - Code: 200, - Msg: "ok", - }, nil -} diff --git a/rpc/internal/logic/participantservice/restartlistlogic.go b/rpc/internal/logic/participantservice/restartlistlogic.go deleted file mode 100644 index b741cea1..00000000 --- a/rpc/internal/logic/participantservice/restartlistlogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package participantservicelogic - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type RestartListLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewRestartListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RestartListLogic { - return &RestartListLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// RestartList 重启任务列表 -func (l *RestartListLogic) RestartList(in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - result := pcmCore.ApplyListResp{ - InfoList: make([]*pcmCore.ApplyInfo, 0), - } - l.svcCtx.DbEngin.Raw("SELECT sppi.`name` as ParticipantName, c.ns_id as namespace,c.name as name , c.kind as kind FROM cloud c,sc_participant_phy_info sppi where c.`status` = 'WaitRestart' and sppi.id = c.participant_id and deleted_at is null").Scan(&result.InfoList) - if len(result.InfoList) != 0 { - l.svcCtx.DbEngin.Exec("update cloud set status = ? where status = ?", "Issued", "WaitRestart") - } - return &result, nil -} diff --git a/rpc/internal/logic/participantservice/startlistlogic.go b/rpc/internal/logic/participantservice/startlistlogic.go deleted file mode 100644 index dfab90af..00000000 --- a/rpc/internal/logic/participantservice/startlistlogic.go +++ /dev/null @@ -1,36 +0,0 @@ -package participantservicelogic - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - - "github.com/zeromicro/go-zero/core/logx" -) - -type StartListLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewStartListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StartListLogic { - return &StartListLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// StartList 启动任务列表 -func (l *StartListLogic) StartList(in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - result := pcmCore.ApplyListResp{ - InfoList: make([]*pcmCore.ApplyInfo, 0), - } - l.svcCtx.DbEngin.Raw("SELECT sppi.`name` as ParticipantName, c.ns_id as namespace,c.name as name , c.kind as kind FROM cloud c,sc_participant_phy_info sppi where c.`status` = 'WaitStart' and sppi.id = c.participant_id and deleted_at is null").Scan(&result.InfoList) - if len(result.InfoList) != 0 { - l.svcCtx.DbEngin.Exec("update cloud set status = ? where status = ?", "Issued", "WaitStart") - } - return &result, nil -} diff --git a/rpc/internal/logic/pcmcore/infolistlogic.go b/rpc/internal/logic/pcmcore/infolistlogic.go deleted file mode 100644 index d2ef8768..00000000 --- a/rpc/internal/logic/pcmcore/infolistlogic.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package pcmcorelogic - -import ( - "context" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - "gorm.io/gorm" -) - -type InfoListLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewInfoListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoListLogic { - return &InfoListLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// InfoList p端根据id查询任务列表 -func (l *InfoListLogic) InfoList(in *pcmCore.InfoListReq) (*pcmCore.InfoListResp, error) { - result := pcmCore.InfoListResp{} - // 查询p端类型 - var kind string - l.svcCtx.DbEngin.Raw("select type as kind from sc_participant_phy_info where id = ?", in.ParticipantId).Scan(&kind) - // 查询云智超中的数据列表 - switch kind { - case constants.HPC: - var hpcModelList []models.Hpc - findModelList(in.ParticipantId, l.svcCtx.DbEngin, &hpcModelList) - utils.Convert(hpcModelList, &result.HpcInfoList) - case constants.CLOUD, constants.SEALOS: - var cloudModelList []models.Cloud - findModelList(in.ParticipantId, l.svcCtx.DbEngin, &cloudModelList) - utils.Convert(cloudModelList, &result.CloudInfoList) - case constants.AI: - var aiModelList []models.Ai - findModelList(in.ParticipantId, l.svcCtx.DbEngin, &aiModelList) - utils.Convert(aiModelList, &result.AiInfoList) - } - return &result, nil -} - -func findModelList(participantId int64, dbEngin *gorm.DB, data interface{}) error { - tx := dbEngin.Where("participant_id = ? AND status NOT IN ?", participantId, []string{"Deleted", "Succeeded", "Completed", "Failed"}).Find(data) - if tx.Error != nil { - return tx.Error - } - return nil -} diff --git a/rpc/internal/logic/pcmcore/syncinfologic.go b/rpc/internal/logic/pcmcore/syncinfologic.go deleted file mode 100644 index 1567259d..00000000 --- a/rpc/internal/logic/pcmcore/syncinfologic.go +++ /dev/null @@ -1,129 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package pcmcorelogic - -import ( - "context" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - "gorm.io/gorm" - "strings" - "time" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ExternalInfo struct { - TaskId int64 - ExternalField string - Name string - Status string - StartTime time.Time - RunningTime int64 -} -type SyncInfoLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewSyncInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncInfoLogic { - return &SyncInfoLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -// SyncInfo Synchronous data information -func (l *SyncInfoLogic) SyncInfo(in *pcmCore.SyncInfoReq) (*pcmCore.SyncInfoResp, error) { - // 查询p端类型 - var kind string - l.svcCtx.DbEngin.Raw("select type as kind from sc_participant_phy_info where id = ?", in.ParticipantId).Scan(&kind) - switch kind { - case constants.CLOUD, constants.SEALOS: - for _, cloudInfo := range in.CloudInfoList { - l.svcCtx.DbEngin.Exec("update cloud set status = ?,start_time = ?,result = ? where participant_id = ? and id = ?", - cloudInfo.Status, cloudInfo.StartTime, cloudInfo.Result, in.ParticipantId, cloudInfo.Id) - syncTask(l.svcCtx.DbEngin, cloudInfo.TaskId) - } - case constants.HPC: - for _, hpcInfo := range in.HpcInfoList { - l.svcCtx.DbEngin.Exec("update hpc set status = ?,start_time = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?", - hpcInfo.Status, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, in.ParticipantId, hpcInfo.TaskId, hpcInfo.Name) - syncTask(l.svcCtx.DbEngin, hpcInfo.TaskId) - } - case constants.AI: - for _, aiInfo := range in.AiInfoList { - l.svcCtx.DbEngin.Exec("update ai set status = ?,start_time = ?,project_id = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?", - aiInfo.Status, aiInfo.StartTime, aiInfo.ProjectId, aiInfo.JobId, in.ParticipantId, aiInfo.TaskId, aiInfo.Name) - syncTask(l.svcCtx.DbEngin, aiInfo.TaskId) - } - } - - return &pcmCore.SyncInfoResp{}, nil -} - -func syncTask(gorm *gorm.DB, taskId int64) { - - var allStatus string - tx := gorm.Raw("SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.status) ,GROUP_CONCAT(DISTINCT a.status) ,GROUP_CONCAT(DISTINCT c.status))as status from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?", taskId).Scan(&allStatus) - if tx.Error != nil { - logx.Error(tx.Error) - } - // 子状态统一则修改主任务状态 - statusArray := strings.Split(allStatus, ",") - if len(removeRepeatedElement(statusArray)) == 1 { - updateTask(gorm, taskId, statusArray[0]) - - } - // 子任务包含失败状态 主任务则失败 - if strings.Contains(allStatus, constants.Failed) { - updateTask(gorm, taskId, constants.Failed) - - } - if strings.Contains(allStatus, constants.Running) { - updateTask(gorm, taskId, constants.Running) - } - -} - -func updateTask(gorm *gorm.DB, taskId int64, status string) { - var task models.Task - gorm.Where("id = ? ", taskId).Find(&task) - if task.Status != status { - task.Status = status - gorm.Updates(&task) - } -} - -func removeRepeatedElement(arr []string) (newArr []string) { - newArr = make([]string, 0) - for i := 0; i < len(arr); i++ { - repeat := false - for j := i + 1; j < len(arr); j++ { - if arr[i] == arr[j] { - repeat = true - break - } - } - if !repeat { - newArr = append(newArr, arr[i]) - } - } - return -} diff --git a/rpc/internal/server/participantservice/participantserviceserver.go b/rpc/internal/server/participantservice/participantserviceserver.go deleted file mode 100644 index d6f61eda..00000000 --- a/rpc/internal/server/participantservice/participantserviceserver.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// Source: pcmCore.proto - -package server - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/logic/participantservice" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" -) - -type ParticipantServiceServer struct { - svcCtx *svc.ServiceContext - pcmCore.UnimplementedParticipantServiceServer -} - -func NewParticipantServiceServer(svcCtx *svc.ServiceContext) *ParticipantServiceServer { - return &ParticipantServiceServer{ - svcCtx: svcCtx, - } -} - -// registerParticipant Participant注册接口 -func (s *ParticipantServiceServer) RegisterParticipant(ctx context.Context, in *pcmCore.ParticipantPhyReq) (*pcmCore.ParticipantPhyResp, error) { - l := participantservicelogic.NewRegisterParticipantLogic(ctx, s.svcCtx) - return l.RegisterParticipant(in) -} - -// reportHeartbeat 心跳请求 -func (s *ParticipantServiceServer) ReportHeartbeat(ctx context.Context, in *pcmCore.ParticipantHeartbeatReq) (*pcmCore.HealthCheckResp, error) { - l := participantservicelogic.NewReportHeartbeatLogic(ctx, s.svcCtx) - return l.ReportHeartbeat(in) -} - -// reportAvailable 监控数据上报 -func (s *ParticipantServiceServer) ReportAvailable(ctx context.Context, in *pcmCore.ParticipantAvailReq) (*pcmCore.ParticipantResp, error) { - l := participantservicelogic.NewReportAvailableLogic(ctx, s.svcCtx) - return l.ReportAvailable(in) -} - -// listParticipant 服务列表 -func (s *ParticipantServiceServer) ListParticipant(ctx context.Context, in *pcmCore.ParticipantTenant) (*pcmCore.ParticipantServiceResp, error) { - l := participantservicelogic.NewListParticipantLogic(ctx, s.svcCtx) - return l.ListParticipant(in) -} - -// listAvailable 集群动态信息列表 -func (s *ParticipantServiceServer) ListPhyAvailable(ctx context.Context, in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantAvailResp, error) { - l := participantservicelogic.NewListPhyAvailableLogic(ctx, s.svcCtx) - return l.ListPhyAvailable(in) -} - -// listPhyInformation 集群静态信息列表 -func (s *ParticipantServiceServer) ListPhyInformation(ctx context.Context, in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantPhyResp, error) { - l := participantservicelogic.NewListPhyInformationLogic(ctx, s.svcCtx) - return l.ListPhyInformation(in) -} - -// registerTenant 注册租户信息 -func (s *ParticipantServiceServer) RegisterTenant(ctx context.Context, in *pcmCore.TenantInfo) (*pcmCore.TenantResp, error) { - l := participantservicelogic.NewRegisterTenantLogic(ctx, s.svcCtx) - return l.RegisterTenant(in) -} - -// listTenant 租户列表信息 -func (s *ParticipantServiceServer) ListTenant(ctx context.Context, in *pcmCore.TenantInfo) (*pcmCore.ListTenantResp, error) { - l := participantservicelogic.NewListTenantLogic(ctx, s.svcCtx) - return l.ListTenant(in) -} - -// applyList 执行任务列表 -func (s *ParticipantServiceServer) ApplyList(ctx context.Context, in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - l := participantservicelogic.NewApplyListLogic(ctx, s.svcCtx) - return l.ApplyList(in) -} - -// DeleteList 删除任务列表 -func (s *ParticipantServiceServer) DeleteList(ctx context.Context, in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - l := participantservicelogic.NewDeleteListLogic(ctx, s.svcCtx) - return l.DeleteList(in) -} - -// RestartList 重启任务列表 -func (s *ParticipantServiceServer) RestartList(ctx context.Context, in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - l := participantservicelogic.NewRestartListLogic(ctx, s.svcCtx) - return l.RestartList(in) -} - -// PauseList 暂停任务列表 -func (s *ParticipantServiceServer) PauseList(ctx context.Context, in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - l := participantservicelogic.NewPauseListLogic(ctx, s.svcCtx) - return l.PauseList(in) -} - -// StartList 启动任务列表 -func (s *ParticipantServiceServer) StartList(ctx context.Context, in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) { - l := participantservicelogic.NewStartListLogic(ctx, s.svcCtx) - return l.StartList(in) -} diff --git a/rpc/internal/server/pcmcore/pcmcoreserver.go b/rpc/internal/server/pcmcore/pcmcoreserver.go deleted file mode 100644 index eb5c2d0f..00000000 --- a/rpc/internal/server/pcmcore/pcmcoreserver.go +++ /dev/null @@ -1,35 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// Source: pcmCore.proto - -package server - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/logic/pcmcore" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" -) - -type PcmCoreServer struct { - svcCtx *svc.ServiceContext - pcmCore.UnimplementedPcmCoreServer -} - -func NewPcmCoreServer(svcCtx *svc.ServiceContext) *PcmCoreServer { - return &PcmCoreServer{ - svcCtx: svcCtx, - } -} - -// SyncInfo Synchronous data information -func (s *PcmCoreServer) SyncInfo(ctx context.Context, in *pcmCore.SyncInfoReq) (*pcmCore.SyncInfoResp, error) { - l := pcmcorelogic.NewSyncInfoLogic(ctx, s.svcCtx) - return l.SyncInfo(in) -} - -// InfoList -func (s *PcmCoreServer) InfoList(ctx context.Context, in *pcmCore.InfoListReq) (*pcmCore.InfoListResp, error) { - l := pcmcorelogic.NewInfoListLogic(ctx, s.svcCtx) - return l.InfoList(in) -} diff --git a/rpc/internal/svc/servicecontext.go b/rpc/internal/svc/servicecontext.go deleted file mode 100644 index 34775b92..00000000 --- a/rpc/internal/svc/servicecontext.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package svc - -import ( - "github.com/go-redis/redis/v8" - _ "github.com/go-sql-driver/mysql" - "github.com/zeromicro/go-zero/core/logx" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/config" - "gorm.io/driver/mysql" - "gorm.io/gorm" - "gorm.io/gorm/logger" - "gorm.io/gorm/schema" - "time" -) - -type ServiceContext struct { - Config config.Config - DbEngin *gorm.DB - RedisClient *redis.Client -} - -func NewServiceContext(c config.Config) *ServiceContext { - //启动Gorm支持 - dbEngin, _ := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{ - NamingStrategy: schema.NamingStrategy{ - SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user` - }, - Logger: logger.Default.LogMode(logger.Warn), - }) - sqlDB, err := dbEngin.DB() - // SetMaxIdleConns 设置空闲连接池中连接的最大数量 - sqlDB.SetMaxIdleConns(10) - - // SetMaxOpenConns 设置打开数据库连接的最大数量。 - sqlDB.SetMaxOpenConns(50) - - // SetConnMaxLifetime 设置了连接可复用的最大时间。 - sqlDB.SetConnMaxLifetime(time.Hour) - //添加snowflake支持 - err = utils.InitSnowflake(c.SnowflakeConf.MachineId) - if err != nil { - logx.Errorf("InitSnowflake err: ", err) - panic("InitSnowflake err") - } - return &ServiceContext{ - Config: c, - DbEngin: dbEngin, - RedisClient: redis.NewClient(&redis.Options{ - Addr: c.RedisConf.Host, - Password: c.RedisConf.Pass, - DB: 0, // use default DB - }), - } -} diff --git a/rpc/pb/pcmCore.proto b/rpc/pb/pcmCore.proto deleted file mode 100644 index cf781833..00000000 --- a/rpc/pb/pcmCore.proto +++ /dev/null @@ -1,345 +0,0 @@ -syntax = "proto3"; - -package pcmCore; -option go_package = "/pcmCore"; - -message SyncInfoReq { - int64 participantId = 1; - repeated HpcInfo HpcInfoList = 2; - repeated CloudInfo CloudInfoList = 3; - repeated AiInfo AiInfoList = 4; - repeated VmInfo VmInfoList = 5; -} - -message AiInfo { - int64 participantId = 1; - int64 taskId = 2; - string project_id = 3; - string name = 4; - string status = 5; - string startTime = 6; - int64 runningTime = 7; - string result = 8; - string jobId = 9; - string createTime = 10; - string imageUrl = 11; - string command = 12; - string flavorId = 13; - string subscriptionId = 14; - string itemVersionId = 15; - -} - -message CloudInfo { - int64 participant = 1; - int64 id = 2; - int64 taskId = 3; - string apiVersion = 4; - string kind = 5; - string namespace = 6; - string name = 7; - string status = 11; - string startTime = 8; - int64 runningTime = 9; - string result = 10; - string yamlString = 12; -} - -message VmInfo { - int64 participantId = 1; - int64 taskId = 2; - string name = 3; - string flavor_ref = 4; - string image_ref = 5; - string network_uuid = 6; - string block_uuid = 7; - string source_type = 8; - bool delete_on_termination = 9; - string state = 10; -} - -message HpcInfo { - int64 participantId = 1; - int64 taskId = 2; - string jobId = 3; - string name = 4; - string status = 5; - string startTime = 6; - int64 runningTime = 7; - string result = 8; - string workDir = 9; - string wallTime = 10; - string cmdScript = 11; - string derivedEs = 12; - string cluster = 13; - string blockId = 14; - uint32 allocNodes = 15; - uint32 allocCpu = 16; - string version = 17; - string account = 18; - uint32 exitCode = 19; - uint32 assocId = 20; - string appType = 21; - string appName = 22; - string queue = 23; - string submitType = 24; - string nNode = 25; - string stdOutFile = 26; - string stdErrFile = 27; - string stdInput = 28; - string environment = 29; -} - -message SyncInfoResp { - int64 code = 1; - string msg = 2; -} - -message InfoListReq { - int64 participantId = 1; -} - -message InfoListResp { - repeated HpcInfo HpcInfoList = 1; - repeated CloudInfo CloudInfoList = 2; - repeated AiInfo AiInfoList = 3; - repeated VmInfo VmInfoList = 4; -} - -// pcm core services -service pcmCore { - - // SyncInfo Synchronous data information - rpc SyncInfo(SyncInfoReq) returns (SyncInfoResp); - - // InfoList - rpc InfoList(InfoListReq) returns (InfoListResp); -} - -// participantTenant 租户信息 -message ParticipantTenant { - string tenantName = 1; // 租户名称 -} - -// 集群标签 -message ParticipantLabel { - int64 id = 1; // id - string key = 2; // 标签名 - string value = 3; // 标签值 -} - -enum MessageStatus { - FAIL = 0; - SUCCESS = 1; - UNKNOWN = 2; -} - -message HealthCheckResp { - MessageStatus messageStatus = 1; - int64 code = 2; - string msg = 3; -} - -message ParticipantPhyResp { - int64 code = 1; - string msg = 2; - int64 participantId = 3; // participant 唯一标识 -} - -// 集群静态信息返回 -message ListParticipantPhyResp { - int64 code = 1; - string msg = 2; - repeated ParticipantPhyReq ParticipantPhys = 3; -} - -// participantPhy 静态信息 -message ParticipantPhyReq { - string name = 1; // 名称 - string address = 2; // 地址 - string networkType = 4; // 集群网络类型 - string networkBandwidth = 5; // 集群网络带宽 - string storageType = 6; // 集群存储类型 - string storageSpace = 7; // 集群存储空间 - string storageAvailSpace = 8; // 集群存储可用空间 - string storageBandwidth = 9; // 集群存储带宽 - string type = 10; // 参与者类型:CLOUD-数算集群;AI-智算集群;HPC-超算集群 - int64 tenantId = 11; // 租户id - string tenantName = 12; // 租户名称 - repeated NodePhyInfo nodeInfo = 13; // 节点信息 - int64 participantId = 14; // participant id - repeated ParticipantLabel labelInfo = 15; // 标签信息 - repeated QueuePhyInfo queueInfo = 16; // 队列信息 - int64 id = 17; // id - string MetricsUrl = 18; //监控url - string RpcAddress = 19; - string Token = 20; //token -} - -// NodePhyInfo 节点信息 -message NodePhyInfo { - int64 id = 1; - string nodeName = 2; // 节点名称 - string osName = 3; // 系统名称 - string osVersion = 4; // 系统版本 - string archType = 5; // 架构类型 - string archName = 6; // 架构名称 - string archFreq = 7; // 架构频率 -} - -// QueuePhyInfo 队列信息 -message QueuePhyInfo { - int64 id = 1; // id - string aclHosts = 2; // 可用节点,多个节点用逗号隔开 - string queueId = 3; // 队列名称 - string text = 4 ; // 队列名称 - string queueName = 5; //队列名称 - string queNodes = 6; // 队列节点总数 - string queMinNodect = 7; // 队列最小节点数 - string queMaxNgpus = 8; // 队列最大GPU卡数 - string queMaxPpn = 9; // 使用该队列作业最大CPU核心数 - string queChargeRate = 10; // 费率 - string queMaxNcpus = 11; // 用户最大可用核心数 - string queMaxNdcus = 12; // 队列总DCU卡数 - string queMinNcpus = 13; // 队列最小CPU核数 - string queFreeNodes = 14; // 队列空闲节点数 - string queMaxNodect = 15; // 队列作业最大节点数 - string queMaxGpuPN = 16; // 队列单作业最大GPU卡数 - string queMaxWalltime = 17; // 队列最大运行时间 - string queMaxDcuPN = 18; // 队列单作业最大DCU卡数 - string queNcpus = 19; //队列cpu数 - string queFreeNcpus = 20; //队列空闲cpu数 -} - -// ParticipantHeartbeatReq 心跳请求 -message ParticipantHeartbeatReq { - int64 participantId = 1; // participantId - string address = 2; -} - -// ParticipantAvailInfo Participant可用信息 -message ParticipantAvailReq { - int64 id = 1; // id - int64 availStorageSpace = 2; // 集群存储可用空间 - int64 userNum = 3; // 用户数量 - int64 pendingJobNum = 4; // 待处理作业数量 - int64 runningJobNum = 5; // 运行作业数量 - int64 participantId = 6; // 集群静态信息id - repeated NodeAvailInfo nodeAvailInfo = 7; // 节点可用信息 -} - -// NodeAvailInfo 节点可用信息 -message NodeAvailInfo { - int64 id = 1; // id - string nodeName = 2; // 节点名称 - int64 cpuTotal = 3; // cpu核数 - double cpuUsable = 4; // cpu可用率 - int64 diskTotal = 5; // 磁盘空间 - int64 diskAvail = 6; // 磁盘可用空间 - int64 memTotal = 7; // 内存总数 - int64 memAvail = 8; // 内存可用数 - int64 gpuTotal = 9; // gpu总数 - int64 gpuAvail = 10; // gpu可用数 - int64 participantId = 11; // 集群动态信息id -} - -// 集群可用信息 -message ListParticipantAvailResp { - int64 code = 1; - string msg = 2; - repeated ParticipantAvailReq ParticipantAvails = 3; -} - -message ParticipantResp { - int64 code = 1; - string msg = 2; -} -message ParticipantServiceResp { - int64 code = 1; - string msg = 2; - repeated ClientInfo data = 3; -} - -message ClientInfo { - string address = 1; // @gotags: redis:"address" - int64 participantId = 2; // @gotags: redis:"participantId" - string clientState = 3; // @gotags: redis:"clientState" - int64 lastHeartbeat = 4; // @gotags: redis:"lastHeartbeat" -} - -message TenantInfo { - int64 id = 1; - string tenantName = 2; - string tenantDesc = 3; -} - -message TenantResp { - int64 code = 1; - string msg = 2; - int64 id = 3; -} - -message ListTenantResp { - int64 code = 1; - string msg = 2; - repeated TenantInfo tenantInfos = 3; -} - -message ApplyListReq{ - -} - -message ApplyListResp{ - repeated ApplyInfo infoList = 1; -} - -message ApplyInfo{ - string participantName = 1; - string yamlString = 2; - string namespace =3; - string name = 4; - string kind = 5; -} - -// participant 参与者 -service participantService { - - // registerParticipant Participant注册接口 - rpc registerParticipant(ParticipantPhyReq) returns (ParticipantPhyResp) {}; - - // reportHeartbeat 心跳请求 - rpc reportHeartbeat(ParticipantHeartbeatReq) returns (HealthCheckResp) {}; - - // reportAvailable 监控数据上报 - rpc reportAvailable(ParticipantAvailReq) returns (ParticipantResp) {} - - // listParticipant 服务列表 - rpc listParticipant(ParticipantTenant) returns (ParticipantServiceResp) {} - - // listAvailable 集群动态信息列表 - rpc listPhyAvailable(ParticipantTenant) returns (ListParticipantAvailResp) {} - - // listPhyInformation 集群静态信息列表 - rpc listPhyInformation(ParticipantTenant) returns (ListParticipantPhyResp) {}; - - // registerTenant 注册租户信息 - rpc registerTenant(TenantInfo) returns (TenantResp) {}; - - // listTenant 租户列表信息 - rpc listTenant(TenantInfo) returns (ListTenantResp) {}; - - // applyList 执行任务列表 - rpc applyList(ApplyListReq) returns (ApplyListResp) {}; - - // DeleteList 删除任务列表 - rpc deleteList(ApplyListReq) returns (ApplyListResp) {}; - - // RestartList 重启任务列表 - rpc restartList(ApplyListReq) returns (ApplyListResp) {}; - - // PauseList 暂停任务列表 - rpc pauseList(ApplyListReq) returns (ApplyListResp) {}; - - // StartList 启动任务列表 - rpc startList(ApplyListReq) returns (ApplyListResp) {}; -} \ No newline at end of file diff --git a/rpc/pcm-coordinator-rpc.yaml b/rpc/pcm-coordinator-rpc.yaml deleted file mode 100644 index 769467d3..00000000 --- a/rpc/pcm-coordinator-rpc.yaml +++ /dev/null @@ -1,64 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - name: pcm-coordinator-rpc-deployment - namespace: jcce-system - labels: - k8s-app: pcm-coordinator-rpc -spec: - replicas: 1 - selector: - matchLabels: - k8s-app: pcm-coordinator-rpc - template: - metadata: - name: pcm-coordinator-rpc - labels: - k8s-app: pcm-coordinator-rpc - spec: - imagePullSecrets: - - name: secret_name - containers: - - name: pcm-coordinator-rpc - image: image_name - resources: {} - imagePullPolicy: Always - securityContext: - privileged: false - procMount: Default - ports: - - containerPort: 80 - volumeMounts: [] - volumes: [] - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - securityContext: {} - schedulerName: default-scheduler - strategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 25% - maxSurge: 25% - revisionHistoryLimit: 10 - progressDeadlineSeconds: 600 - ---- - -apiVersion: v1 -kind: Service -metadata: - namespace: jcce-system - name: pcm-coordinator-rpc-service - labels: - k8s-service: pcm-coordinator-rpc -spec: - selector: - k8s-app: pcm-coordinator-rpc - ports: - - name: web - protocol: TCP - port: 2004 - targetPort: 2004 - nodePort: 32456 - type: NodePort diff --git a/rpc/pcmCore/pcmCore.pb.go b/rpc/pcmCore/pcmCore.pb.go deleted file mode 100644 index 41a69fb1..00000000 --- a/rpc/pcmCore/pcmCore.pb.go +++ /dev/null @@ -1,3627 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v3.19.4 -// source: pcmCore.proto - -package pcmCore - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type MessageStatus int32 - -const ( - MessageStatus_FAIL MessageStatus = 0 - MessageStatus_SUCCESS MessageStatus = 1 - MessageStatus_UNKNOWN MessageStatus = 2 -) - -// Enum value maps for MessageStatus. -var ( - MessageStatus_name = map[int32]string{ - 0: "FAIL", - 1: "SUCCESS", - 2: "UNKNOWN", - } - MessageStatus_value = map[string]int32{ - "FAIL": 0, - "SUCCESS": 1, - "UNKNOWN": 2, - } -) - -func (x MessageStatus) Enum() *MessageStatus { - p := new(MessageStatus) - *p = x - return p -} - -func (x MessageStatus) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (MessageStatus) Descriptor() protoreflect.EnumDescriptor { - return file_pcmCore_proto_enumTypes[0].Descriptor() -} - -func (MessageStatus) Type() protoreflect.EnumType { - return &file_pcmCore_proto_enumTypes[0] -} - -func (x MessageStatus) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use MessageStatus.Descriptor instead. -func (MessageStatus) EnumDescriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{0} -} - -type SyncInfoReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ParticipantId int64 `protobuf:"varint,1,opt,name=participantId,proto3" json:"participantId,omitempty"` - HpcInfoList []*HpcInfo `protobuf:"bytes,2,rep,name=HpcInfoList,proto3" json:"HpcInfoList,omitempty"` - CloudInfoList []*CloudInfo `protobuf:"bytes,3,rep,name=CloudInfoList,proto3" json:"CloudInfoList,omitempty"` - AiInfoList []*AiInfo `protobuf:"bytes,4,rep,name=AiInfoList,proto3" json:"AiInfoList,omitempty"` - VmInfoList []*VmInfo `protobuf:"bytes,5,rep,name=VmInfoList,proto3" json:"VmInfoList,omitempty"` -} - -func (x *SyncInfoReq) Reset() { - *x = SyncInfoReq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SyncInfoReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncInfoReq) ProtoMessage() {} - -func (x *SyncInfoReq) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncInfoReq.ProtoReflect.Descriptor instead. -func (*SyncInfoReq) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{0} -} - -func (x *SyncInfoReq) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *SyncInfoReq) GetHpcInfoList() []*HpcInfo { - if x != nil { - return x.HpcInfoList - } - return nil -} - -func (x *SyncInfoReq) GetCloudInfoList() []*CloudInfo { - if x != nil { - return x.CloudInfoList - } - return nil -} - -func (x *SyncInfoReq) GetAiInfoList() []*AiInfo { - if x != nil { - return x.AiInfoList - } - return nil -} - -func (x *SyncInfoReq) GetVmInfoList() []*VmInfo { - if x != nil { - return x.VmInfoList - } - return nil -} - -type AiInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ParticipantId int64 `protobuf:"varint,1,opt,name=participantId,proto3" json:"participantId,omitempty"` - TaskId int64 `protobuf:"varint,2,opt,name=taskId,proto3" json:"taskId,omitempty"` - ProjectId string `protobuf:"bytes,3,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Status string `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` - StartTime string `protobuf:"bytes,6,opt,name=startTime,proto3" json:"startTime,omitempty"` - RunningTime int64 `protobuf:"varint,7,opt,name=runningTime,proto3" json:"runningTime,omitempty"` - Result string `protobuf:"bytes,8,opt,name=result,proto3" json:"result,omitempty"` - JobId string `protobuf:"bytes,9,opt,name=jobId,proto3" json:"jobId,omitempty"` - CreateTime string `protobuf:"bytes,10,opt,name=createTime,proto3" json:"createTime,omitempty"` - ImageUrl string `protobuf:"bytes,11,opt,name=imageUrl,proto3" json:"imageUrl,omitempty"` - Command string `protobuf:"bytes,12,opt,name=command,proto3" json:"command,omitempty"` - FlavorId string `protobuf:"bytes,13,opt,name=flavorId,proto3" json:"flavorId,omitempty"` - SubscriptionId string `protobuf:"bytes,14,opt,name=subscriptionId,proto3" json:"subscriptionId,omitempty"` - ItemVersionId string `protobuf:"bytes,15,opt,name=itemVersionId,proto3" json:"itemVersionId,omitempty"` -} - -func (x *AiInfo) Reset() { - *x = AiInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AiInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AiInfo) ProtoMessage() {} - -func (x *AiInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AiInfo.ProtoReflect.Descriptor instead. -func (*AiInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{1} -} - -func (x *AiInfo) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *AiInfo) GetTaskId() int64 { - if x != nil { - return x.TaskId - } - return 0 -} - -func (x *AiInfo) GetProjectId() string { - if x != nil { - return x.ProjectId - } - return "" -} - -func (x *AiInfo) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *AiInfo) GetStatus() string { - if x != nil { - return x.Status - } - return "" -} - -func (x *AiInfo) GetStartTime() string { - if x != nil { - return x.StartTime - } - return "" -} - -func (x *AiInfo) GetRunningTime() int64 { - if x != nil { - return x.RunningTime - } - return 0 -} - -func (x *AiInfo) GetResult() string { - if x != nil { - return x.Result - } - return "" -} - -func (x *AiInfo) GetJobId() string { - if x != nil { - return x.JobId - } - return "" -} - -func (x *AiInfo) GetCreateTime() string { - if x != nil { - return x.CreateTime - } - return "" -} - -func (x *AiInfo) GetImageUrl() string { - if x != nil { - return x.ImageUrl - } - return "" -} - -func (x *AiInfo) GetCommand() string { - if x != nil { - return x.Command - } - return "" -} - -func (x *AiInfo) GetFlavorId() string { - if x != nil { - return x.FlavorId - } - return "" -} - -func (x *AiInfo) GetSubscriptionId() string { - if x != nil { - return x.SubscriptionId - } - return "" -} - -func (x *AiInfo) GetItemVersionId() string { - if x != nil { - return x.ItemVersionId - } - return "" -} - -type CloudInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Participant int64 `protobuf:"varint,1,opt,name=participant,proto3" json:"participant,omitempty"` - Id int64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` - TaskId int64 `protobuf:"varint,3,opt,name=taskId,proto3" json:"taskId,omitempty"` - ApiVersion string `protobuf:"bytes,4,opt,name=apiVersion,proto3" json:"apiVersion,omitempty"` - Kind string `protobuf:"bytes,5,opt,name=kind,proto3" json:"kind,omitempty"` - Namespace string `protobuf:"bytes,6,opt,name=namespace,proto3" json:"namespace,omitempty"` - Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` - Status string `protobuf:"bytes,11,opt,name=status,proto3" json:"status,omitempty"` - StartTime string `protobuf:"bytes,8,opt,name=startTime,proto3" json:"startTime,omitempty"` - RunningTime int64 `protobuf:"varint,9,opt,name=runningTime,proto3" json:"runningTime,omitempty"` - Result string `protobuf:"bytes,10,opt,name=result,proto3" json:"result,omitempty"` - YamlString string `protobuf:"bytes,12,opt,name=yamlString,proto3" json:"yamlString,omitempty"` -} - -func (x *CloudInfo) Reset() { - *x = CloudInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CloudInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CloudInfo) ProtoMessage() {} - -func (x *CloudInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CloudInfo.ProtoReflect.Descriptor instead. -func (*CloudInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{2} -} - -func (x *CloudInfo) GetParticipant() int64 { - if x != nil { - return x.Participant - } - return 0 -} - -func (x *CloudInfo) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *CloudInfo) GetTaskId() int64 { - if x != nil { - return x.TaskId - } - return 0 -} - -func (x *CloudInfo) GetApiVersion() string { - if x != nil { - return x.ApiVersion - } - return "" -} - -func (x *CloudInfo) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -func (x *CloudInfo) GetNamespace() string { - if x != nil { - return x.Namespace - } - return "" -} - -func (x *CloudInfo) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CloudInfo) GetStatus() string { - if x != nil { - return x.Status - } - return "" -} - -func (x *CloudInfo) GetStartTime() string { - if x != nil { - return x.StartTime - } - return "" -} - -func (x *CloudInfo) GetRunningTime() int64 { - if x != nil { - return x.RunningTime - } - return 0 -} - -func (x *CloudInfo) GetResult() string { - if x != nil { - return x.Result - } - return "" -} - -func (x *CloudInfo) GetYamlString() string { - if x != nil { - return x.YamlString - } - return "" -} - -type VmInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ParticipantId int64 `protobuf:"varint,1,opt,name=participantId,proto3" json:"participantId,omitempty"` - TaskId int64 `protobuf:"varint,2,opt,name=taskId,proto3" json:"taskId,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - FlavorRef string `protobuf:"bytes,4,opt,name=flavor_ref,json=flavorRef,proto3" json:"flavor_ref,omitempty"` - ImageRef string `protobuf:"bytes,5,opt,name=image_ref,json=imageRef,proto3" json:"image_ref,omitempty"` - NetworkUuid string `protobuf:"bytes,6,opt,name=network_uuid,json=networkUuid,proto3" json:"network_uuid,omitempty"` - BlockUuid string `protobuf:"bytes,7,opt,name=block_uuid,json=blockUuid,proto3" json:"block_uuid,omitempty"` - SourceType string `protobuf:"bytes,8,opt,name=source_type,json=sourceType,proto3" json:"source_type,omitempty"` - DeleteOnTermination bool `protobuf:"varint,9,opt,name=delete_on_termination,json=deleteOnTermination,proto3" json:"delete_on_termination,omitempty"` - State string `protobuf:"bytes,10,opt,name=state,proto3" json:"state,omitempty"` -} - -func (x *VmInfo) Reset() { - *x = VmInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VmInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VmInfo) ProtoMessage() {} - -func (x *VmInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VmInfo.ProtoReflect.Descriptor instead. -func (*VmInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{3} -} - -func (x *VmInfo) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *VmInfo) GetTaskId() int64 { - if x != nil { - return x.TaskId - } - return 0 -} - -func (x *VmInfo) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *VmInfo) GetFlavorRef() string { - if x != nil { - return x.FlavorRef - } - return "" -} - -func (x *VmInfo) GetImageRef() string { - if x != nil { - return x.ImageRef - } - return "" -} - -func (x *VmInfo) GetNetworkUuid() string { - if x != nil { - return x.NetworkUuid - } - return "" -} - -func (x *VmInfo) GetBlockUuid() string { - if x != nil { - return x.BlockUuid - } - return "" -} - -func (x *VmInfo) GetSourceType() string { - if x != nil { - return x.SourceType - } - return "" -} - -func (x *VmInfo) GetDeleteOnTermination() bool { - if x != nil { - return x.DeleteOnTermination - } - return false -} - -func (x *VmInfo) GetState() string { - if x != nil { - return x.State - } - return "" -} - -type HpcInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ParticipantId int64 `protobuf:"varint,1,opt,name=participantId,proto3" json:"participantId,omitempty"` - TaskId int64 `protobuf:"varint,2,opt,name=taskId,proto3" json:"taskId,omitempty"` - JobId string `protobuf:"bytes,3,opt,name=jobId,proto3" json:"jobId,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Status string `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` - StartTime string `protobuf:"bytes,6,opt,name=startTime,proto3" json:"startTime,omitempty"` - RunningTime int64 `protobuf:"varint,7,opt,name=runningTime,proto3" json:"runningTime,omitempty"` - Result string `protobuf:"bytes,8,opt,name=result,proto3" json:"result,omitempty"` - WorkDir string `protobuf:"bytes,9,opt,name=workDir,proto3" json:"workDir,omitempty"` - WallTime string `protobuf:"bytes,10,opt,name=wallTime,proto3" json:"wallTime,omitempty"` - CmdScript string `protobuf:"bytes,11,opt,name=cmdScript,proto3" json:"cmdScript,omitempty"` - DerivedEs string `protobuf:"bytes,12,opt,name=derivedEs,proto3" json:"derivedEs,omitempty"` - Cluster string `protobuf:"bytes,13,opt,name=cluster,proto3" json:"cluster,omitempty"` - BlockId string `protobuf:"bytes,14,opt,name=blockId,proto3" json:"blockId,omitempty"` - AllocNodes uint32 `protobuf:"varint,15,opt,name=allocNodes,proto3" json:"allocNodes,omitempty"` - AllocCpu uint32 `protobuf:"varint,16,opt,name=allocCpu,proto3" json:"allocCpu,omitempty"` - Version string `protobuf:"bytes,17,opt,name=version,proto3" json:"version,omitempty"` - Account string `protobuf:"bytes,18,opt,name=account,proto3" json:"account,omitempty"` - ExitCode uint32 `protobuf:"varint,19,opt,name=exitCode,proto3" json:"exitCode,omitempty"` - AssocId uint32 `protobuf:"varint,20,opt,name=assocId,proto3" json:"assocId,omitempty"` - AppType string `protobuf:"bytes,21,opt,name=appType,proto3" json:"appType,omitempty"` - AppName string `protobuf:"bytes,22,opt,name=appName,proto3" json:"appName,omitempty"` - Queue string `protobuf:"bytes,23,opt,name=queue,proto3" json:"queue,omitempty"` - SubmitType string `protobuf:"bytes,24,opt,name=submitType,proto3" json:"submitType,omitempty"` - NNode string `protobuf:"bytes,25,opt,name=nNode,proto3" json:"nNode,omitempty"` - StdOutFile string `protobuf:"bytes,26,opt,name=stdOutFile,proto3" json:"stdOutFile,omitempty"` - StdErrFile string `protobuf:"bytes,27,opt,name=stdErrFile,proto3" json:"stdErrFile,omitempty"` - StdInput string `protobuf:"bytes,28,opt,name=stdInput,proto3" json:"stdInput,omitempty"` - Environment string `protobuf:"bytes,29,opt,name=environment,proto3" json:"environment,omitempty"` -} - -func (x *HpcInfo) Reset() { - *x = HpcInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HpcInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HpcInfo) ProtoMessage() {} - -func (x *HpcInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HpcInfo.ProtoReflect.Descriptor instead. -func (*HpcInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{4} -} - -func (x *HpcInfo) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *HpcInfo) GetTaskId() int64 { - if x != nil { - return x.TaskId - } - return 0 -} - -func (x *HpcInfo) GetJobId() string { - if x != nil { - return x.JobId - } - return "" -} - -func (x *HpcInfo) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *HpcInfo) GetStatus() string { - if x != nil { - return x.Status - } - return "" -} - -func (x *HpcInfo) GetStartTime() string { - if x != nil { - return x.StartTime - } - return "" -} - -func (x *HpcInfo) GetRunningTime() int64 { - if x != nil { - return x.RunningTime - } - return 0 -} - -func (x *HpcInfo) GetResult() string { - if x != nil { - return x.Result - } - return "" -} - -func (x *HpcInfo) GetWorkDir() string { - if x != nil { - return x.WorkDir - } - return "" -} - -func (x *HpcInfo) GetWallTime() string { - if x != nil { - return x.WallTime - } - return "" -} - -func (x *HpcInfo) GetCmdScript() string { - if x != nil { - return x.CmdScript - } - return "" -} - -func (x *HpcInfo) GetDerivedEs() string { - if x != nil { - return x.DerivedEs - } - return "" -} - -func (x *HpcInfo) GetCluster() string { - if x != nil { - return x.Cluster - } - return "" -} - -func (x *HpcInfo) GetBlockId() string { - if x != nil { - return x.BlockId - } - return "" -} - -func (x *HpcInfo) GetAllocNodes() uint32 { - if x != nil { - return x.AllocNodes - } - return 0 -} - -func (x *HpcInfo) GetAllocCpu() uint32 { - if x != nil { - return x.AllocCpu - } - return 0 -} - -func (x *HpcInfo) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *HpcInfo) GetAccount() string { - if x != nil { - return x.Account - } - return "" -} - -func (x *HpcInfo) GetExitCode() uint32 { - if x != nil { - return x.ExitCode - } - return 0 -} - -func (x *HpcInfo) GetAssocId() uint32 { - if x != nil { - return x.AssocId - } - return 0 -} - -func (x *HpcInfo) GetAppType() string { - if x != nil { - return x.AppType - } - return "" -} - -func (x *HpcInfo) GetAppName() string { - if x != nil { - return x.AppName - } - return "" -} - -func (x *HpcInfo) GetQueue() string { - if x != nil { - return x.Queue - } - return "" -} - -func (x *HpcInfo) GetSubmitType() string { - if x != nil { - return x.SubmitType - } - return "" -} - -func (x *HpcInfo) GetNNode() string { - if x != nil { - return x.NNode - } - return "" -} - -func (x *HpcInfo) GetStdOutFile() string { - if x != nil { - return x.StdOutFile - } - return "" -} - -func (x *HpcInfo) GetStdErrFile() string { - if x != nil { - return x.StdErrFile - } - return "" -} - -func (x *HpcInfo) GetStdInput() string { - if x != nil { - return x.StdInput - } - return "" -} - -func (x *HpcInfo) GetEnvironment() string { - if x != nil { - return x.Environment - } - return "" -} - -type SyncInfoResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` -} - -func (x *SyncInfoResp) Reset() { - *x = SyncInfoResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SyncInfoResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncInfoResp) ProtoMessage() {} - -func (x *SyncInfoResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncInfoResp.ProtoReflect.Descriptor instead. -func (*SyncInfoResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{5} -} - -func (x *SyncInfoResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *SyncInfoResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -type InfoListReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ParticipantId int64 `protobuf:"varint,1,opt,name=participantId,proto3" json:"participantId,omitempty"` -} - -func (x *InfoListReq) Reset() { - *x = InfoListReq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InfoListReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InfoListReq) ProtoMessage() {} - -func (x *InfoListReq) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InfoListReq.ProtoReflect.Descriptor instead. -func (*InfoListReq) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{6} -} - -func (x *InfoListReq) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -type InfoListResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - HpcInfoList []*HpcInfo `protobuf:"bytes,1,rep,name=HpcInfoList,proto3" json:"HpcInfoList,omitempty"` - CloudInfoList []*CloudInfo `protobuf:"bytes,2,rep,name=CloudInfoList,proto3" json:"CloudInfoList,omitempty"` - AiInfoList []*AiInfo `protobuf:"bytes,3,rep,name=AiInfoList,proto3" json:"AiInfoList,omitempty"` - VmInfoList []*VmInfo `protobuf:"bytes,4,rep,name=VmInfoList,proto3" json:"VmInfoList,omitempty"` -} - -func (x *InfoListResp) Reset() { - *x = InfoListResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InfoListResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InfoListResp) ProtoMessage() {} - -func (x *InfoListResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InfoListResp.ProtoReflect.Descriptor instead. -func (*InfoListResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{7} -} - -func (x *InfoListResp) GetHpcInfoList() []*HpcInfo { - if x != nil { - return x.HpcInfoList - } - return nil -} - -func (x *InfoListResp) GetCloudInfoList() []*CloudInfo { - if x != nil { - return x.CloudInfoList - } - return nil -} - -func (x *InfoListResp) GetAiInfoList() []*AiInfo { - if x != nil { - return x.AiInfoList - } - return nil -} - -func (x *InfoListResp) GetVmInfoList() []*VmInfo { - if x != nil { - return x.VmInfoList - } - return nil -} - -// participantTenant 租户信息 -type ParticipantTenant struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - TenantName string `protobuf:"bytes,1,opt,name=tenantName,proto3" json:"tenantName,omitempty"` // 租户名称 -} - -func (x *ParticipantTenant) Reset() { - *x = ParticipantTenant{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantTenant) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantTenant) ProtoMessage() {} - -func (x *ParticipantTenant) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantTenant.ProtoReflect.Descriptor instead. -func (*ParticipantTenant) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{8} -} - -func (x *ParticipantTenant) GetTenantName() string { - if x != nil { - return x.TenantName - } - return "" -} - -// 集群标签 -type ParticipantLabel struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // id - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` // 标签名 - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` // 标签值 -} - -func (x *ParticipantLabel) Reset() { - *x = ParticipantLabel{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantLabel) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantLabel) ProtoMessage() {} - -func (x *ParticipantLabel) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantLabel.ProtoReflect.Descriptor instead. -func (*ParticipantLabel) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{9} -} - -func (x *ParticipantLabel) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ParticipantLabel) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *ParticipantLabel) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -type HealthCheckResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - MessageStatus MessageStatus `protobuf:"varint,1,opt,name=messageStatus,proto3,enum=pcmCore.MessageStatus" json:"messageStatus,omitempty"` - Code int64 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,3,opt,name=msg,proto3" json:"msg,omitempty"` -} - -func (x *HealthCheckResp) Reset() { - *x = HealthCheckResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HealthCheckResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HealthCheckResp) ProtoMessage() {} - -func (x *HealthCheckResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HealthCheckResp.ProtoReflect.Descriptor instead. -func (*HealthCheckResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{10} -} - -func (x *HealthCheckResp) GetMessageStatus() MessageStatus { - if x != nil { - return x.MessageStatus - } - return MessageStatus_FAIL -} - -func (x *HealthCheckResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *HealthCheckResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -type ParticipantPhyResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - ParticipantId int64 `protobuf:"varint,3,opt,name=participantId,proto3" json:"participantId,omitempty"` // participant 唯一标识 -} - -func (x *ParticipantPhyResp) Reset() { - *x = ParticipantPhyResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantPhyResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantPhyResp) ProtoMessage() {} - -func (x *ParticipantPhyResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantPhyResp.ProtoReflect.Descriptor instead. -func (*ParticipantPhyResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{11} -} - -func (x *ParticipantPhyResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *ParticipantPhyResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *ParticipantPhyResp) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -// 集群静态信息返回 -type ListParticipantPhyResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - ParticipantPhys []*ParticipantPhyReq `protobuf:"bytes,3,rep,name=ParticipantPhys,proto3" json:"ParticipantPhys,omitempty"` -} - -func (x *ListParticipantPhyResp) Reset() { - *x = ListParticipantPhyResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListParticipantPhyResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListParticipantPhyResp) ProtoMessage() {} - -func (x *ListParticipantPhyResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListParticipantPhyResp.ProtoReflect.Descriptor instead. -func (*ListParticipantPhyResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{12} -} - -func (x *ListParticipantPhyResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *ListParticipantPhyResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *ListParticipantPhyResp) GetParticipantPhys() []*ParticipantPhyReq { - if x != nil { - return x.ParticipantPhys - } - return nil -} - -// participantPhy 静态信息 -type ParticipantPhyReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // 名称 - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // 地址 - NetworkType string `protobuf:"bytes,4,opt,name=networkType,proto3" json:"networkType,omitempty"` // 集群网络类型 - NetworkBandwidth string `protobuf:"bytes,5,opt,name=networkBandwidth,proto3" json:"networkBandwidth,omitempty"` // 集群网络带宽 - StorageType string `protobuf:"bytes,6,opt,name=storageType,proto3" json:"storageType,omitempty"` // 集群存储类型 - StorageSpace string `protobuf:"bytes,7,opt,name=storageSpace,proto3" json:"storageSpace,omitempty"` // 集群存储空间 - StorageAvailSpace string `protobuf:"bytes,8,opt,name=storageAvailSpace,proto3" json:"storageAvailSpace,omitempty"` // 集群存储可用空间 - StorageBandwidth string `protobuf:"bytes,9,opt,name=storageBandwidth,proto3" json:"storageBandwidth,omitempty"` // 集群存储带宽 - Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` // 参与者类型:CLOUD-数算集群;AI-智算集群;HPC-超算集群 - TenantId int64 `protobuf:"varint,11,opt,name=tenantId,proto3" json:"tenantId,omitempty"` // 租户id - TenantName string `protobuf:"bytes,12,opt,name=tenantName,proto3" json:"tenantName,omitempty"` // 租户名称 - NodeInfo []*NodePhyInfo `protobuf:"bytes,13,rep,name=nodeInfo,proto3" json:"nodeInfo,omitempty"` // 节点信息 - ParticipantId int64 `protobuf:"varint,14,opt,name=participantId,proto3" json:"participantId,omitempty"` // participant id - LabelInfo []*ParticipantLabel `protobuf:"bytes,15,rep,name=labelInfo,proto3" json:"labelInfo,omitempty"` // 标签信息 - QueueInfo []*QueuePhyInfo `protobuf:"bytes,16,rep,name=queueInfo,proto3" json:"queueInfo,omitempty"` // 队列信息 - Id int64 `protobuf:"varint,17,opt,name=id,proto3" json:"id,omitempty"` // id - MetricsUrl string `protobuf:"bytes,18,opt,name=MetricsUrl,proto3" json:"MetricsUrl,omitempty"` //监控url - RpcAddress string `protobuf:"bytes,19,opt,name=RpcAddress,proto3" json:"RpcAddress,omitempty"` - Token string `protobuf:"bytes,20,opt,name=Token,proto3" json:"Token,omitempty"` //token -} - -func (x *ParticipantPhyReq) Reset() { - *x = ParticipantPhyReq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantPhyReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantPhyReq) ProtoMessage() {} - -func (x *ParticipantPhyReq) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantPhyReq.ProtoReflect.Descriptor instead. -func (*ParticipantPhyReq) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{13} -} - -func (x *ParticipantPhyReq) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ParticipantPhyReq) GetAddress() string { - if x != nil { - return x.Address - } - return "" -} - -func (x *ParticipantPhyReq) GetNetworkType() string { - if x != nil { - return x.NetworkType - } - return "" -} - -func (x *ParticipantPhyReq) GetNetworkBandwidth() string { - if x != nil { - return x.NetworkBandwidth - } - return "" -} - -func (x *ParticipantPhyReq) GetStorageType() string { - if x != nil { - return x.StorageType - } - return "" -} - -func (x *ParticipantPhyReq) GetStorageSpace() string { - if x != nil { - return x.StorageSpace - } - return "" -} - -func (x *ParticipantPhyReq) GetStorageAvailSpace() string { - if x != nil { - return x.StorageAvailSpace - } - return "" -} - -func (x *ParticipantPhyReq) GetStorageBandwidth() string { - if x != nil { - return x.StorageBandwidth - } - return "" -} - -func (x *ParticipantPhyReq) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *ParticipantPhyReq) GetTenantId() int64 { - if x != nil { - return x.TenantId - } - return 0 -} - -func (x *ParticipantPhyReq) GetTenantName() string { - if x != nil { - return x.TenantName - } - return "" -} - -func (x *ParticipantPhyReq) GetNodeInfo() []*NodePhyInfo { - if x != nil { - return x.NodeInfo - } - return nil -} - -func (x *ParticipantPhyReq) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *ParticipantPhyReq) GetLabelInfo() []*ParticipantLabel { - if x != nil { - return x.LabelInfo - } - return nil -} - -func (x *ParticipantPhyReq) GetQueueInfo() []*QueuePhyInfo { - if x != nil { - return x.QueueInfo - } - return nil -} - -func (x *ParticipantPhyReq) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ParticipantPhyReq) GetMetricsUrl() string { - if x != nil { - return x.MetricsUrl - } - return "" -} - -func (x *ParticipantPhyReq) GetRpcAddress() string { - if x != nil { - return x.RpcAddress - } - return "" -} - -func (x *ParticipantPhyReq) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -// NodePhyInfo 节点信息 -type NodePhyInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - NodeName string `protobuf:"bytes,2,opt,name=nodeName,proto3" json:"nodeName,omitempty"` // 节点名称 - OsName string `protobuf:"bytes,3,opt,name=osName,proto3" json:"osName,omitempty"` // 系统名称 - OsVersion string `protobuf:"bytes,4,opt,name=osVersion,proto3" json:"osVersion,omitempty"` // 系统版本 - ArchType string `protobuf:"bytes,5,opt,name=archType,proto3" json:"archType,omitempty"` // 架构类型 - ArchName string `protobuf:"bytes,6,opt,name=archName,proto3" json:"archName,omitempty"` // 架构名称 - ArchFreq string `protobuf:"bytes,7,opt,name=archFreq,proto3" json:"archFreq,omitempty"` // 架构频率 -} - -func (x *NodePhyInfo) Reset() { - *x = NodePhyInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NodePhyInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NodePhyInfo) ProtoMessage() {} - -func (x *NodePhyInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NodePhyInfo.ProtoReflect.Descriptor instead. -func (*NodePhyInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{14} -} - -func (x *NodePhyInfo) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *NodePhyInfo) GetNodeName() string { - if x != nil { - return x.NodeName - } - return "" -} - -func (x *NodePhyInfo) GetOsName() string { - if x != nil { - return x.OsName - } - return "" -} - -func (x *NodePhyInfo) GetOsVersion() string { - if x != nil { - return x.OsVersion - } - return "" -} - -func (x *NodePhyInfo) GetArchType() string { - if x != nil { - return x.ArchType - } - return "" -} - -func (x *NodePhyInfo) GetArchName() string { - if x != nil { - return x.ArchName - } - return "" -} - -func (x *NodePhyInfo) GetArchFreq() string { - if x != nil { - return x.ArchFreq - } - return "" -} - -// QueuePhyInfo 队列信息 -type QueuePhyInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // id - AclHosts string `protobuf:"bytes,2,opt,name=aclHosts,proto3" json:"aclHosts,omitempty"` // 可用节点,多个节点用逗号隔开 - QueueId string `protobuf:"bytes,3,opt,name=queueId,proto3" json:"queueId,omitempty"` // 队列名称 - Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"` // 队列名称 - QueueName string `protobuf:"bytes,5,opt,name=queueName,proto3" json:"queueName,omitempty"` //队列名称 - QueNodes string `protobuf:"bytes,6,opt,name=queNodes,proto3" json:"queNodes,omitempty"` // 队列节点总数 - QueMinNodect string `protobuf:"bytes,7,opt,name=queMinNodect,proto3" json:"queMinNodect,omitempty"` // 队列最小节点数 - QueMaxNgpus string `protobuf:"bytes,8,opt,name=queMaxNgpus,proto3" json:"queMaxNgpus,omitempty"` // 队列最大GPU卡数 - QueMaxPpn string `protobuf:"bytes,9,opt,name=queMaxPpn,proto3" json:"queMaxPpn,omitempty"` // 使用该队列作业最大CPU核心数 - QueChargeRate string `protobuf:"bytes,10,opt,name=queChargeRate,proto3" json:"queChargeRate,omitempty"` // 费率 - QueMaxNcpus string `protobuf:"bytes,11,opt,name=queMaxNcpus,proto3" json:"queMaxNcpus,omitempty"` // 用户最大可用核心数 - QueMaxNdcus string `protobuf:"bytes,12,opt,name=queMaxNdcus,proto3" json:"queMaxNdcus,omitempty"` // 队列总DCU卡数 - QueMinNcpus string `protobuf:"bytes,13,opt,name=queMinNcpus,proto3" json:"queMinNcpus,omitempty"` // 队列最小CPU核数 - QueFreeNodes string `protobuf:"bytes,14,opt,name=queFreeNodes,proto3" json:"queFreeNodes,omitempty"` // 队列空闲节点数 - QueMaxNodect string `protobuf:"bytes,15,opt,name=queMaxNodect,proto3" json:"queMaxNodect,omitempty"` // 队列作业最大节点数 - QueMaxGpuPN string `protobuf:"bytes,16,opt,name=queMaxGpuPN,proto3" json:"queMaxGpuPN,omitempty"` // 队列单作业最大GPU卡数 - QueMaxWalltime string `protobuf:"bytes,17,opt,name=queMaxWalltime,proto3" json:"queMaxWalltime,omitempty"` // 队列最大运行时间 - QueMaxDcuPN string `protobuf:"bytes,18,opt,name=queMaxDcuPN,proto3" json:"queMaxDcuPN,omitempty"` // 队列单作业最大DCU卡数 - QueNcpus string `protobuf:"bytes,19,opt,name=queNcpus,proto3" json:"queNcpus,omitempty"` //队列cpu数 - QueFreeNcpus string `protobuf:"bytes,20,opt,name=queFreeNcpus,proto3" json:"queFreeNcpus,omitempty"` //队列空闲cpu数 -} - -func (x *QueuePhyInfo) Reset() { - *x = QueuePhyInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QueuePhyInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QueuePhyInfo) ProtoMessage() {} - -func (x *QueuePhyInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use QueuePhyInfo.ProtoReflect.Descriptor instead. -func (*QueuePhyInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{15} -} - -func (x *QueuePhyInfo) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *QueuePhyInfo) GetAclHosts() string { - if x != nil { - return x.AclHosts - } - return "" -} - -func (x *QueuePhyInfo) GetQueueId() string { - if x != nil { - return x.QueueId - } - return "" -} - -func (x *QueuePhyInfo) GetText() string { - if x != nil { - return x.Text - } - return "" -} - -func (x *QueuePhyInfo) GetQueueName() string { - if x != nil { - return x.QueueName - } - return "" -} - -func (x *QueuePhyInfo) GetQueNodes() string { - if x != nil { - return x.QueNodes - } - return "" -} - -func (x *QueuePhyInfo) GetQueMinNodect() string { - if x != nil { - return x.QueMinNodect - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxNgpus() string { - if x != nil { - return x.QueMaxNgpus - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxPpn() string { - if x != nil { - return x.QueMaxPpn - } - return "" -} - -func (x *QueuePhyInfo) GetQueChargeRate() string { - if x != nil { - return x.QueChargeRate - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxNcpus() string { - if x != nil { - return x.QueMaxNcpus - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxNdcus() string { - if x != nil { - return x.QueMaxNdcus - } - return "" -} - -func (x *QueuePhyInfo) GetQueMinNcpus() string { - if x != nil { - return x.QueMinNcpus - } - return "" -} - -func (x *QueuePhyInfo) GetQueFreeNodes() string { - if x != nil { - return x.QueFreeNodes - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxNodect() string { - if x != nil { - return x.QueMaxNodect - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxGpuPN() string { - if x != nil { - return x.QueMaxGpuPN - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxWalltime() string { - if x != nil { - return x.QueMaxWalltime - } - return "" -} - -func (x *QueuePhyInfo) GetQueMaxDcuPN() string { - if x != nil { - return x.QueMaxDcuPN - } - return "" -} - -func (x *QueuePhyInfo) GetQueNcpus() string { - if x != nil { - return x.QueNcpus - } - return "" -} - -func (x *QueuePhyInfo) GetQueFreeNcpus() string { - if x != nil { - return x.QueFreeNcpus - } - return "" -} - -// ParticipantHeartbeatReq 心跳请求 -type ParticipantHeartbeatReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ParticipantId int64 `protobuf:"varint,1,opt,name=participantId,proto3" json:"participantId,omitempty"` // participantId - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` -} - -func (x *ParticipantHeartbeatReq) Reset() { - *x = ParticipantHeartbeatReq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantHeartbeatReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantHeartbeatReq) ProtoMessage() {} - -func (x *ParticipantHeartbeatReq) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantHeartbeatReq.ProtoReflect.Descriptor instead. -func (*ParticipantHeartbeatReq) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{16} -} - -func (x *ParticipantHeartbeatReq) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *ParticipantHeartbeatReq) GetAddress() string { - if x != nil { - return x.Address - } - return "" -} - -// ParticipantAvailInfo Participant可用信息 -type ParticipantAvailReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // id - AvailStorageSpace int64 `protobuf:"varint,2,opt,name=availStorageSpace,proto3" json:"availStorageSpace,omitempty"` // 集群存储可用空间 - UserNum int64 `protobuf:"varint,3,opt,name=userNum,proto3" json:"userNum,omitempty"` // 用户数量 - PendingJobNum int64 `protobuf:"varint,4,opt,name=pendingJobNum,proto3" json:"pendingJobNum,omitempty"` // 待处理作业数量 - RunningJobNum int64 `protobuf:"varint,5,opt,name=runningJobNum,proto3" json:"runningJobNum,omitempty"` // 运行作业数量 - ParticipantId int64 `protobuf:"varint,6,opt,name=participantId,proto3" json:"participantId,omitempty"` // 集群静态信息id - NodeAvailInfo []*NodeAvailInfo `protobuf:"bytes,7,rep,name=nodeAvailInfo,proto3" json:"nodeAvailInfo,omitempty"` // 节点可用信息 -} - -func (x *ParticipantAvailReq) Reset() { - *x = ParticipantAvailReq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantAvailReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantAvailReq) ProtoMessage() {} - -func (x *ParticipantAvailReq) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantAvailReq.ProtoReflect.Descriptor instead. -func (*ParticipantAvailReq) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{17} -} - -func (x *ParticipantAvailReq) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ParticipantAvailReq) GetAvailStorageSpace() int64 { - if x != nil { - return x.AvailStorageSpace - } - return 0 -} - -func (x *ParticipantAvailReq) GetUserNum() int64 { - if x != nil { - return x.UserNum - } - return 0 -} - -func (x *ParticipantAvailReq) GetPendingJobNum() int64 { - if x != nil { - return x.PendingJobNum - } - return 0 -} - -func (x *ParticipantAvailReq) GetRunningJobNum() int64 { - if x != nil { - return x.RunningJobNum - } - return 0 -} - -func (x *ParticipantAvailReq) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *ParticipantAvailReq) GetNodeAvailInfo() []*NodeAvailInfo { - if x != nil { - return x.NodeAvailInfo - } - return nil -} - -// NodeAvailInfo 节点可用信息 -type NodeAvailInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // id - NodeName string `protobuf:"bytes,2,opt,name=nodeName,proto3" json:"nodeName,omitempty"` // 节点名称 - CpuTotal int64 `protobuf:"varint,3,opt,name=cpuTotal,proto3" json:"cpuTotal,omitempty"` // cpu核数 - CpuUsable float64 `protobuf:"fixed64,4,opt,name=cpuUsable,proto3" json:"cpuUsable,omitempty"` // cpu可用率 - DiskTotal int64 `protobuf:"varint,5,opt,name=diskTotal,proto3" json:"diskTotal,omitempty"` // 磁盘空间 - DiskAvail int64 `protobuf:"varint,6,opt,name=diskAvail,proto3" json:"diskAvail,omitempty"` // 磁盘可用空间 - MemTotal int64 `protobuf:"varint,7,opt,name=memTotal,proto3" json:"memTotal,omitempty"` // 内存总数 - MemAvail int64 `protobuf:"varint,8,opt,name=memAvail,proto3" json:"memAvail,omitempty"` // 内存可用数 - GpuTotal int64 `protobuf:"varint,9,opt,name=gpuTotal,proto3" json:"gpuTotal,omitempty"` // gpu总数 - GpuAvail int64 `protobuf:"varint,10,opt,name=gpuAvail,proto3" json:"gpuAvail,omitempty"` // gpu可用数 - ParticipantId int64 `protobuf:"varint,11,opt,name=participantId,proto3" json:"participantId,omitempty"` // 集群动态信息id -} - -func (x *NodeAvailInfo) Reset() { - *x = NodeAvailInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NodeAvailInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NodeAvailInfo) ProtoMessage() {} - -func (x *NodeAvailInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[18] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NodeAvailInfo.ProtoReflect.Descriptor instead. -func (*NodeAvailInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{18} -} - -func (x *NodeAvailInfo) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *NodeAvailInfo) GetNodeName() string { - if x != nil { - return x.NodeName - } - return "" -} - -func (x *NodeAvailInfo) GetCpuTotal() int64 { - if x != nil { - return x.CpuTotal - } - return 0 -} - -func (x *NodeAvailInfo) GetCpuUsable() float64 { - if x != nil { - return x.CpuUsable - } - return 0 -} - -func (x *NodeAvailInfo) GetDiskTotal() int64 { - if x != nil { - return x.DiskTotal - } - return 0 -} - -func (x *NodeAvailInfo) GetDiskAvail() int64 { - if x != nil { - return x.DiskAvail - } - return 0 -} - -func (x *NodeAvailInfo) GetMemTotal() int64 { - if x != nil { - return x.MemTotal - } - return 0 -} - -func (x *NodeAvailInfo) GetMemAvail() int64 { - if x != nil { - return x.MemAvail - } - return 0 -} - -func (x *NodeAvailInfo) GetGpuTotal() int64 { - if x != nil { - return x.GpuTotal - } - return 0 -} - -func (x *NodeAvailInfo) GetGpuAvail() int64 { - if x != nil { - return x.GpuAvail - } - return 0 -} - -func (x *NodeAvailInfo) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -// 集群可用信息 -type ListParticipantAvailResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - ParticipantAvails []*ParticipantAvailReq `protobuf:"bytes,3,rep,name=ParticipantAvails,proto3" json:"ParticipantAvails,omitempty"` -} - -func (x *ListParticipantAvailResp) Reset() { - *x = ListParticipantAvailResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListParticipantAvailResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListParticipantAvailResp) ProtoMessage() {} - -func (x *ListParticipantAvailResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[19] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListParticipantAvailResp.ProtoReflect.Descriptor instead. -func (*ListParticipantAvailResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{19} -} - -func (x *ListParticipantAvailResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *ListParticipantAvailResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *ListParticipantAvailResp) GetParticipantAvails() []*ParticipantAvailReq { - if x != nil { - return x.ParticipantAvails - } - return nil -} - -type ParticipantResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` -} - -func (x *ParticipantResp) Reset() { - *x = ParticipantResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantResp) ProtoMessage() {} - -func (x *ParticipantResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[20] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantResp.ProtoReflect.Descriptor instead. -func (*ParticipantResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{20} -} - -func (x *ParticipantResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *ParticipantResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -type ParticipantServiceResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - Data []*ClientInfo `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"` -} - -func (x *ParticipantServiceResp) Reset() { - *x = ParticipantServiceResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParticipantServiceResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParticipantServiceResp) ProtoMessage() {} - -func (x *ParticipantServiceResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[21] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParticipantServiceResp.ProtoReflect.Descriptor instead. -func (*ParticipantServiceResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{21} -} - -func (x *ParticipantServiceResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *ParticipantServiceResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *ParticipantServiceResp) GetData() []*ClientInfo { - if x != nil { - return x.Data - } - return nil -} - -type ClientInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // @gotags: redis:"address" - ParticipantId int64 `protobuf:"varint,2,opt,name=participantId,proto3" json:"participantId,omitempty"` // @gotags: redis:"participantId" - ClientState string `protobuf:"bytes,3,opt,name=clientState,proto3" json:"clientState,omitempty"` // @gotags: redis:"clientState" - LastHeartbeat int64 `protobuf:"varint,4,opt,name=lastHeartbeat,proto3" json:"lastHeartbeat,omitempty"` // @gotags: redis:"lastHeartbeat" -} - -func (x *ClientInfo) Reset() { - *x = ClientInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ClientInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ClientInfo) ProtoMessage() {} - -func (x *ClientInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[22] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ClientInfo.ProtoReflect.Descriptor instead. -func (*ClientInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{22} -} - -func (x *ClientInfo) GetAddress() string { - if x != nil { - return x.Address - } - return "" -} - -func (x *ClientInfo) GetParticipantId() int64 { - if x != nil { - return x.ParticipantId - } - return 0 -} - -func (x *ClientInfo) GetClientState() string { - if x != nil { - return x.ClientState - } - return "" -} - -func (x *ClientInfo) GetLastHeartbeat() int64 { - if x != nil { - return x.LastHeartbeat - } - return 0 -} - -type TenantInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - TenantName string `protobuf:"bytes,2,opt,name=tenantName,proto3" json:"tenantName,omitempty"` - TenantDesc string `protobuf:"bytes,3,opt,name=tenantDesc,proto3" json:"tenantDesc,omitempty"` -} - -func (x *TenantInfo) Reset() { - *x = TenantInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TenantInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TenantInfo) ProtoMessage() {} - -func (x *TenantInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[23] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TenantInfo.ProtoReflect.Descriptor instead. -func (*TenantInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{23} -} - -func (x *TenantInfo) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *TenantInfo) GetTenantName() string { - if x != nil { - return x.TenantName - } - return "" -} - -func (x *TenantInfo) GetTenantDesc() string { - if x != nil { - return x.TenantDesc - } - return "" -} - -type TenantResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` -} - -func (x *TenantResp) Reset() { - *x = TenantResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TenantResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TenantResp) ProtoMessage() {} - -func (x *TenantResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[24] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TenantResp.ProtoReflect.Descriptor instead. -func (*TenantResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{24} -} - -func (x *TenantResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *TenantResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *TenantResp) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type ListTenantResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` - TenantInfos []*TenantInfo `protobuf:"bytes,3,rep,name=tenantInfos,proto3" json:"tenantInfos,omitempty"` -} - -func (x *ListTenantResp) Reset() { - *x = ListTenantResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListTenantResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListTenantResp) ProtoMessage() {} - -func (x *ListTenantResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[25] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListTenantResp.ProtoReflect.Descriptor instead. -func (*ListTenantResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{25} -} - -func (x *ListTenantResp) GetCode() int64 { - if x != nil { - return x.Code - } - return 0 -} - -func (x *ListTenantResp) GetMsg() string { - if x != nil { - return x.Msg - } - return "" -} - -func (x *ListTenantResp) GetTenantInfos() []*TenantInfo { - if x != nil { - return x.TenantInfos - } - return nil -} - -type ApplyListReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ApplyListReq) Reset() { - *x = ApplyListReq{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyListReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyListReq) ProtoMessage() {} - -func (x *ApplyListReq) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[26] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyListReq.ProtoReflect.Descriptor instead. -func (*ApplyListReq) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{26} -} - -type ApplyListResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - InfoList []*ApplyInfo `protobuf:"bytes,1,rep,name=infoList,proto3" json:"infoList,omitempty"` -} - -func (x *ApplyListResp) Reset() { - *x = ApplyListResp{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyListResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyListResp) ProtoMessage() {} - -func (x *ApplyListResp) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[27] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyListResp.ProtoReflect.Descriptor instead. -func (*ApplyListResp) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{27} -} - -func (x *ApplyListResp) GetInfoList() []*ApplyInfo { - if x != nil { - return x.InfoList - } - return nil -} - -type ApplyInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ParticipantName string `protobuf:"bytes,1,opt,name=participantName,proto3" json:"participantName,omitempty"` - YamlString string `protobuf:"bytes,2,opt,name=yamlString,proto3" json:"yamlString,omitempty"` - Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Kind string `protobuf:"bytes,5,opt,name=kind,proto3" json:"kind,omitempty"` -} - -func (x *ApplyInfo) Reset() { - *x = ApplyInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_pcmCore_proto_msgTypes[28] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyInfo) ProtoMessage() {} - -func (x *ApplyInfo) ProtoReflect() protoreflect.Message { - mi := &file_pcmCore_proto_msgTypes[28] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyInfo.ProtoReflect.Descriptor instead. -func (*ApplyInfo) Descriptor() ([]byte, []int) { - return file_pcmCore_proto_rawDescGZIP(), []int{28} -} - -func (x *ApplyInfo) GetParticipantName() string { - if x != nil { - return x.ParticipantName - } - return "" -} - -func (x *ApplyInfo) GetYamlString() string { - if x != nil { - return x.YamlString - } - return "" -} - -func (x *ApplyInfo) GetNamespace() string { - if x != nil { - return x.Namespace - } - return "" -} - -func (x *ApplyInfo) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ApplyInfo) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -var File_pcmCore_proto protoreflect.FileDescriptor - -var file_pcmCore_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x22, 0x83, 0x02, 0x0a, 0x0b, 0x53, 0x79, 0x6e, - 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, - 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x32, - 0x0a, 0x0b, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x48, 0x70, - 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, - 0x73, 0x74, 0x12, 0x38, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c, - 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x63, 0x6d, 0x43, - 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x43, - 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x0a, - 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x69, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x0a, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x0a, - 0x0a, 0x56, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x6d, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x0a, 0x56, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xbf, - 0x03, 0x0a, 0x06, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, - 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, - 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, - 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, - 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6a, 0x6f, - 0x62, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, - 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x18, 0x0a, 0x07, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x6c, 0x61, 0x76, 0x6f, 0x72, - 0x49, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x6c, 0x61, 0x76, 0x6f, 0x72, - 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x69, 0x74, - 0x65, 0x6d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0d, 0x69, 0x74, 0x65, 0x6d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x22, 0xcb, 0x02, 0x0a, 0x09, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x20, - 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x69, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, - 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, - 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, - 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x54, - 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, - 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1e, - 0x0a, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x0c, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xc3, - 0x02, 0x0a, 0x06, 0x56, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, - 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, - 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x66, - 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x66, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x52, 0x65, 0x66, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6d, - 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, - 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x66, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x55, 0x75, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x55, 0x75, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x64, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x5f, 0x6f, 0x6e, 0x5f, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x64, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x4f, 0x6e, 0x54, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, - 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x22, 0xab, 0x06, 0x0a, 0x07, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, - 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, - 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, - 0x6f, 0x62, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x20, - 0x0a, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, - 0x44, 0x69, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, - 0x69, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x77, 0x61, 0x6c, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x77, 0x61, 0x6c, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1c, - 0x0a, 0x09, 0x63, 0x6d, 0x64, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x63, 0x6d, 0x64, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x1c, 0x0a, 0x09, - 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x45, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x45, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x18, - 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x1e, - 0x0a, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1a, - 0x0a, 0x08, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x43, 0x70, 0x75, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x08, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x43, 0x70, 0x75, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, - 0x0a, 0x08, 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x08, 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x73, - 0x73, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x61, 0x73, 0x73, - 0x6f, 0x63, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x54, 0x79, 0x70, 0x65, 0x18, - 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x75, - 0x65, 0x18, 0x17, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x75, 0x65, 0x12, 0x1e, - 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x18, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6e, - 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x64, 0x4f, 0x75, 0x74, 0x46, 0x69, - 0x6c, 0x65, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x64, 0x4f, 0x75, 0x74, - 0x46, 0x69, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x64, 0x45, 0x72, 0x72, 0x46, 0x69, - 0x6c, 0x65, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x64, 0x45, 0x72, 0x72, - 0x46, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x74, 0x64, 0x49, 0x6e, 0x70, 0x75, 0x74, - 0x18, 0x1c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x74, 0x64, 0x49, 0x6e, 0x70, 0x75, 0x74, - 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, - 0x1d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, - 0x6e, 0x74, 0x22, 0x34, 0x0a, 0x0c, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x33, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, - 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, - 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x22, 0xde, 0x01, - 0x0a, 0x0c, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x32, - 0x0a, 0x0b, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x48, 0x70, - 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x48, 0x70, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, - 0x73, 0x74, 0x12, 0x38, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c, - 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x63, 0x6d, 0x43, - 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x43, - 0x6c, 0x6f, 0x75, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x0a, - 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x69, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x0a, 0x41, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x0a, - 0x0a, 0x56, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x6d, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x0a, 0x56, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x33, - 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x54, 0x65, 0x6e, - 0x61, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, - 0x61, 0x6d, 0x65, 0x22, 0x4a, 0x0a, 0x10, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, - 0x6e, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, - 0x75, 0x0a, 0x0f, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x3c, 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x70, 0x63, 0x6d, 0x43, - 0x6f, 0x72, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, - 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x60, 0x0a, 0x12, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, - 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, - 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, - 0x73, 0x67, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, - 0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, - 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x84, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x73, - 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x44, 0x0a, 0x0f, 0x50, 0x61, 0x72, - 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, - 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x71, 0x52, 0x0f, - 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x73, 0x22, - 0xab, 0x05, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, - 0x68, 0x79, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, 0x79, - 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, - 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x10, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, - 0x68, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x70, - 0x61, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, - 0x67, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x11, 0x73, 0x74, 0x6f, 0x72, 0x61, - 0x67, 0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x53, 0x70, 0x61, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x11, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, - 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x10, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, - 0x68, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, - 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, - 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x30, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0d, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4e, 0x6f, - 0x64, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, - 0x6e, 0x74, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, - 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x37, 0x0a, 0x09, 0x6c, 0x61, 0x62, - 0x65, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, - 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, - 0x6e, 0x74, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x52, 0x09, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x09, 0x71, 0x75, 0x65, 0x75, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x18, - 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, - 0x51, 0x75, 0x65, 0x75, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x71, 0x75, - 0x65, 0x75, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x11, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x4d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x55, 0x72, 0x6c, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x4d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x73, 0x55, 0x72, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x70, 0x63, 0x41, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x52, 0x70, 0x63, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xc3, 0x01, - 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, - 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x73, 0x4e, - 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x73, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x1a, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x61, - 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, - 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x46, - 0x72, 0x65, 0x71, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x46, - 0x72, 0x65, 0x71, 0x22, 0x86, 0x05, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x75, 0x65, 0x50, 0x68, 0x79, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x63, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x63, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x73, - 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x75, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x71, 0x75, 0x65, 0x75, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, - 0x78, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1c, - 0x0a, 0x09, 0x71, 0x75, 0x65, 0x75, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x71, 0x75, 0x65, 0x75, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, - 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x71, 0x75, 0x65, 0x4d, - 0x69, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x63, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x71, 0x75, 0x65, 0x4d, 0x69, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x63, 0x74, 0x12, 0x20, 0x0a, 0x0b, - 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x4e, 0x67, 0x70, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x4e, 0x67, 0x70, 0x75, 0x73, 0x12, 0x1c, - 0x0a, 0x09, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x50, 0x70, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x50, 0x70, 0x6e, 0x12, 0x24, 0x0a, 0x0d, - 0x71, 0x75, 0x65, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x43, 0x68, 0x61, 0x72, 0x67, 0x65, 0x52, 0x61, - 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x4e, 0x63, 0x70, 0x75, - 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x4e, - 0x63, 0x70, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x4e, 0x64, - 0x63, 0x75, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, - 0x78, 0x4e, 0x64, 0x63, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x69, 0x6e, - 0x4e, 0x63, 0x70, 0x75, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x71, 0x75, 0x65, - 0x4d, 0x69, 0x6e, 0x4e, 0x63, 0x70, 0x75, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x71, 0x75, 0x65, 0x46, - 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x71, 0x75, 0x65, 0x46, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, - 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x4e, 0x6f, 0x64, 0x65, 0x63, 0x74, 0x18, 0x0f, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x4e, 0x6f, 0x64, 0x65, 0x63, 0x74, - 0x12, 0x20, 0x0a, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x47, 0x70, 0x75, 0x50, 0x4e, 0x18, - 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x47, 0x70, 0x75, - 0x50, 0x4e, 0x12, 0x26, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x57, 0x61, 0x6c, 0x6c, - 0x74, 0x69, 0x6d, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x71, 0x75, 0x65, 0x4d, - 0x61, 0x78, 0x57, 0x61, 0x6c, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x71, 0x75, - 0x65, 0x4d, 0x61, 0x78, 0x44, 0x63, 0x75, 0x50, 0x4e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x71, 0x75, 0x65, 0x4d, 0x61, 0x78, 0x44, 0x63, 0x75, 0x50, 0x4e, 0x12, 0x1a, 0x0a, 0x08, - 0x71, 0x75, 0x65, 0x4e, 0x63, 0x70, 0x75, 0x73, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x71, 0x75, 0x65, 0x4e, 0x63, 0x70, 0x75, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x71, 0x75, 0x65, 0x46, - 0x72, 0x65, 0x65, 0x4e, 0x63, 0x70, 0x75, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x71, 0x75, 0x65, 0x46, 0x72, 0x65, 0x65, 0x4e, 0x63, 0x70, 0x75, 0x73, 0x22, 0x59, 0x0a, 0x17, - 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, - 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, - 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x9d, 0x02, 0x0a, 0x13, 0x50, 0x61, 0x72, 0x74, - 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x2c, 0x0a, 0x11, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, - 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x61, 0x76, 0x61, 0x69, - 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x75, 0x73, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x6e, 0x64, 0x69, - 0x6e, 0x67, 0x4a, 0x6f, 0x62, 0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, - 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4a, 0x6f, 0x62, 0x4e, 0x75, 0x6d, 0x12, 0x24, 0x0a, - 0x0d, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x4a, 0x6f, 0x62, 0x4e, 0x75, 0x6d, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x4a, 0x6f, 0x62, - 0x4e, 0x75, 0x6d, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, - 0x6e, 0x74, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, - 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x3c, 0x0a, 0x0d, 0x6e, 0x6f, 0x64, - 0x65, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x16, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x41, - 0x76, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x41, 0x76, - 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0xc7, 0x02, 0x0a, 0x0d, 0x4e, 0x6f, 0x64, 0x65, - 0x41, 0x76, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x6f, 0x64, - 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, - 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x70, 0x75, 0x54, 0x6f, 0x74, 0x61, - 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x63, 0x70, 0x75, 0x54, 0x6f, 0x74, 0x61, - 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x70, 0x75, 0x55, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x63, 0x70, 0x75, 0x55, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x12, - 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x73, 0x6b, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x64, 0x69, 0x73, 0x6b, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x1c, 0x0a, - 0x09, 0x64, 0x69, 0x73, 0x6b, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x09, 0x64, 0x69, 0x73, 0x6b, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x6d, - 0x65, 0x6d, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, - 0x65, 0x6d, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x6d, 0x41, 0x76, - 0x61, 0x69, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, 0x65, 0x6d, 0x41, 0x76, - 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x67, 0x70, 0x75, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x67, 0x70, 0x75, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x12, - 0x1a, 0x0a, 0x08, 0x67, 0x70, 0x75, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x08, 0x67, 0x70, 0x75, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x70, - 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, - 0x64, 0x22, 0x8c, 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, - 0x69, 0x70, 0x61, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, - 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, - 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6d, 0x73, 0x67, 0x12, 0x4a, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, - 0x61, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, - 0x69, 0x70, 0x61, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x52, 0x11, 0x50, - 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x73, - 0x22, 0x37, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x67, 0x0a, 0x16, 0x50, 0x61, 0x72, - 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x27, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, - 0x65, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x22, 0x94, 0x01, 0x0a, 0x0a, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x70, - 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, - 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, - 0x62, 0x65, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6c, 0x61, 0x73, 0x74, - 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x22, 0x5c, 0x0a, 0x0a, 0x54, 0x65, 0x6e, - 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, - 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6e, - 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x65, 0x6e, 0x61, 0x6e, - 0x74, 0x44, 0x65, 0x73, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x65, 0x6e, - 0x61, 0x6e, 0x74, 0x44, 0x65, 0x73, 0x63, 0x22, 0x42, 0x0a, 0x0a, 0x54, 0x65, 0x6e, 0x61, 0x6e, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x6d, 0x0a, 0x0e, 0x4c, - 0x69, 0x73, 0x74, 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, - 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, - 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6d, 0x73, 0x67, 0x12, 0x35, 0x0a, 0x0b, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, - 0x72, 0x65, 0x2e, 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x74, - 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x22, 0x0e, 0x0a, 0x0c, 0x41, 0x70, - 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x3f, 0x0a, 0x0d, 0x41, 0x70, - 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2e, 0x0a, 0x08, 0x69, - 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x08, 0x69, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x9b, 0x01, 0x0a, 0x09, - 0x41, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x28, 0x0a, 0x0f, 0x70, 0x61, 0x72, - 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x4e, - 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x79, 0x61, 0x6d, 0x6c, 0x53, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x2a, 0x33, 0x0a, 0x0d, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x41, - 0x49, 0x4c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, - 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x32, 0x7b, - 0x0a, 0x07, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x53, 0x79, 0x6e, - 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, - 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, - 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x37, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, - 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, - 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x32, 0xb5, 0x07, 0x0a, 0x12, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x50, 0x0a, 0x13, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x61, - 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, - 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, - 0x68, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, - 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x0f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, - 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x20, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, - 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x48, 0x65, 0x61, - 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x63, 0x6d, 0x43, - 0x6f, 0x72, 0x65, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x41, - 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1c, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, - 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x41, 0x76, - 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, - 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0f, 0x6c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, - 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, - 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x54, 0x65, 0x6e, 0x61, 0x6e, - 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, - 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x10, 0x6c, 0x69, 0x73, 0x74, 0x50, 0x68, 0x79, 0x41, - 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, - 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x54, 0x65, - 0x6e, 0x61, 0x6e, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x41, 0x76, - 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x12, 0x6c, 0x69, 0x73, - 0x74, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, - 0x69, 0x70, 0x61, 0x6e, 0x74, 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x63, - 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, - 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3c, - 0x0a, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, - 0x12, 0x13, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x6e, 0x61, 0x6e, - 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x13, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, - 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x0a, - 0x6c, 0x69, 0x73, 0x74, 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x70, 0x63, 0x6d, - 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x1a, - 0x17, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x65, - 0x6e, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x09, 0x61, 0x70, - 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, - 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, - 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x0a, 0x64, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, - 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, - 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, - 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, - 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x09, 0x70, 0x61, 0x75, 0x73, 0x65, - 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, - 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70, 0x63, - 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4c, 0x69, - 0x73, 0x74, 0x12, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, - 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70, 0x63, 0x6d, 0x43, - 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_pcmCore_proto_rawDescOnce sync.Once - file_pcmCore_proto_rawDescData = file_pcmCore_proto_rawDesc -) - -func file_pcmCore_proto_rawDescGZIP() []byte { - file_pcmCore_proto_rawDescOnce.Do(func() { - file_pcmCore_proto_rawDescData = protoimpl.X.CompressGZIP(file_pcmCore_proto_rawDescData) - }) - return file_pcmCore_proto_rawDescData -} - -var file_pcmCore_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_pcmCore_proto_msgTypes = make([]protoimpl.MessageInfo, 29) -var file_pcmCore_proto_goTypes = []interface{}{ - (MessageStatus)(0), // 0: pcmCore.MessageStatus - (*SyncInfoReq)(nil), // 1: pcmCore.SyncInfoReq - (*AiInfo)(nil), // 2: pcmCore.AiInfo - (*CloudInfo)(nil), // 3: pcmCore.CloudInfo - (*VmInfo)(nil), // 4: pcmCore.VmInfo - (*HpcInfo)(nil), // 5: pcmCore.HpcInfo - (*SyncInfoResp)(nil), // 6: pcmCore.SyncInfoResp - (*InfoListReq)(nil), // 7: pcmCore.InfoListReq - (*InfoListResp)(nil), // 8: pcmCore.InfoListResp - (*ParticipantTenant)(nil), // 9: pcmCore.ParticipantTenant - (*ParticipantLabel)(nil), // 10: pcmCore.ParticipantLabel - (*HealthCheckResp)(nil), // 11: pcmCore.HealthCheckResp - (*ParticipantPhyResp)(nil), // 12: pcmCore.ParticipantPhyResp - (*ListParticipantPhyResp)(nil), // 13: pcmCore.ListParticipantPhyResp - (*ParticipantPhyReq)(nil), // 14: pcmCore.ParticipantPhyReq - (*NodePhyInfo)(nil), // 15: pcmCore.NodePhyInfo - (*QueuePhyInfo)(nil), // 16: pcmCore.QueuePhyInfo - (*ParticipantHeartbeatReq)(nil), // 17: pcmCore.ParticipantHeartbeatReq - (*ParticipantAvailReq)(nil), // 18: pcmCore.ParticipantAvailReq - (*NodeAvailInfo)(nil), // 19: pcmCore.NodeAvailInfo - (*ListParticipantAvailResp)(nil), // 20: pcmCore.ListParticipantAvailResp - (*ParticipantResp)(nil), // 21: pcmCore.ParticipantResp - (*ParticipantServiceResp)(nil), // 22: pcmCore.ParticipantServiceResp - (*ClientInfo)(nil), // 23: pcmCore.ClientInfo - (*TenantInfo)(nil), // 24: pcmCore.TenantInfo - (*TenantResp)(nil), // 25: pcmCore.TenantResp - (*ListTenantResp)(nil), // 26: pcmCore.ListTenantResp - (*ApplyListReq)(nil), // 27: pcmCore.ApplyListReq - (*ApplyListResp)(nil), // 28: pcmCore.ApplyListResp - (*ApplyInfo)(nil), // 29: pcmCore.ApplyInfo -} -var file_pcmCore_proto_depIdxs = []int32{ - 5, // 0: pcmCore.SyncInfoReq.HpcInfoList:type_name -> pcmCore.HpcInfo - 3, // 1: pcmCore.SyncInfoReq.CloudInfoList:type_name -> pcmCore.CloudInfo - 2, // 2: pcmCore.SyncInfoReq.AiInfoList:type_name -> pcmCore.AiInfo - 4, // 3: pcmCore.SyncInfoReq.VmInfoList:type_name -> pcmCore.VmInfo - 5, // 4: pcmCore.InfoListResp.HpcInfoList:type_name -> pcmCore.HpcInfo - 3, // 5: pcmCore.InfoListResp.CloudInfoList:type_name -> pcmCore.CloudInfo - 2, // 6: pcmCore.InfoListResp.AiInfoList:type_name -> pcmCore.AiInfo - 4, // 7: pcmCore.InfoListResp.VmInfoList:type_name -> pcmCore.VmInfo - 0, // 8: pcmCore.HealthCheckResp.messageStatus:type_name -> pcmCore.MessageStatus - 14, // 9: pcmCore.ListParticipantPhyResp.ParticipantPhys:type_name -> pcmCore.ParticipantPhyReq - 15, // 10: pcmCore.ParticipantPhyReq.nodeInfo:type_name -> pcmCore.NodePhyInfo - 10, // 11: pcmCore.ParticipantPhyReq.labelInfo:type_name -> pcmCore.ParticipantLabel - 16, // 12: pcmCore.ParticipantPhyReq.queueInfo:type_name -> pcmCore.QueuePhyInfo - 19, // 13: pcmCore.ParticipantAvailReq.nodeAvailInfo:type_name -> pcmCore.NodeAvailInfo - 18, // 14: pcmCore.ListParticipantAvailResp.ParticipantAvails:type_name -> pcmCore.ParticipantAvailReq - 23, // 15: pcmCore.ParticipantServiceResp.data:type_name -> pcmCore.ClientInfo - 24, // 16: pcmCore.ListTenantResp.tenantInfos:type_name -> pcmCore.TenantInfo - 29, // 17: pcmCore.ApplyListResp.infoList:type_name -> pcmCore.ApplyInfo - 1, // 18: pcmCore.pcmCore.SyncInfo:input_type -> pcmCore.SyncInfoReq - 7, // 19: pcmCore.pcmCore.InfoList:input_type -> pcmCore.InfoListReq - 14, // 20: pcmCore.participantService.registerParticipant:input_type -> pcmCore.ParticipantPhyReq - 17, // 21: pcmCore.participantService.reportHeartbeat:input_type -> pcmCore.ParticipantHeartbeatReq - 18, // 22: pcmCore.participantService.reportAvailable:input_type -> pcmCore.ParticipantAvailReq - 9, // 23: pcmCore.participantService.listParticipant:input_type -> pcmCore.ParticipantTenant - 9, // 24: pcmCore.participantService.listPhyAvailable:input_type -> pcmCore.ParticipantTenant - 9, // 25: pcmCore.participantService.listPhyInformation:input_type -> pcmCore.ParticipantTenant - 24, // 26: pcmCore.participantService.registerTenant:input_type -> pcmCore.TenantInfo - 24, // 27: pcmCore.participantService.listTenant:input_type -> pcmCore.TenantInfo - 27, // 28: pcmCore.participantService.applyList:input_type -> pcmCore.ApplyListReq - 27, // 29: pcmCore.participantService.deleteList:input_type -> pcmCore.ApplyListReq - 27, // 30: pcmCore.participantService.restartList:input_type -> pcmCore.ApplyListReq - 27, // 31: pcmCore.participantService.pauseList:input_type -> pcmCore.ApplyListReq - 27, // 32: pcmCore.participantService.startList:input_type -> pcmCore.ApplyListReq - 6, // 33: pcmCore.pcmCore.SyncInfo:output_type -> pcmCore.SyncInfoResp - 8, // 34: pcmCore.pcmCore.InfoList:output_type -> pcmCore.InfoListResp - 12, // 35: pcmCore.participantService.registerParticipant:output_type -> pcmCore.ParticipantPhyResp - 11, // 36: pcmCore.participantService.reportHeartbeat:output_type -> pcmCore.HealthCheckResp - 21, // 37: pcmCore.participantService.reportAvailable:output_type -> pcmCore.ParticipantResp - 22, // 38: pcmCore.participantService.listParticipant:output_type -> pcmCore.ParticipantServiceResp - 20, // 39: pcmCore.participantService.listPhyAvailable:output_type -> pcmCore.ListParticipantAvailResp - 13, // 40: pcmCore.participantService.listPhyInformation:output_type -> pcmCore.ListParticipantPhyResp - 25, // 41: pcmCore.participantService.registerTenant:output_type -> pcmCore.TenantResp - 26, // 42: pcmCore.participantService.listTenant:output_type -> pcmCore.ListTenantResp - 28, // 43: pcmCore.participantService.applyList:output_type -> pcmCore.ApplyListResp - 28, // 44: pcmCore.participantService.deleteList:output_type -> pcmCore.ApplyListResp - 28, // 45: pcmCore.participantService.restartList:output_type -> pcmCore.ApplyListResp - 28, // 46: pcmCore.participantService.pauseList:output_type -> pcmCore.ApplyListResp - 28, // 47: pcmCore.participantService.startList:output_type -> pcmCore.ApplyListResp - 33, // [33:48] is the sub-list for method output_type - 18, // [18:33] is the sub-list for method input_type - 18, // [18:18] is the sub-list for extension type_name - 18, // [18:18] is the sub-list for extension extendee - 0, // [0:18] is the sub-list for field type_name -} - -func init() { file_pcmCore_proto_init() } -func file_pcmCore_proto_init() { - if File_pcmCore_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_pcmCore_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SyncInfoReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AiInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CloudInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VmInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HpcInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SyncInfoResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InfoListReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InfoListResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantTenant); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantLabel); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HealthCheckResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantPhyResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListParticipantPhyResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantPhyReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NodePhyInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueuePhyInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantHeartbeatReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantAvailReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NodeAvailInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListParticipantAvailResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParticipantServiceResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ClientInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TenantInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TenantResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListTenantResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyListReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyListResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pcmCore_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_pcmCore_proto_rawDesc, - NumEnums: 1, - NumMessages: 29, - NumExtensions: 0, - NumServices: 2, - }, - GoTypes: file_pcmCore_proto_goTypes, - DependencyIndexes: file_pcmCore_proto_depIdxs, - EnumInfos: file_pcmCore_proto_enumTypes, - MessageInfos: file_pcmCore_proto_msgTypes, - }.Build() - File_pcmCore_proto = out.File - file_pcmCore_proto_rawDesc = nil - file_pcmCore_proto_goTypes = nil - file_pcmCore_proto_depIdxs = nil -} diff --git a/rpc/pcmCore/pcmCore_grpc.pb.go b/rpc/pcmCore/pcmCore_grpc.pb.go deleted file mode 100644 index fcacc346..00000000 --- a/rpc/pcmCore/pcmCore_grpc.pb.go +++ /dev/null @@ -1,710 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v3.19.4 -// source: pcmCore.proto - -package pcmCore - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - PcmCore_SyncInfo_FullMethodName = "/pcmCore.pcmCore/SyncInfo" - PcmCore_InfoList_FullMethodName = "/pcmCore.pcmCore/InfoList" -) - -// PcmCoreClient is the client API for PcmCore service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type PcmCoreClient interface { - // SyncInfo Synchronous data information - SyncInfo(ctx context.Context, in *SyncInfoReq, opts ...grpc.CallOption) (*SyncInfoResp, error) - // InfoList - InfoList(ctx context.Context, in *InfoListReq, opts ...grpc.CallOption) (*InfoListResp, error) -} - -type pcmCoreClient struct { - cc grpc.ClientConnInterface -} - -func NewPcmCoreClient(cc grpc.ClientConnInterface) PcmCoreClient { - return &pcmCoreClient{cc} -} - -func (c *pcmCoreClient) SyncInfo(ctx context.Context, in *SyncInfoReq, opts ...grpc.CallOption) (*SyncInfoResp, error) { - out := new(SyncInfoResp) - err := c.cc.Invoke(ctx, PcmCore_SyncInfo_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *pcmCoreClient) InfoList(ctx context.Context, in *InfoListReq, opts ...grpc.CallOption) (*InfoListResp, error) { - out := new(InfoListResp) - err := c.cc.Invoke(ctx, PcmCore_InfoList_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PcmCoreServer is the server API for PcmCore service. -// All implementations must embed UnimplementedPcmCoreServer -// for forward compatibility -type PcmCoreServer interface { - // SyncInfo Synchronous data information - SyncInfo(context.Context, *SyncInfoReq) (*SyncInfoResp, error) - // InfoList - InfoList(context.Context, *InfoListReq) (*InfoListResp, error) - mustEmbedUnimplementedPcmCoreServer() -} - -// UnimplementedPcmCoreServer must be embedded to have forward compatible implementations. -type UnimplementedPcmCoreServer struct { -} - -func (UnimplementedPcmCoreServer) SyncInfo(context.Context, *SyncInfoReq) (*SyncInfoResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method SyncInfo not implemented") -} -func (UnimplementedPcmCoreServer) InfoList(context.Context, *InfoListReq) (*InfoListResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method InfoList not implemented") -} -func (UnimplementedPcmCoreServer) mustEmbedUnimplementedPcmCoreServer() {} - -// UnsafePcmCoreServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to PcmCoreServer will -// result in compilation errors. -type UnsafePcmCoreServer interface { - mustEmbedUnimplementedPcmCoreServer() -} - -func RegisterPcmCoreServer(s grpc.ServiceRegistrar, srv PcmCoreServer) { - s.RegisterService(&PcmCore_ServiceDesc, srv) -} - -func _PcmCore_SyncInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SyncInfoReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PcmCoreServer).SyncInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PcmCore_SyncInfo_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PcmCoreServer).SyncInfo(ctx, req.(*SyncInfoReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _PcmCore_InfoList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InfoListReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PcmCoreServer).InfoList(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PcmCore_InfoList_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PcmCoreServer).InfoList(ctx, req.(*InfoListReq)) - } - return interceptor(ctx, in, info, handler) -} - -// PcmCore_ServiceDesc is the grpc.ServiceDesc for PcmCore service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var PcmCore_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "pcmCore.pcmCore", - HandlerType: (*PcmCoreServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SyncInfo", - Handler: _PcmCore_SyncInfo_Handler, - }, - { - MethodName: "InfoList", - Handler: _PcmCore_InfoList_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "pcmCore.proto", -} - -const ( - ParticipantService_RegisterParticipant_FullMethodName = "/pcmCore.participantService/registerParticipant" - ParticipantService_ReportHeartbeat_FullMethodName = "/pcmCore.participantService/reportHeartbeat" - ParticipantService_ReportAvailable_FullMethodName = "/pcmCore.participantService/reportAvailable" - ParticipantService_ListParticipant_FullMethodName = "/pcmCore.participantService/listParticipant" - ParticipantService_ListPhyAvailable_FullMethodName = "/pcmCore.participantService/listPhyAvailable" - ParticipantService_ListPhyInformation_FullMethodName = "/pcmCore.participantService/listPhyInformation" - ParticipantService_RegisterTenant_FullMethodName = "/pcmCore.participantService/registerTenant" - ParticipantService_ListTenant_FullMethodName = "/pcmCore.participantService/listTenant" - ParticipantService_ApplyList_FullMethodName = "/pcmCore.participantService/applyList" - ParticipantService_DeleteList_FullMethodName = "/pcmCore.participantService/deleteList" - ParticipantService_RestartList_FullMethodName = "/pcmCore.participantService/restartList" - ParticipantService_PauseList_FullMethodName = "/pcmCore.participantService/pauseList" - ParticipantService_StartList_FullMethodName = "/pcmCore.participantService/startList" -) - -// ParticipantServiceClient is the client API for ParticipantService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ParticipantServiceClient interface { - // registerParticipant Participant注册接口 - RegisterParticipant(ctx context.Context, in *ParticipantPhyReq, opts ...grpc.CallOption) (*ParticipantPhyResp, error) - // reportHeartbeat 心跳请求 - ReportHeartbeat(ctx context.Context, in *ParticipantHeartbeatReq, opts ...grpc.CallOption) (*HealthCheckResp, error) - // reportAvailable 监控数据上报 - ReportAvailable(ctx context.Context, in *ParticipantAvailReq, opts ...grpc.CallOption) (*ParticipantResp, error) - // listParticipant 服务列表 - ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantServiceResp, error) - // listAvailable 集群动态信息列表 - ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error) - // listPhyInformation 集群静态信息列表 - ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error) - // registerTenant 注册租户信息 - RegisterTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*TenantResp, error) - // listTenant 租户列表信息 - ListTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*ListTenantResp, error) - // applyList 执行任务列表 - ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // DeleteList 删除任务列表 - DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // RestartList 重启任务列表 - RestartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // PauseList 暂停任务列表 - PauseList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) - // StartList 启动任务列表 - StartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) -} - -type participantServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewParticipantServiceClient(cc grpc.ClientConnInterface) ParticipantServiceClient { - return &participantServiceClient{cc} -} - -func (c *participantServiceClient) RegisterParticipant(ctx context.Context, in *ParticipantPhyReq, opts ...grpc.CallOption) (*ParticipantPhyResp, error) { - out := new(ParticipantPhyResp) - err := c.cc.Invoke(ctx, ParticipantService_RegisterParticipant_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) ReportHeartbeat(ctx context.Context, in *ParticipantHeartbeatReq, opts ...grpc.CallOption) (*HealthCheckResp, error) { - out := new(HealthCheckResp) - err := c.cc.Invoke(ctx, ParticipantService_ReportHeartbeat_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) ReportAvailable(ctx context.Context, in *ParticipantAvailReq, opts ...grpc.CallOption) (*ParticipantResp, error) { - out := new(ParticipantResp) - err := c.cc.Invoke(ctx, ParticipantService_ReportAvailable_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantServiceResp, error) { - out := new(ParticipantServiceResp) - err := c.cc.Invoke(ctx, ParticipantService_ListParticipant_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error) { - out := new(ListParticipantAvailResp) - err := c.cc.Invoke(ctx, ParticipantService_ListPhyAvailable_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error) { - out := new(ListParticipantPhyResp) - err := c.cc.Invoke(ctx, ParticipantService_ListPhyInformation_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) RegisterTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*TenantResp, error) { - out := new(TenantResp) - err := c.cc.Invoke(ctx, ParticipantService_RegisterTenant_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) ListTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*ListTenantResp, error) { - out := new(ListTenantResp) - err := c.cc.Invoke(ctx, ParticipantService_ListTenant_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - out := new(ApplyListResp) - err := c.cc.Invoke(ctx, ParticipantService_ApplyList_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - out := new(ApplyListResp) - err := c.cc.Invoke(ctx, ParticipantService_DeleteList_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) RestartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - out := new(ApplyListResp) - err := c.cc.Invoke(ctx, ParticipantService_RestartList_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) PauseList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - out := new(ApplyListResp) - err := c.cc.Invoke(ctx, ParticipantService_PauseList_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *participantServiceClient) StartList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) { - out := new(ApplyListResp) - err := c.cc.Invoke(ctx, ParticipantService_StartList_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ParticipantServiceServer is the server API for ParticipantService service. -// All implementations must embed UnimplementedParticipantServiceServer -// for forward compatibility -type ParticipantServiceServer interface { - // registerParticipant Participant注册接口 - RegisterParticipant(context.Context, *ParticipantPhyReq) (*ParticipantPhyResp, error) - // reportHeartbeat 心跳请求 - ReportHeartbeat(context.Context, *ParticipantHeartbeatReq) (*HealthCheckResp, error) - // reportAvailable 监控数据上报 - ReportAvailable(context.Context, *ParticipantAvailReq) (*ParticipantResp, error) - // listParticipant 服务列表 - ListParticipant(context.Context, *ParticipantTenant) (*ParticipantServiceResp, error) - // listAvailable 集群动态信息列表 - ListPhyAvailable(context.Context, *ParticipantTenant) (*ListParticipantAvailResp, error) - // listPhyInformation 集群静态信息列表 - ListPhyInformation(context.Context, *ParticipantTenant) (*ListParticipantPhyResp, error) - // registerTenant 注册租户信息 - RegisterTenant(context.Context, *TenantInfo) (*TenantResp, error) - // listTenant 租户列表信息 - ListTenant(context.Context, *TenantInfo) (*ListTenantResp, error) - // applyList 执行任务列表 - ApplyList(context.Context, *ApplyListReq) (*ApplyListResp, error) - // DeleteList 删除任务列表 - DeleteList(context.Context, *ApplyListReq) (*ApplyListResp, error) - // RestartList 重启任务列表 - RestartList(context.Context, *ApplyListReq) (*ApplyListResp, error) - // PauseList 暂停任务列表 - PauseList(context.Context, *ApplyListReq) (*ApplyListResp, error) - // StartList 启动任务列表 - StartList(context.Context, *ApplyListReq) (*ApplyListResp, error) - mustEmbedUnimplementedParticipantServiceServer() -} - -// UnimplementedParticipantServiceServer must be embedded to have forward compatible implementations. -type UnimplementedParticipantServiceServer struct { -} - -func (UnimplementedParticipantServiceServer) RegisterParticipant(context.Context, *ParticipantPhyReq) (*ParticipantPhyResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterParticipant not implemented") -} -func (UnimplementedParticipantServiceServer) ReportHeartbeat(context.Context, *ParticipantHeartbeatReq) (*HealthCheckResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method ReportHeartbeat not implemented") -} -func (UnimplementedParticipantServiceServer) ReportAvailable(context.Context, *ParticipantAvailReq) (*ParticipantResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method ReportAvailable not implemented") -} -func (UnimplementedParticipantServiceServer) ListParticipant(context.Context, *ParticipantTenant) (*ParticipantServiceResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListParticipant not implemented") -} -func (UnimplementedParticipantServiceServer) ListPhyAvailable(context.Context, *ParticipantTenant) (*ListParticipantAvailResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPhyAvailable not implemented") -} -func (UnimplementedParticipantServiceServer) ListPhyInformation(context.Context, *ParticipantTenant) (*ListParticipantPhyResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPhyInformation not implemented") -} -func (UnimplementedParticipantServiceServer) RegisterTenant(context.Context, *TenantInfo) (*TenantResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterTenant not implemented") -} -func (UnimplementedParticipantServiceServer) ListTenant(context.Context, *TenantInfo) (*ListTenantResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListTenant not implemented") -} -func (UnimplementedParticipantServiceServer) ApplyList(context.Context, *ApplyListReq) (*ApplyListResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method ApplyList not implemented") -} -func (UnimplementedParticipantServiceServer) DeleteList(context.Context, *ApplyListReq) (*ApplyListResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteList not implemented") -} -func (UnimplementedParticipantServiceServer) RestartList(context.Context, *ApplyListReq) (*ApplyListResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method RestartList not implemented") -} -func (UnimplementedParticipantServiceServer) PauseList(context.Context, *ApplyListReq) (*ApplyListResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method PauseList not implemented") -} -func (UnimplementedParticipantServiceServer) StartList(context.Context, *ApplyListReq) (*ApplyListResp, error) { - return nil, status.Errorf(codes.Unimplemented, "method StartList not implemented") -} -func (UnimplementedParticipantServiceServer) mustEmbedUnimplementedParticipantServiceServer() {} - -// UnsafeParticipantServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ParticipantServiceServer will -// result in compilation errors. -type UnsafeParticipantServiceServer interface { - mustEmbedUnimplementedParticipantServiceServer() -} - -func RegisterParticipantServiceServer(s grpc.ServiceRegistrar, srv ParticipantServiceServer) { - s.RegisterService(&ParticipantService_ServiceDesc, srv) -} - -func _ParticipantService_RegisterParticipant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ParticipantPhyReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).RegisterParticipant(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_RegisterParticipant_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).RegisterParticipant(ctx, req.(*ParticipantPhyReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_ReportHeartbeat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ParticipantHeartbeatReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).ReportHeartbeat(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_ReportHeartbeat_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).ReportHeartbeat(ctx, req.(*ParticipantHeartbeatReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_ReportAvailable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ParticipantAvailReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).ReportAvailable(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_ReportAvailable_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).ReportAvailable(ctx, req.(*ParticipantAvailReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_ListParticipant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ParticipantTenant) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).ListParticipant(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_ListParticipant_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).ListParticipant(ctx, req.(*ParticipantTenant)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_ListPhyAvailable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ParticipantTenant) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).ListPhyAvailable(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_ListPhyAvailable_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).ListPhyAvailable(ctx, req.(*ParticipantTenant)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_ListPhyInformation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ParticipantTenant) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).ListPhyInformation(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_ListPhyInformation_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).ListPhyInformation(ctx, req.(*ParticipantTenant)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_RegisterTenant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TenantInfo) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).RegisterTenant(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_RegisterTenant_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).RegisterTenant(ctx, req.(*TenantInfo)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_ListTenant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TenantInfo) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).ListTenant(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_ListTenant_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).ListTenant(ctx, req.(*TenantInfo)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_ApplyList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ApplyListReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).ApplyList(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_ApplyList_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).ApplyList(ctx, req.(*ApplyListReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_DeleteList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ApplyListReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).DeleteList(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_DeleteList_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).DeleteList(ctx, req.(*ApplyListReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_RestartList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ApplyListReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).RestartList(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_RestartList_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).RestartList(ctx, req.(*ApplyListReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_PauseList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ApplyListReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).PauseList(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_PauseList_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).PauseList(ctx, req.(*ApplyListReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ParticipantService_StartList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ApplyListReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ParticipantServiceServer).StartList(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ParticipantService_StartList_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ParticipantServiceServer).StartList(ctx, req.(*ApplyListReq)) - } - return interceptor(ctx, in, info, handler) -} - -// ParticipantService_ServiceDesc is the grpc.ServiceDesc for ParticipantService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var ParticipantService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "pcmCore.participantService", - HandlerType: (*ParticipantServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "registerParticipant", - Handler: _ParticipantService_RegisterParticipant_Handler, - }, - { - MethodName: "reportHeartbeat", - Handler: _ParticipantService_ReportHeartbeat_Handler, - }, - { - MethodName: "reportAvailable", - Handler: _ParticipantService_ReportAvailable_Handler, - }, - { - MethodName: "listParticipant", - Handler: _ParticipantService_ListParticipant_Handler, - }, - { - MethodName: "listPhyAvailable", - Handler: _ParticipantService_ListPhyAvailable_Handler, - }, - { - MethodName: "listPhyInformation", - Handler: _ParticipantService_ListPhyInformation_Handler, - }, - { - MethodName: "registerTenant", - Handler: _ParticipantService_RegisterTenant_Handler, - }, - { - MethodName: "listTenant", - Handler: _ParticipantService_ListTenant_Handler, - }, - { - MethodName: "applyList", - Handler: _ParticipantService_ApplyList_Handler, - }, - { - MethodName: "deleteList", - Handler: _ParticipantService_DeleteList_Handler, - }, - { - MethodName: "restartList", - Handler: _ParticipantService_RestartList_Handler, - }, - { - MethodName: "pauseList", - Handler: _ParticipantService_PauseList_Handler, - }, - { - MethodName: "startList", - Handler: _ParticipantService_StartList_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "pcmCore.proto", -} diff --git a/rpc/pcmcore.go b/rpc/pcmcore.go deleted file mode 100644 index e40caa16..00000000 --- a/rpc/pcmcore.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - -package main - -import ( - "flag" - "github.com/zeromicro/go-zero/core/conf" - "github.com/zeromicro/go-zero/core/logx" - "github.com/zeromicro/go-zero/core/service" - "github.com/zeromicro/go-zero/zrpc" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/interceptor/rpcserver" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/config" - participantserviceServer "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/server/participantservice" - pcmcoreServer "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/server/pcmcore" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/rpc/pcmCore" - "google.golang.org/grpc" - "google.golang.org/grpc/reflection" -) - -var configFile = flag.String("f", "rpc/etc/pcmcore.yaml", "the config file") - -func main() { - - flag.Parse() - - var c config.Config - conf.MustLoad(*configFile, &c) - - ctx := svc.NewServiceContext(c) - - s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { - pcmCore.RegisterPcmCoreServer(grpcServer, pcmcoreServer.NewPcmCoreServer(ctx)) - pcmCore.RegisterParticipantServiceServer(grpcServer, participantserviceServer.NewParticipantServiceServer(ctx)) - if c.Mode == service.DevMode || c.Mode == service.TestMode { - reflection.Register(grpcServer) - } - }) - - //rpc log - s.AddUnaryInterceptors(rpcserver.LoggerInterceptor) - - defer s.Stop() - logx.Infof("Starting rpc server at %s...\n", c.ListenOn) - s.Start() -} diff --git a/vendor/google.golang.org/grpc/reflection/README.md b/vendor/google.golang.org/grpc/reflection/README.md deleted file mode 100644 index 9ace83cc..00000000 --- a/vendor/google.golang.org/grpc/reflection/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Reflection - -Package reflection implements server reflection service. - -The service implemented is defined in: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1/reflection.proto. - -To register server reflection on a gRPC server: -```go -import "google.golang.org/grpc/reflection" - -s := grpc.NewServer() -pb.RegisterYourOwnServer(s, &server{}) - -// Register reflection service on gRPC server. -reflection.Register(s) - -s.Serve(lis) -``` diff --git a/vendor/google.golang.org/grpc/reflection/adapt.go b/vendor/google.golang.org/grpc/reflection/adapt.go deleted file mode 100644 index 6997e474..00000000 --- a/vendor/google.golang.org/grpc/reflection/adapt.go +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Copyright 2023 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package reflection - -import ( - "google.golang.org/grpc/reflection/internal" - - v1reflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1" - v1reflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1" - v1alphareflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" -) - -// asV1Alpha returns an implementation of the v1alpha version of the reflection -// interface that delegates all calls to the given v1 version. -func asV1Alpha(svr v1reflectiongrpc.ServerReflectionServer) v1alphareflectiongrpc.ServerReflectionServer { - return v1AlphaServerImpl{svr: svr} -} - -type v1AlphaServerImpl struct { - svr v1reflectiongrpc.ServerReflectionServer -} - -func (s v1AlphaServerImpl) ServerReflectionInfo(stream v1alphareflectiongrpc.ServerReflection_ServerReflectionInfoServer) error { - return s.svr.ServerReflectionInfo(v1AlphaServerStreamAdapter{stream}) -} - -type v1AlphaServerStreamAdapter struct { - v1alphareflectiongrpc.ServerReflection_ServerReflectionInfoServer -} - -func (s v1AlphaServerStreamAdapter) Send(response *v1reflectionpb.ServerReflectionResponse) error { - return s.ServerReflection_ServerReflectionInfoServer.Send(internal.V1ToV1AlphaResponse(response)) -} - -func (s v1AlphaServerStreamAdapter) Recv() (*v1reflectionpb.ServerReflectionRequest, error) { - resp, err := s.ServerReflection_ServerReflectionInfoServer.Recv() - if err != nil { - return nil, err - } - return internal.V1AlphaToV1Request(resp), nil -} diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go deleted file mode 100644 index 6c49c233..00000000 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go +++ /dev/null @@ -1,953 +0,0 @@ -// Copyright 2016 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Service exported by server reflection. A more complete description of how -// server reflection works can be found at -// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md -// -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.33.0 -// protoc v4.25.2 -// source: grpc/reflection/v1/reflection.proto - -package grpc_reflection_v1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The message sent by the client when calling ServerReflectionInfo method. -type ServerReflectionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` - // To use reflection service, the client should set one of the following - // fields in message_request. The server distinguishes requests by their - // defined field and then handles them using corresponding methods. - // - // Types that are assignable to MessageRequest: - // - // *ServerReflectionRequest_FileByFilename - // *ServerReflectionRequest_FileContainingSymbol - // *ServerReflectionRequest_FileContainingExtension - // *ServerReflectionRequest_AllExtensionNumbersOfType - // *ServerReflectionRequest_ListServices - MessageRequest isServerReflectionRequest_MessageRequest `protobuf_oneof:"message_request"` -} - -func (x *ServerReflectionRequest) Reset() { - *x = ServerReflectionRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerReflectionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerReflectionRequest) ProtoMessage() {} - -func (x *ServerReflectionRequest) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServerReflectionRequest.ProtoReflect.Descriptor instead. -func (*ServerReflectionRequest) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{0} -} - -func (x *ServerReflectionRequest) GetHost() string { - if x != nil { - return x.Host - } - return "" -} - -func (m *ServerReflectionRequest) GetMessageRequest() isServerReflectionRequest_MessageRequest { - if m != nil { - return m.MessageRequest - } - return nil -} - -func (x *ServerReflectionRequest) GetFileByFilename() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileByFilename); ok { - return x.FileByFilename - } - return "" -} - -func (x *ServerReflectionRequest) GetFileContainingSymbol() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingSymbol); ok { - return x.FileContainingSymbol - } - return "" -} - -func (x *ServerReflectionRequest) GetFileContainingExtension() *ExtensionRequest { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingExtension); ok { - return x.FileContainingExtension - } - return nil -} - -func (x *ServerReflectionRequest) GetAllExtensionNumbersOfType() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_AllExtensionNumbersOfType); ok { - return x.AllExtensionNumbersOfType - } - return "" -} - -func (x *ServerReflectionRequest) GetListServices() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_ListServices); ok { - return x.ListServices - } - return "" -} - -type isServerReflectionRequest_MessageRequest interface { - isServerReflectionRequest_MessageRequest() -} - -type ServerReflectionRequest_FileByFilename struct { - // Find a proto file by the file name. - FileByFilename string `protobuf:"bytes,3,opt,name=file_by_filename,json=fileByFilename,proto3,oneof"` -} - -type ServerReflectionRequest_FileContainingSymbol struct { - // Find the proto file that declares the given fully-qualified symbol name. - // This field should be a fully-qualified symbol name - // (e.g. .[.] or .). - FileContainingSymbol string `protobuf:"bytes,4,opt,name=file_containing_symbol,json=fileContainingSymbol,proto3,oneof"` -} - -type ServerReflectionRequest_FileContainingExtension struct { - // Find the proto file which defines an extension extending the given - // message type with the given field number. - FileContainingExtension *ExtensionRequest `protobuf:"bytes,5,opt,name=file_containing_extension,json=fileContainingExtension,proto3,oneof"` -} - -type ServerReflectionRequest_AllExtensionNumbersOfType struct { - // Finds the tag numbers used by all known extensions of the given message - // type, and appends them to ExtensionNumberResponse in an undefined order. - // Its corresponding method is best-effort: it's not guaranteed that the - // reflection service will implement this method, and it's not guaranteed - // that this method will provide all extensions. Returns - // StatusCode::UNIMPLEMENTED if it's not implemented. - // This field should be a fully-qualified type name. The format is - // . - AllExtensionNumbersOfType string `protobuf:"bytes,6,opt,name=all_extension_numbers_of_type,json=allExtensionNumbersOfType,proto3,oneof"` -} - -type ServerReflectionRequest_ListServices struct { - // List the full names of registered services. The content will not be - // checked. - ListServices string `protobuf:"bytes,7,opt,name=list_services,json=listServices,proto3,oneof"` -} - -func (*ServerReflectionRequest_FileByFilename) isServerReflectionRequest_MessageRequest() {} - -func (*ServerReflectionRequest_FileContainingSymbol) isServerReflectionRequest_MessageRequest() {} - -func (*ServerReflectionRequest_FileContainingExtension) isServerReflectionRequest_MessageRequest() {} - -func (*ServerReflectionRequest_AllExtensionNumbersOfType) isServerReflectionRequest_MessageRequest() { -} - -func (*ServerReflectionRequest_ListServices) isServerReflectionRequest_MessageRequest() {} - -// The type name and extension number sent by the client when requesting -// file_containing_extension. -type ExtensionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Fully-qualified type name. The format should be . - ContainingType string `protobuf:"bytes,1,opt,name=containing_type,json=containingType,proto3" json:"containing_type,omitempty"` - ExtensionNumber int32 `protobuf:"varint,2,opt,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` -} - -func (x *ExtensionRequest) Reset() { - *x = ExtensionRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExtensionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExtensionRequest) ProtoMessage() {} - -func (x *ExtensionRequest) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExtensionRequest.ProtoReflect.Descriptor instead. -func (*ExtensionRequest) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{1} -} - -func (x *ExtensionRequest) GetContainingType() string { - if x != nil { - return x.ContainingType - } - return "" -} - -func (x *ExtensionRequest) GetExtensionNumber() int32 { - if x != nil { - return x.ExtensionNumber - } - return 0 -} - -// The message sent by the server to answer ServerReflectionInfo method. -type ServerReflectionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ValidHost string `protobuf:"bytes,1,opt,name=valid_host,json=validHost,proto3" json:"valid_host,omitempty"` - OriginalRequest *ServerReflectionRequest `protobuf:"bytes,2,opt,name=original_request,json=originalRequest,proto3" json:"original_request,omitempty"` - // The server sets one of the following fields according to the message_request - // in the request. - // - // Types that are assignable to MessageResponse: - // - // *ServerReflectionResponse_FileDescriptorResponse - // *ServerReflectionResponse_AllExtensionNumbersResponse - // *ServerReflectionResponse_ListServicesResponse - // *ServerReflectionResponse_ErrorResponse - MessageResponse isServerReflectionResponse_MessageResponse `protobuf_oneof:"message_response"` -} - -func (x *ServerReflectionResponse) Reset() { - *x = ServerReflectionResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerReflectionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerReflectionResponse) ProtoMessage() {} - -func (x *ServerReflectionResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServerReflectionResponse.ProtoReflect.Descriptor instead. -func (*ServerReflectionResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{2} -} - -func (x *ServerReflectionResponse) GetValidHost() string { - if x != nil { - return x.ValidHost - } - return "" -} - -func (x *ServerReflectionResponse) GetOriginalRequest() *ServerReflectionRequest { - if x != nil { - return x.OriginalRequest - } - return nil -} - -func (m *ServerReflectionResponse) GetMessageResponse() isServerReflectionResponse_MessageResponse { - if m != nil { - return m.MessageResponse - } - return nil -} - -func (x *ServerReflectionResponse) GetFileDescriptorResponse() *FileDescriptorResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_FileDescriptorResponse); ok { - return x.FileDescriptorResponse - } - return nil -} - -func (x *ServerReflectionResponse) GetAllExtensionNumbersResponse() *ExtensionNumberResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_AllExtensionNumbersResponse); ok { - return x.AllExtensionNumbersResponse - } - return nil -} - -func (x *ServerReflectionResponse) GetListServicesResponse() *ListServiceResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ListServicesResponse); ok { - return x.ListServicesResponse - } - return nil -} - -func (x *ServerReflectionResponse) GetErrorResponse() *ErrorResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ErrorResponse); ok { - return x.ErrorResponse - } - return nil -} - -type isServerReflectionResponse_MessageResponse interface { - isServerReflectionResponse_MessageResponse() -} - -type ServerReflectionResponse_FileDescriptorResponse struct { - // This message is used to answer file_by_filename, file_containing_symbol, - // file_containing_extension requests with transitive dependencies. - // As the repeated label is not allowed in oneof fields, we use a - // FileDescriptorResponse message to encapsulate the repeated fields. - // The reflection service is allowed to avoid sending FileDescriptorProtos - // that were previously sent in response to earlier requests in the stream. - FileDescriptorResponse *FileDescriptorResponse `protobuf:"bytes,4,opt,name=file_descriptor_response,json=fileDescriptorResponse,proto3,oneof"` -} - -type ServerReflectionResponse_AllExtensionNumbersResponse struct { - // This message is used to answer all_extension_numbers_of_type requests. - AllExtensionNumbersResponse *ExtensionNumberResponse `protobuf:"bytes,5,opt,name=all_extension_numbers_response,json=allExtensionNumbersResponse,proto3,oneof"` -} - -type ServerReflectionResponse_ListServicesResponse struct { - // This message is used to answer list_services requests. - ListServicesResponse *ListServiceResponse `protobuf:"bytes,6,opt,name=list_services_response,json=listServicesResponse,proto3,oneof"` -} - -type ServerReflectionResponse_ErrorResponse struct { - // This message is used when an error occurs. - ErrorResponse *ErrorResponse `protobuf:"bytes,7,opt,name=error_response,json=errorResponse,proto3,oneof"` -} - -func (*ServerReflectionResponse_FileDescriptorResponse) isServerReflectionResponse_MessageResponse() { -} - -func (*ServerReflectionResponse_AllExtensionNumbersResponse) isServerReflectionResponse_MessageResponse() { -} - -func (*ServerReflectionResponse_ListServicesResponse) isServerReflectionResponse_MessageResponse() {} - -func (*ServerReflectionResponse_ErrorResponse) isServerReflectionResponse_MessageResponse() {} - -// Serialized FileDescriptorProto messages sent by the server answering -// a file_by_filename, file_containing_symbol, or file_containing_extension -// request. -type FileDescriptorResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Serialized FileDescriptorProto messages. We avoid taking a dependency on - // descriptor.proto, which uses proto2 only features, by making them opaque - // bytes instead. - FileDescriptorProto [][]byte `protobuf:"bytes,1,rep,name=file_descriptor_proto,json=fileDescriptorProto,proto3" json:"file_descriptor_proto,omitempty"` -} - -func (x *FileDescriptorResponse) Reset() { - *x = FileDescriptorResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FileDescriptorResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FileDescriptorResponse) ProtoMessage() {} - -func (x *FileDescriptorResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FileDescriptorResponse.ProtoReflect.Descriptor instead. -func (*FileDescriptorResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{3} -} - -func (x *FileDescriptorResponse) GetFileDescriptorProto() [][]byte { - if x != nil { - return x.FileDescriptorProto - } - return nil -} - -// A list of extension numbers sent by the server answering -// all_extension_numbers_of_type request. -type ExtensionNumberResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Full name of the base type, including the package name. The format - // is . - BaseTypeName string `protobuf:"bytes,1,opt,name=base_type_name,json=baseTypeName,proto3" json:"base_type_name,omitempty"` - ExtensionNumber []int32 `protobuf:"varint,2,rep,packed,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` -} - -func (x *ExtensionNumberResponse) Reset() { - *x = ExtensionNumberResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExtensionNumberResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExtensionNumberResponse) ProtoMessage() {} - -func (x *ExtensionNumberResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExtensionNumberResponse.ProtoReflect.Descriptor instead. -func (*ExtensionNumberResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{4} -} - -func (x *ExtensionNumberResponse) GetBaseTypeName() string { - if x != nil { - return x.BaseTypeName - } - return "" -} - -func (x *ExtensionNumberResponse) GetExtensionNumber() []int32 { - if x != nil { - return x.ExtensionNumber - } - return nil -} - -// A list of ServiceResponse sent by the server answering list_services request. -type ListServiceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The information of each service may be expanded in the future, so we use - // ServiceResponse message to encapsulate it. - Service []*ServiceResponse `protobuf:"bytes,1,rep,name=service,proto3" json:"service,omitempty"` -} - -func (x *ListServiceResponse) Reset() { - *x = ListServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListServiceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListServiceResponse) ProtoMessage() {} - -func (x *ListServiceResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListServiceResponse.ProtoReflect.Descriptor instead. -func (*ListServiceResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{5} -} - -func (x *ListServiceResponse) GetService() []*ServiceResponse { - if x != nil { - return x.Service - } - return nil -} - -// The information of a single service used by ListServiceResponse to answer -// list_services request. -type ServiceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Full name of a registered service, including its package name. The format - // is . - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *ServiceResponse) Reset() { - *x = ServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServiceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceResponse) ProtoMessage() {} - -func (x *ServiceResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServiceResponse.ProtoReflect.Descriptor instead. -func (*ServiceResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{6} -} - -func (x *ServiceResponse) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The error code and error message sent by the server when an error occurs. -type ErrorResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // This field uses the error codes defined in grpc::StatusCode. - ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` -} - -func (x *ErrorResponse) Reset() { - *x = ErrorResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ErrorResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ErrorResponse) ProtoMessage() {} - -func (x *ErrorResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1_reflection_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead. -func (*ErrorResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1_reflection_proto_rawDescGZIP(), []int{7} -} - -func (x *ErrorResponse) GetErrorCode() int32 { - if x != nil { - return x.ErrorCode - } - return 0 -} - -func (x *ErrorResponse) GetErrorMessage() string { - if x != nil { - return x.ErrorMessage - } - return "" -} - -var File_grpc_reflection_v1_reflection_proto protoreflect.FileDescriptor - -var file_grpc_reflection_v1_reflection_proto_rawDesc = []byte{ - 0x0a, 0x23, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x22, 0xf3, 0x02, 0x0a, 0x17, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x66, 0x69, 0x6c, - 0x65, 0x5f, 0x62, 0x79, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0e, 0x66, 0x69, 0x6c, 0x65, 0x42, 0x79, 0x46, 0x69, 0x6c, - 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x16, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x14, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x62, 0x0a, - 0x19, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, - 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x24, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x17, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x42, 0x0a, 0x1d, 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, - 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x19, 0x61, 0x6c, 0x6c, 0x45, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x4f, - 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x0d, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, - 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x42, 0x11, 0x0a, 0x0f, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, - 0x66, 0x0a, 0x10, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, - 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, - 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, - 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, - 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xae, 0x04, 0x0a, 0x18, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x68, 0x6f, - 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x48, - 0x6f, 0x73, 0x74, 0x12, 0x56, 0x0a, 0x10, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0f, 0x6f, 0x72, 0x69, 0x67, - 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x66, 0x0a, 0x18, 0x66, - 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x72, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x76, 0x31, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x66, 0x69, 0x6c, - 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x72, 0x0a, 0x1e, 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, - 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x1b, 0x61, 0x6c, 0x6c, 0x45, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x16, 0x6c, 0x69, 0x73, 0x74, 0x5f, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, - 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x48, 0x00, 0x52, 0x14, 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x21, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x12, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4c, 0x0a, 0x16, 0x46, 0x69, 0x6c, 0x65, - 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0c, 0x52, 0x13, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, - 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a, 0x0a, 0x17, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, - 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x22, 0x54, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x67, 0x72, 0x70, - 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, - 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, - 0x53, 0x0a, 0x0d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, - 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x32, 0x89, 0x01, 0x0a, 0x10, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, - 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x75, 0x0a, 0x14, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, - 0x6f, 0x12, 0x2b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, - 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, - 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, - 0x42, 0x66, 0x0a, 0x15, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x42, 0x15, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x34, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, - 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x72, 0x65, 0x66, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_grpc_reflection_v1_reflection_proto_rawDescOnce sync.Once - file_grpc_reflection_v1_reflection_proto_rawDescData = file_grpc_reflection_v1_reflection_proto_rawDesc -) - -func file_grpc_reflection_v1_reflection_proto_rawDescGZIP() []byte { - file_grpc_reflection_v1_reflection_proto_rawDescOnce.Do(func() { - file_grpc_reflection_v1_reflection_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_reflection_v1_reflection_proto_rawDescData) - }) - return file_grpc_reflection_v1_reflection_proto_rawDescData -} - -var file_grpc_reflection_v1_reflection_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_grpc_reflection_v1_reflection_proto_goTypes = []interface{}{ - (*ServerReflectionRequest)(nil), // 0: grpc.reflection.v1.ServerReflectionRequest - (*ExtensionRequest)(nil), // 1: grpc.reflection.v1.ExtensionRequest - (*ServerReflectionResponse)(nil), // 2: grpc.reflection.v1.ServerReflectionResponse - (*FileDescriptorResponse)(nil), // 3: grpc.reflection.v1.FileDescriptorResponse - (*ExtensionNumberResponse)(nil), // 4: grpc.reflection.v1.ExtensionNumberResponse - (*ListServiceResponse)(nil), // 5: grpc.reflection.v1.ListServiceResponse - (*ServiceResponse)(nil), // 6: grpc.reflection.v1.ServiceResponse - (*ErrorResponse)(nil), // 7: grpc.reflection.v1.ErrorResponse -} -var file_grpc_reflection_v1_reflection_proto_depIdxs = []int32{ - 1, // 0: grpc.reflection.v1.ServerReflectionRequest.file_containing_extension:type_name -> grpc.reflection.v1.ExtensionRequest - 0, // 1: grpc.reflection.v1.ServerReflectionResponse.original_request:type_name -> grpc.reflection.v1.ServerReflectionRequest - 3, // 2: grpc.reflection.v1.ServerReflectionResponse.file_descriptor_response:type_name -> grpc.reflection.v1.FileDescriptorResponse - 4, // 3: grpc.reflection.v1.ServerReflectionResponse.all_extension_numbers_response:type_name -> grpc.reflection.v1.ExtensionNumberResponse - 5, // 4: grpc.reflection.v1.ServerReflectionResponse.list_services_response:type_name -> grpc.reflection.v1.ListServiceResponse - 7, // 5: grpc.reflection.v1.ServerReflectionResponse.error_response:type_name -> grpc.reflection.v1.ErrorResponse - 6, // 6: grpc.reflection.v1.ListServiceResponse.service:type_name -> grpc.reflection.v1.ServiceResponse - 0, // 7: grpc.reflection.v1.ServerReflection.ServerReflectionInfo:input_type -> grpc.reflection.v1.ServerReflectionRequest - 2, // 8: grpc.reflection.v1.ServerReflection.ServerReflectionInfo:output_type -> grpc.reflection.v1.ServerReflectionResponse - 8, // [8:9] is the sub-list for method output_type - 7, // [7:8] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_grpc_reflection_v1_reflection_proto_init() } -func file_grpc_reflection_v1_reflection_proto_init() { - if File_grpc_reflection_v1_reflection_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_grpc_reflection_v1_reflection_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerReflectionRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExtensionRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerReflectionResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FileDescriptorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExtensionNumberResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ErrorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_grpc_reflection_v1_reflection_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*ServerReflectionRequest_FileByFilename)(nil), - (*ServerReflectionRequest_FileContainingSymbol)(nil), - (*ServerReflectionRequest_FileContainingExtension)(nil), - (*ServerReflectionRequest_AllExtensionNumbersOfType)(nil), - (*ServerReflectionRequest_ListServices)(nil), - } - file_grpc_reflection_v1_reflection_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*ServerReflectionResponse_FileDescriptorResponse)(nil), - (*ServerReflectionResponse_AllExtensionNumbersResponse)(nil), - (*ServerReflectionResponse_ListServicesResponse)(nil), - (*ServerReflectionResponse_ErrorResponse)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_grpc_reflection_v1_reflection_proto_rawDesc, - NumEnums: 0, - NumMessages: 8, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_grpc_reflection_v1_reflection_proto_goTypes, - DependencyIndexes: file_grpc_reflection_v1_reflection_proto_depIdxs, - MessageInfos: file_grpc_reflection_v1_reflection_proto_msgTypes, - }.Build() - File_grpc_reflection_v1_reflection_proto = out.File - file_grpc_reflection_v1_reflection_proto_rawDesc = nil - file_grpc_reflection_v1_reflection_proto_goTypes = nil - file_grpc_reflection_v1_reflection_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go deleted file mode 100644 index 6e544f81..00000000 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2016 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Service exported by server reflection. A more complete description of how -// server reflection works can be found at -// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md -// -// The canonical version of this proto can be found at -// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto - -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v4.25.2 -// source: grpc/reflection/v1/reflection.proto - -package grpc_reflection_v1 - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 - -const ( - ServerReflection_ServerReflectionInfo_FullMethodName = "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo" -) - -// ServerReflectionClient is the client API for ServerReflection service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ServerReflectionClient interface { - // The reflection service is structured as a bidirectional stream, ensuring - // all related requests go to a single server. - ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) -} - -type serverReflectionClient struct { - cc grpc.ClientConnInterface -} - -func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClient { - return &serverReflectionClient{cc} -} - -func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], ServerReflection_ServerReflectionInfo_FullMethodName, cOpts...) - if err != nil { - return nil, err - } - x := &serverReflectionServerReflectionInfoClient{ClientStream: stream} - return x, nil -} - -type ServerReflection_ServerReflectionInfoClient interface { - Send(*ServerReflectionRequest) error - Recv() (*ServerReflectionResponse, error) - grpc.ClientStream -} - -type serverReflectionServerReflectionInfoClient struct { - grpc.ClientStream -} - -func (x *serverReflectionServerReflectionInfoClient) Send(m *ServerReflectionRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *serverReflectionServerReflectionInfoClient) Recv() (*ServerReflectionResponse, error) { - m := new(ServerReflectionResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// ServerReflectionServer is the server API for ServerReflection service. -// All implementations should embed UnimplementedServerReflectionServer -// for forward compatibility -type ServerReflectionServer interface { - // The reflection service is structured as a bidirectional stream, ensuring - // all related requests go to a single server. - ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error -} - -// UnimplementedServerReflectionServer should be embedded to have forward compatible implementations. -type UnimplementedServerReflectionServer struct { -} - -func (UnimplementedServerReflectionServer) ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error { - return status.Errorf(codes.Unimplemented, "method ServerReflectionInfo not implemented") -} - -// UnsafeServerReflectionServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ServerReflectionServer will -// result in compilation errors. -type UnsafeServerReflectionServer interface { - mustEmbedUnimplementedServerReflectionServer() -} - -func RegisterServerReflectionServer(s grpc.ServiceRegistrar, srv ServerReflectionServer) { - s.RegisterService(&ServerReflection_ServiceDesc, srv) -} - -func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{ServerStream: stream}) -} - -type ServerReflection_ServerReflectionInfoServer interface { - Send(*ServerReflectionResponse) error - Recv() (*ServerReflectionRequest, error) - grpc.ServerStream -} - -type serverReflectionServerReflectionInfoServer struct { - grpc.ServerStream -} - -func (x *serverReflectionServerReflectionInfoServer) Send(m *ServerReflectionResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *serverReflectionServerReflectionInfoServer) Recv() (*ServerReflectionRequest, error) { - m := new(ServerReflectionRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// ServerReflection_ServiceDesc is the grpc.ServiceDesc for ServerReflection service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var ServerReflection_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "grpc.reflection.v1.ServerReflection", - HandlerType: (*ServerReflectionServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "ServerReflectionInfo", - Handler: _ServerReflection_ServerReflectionInfo_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "grpc/reflection/v1/reflection.proto", -} diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go deleted file mode 100644 index 909b24a1..00000000 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go +++ /dev/null @@ -1,1028 +0,0 @@ -// Copyright 2016 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// Service exported by server reflection - -// Warning: this entire file is deprecated. Use this instead: -// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.33.0 -// protoc v4.25.2 -// grpc/reflection/v1alpha/reflection.proto is a deprecated file. - -package grpc_reflection_v1alpha - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The message sent by the client when calling ServerReflectionInfo method. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type ServerReflectionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` - // To use reflection service, the client should set one of the following - // fields in message_request. The server distinguishes requests by their - // defined field and then handles them using corresponding methods. - // - // Types that are assignable to MessageRequest: - // - // *ServerReflectionRequest_FileByFilename - // *ServerReflectionRequest_FileContainingSymbol - // *ServerReflectionRequest_FileContainingExtension - // *ServerReflectionRequest_AllExtensionNumbersOfType - // *ServerReflectionRequest_ListServices - MessageRequest isServerReflectionRequest_MessageRequest `protobuf_oneof:"message_request"` -} - -func (x *ServerReflectionRequest) Reset() { - *x = ServerReflectionRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerReflectionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerReflectionRequest) ProtoMessage() {} - -func (x *ServerReflectionRequest) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServerReflectionRequest.ProtoReflect.Descriptor instead. -func (*ServerReflectionRequest) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{0} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionRequest) GetHost() string { - if x != nil { - return x.Host - } - return "" -} - -func (m *ServerReflectionRequest) GetMessageRequest() isServerReflectionRequest_MessageRequest { - if m != nil { - return m.MessageRequest - } - return nil -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionRequest) GetFileByFilename() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileByFilename); ok { - return x.FileByFilename - } - return "" -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionRequest) GetFileContainingSymbol() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingSymbol); ok { - return x.FileContainingSymbol - } - return "" -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionRequest) GetFileContainingExtension() *ExtensionRequest { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingExtension); ok { - return x.FileContainingExtension - } - return nil -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionRequest) GetAllExtensionNumbersOfType() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_AllExtensionNumbersOfType); ok { - return x.AllExtensionNumbersOfType - } - return "" -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionRequest) GetListServices() string { - if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_ListServices); ok { - return x.ListServices - } - return "" -} - -type isServerReflectionRequest_MessageRequest interface { - isServerReflectionRequest_MessageRequest() -} - -type ServerReflectionRequest_FileByFilename struct { - // Find a proto file by the file name. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - FileByFilename string `protobuf:"bytes,3,opt,name=file_by_filename,json=fileByFilename,proto3,oneof"` -} - -type ServerReflectionRequest_FileContainingSymbol struct { - // Find the proto file that declares the given fully-qualified symbol name. - // This field should be a fully-qualified symbol name - // (e.g. .[.] or .). - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - FileContainingSymbol string `protobuf:"bytes,4,opt,name=file_containing_symbol,json=fileContainingSymbol,proto3,oneof"` -} - -type ServerReflectionRequest_FileContainingExtension struct { - // Find the proto file which defines an extension extending the given - // message type with the given field number. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - FileContainingExtension *ExtensionRequest `protobuf:"bytes,5,opt,name=file_containing_extension,json=fileContainingExtension,proto3,oneof"` -} - -type ServerReflectionRequest_AllExtensionNumbersOfType struct { - // Finds the tag numbers used by all known extensions of extendee_type, and - // appends them to ExtensionNumberResponse in an undefined order. - // Its corresponding method is best-effort: it's not guaranteed that the - // reflection service will implement this method, and it's not guaranteed - // that this method will provide all extensions. Returns - // StatusCode::UNIMPLEMENTED if it's not implemented. - // This field should be a fully-qualified type name. The format is - // . - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - AllExtensionNumbersOfType string `protobuf:"bytes,6,opt,name=all_extension_numbers_of_type,json=allExtensionNumbersOfType,proto3,oneof"` -} - -type ServerReflectionRequest_ListServices struct { - // List the full names of registered services. The content will not be - // checked. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ListServices string `protobuf:"bytes,7,opt,name=list_services,json=listServices,proto3,oneof"` -} - -func (*ServerReflectionRequest_FileByFilename) isServerReflectionRequest_MessageRequest() {} - -func (*ServerReflectionRequest_FileContainingSymbol) isServerReflectionRequest_MessageRequest() {} - -func (*ServerReflectionRequest_FileContainingExtension) isServerReflectionRequest_MessageRequest() {} - -func (*ServerReflectionRequest_AllExtensionNumbersOfType) isServerReflectionRequest_MessageRequest() { -} - -func (*ServerReflectionRequest_ListServices) isServerReflectionRequest_MessageRequest() {} - -// The type name and extension number sent by the client when requesting -// file_containing_extension. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type ExtensionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Fully-qualified type name. The format should be . - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ContainingType string `protobuf:"bytes,1,opt,name=containing_type,json=containingType,proto3" json:"containing_type,omitempty"` - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ExtensionNumber int32 `protobuf:"varint,2,opt,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` -} - -func (x *ExtensionRequest) Reset() { - *x = ExtensionRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExtensionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExtensionRequest) ProtoMessage() {} - -func (x *ExtensionRequest) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExtensionRequest.ProtoReflect.Descriptor instead. -func (*ExtensionRequest) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{1} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ExtensionRequest) GetContainingType() string { - if x != nil { - return x.ContainingType - } - return "" -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ExtensionRequest) GetExtensionNumber() int32 { - if x != nil { - return x.ExtensionNumber - } - return 0 -} - -// The message sent by the server to answer ServerReflectionInfo method. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type ServerReflectionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ValidHost string `protobuf:"bytes,1,opt,name=valid_host,json=validHost,proto3" json:"valid_host,omitempty"` - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - OriginalRequest *ServerReflectionRequest `protobuf:"bytes,2,opt,name=original_request,json=originalRequest,proto3" json:"original_request,omitempty"` - // The server set one of the following fields according to the message_request - // in the request. - // - // Types that are assignable to MessageResponse: - // - // *ServerReflectionResponse_FileDescriptorResponse - // *ServerReflectionResponse_AllExtensionNumbersResponse - // *ServerReflectionResponse_ListServicesResponse - // *ServerReflectionResponse_ErrorResponse - MessageResponse isServerReflectionResponse_MessageResponse `protobuf_oneof:"message_response"` -} - -func (x *ServerReflectionResponse) Reset() { - *x = ServerReflectionResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerReflectionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerReflectionResponse) ProtoMessage() {} - -func (x *ServerReflectionResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServerReflectionResponse.ProtoReflect.Descriptor instead. -func (*ServerReflectionResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{2} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionResponse) GetValidHost() string { - if x != nil { - return x.ValidHost - } - return "" -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionResponse) GetOriginalRequest() *ServerReflectionRequest { - if x != nil { - return x.OriginalRequest - } - return nil -} - -func (m *ServerReflectionResponse) GetMessageResponse() isServerReflectionResponse_MessageResponse { - if m != nil { - return m.MessageResponse - } - return nil -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionResponse) GetFileDescriptorResponse() *FileDescriptorResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_FileDescriptorResponse); ok { - return x.FileDescriptorResponse - } - return nil -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionResponse) GetAllExtensionNumbersResponse() *ExtensionNumberResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_AllExtensionNumbersResponse); ok { - return x.AllExtensionNumbersResponse - } - return nil -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionResponse) GetListServicesResponse() *ListServiceResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ListServicesResponse); ok { - return x.ListServicesResponse - } - return nil -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServerReflectionResponse) GetErrorResponse() *ErrorResponse { - if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ErrorResponse); ok { - return x.ErrorResponse - } - return nil -} - -type isServerReflectionResponse_MessageResponse interface { - isServerReflectionResponse_MessageResponse() -} - -type ServerReflectionResponse_FileDescriptorResponse struct { - // This message is used to answer file_by_filename, file_containing_symbol, - // file_containing_extension requests with transitive dependencies. As - // the repeated label is not allowed in oneof fields, we use a - // FileDescriptorResponse message to encapsulate the repeated fields. - // The reflection service is allowed to avoid sending FileDescriptorProtos - // that were previously sent in response to earlier requests in the stream. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - FileDescriptorResponse *FileDescriptorResponse `protobuf:"bytes,4,opt,name=file_descriptor_response,json=fileDescriptorResponse,proto3,oneof"` -} - -type ServerReflectionResponse_AllExtensionNumbersResponse struct { - // This message is used to answer all_extension_numbers_of_type requst. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - AllExtensionNumbersResponse *ExtensionNumberResponse `protobuf:"bytes,5,opt,name=all_extension_numbers_response,json=allExtensionNumbersResponse,proto3,oneof"` -} - -type ServerReflectionResponse_ListServicesResponse struct { - // This message is used to answer list_services request. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ListServicesResponse *ListServiceResponse `protobuf:"bytes,6,opt,name=list_services_response,json=listServicesResponse,proto3,oneof"` -} - -type ServerReflectionResponse_ErrorResponse struct { - // This message is used when an error occurs. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ErrorResponse *ErrorResponse `protobuf:"bytes,7,opt,name=error_response,json=errorResponse,proto3,oneof"` -} - -func (*ServerReflectionResponse_FileDescriptorResponse) isServerReflectionResponse_MessageResponse() { -} - -func (*ServerReflectionResponse_AllExtensionNumbersResponse) isServerReflectionResponse_MessageResponse() { -} - -func (*ServerReflectionResponse_ListServicesResponse) isServerReflectionResponse_MessageResponse() {} - -func (*ServerReflectionResponse_ErrorResponse) isServerReflectionResponse_MessageResponse() {} - -// Serialized FileDescriptorProto messages sent by the server answering -// a file_by_filename, file_containing_symbol, or file_containing_extension -// request. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type FileDescriptorResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Serialized FileDescriptorProto messages. We avoid taking a dependency on - // descriptor.proto, which uses proto2 only features, by making them opaque - // bytes instead. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - FileDescriptorProto [][]byte `protobuf:"bytes,1,rep,name=file_descriptor_proto,json=fileDescriptorProto,proto3" json:"file_descriptor_proto,omitempty"` -} - -func (x *FileDescriptorResponse) Reset() { - *x = FileDescriptorResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FileDescriptorResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FileDescriptorResponse) ProtoMessage() {} - -func (x *FileDescriptorResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FileDescriptorResponse.ProtoReflect.Descriptor instead. -func (*FileDescriptorResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{3} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *FileDescriptorResponse) GetFileDescriptorProto() [][]byte { - if x != nil { - return x.FileDescriptorProto - } - return nil -} - -// A list of extension numbers sent by the server answering -// all_extension_numbers_of_type request. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type ExtensionNumberResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Full name of the base type, including the package name. The format - // is . - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - BaseTypeName string `protobuf:"bytes,1,opt,name=base_type_name,json=baseTypeName,proto3" json:"base_type_name,omitempty"` - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ExtensionNumber []int32 `protobuf:"varint,2,rep,packed,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"` -} - -func (x *ExtensionNumberResponse) Reset() { - *x = ExtensionNumberResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExtensionNumberResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExtensionNumberResponse) ProtoMessage() {} - -func (x *ExtensionNumberResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExtensionNumberResponse.ProtoReflect.Descriptor instead. -func (*ExtensionNumberResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{4} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ExtensionNumberResponse) GetBaseTypeName() string { - if x != nil { - return x.BaseTypeName - } - return "" -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ExtensionNumberResponse) GetExtensionNumber() []int32 { - if x != nil { - return x.ExtensionNumber - } - return nil -} - -// A list of ServiceResponse sent by the server answering list_services request. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type ListServiceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The information of each service may be expanded in the future, so we use - // ServiceResponse message to encapsulate it. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - Service []*ServiceResponse `protobuf:"bytes,1,rep,name=service,proto3" json:"service,omitempty"` -} - -func (x *ListServiceResponse) Reset() { - *x = ListServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListServiceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListServiceResponse) ProtoMessage() {} - -func (x *ListServiceResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListServiceResponse.ProtoReflect.Descriptor instead. -func (*ListServiceResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{5} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ListServiceResponse) GetService() []*ServiceResponse { - if x != nil { - return x.Service - } - return nil -} - -// The information of a single service used by ListServiceResponse to answer -// list_services request. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type ServiceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Full name of a registered service, including its package name. The format - // is . - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *ServiceResponse) Reset() { - *x = ServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServiceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceResponse) ProtoMessage() {} - -func (x *ServiceResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServiceResponse.ProtoReflect.Descriptor instead. -func (*ServiceResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{6} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ServiceResponse) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The error code and error message sent by the server when an error occurs. -// -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -type ErrorResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // This field uses the error codes defined in grpc::StatusCode. - // - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` - // Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` -} - -func (x *ErrorResponse) Reset() { - *x = ErrorResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ErrorResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ErrorResponse) ProtoMessage() {} - -func (x *ErrorResponse) ProtoReflect() protoreflect.Message { - mi := &file_grpc_reflection_v1alpha_reflection_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead. -func (*ErrorResponse) Descriptor() ([]byte, []int) { - return file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{7} -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ErrorResponse) GetErrorCode() int32 { - if x != nil { - return x.ErrorCode - } - return 0 -} - -// Deprecated: The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated. -func (x *ErrorResponse) GetErrorMessage() string { - if x != nil { - return x.ErrorMessage - } - return "" -} - -var File_grpc_reflection_v1alpha_reflection_proto protoreflect.FileDescriptor - -var file_grpc_reflection_v1alpha_reflection_proto_rawDesc = []byte{ - 0x0a, 0x28, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x67, 0x72, 0x70, 0x63, - 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x22, 0xf8, 0x02, 0x0a, 0x17, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, - 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, - 0x6f, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x62, 0x79, 0x5f, 0x66, - 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, - 0x0e, 0x66, 0x69, 0x6c, 0x65, 0x42, 0x79, 0x46, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x36, 0x0a, 0x16, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, - 0x6e, 0x67, 0x5f, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, - 0x00, 0x52, 0x14, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, - 0x67, 0x53, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x67, 0x0a, 0x19, 0x66, 0x69, 0x6c, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x67, 0x72, 0x70, - 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x17, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x42, 0x0a, 0x1d, 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, - 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x19, 0x61, 0x6c, 0x6c, 0x45, 0x78, - 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x4f, 0x66, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x0d, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, 0x6c, - 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x42, 0x11, 0x0a, 0x0f, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x66, - 0x0a, 0x10, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, - 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xc7, 0x04, 0x0a, 0x18, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x68, 0x6f, 0x73, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x48, 0x6f, - 0x73, 0x74, 0x12, 0x5b, 0x0a, 0x10, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, - 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, - 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0f, - 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x6b, 0x0a, 0x18, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x46, 0x69, 0x6c, 0x65, - 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x48, 0x00, 0x52, 0x16, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x77, 0x0a, 0x1e, - 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, - 0x6d, 0x62, 0x65, 0x72, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x1b, 0x61, 0x6c, 0x6c, 0x45, 0x78, 0x74, - 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x64, 0x0a, 0x16, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, - 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x14, 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x0e, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x12, 0x0a, 0x10, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x4c, 0x0a, 0x16, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x66, 0x69, - 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x13, 0x66, 0x69, 0x6c, 0x65, 0x44, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a, - 0x0a, 0x17, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x62, 0x61, 0x73, - 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x62, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x29, 0x0a, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x13, 0x4c, 0x69, - 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x42, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x53, 0x0a, 0x0d, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, - 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x32, 0x93, 0x01, 0x0a, 0x10, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x7f, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x30, - 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, - 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x73, 0x0a, 0x1a, 0x69, 0x6f, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x42, 0x15, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, - 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x39, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, - 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0xb8, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_grpc_reflection_v1alpha_reflection_proto_rawDescOnce sync.Once - file_grpc_reflection_v1alpha_reflection_proto_rawDescData = file_grpc_reflection_v1alpha_reflection_proto_rawDesc -) - -func file_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP() []byte { - file_grpc_reflection_v1alpha_reflection_proto_rawDescOnce.Do(func() { - file_grpc_reflection_v1alpha_reflection_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_reflection_v1alpha_reflection_proto_rawDescData) - }) - return file_grpc_reflection_v1alpha_reflection_proto_rawDescData -} - -var file_grpc_reflection_v1alpha_reflection_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_grpc_reflection_v1alpha_reflection_proto_goTypes = []interface{}{ - (*ServerReflectionRequest)(nil), // 0: grpc.reflection.v1alpha.ServerReflectionRequest - (*ExtensionRequest)(nil), // 1: grpc.reflection.v1alpha.ExtensionRequest - (*ServerReflectionResponse)(nil), // 2: grpc.reflection.v1alpha.ServerReflectionResponse - (*FileDescriptorResponse)(nil), // 3: grpc.reflection.v1alpha.FileDescriptorResponse - (*ExtensionNumberResponse)(nil), // 4: grpc.reflection.v1alpha.ExtensionNumberResponse - (*ListServiceResponse)(nil), // 5: grpc.reflection.v1alpha.ListServiceResponse - (*ServiceResponse)(nil), // 6: grpc.reflection.v1alpha.ServiceResponse - (*ErrorResponse)(nil), // 7: grpc.reflection.v1alpha.ErrorResponse -} -var file_grpc_reflection_v1alpha_reflection_proto_depIdxs = []int32{ - 1, // 0: grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension:type_name -> grpc.reflection.v1alpha.ExtensionRequest - 0, // 1: grpc.reflection.v1alpha.ServerReflectionResponse.original_request:type_name -> grpc.reflection.v1alpha.ServerReflectionRequest - 3, // 2: grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response:type_name -> grpc.reflection.v1alpha.FileDescriptorResponse - 4, // 3: grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response:type_name -> grpc.reflection.v1alpha.ExtensionNumberResponse - 5, // 4: grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response:type_name -> grpc.reflection.v1alpha.ListServiceResponse - 7, // 5: grpc.reflection.v1alpha.ServerReflectionResponse.error_response:type_name -> grpc.reflection.v1alpha.ErrorResponse - 6, // 6: grpc.reflection.v1alpha.ListServiceResponse.service:type_name -> grpc.reflection.v1alpha.ServiceResponse - 0, // 7: grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo:input_type -> grpc.reflection.v1alpha.ServerReflectionRequest - 2, // 8: grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo:output_type -> grpc.reflection.v1alpha.ServerReflectionResponse - 8, // [8:9] is the sub-list for method output_type - 7, // [7:8] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_grpc_reflection_v1alpha_reflection_proto_init() } -func file_grpc_reflection_v1alpha_reflection_proto_init() { - if File_grpc_reflection_v1alpha_reflection_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerReflectionRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExtensionRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerReflectionResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FileDescriptorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExtensionNumberResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ErrorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*ServerReflectionRequest_FileByFilename)(nil), - (*ServerReflectionRequest_FileContainingSymbol)(nil), - (*ServerReflectionRequest_FileContainingExtension)(nil), - (*ServerReflectionRequest_AllExtensionNumbersOfType)(nil), - (*ServerReflectionRequest_ListServices)(nil), - } - file_grpc_reflection_v1alpha_reflection_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*ServerReflectionResponse_FileDescriptorResponse)(nil), - (*ServerReflectionResponse_AllExtensionNumbersResponse)(nil), - (*ServerReflectionResponse_ListServicesResponse)(nil), - (*ServerReflectionResponse_ErrorResponse)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_grpc_reflection_v1alpha_reflection_proto_rawDesc, - NumEnums: 0, - NumMessages: 8, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_grpc_reflection_v1alpha_reflection_proto_goTypes, - DependencyIndexes: file_grpc_reflection_v1alpha_reflection_proto_depIdxs, - MessageInfos: file_grpc_reflection_v1alpha_reflection_proto_msgTypes, - }.Build() - File_grpc_reflection_v1alpha_reflection_proto = out.File - file_grpc_reflection_v1alpha_reflection_proto_rawDesc = nil - file_grpc_reflection_v1alpha_reflection_proto_goTypes = nil - file_grpc_reflection_v1alpha_reflection_proto_depIdxs = nil -} diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go deleted file mode 100644 index 3de5dc35..00000000 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2016 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// Service exported by server reflection - -// Warning: this entire file is deprecated. Use this instead: -// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto - -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v4.25.2 -// grpc/reflection/v1alpha/reflection.proto is a deprecated file. - -package grpc_reflection_v1alpha - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 - -const ( - ServerReflection_ServerReflectionInfo_FullMethodName = "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo" -) - -// ServerReflectionClient is the client API for ServerReflection service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ServerReflectionClient interface { - // The reflection service is structured as a bidirectional stream, ensuring - // all related requests go to a single server. - ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) -} - -type serverReflectionClient struct { - cc grpc.ClientConnInterface -} - -func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClient { - return &serverReflectionClient{cc} -} - -func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], ServerReflection_ServerReflectionInfo_FullMethodName, cOpts...) - if err != nil { - return nil, err - } - x := &serverReflectionServerReflectionInfoClient{ClientStream: stream} - return x, nil -} - -type ServerReflection_ServerReflectionInfoClient interface { - Send(*ServerReflectionRequest) error - Recv() (*ServerReflectionResponse, error) - grpc.ClientStream -} - -type serverReflectionServerReflectionInfoClient struct { - grpc.ClientStream -} - -func (x *serverReflectionServerReflectionInfoClient) Send(m *ServerReflectionRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *serverReflectionServerReflectionInfoClient) Recv() (*ServerReflectionResponse, error) { - m := new(ServerReflectionResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// ServerReflectionServer is the server API for ServerReflection service. -// All implementations should embed UnimplementedServerReflectionServer -// for forward compatibility -type ServerReflectionServer interface { - // The reflection service is structured as a bidirectional stream, ensuring - // all related requests go to a single server. - ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error -} - -// UnimplementedServerReflectionServer should be embedded to have forward compatible implementations. -type UnimplementedServerReflectionServer struct { -} - -func (UnimplementedServerReflectionServer) ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error { - return status.Errorf(codes.Unimplemented, "method ServerReflectionInfo not implemented") -} - -// UnsafeServerReflectionServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ServerReflectionServer will -// result in compilation errors. -type UnsafeServerReflectionServer interface { - mustEmbedUnimplementedServerReflectionServer() -} - -func RegisterServerReflectionServer(s grpc.ServiceRegistrar, srv ServerReflectionServer) { - s.RegisterService(&ServerReflection_ServiceDesc, srv) -} - -func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{ServerStream: stream}) -} - -type ServerReflection_ServerReflectionInfoServer interface { - Send(*ServerReflectionResponse) error - Recv() (*ServerReflectionRequest, error) - grpc.ServerStream -} - -type serverReflectionServerReflectionInfoServer struct { - grpc.ServerStream -} - -func (x *serverReflectionServerReflectionInfoServer) Send(m *ServerReflectionResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *serverReflectionServerReflectionInfoServer) Recv() (*ServerReflectionRequest, error) { - m := new(ServerReflectionRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// ServerReflection_ServiceDesc is the grpc.ServiceDesc for ServerReflection service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var ServerReflection_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "grpc.reflection.v1alpha.ServerReflection", - HandlerType: (*ServerReflectionServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "ServerReflectionInfo", - Handler: _ServerReflection_ServerReflectionInfo_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "grpc/reflection/v1alpha/reflection.proto", -} diff --git a/vendor/google.golang.org/grpc/reflection/internal/internal.go b/vendor/google.golang.org/grpc/reflection/internal/internal.go deleted file mode 100644 index 36ee6507..00000000 --- a/vendor/google.golang.org/grpc/reflection/internal/internal.go +++ /dev/null @@ -1,436 +0,0 @@ -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package internal contains code that is shared by both reflection package and -// the test package. The packages are split in this way inorder to avoid -// depenedency to deprecated package github.com/golang/protobuf. -package internal - -import ( - "io" - "sort" - - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protodesc" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" - - v1reflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1" - v1reflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1" - v1alphareflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" - v1alphareflectionpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" -) - -// ServiceInfoProvider is an interface used to retrieve metadata about the -// services to expose. -type ServiceInfoProvider interface { - GetServiceInfo() map[string]grpc.ServiceInfo -} - -// ExtensionResolver is the interface used to query details about extensions. -// This interface is satisfied by protoregistry.GlobalTypes. -type ExtensionResolver interface { - protoregistry.ExtensionTypeResolver - RangeExtensionsByMessage(message protoreflect.FullName, f func(protoreflect.ExtensionType) bool) -} - -// ServerReflectionServer is the server API for ServerReflection service. -type ServerReflectionServer struct { - v1alphareflectiongrpc.UnimplementedServerReflectionServer - S ServiceInfoProvider - DescResolver protodesc.Resolver - ExtResolver ExtensionResolver -} - -// FileDescWithDependencies returns a slice of serialized fileDescriptors in -// wire format ([]byte). The fileDescriptors will include fd and all the -// transitive dependencies of fd with names not in sentFileDescriptors. -func (s *ServerReflectionServer) FileDescWithDependencies(fd protoreflect.FileDescriptor, sentFileDescriptors map[string]bool) ([][]byte, error) { - if fd.IsPlaceholder() { - // If the given root file is a placeholder, treat it - // as missing instead of serializing it. - return nil, protoregistry.NotFound - } - var r [][]byte - queue := []protoreflect.FileDescriptor{fd} - for len(queue) > 0 { - currentfd := queue[0] - queue = queue[1:] - if currentfd.IsPlaceholder() { - // Skip any missing files in the dependency graph. - continue - } - if sent := sentFileDescriptors[currentfd.Path()]; len(r) == 0 || !sent { - sentFileDescriptors[currentfd.Path()] = true - fdProto := protodesc.ToFileDescriptorProto(currentfd) - currentfdEncoded, err := proto.Marshal(fdProto) - if err != nil { - return nil, err - } - r = append(r, currentfdEncoded) - } - for i := 0; i < currentfd.Imports().Len(); i++ { - queue = append(queue, currentfd.Imports().Get(i)) - } - } - return r, nil -} - -// FileDescEncodingContainingSymbol finds the file descriptor containing the -// given symbol, finds all of its previously unsent transitive dependencies, -// does marshalling on them, and returns the marshalled result. The given symbol -// can be a type, a service or a method. -func (s *ServerReflectionServer) FileDescEncodingContainingSymbol(name string, sentFileDescriptors map[string]bool) ([][]byte, error) { - d, err := s.DescResolver.FindDescriptorByName(protoreflect.FullName(name)) - if err != nil { - return nil, err - } - return s.FileDescWithDependencies(d.ParentFile(), sentFileDescriptors) -} - -// FileDescEncodingContainingExtension finds the file descriptor containing -// given extension, finds all of its previously unsent transitive dependencies, -// does marshalling on them, and returns the marshalled result. -func (s *ServerReflectionServer) FileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) { - xt, err := s.ExtResolver.FindExtensionByNumber(protoreflect.FullName(typeName), protoreflect.FieldNumber(extNum)) - if err != nil { - return nil, err - } - return s.FileDescWithDependencies(xt.TypeDescriptor().ParentFile(), sentFileDescriptors) -} - -// AllExtensionNumbersForTypeName returns all extension numbers for the given type. -func (s *ServerReflectionServer) AllExtensionNumbersForTypeName(name string) ([]int32, error) { - var numbers []int32 - s.ExtResolver.RangeExtensionsByMessage(protoreflect.FullName(name), func(xt protoreflect.ExtensionType) bool { - numbers = append(numbers, int32(xt.TypeDescriptor().Number())) - return true - }) - sort.Slice(numbers, func(i, j int) bool { - return numbers[i] < numbers[j] - }) - if len(numbers) == 0 { - // maybe return an error if given type name is not known - if _, err := s.DescResolver.FindDescriptorByName(protoreflect.FullName(name)); err != nil { - return nil, err - } - } - return numbers, nil -} - -// ListServices returns the names of services this server exposes. -func (s *ServerReflectionServer) ListServices() []*v1reflectionpb.ServiceResponse { - serviceInfo := s.S.GetServiceInfo() - resp := make([]*v1reflectionpb.ServiceResponse, 0, len(serviceInfo)) - for svc := range serviceInfo { - resp = append(resp, &v1reflectionpb.ServiceResponse{Name: svc}) - } - sort.Slice(resp, func(i, j int) bool { - return resp[i].Name < resp[j].Name - }) - return resp -} - -// ServerReflectionInfo is the reflection service handler. -func (s *ServerReflectionServer) ServerReflectionInfo(stream v1reflectiongrpc.ServerReflection_ServerReflectionInfoServer) error { - sentFileDescriptors := make(map[string]bool) - for { - in, err := stream.Recv() - if err == io.EOF { - return nil - } - if err != nil { - return err - } - - out := &v1reflectionpb.ServerReflectionResponse{ - ValidHost: in.Host, - OriginalRequest: in, - } - switch req := in.MessageRequest.(type) { - case *v1reflectionpb.ServerReflectionRequest_FileByFilename: - var b [][]byte - fd, err := s.DescResolver.FindFileByPath(req.FileByFilename) - if err == nil { - b, err = s.FileDescWithDependencies(fd, sentFileDescriptors) - } - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingSymbol: - b, err := s.FileDescEncodingContainingSymbol(req.FileContainingSymbol, sentFileDescriptors) - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingExtension: - typeName := req.FileContainingExtension.ContainingType - extNum := req.FileContainingExtension.ExtensionNumber - b, err := s.FileDescEncodingContainingExtension(typeName, extNum, sentFileDescriptors) - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{FileDescriptorProto: b}, - } - } - case *v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: - extNums, err := s.AllExtensionNumbersForTypeName(req.AllExtensionNumbersOfType) - if err != nil { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: int32(codes.NotFound), - ErrorMessage: err.Error(), - }, - } - } else { - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ - AllExtensionNumbersResponse: &v1reflectionpb.ExtensionNumberResponse{ - BaseTypeName: req.AllExtensionNumbersOfType, - ExtensionNumber: extNums, - }, - } - } - case *v1reflectionpb.ServerReflectionRequest_ListServices: - out.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ListServicesResponse{ - ListServicesResponse: &v1reflectionpb.ListServiceResponse{ - Service: s.ListServices(), - }, - } - default: - return status.Errorf(codes.InvalidArgument, "invalid MessageRequest: %v", in.MessageRequest) - } - - if err := stream.Send(out); err != nil { - return err - } - } -} - -// V1ToV1AlphaResponse converts a v1 ServerReflectionResponse to a v1alpha. -func V1ToV1AlphaResponse(v1 *v1reflectionpb.ServerReflectionResponse) *v1alphareflectionpb.ServerReflectionResponse { - var v1alpha v1alphareflectionpb.ServerReflectionResponse - v1alpha.ValidHost = v1.ValidHost - if v1.OriginalRequest != nil { - v1alpha.OriginalRequest = V1ToV1AlphaRequest(v1.OriginalRequest) - } - switch mr := v1.MessageResponse.(type) { - case *v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse: - if mr != nil { - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1alphareflectionpb.FileDescriptorResponse{ - FileDescriptorProto: mr.FileDescriptorResponse.GetFileDescriptorProto(), - }, - } - } - case *v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse: - if mr != nil { - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ - AllExtensionNumbersResponse: &v1alphareflectionpb.ExtensionNumberResponse{ - BaseTypeName: mr.AllExtensionNumbersResponse.GetBaseTypeName(), - ExtensionNumber: mr.AllExtensionNumbersResponse.GetExtensionNumber(), - }, - } - } - case *v1reflectionpb.ServerReflectionResponse_ListServicesResponse: - if mr != nil { - svcs := make([]*v1alphareflectionpb.ServiceResponse, len(mr.ListServicesResponse.GetService())) - for i, svc := range mr.ListServicesResponse.GetService() { - svcs[i] = &v1alphareflectionpb.ServiceResponse{ - Name: svc.GetName(), - } - } - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_ListServicesResponse{ - ListServicesResponse: &v1alphareflectionpb.ListServiceResponse{ - Service: svcs, - }, - } - } - case *v1reflectionpb.ServerReflectionResponse_ErrorResponse: - if mr != nil { - v1alpha.MessageResponse = &v1alphareflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1alphareflectionpb.ErrorResponse{ - ErrorCode: mr.ErrorResponse.GetErrorCode(), - ErrorMessage: mr.ErrorResponse.GetErrorMessage(), - }, - } - } - default: - // no value set - } - return &v1alpha -} - -// V1AlphaToV1Request converts a v1alpha ServerReflectionRequest to a v1. -func V1AlphaToV1Request(v1alpha *v1alphareflectionpb.ServerReflectionRequest) *v1reflectionpb.ServerReflectionRequest { - var v1 v1reflectionpb.ServerReflectionRequest - v1.Host = v1alpha.Host - switch mr := v1alpha.MessageRequest.(type) { - case *v1alphareflectionpb.ServerReflectionRequest_FileByFilename: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileByFilename{ - FileByFilename: mr.FileByFilename, - } - case *v1alphareflectionpb.ServerReflectionRequest_FileContainingSymbol: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileContainingSymbol{ - FileContainingSymbol: mr.FileContainingSymbol, - } - case *v1alphareflectionpb.ServerReflectionRequest_FileContainingExtension: - if mr.FileContainingExtension != nil { - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_FileContainingExtension{ - FileContainingExtension: &v1reflectionpb.ExtensionRequest{ - ContainingType: mr.FileContainingExtension.GetContainingType(), - ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), - }, - } - } - case *v1alphareflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType{ - AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, - } - case *v1alphareflectionpb.ServerReflectionRequest_ListServices: - v1.MessageRequest = &v1reflectionpb.ServerReflectionRequest_ListServices{ - ListServices: mr.ListServices, - } - default: - // no value set - } - return &v1 -} - -// V1ToV1AlphaRequest converts a v1 ServerReflectionRequest to a v1alpha. -func V1ToV1AlphaRequest(v1 *v1reflectionpb.ServerReflectionRequest) *v1alphareflectionpb.ServerReflectionRequest { - var v1alpha v1alphareflectionpb.ServerReflectionRequest - v1alpha.Host = v1.Host - switch mr := v1.MessageRequest.(type) { - case *v1reflectionpb.ServerReflectionRequest_FileByFilename: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileByFilename{ - FileByFilename: mr.FileByFilename, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingSymbol: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileContainingSymbol{ - FileContainingSymbol: mr.FileContainingSymbol, - } - } - case *v1reflectionpb.ServerReflectionRequest_FileContainingExtension: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_FileContainingExtension{ - FileContainingExtension: &v1alphareflectionpb.ExtensionRequest{ - ContainingType: mr.FileContainingExtension.GetContainingType(), - ExtensionNumber: mr.FileContainingExtension.GetExtensionNumber(), - }, - } - } - case *v1reflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_AllExtensionNumbersOfType{ - AllExtensionNumbersOfType: mr.AllExtensionNumbersOfType, - } - } - case *v1reflectionpb.ServerReflectionRequest_ListServices: - if mr != nil { - v1alpha.MessageRequest = &v1alphareflectionpb.ServerReflectionRequest_ListServices{ - ListServices: mr.ListServices, - } - } - default: - // no value set - } - return &v1alpha -} - -// V1AlphaToV1Response converts a v1alpha ServerReflectionResponse to a v1. -func V1AlphaToV1Response(v1alpha *v1alphareflectionpb.ServerReflectionResponse) *v1reflectionpb.ServerReflectionResponse { - var v1 v1reflectionpb.ServerReflectionResponse - v1.ValidHost = v1alpha.ValidHost - if v1alpha.OriginalRequest != nil { - v1.OriginalRequest = V1AlphaToV1Request(v1alpha.OriginalRequest) - } - switch mr := v1alpha.MessageResponse.(type) { - case *v1alphareflectionpb.ServerReflectionResponse_FileDescriptorResponse: - if mr != nil { - v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_FileDescriptorResponse{ - FileDescriptorResponse: &v1reflectionpb.FileDescriptorResponse{ - FileDescriptorProto: mr.FileDescriptorResponse.GetFileDescriptorProto(), - }, - } - } - case *v1alphareflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse: - if mr != nil { - v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_AllExtensionNumbersResponse{ - AllExtensionNumbersResponse: &v1reflectionpb.ExtensionNumberResponse{ - BaseTypeName: mr.AllExtensionNumbersResponse.GetBaseTypeName(), - ExtensionNumber: mr.AllExtensionNumbersResponse.GetExtensionNumber(), - }, - } - } - case *v1alphareflectionpb.ServerReflectionResponse_ListServicesResponse: - if mr != nil { - svcs := make([]*v1reflectionpb.ServiceResponse, len(mr.ListServicesResponse.GetService())) - for i, svc := range mr.ListServicesResponse.GetService() { - svcs[i] = &v1reflectionpb.ServiceResponse{ - Name: svc.GetName(), - } - } - v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ListServicesResponse{ - ListServicesResponse: &v1reflectionpb.ListServiceResponse{ - Service: svcs, - }, - } - } - case *v1alphareflectionpb.ServerReflectionResponse_ErrorResponse: - if mr != nil { - v1.MessageResponse = &v1reflectionpb.ServerReflectionResponse_ErrorResponse{ - ErrorResponse: &v1reflectionpb.ErrorResponse{ - ErrorCode: mr.ErrorResponse.GetErrorCode(), - ErrorMessage: mr.ErrorResponse.GetErrorMessage(), - }, - } - } - default: - // no value set - } - return &v1 -} diff --git a/vendor/google.golang.org/grpc/reflection/serverreflection.go b/vendor/google.golang.org/grpc/reflection/serverreflection.go deleted file mode 100644 index 13a94e2d..00000000 --- a/vendor/google.golang.org/grpc/reflection/serverreflection.go +++ /dev/null @@ -1,160 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* -Package reflection implements server reflection service. - -The service implemented is defined in: -https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto. - -To register server reflection on a gRPC server: - - import "google.golang.org/grpc/reflection" - - s := grpc.NewServer() - pb.RegisterYourOwnServer(s, &server{}) - - // Register reflection service on gRPC server. - reflection.Register(s) - - s.Serve(lis) -*/ -package reflection // import "google.golang.org/grpc/reflection" - -import ( - "google.golang.org/grpc" - "google.golang.org/grpc/reflection/internal" - "google.golang.org/protobuf/reflect/protodesc" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" - - v1reflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1" - v1alphareflectiongrpc "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" -) - -// GRPCServer is the interface provided by a gRPC server. It is implemented by -// *grpc.Server, but could also be implemented by other concrete types. It acts -// as a registry, for accumulating the services exposed by the server. -type GRPCServer interface { - grpc.ServiceRegistrar - ServiceInfoProvider -} - -var _ GRPCServer = (*grpc.Server)(nil) - -// Register registers the server reflection service on the given gRPC server. -// Both the v1 and v1alpha versions are registered. -func Register(s GRPCServer) { - svr := NewServerV1(ServerOptions{Services: s}) - v1alphareflectiongrpc.RegisterServerReflectionServer(s, asV1Alpha(svr)) - v1reflectiongrpc.RegisterServerReflectionServer(s, svr) -} - -// RegisterV1 registers only the v1 version of the server reflection service -// on the given gRPC server. Many clients may only support v1alpha so most -// users should use Register instead, at least until clients have upgraded. -func RegisterV1(s GRPCServer) { - svr := NewServerV1(ServerOptions{Services: s}) - v1reflectiongrpc.RegisterServerReflectionServer(s, svr) -} - -// ServiceInfoProvider is an interface used to retrieve metadata about the -// services to expose. -// -// The reflection service is only interested in the service names, but the -// signature is this way so that *grpc.Server implements it. So it is okay -// for a custom implementation to return zero values for the -// grpc.ServiceInfo values in the map. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type ServiceInfoProvider interface { - GetServiceInfo() map[string]grpc.ServiceInfo -} - -// ExtensionResolver is the interface used to query details about extensions. -// This interface is satisfied by protoregistry.GlobalTypes. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type ExtensionResolver interface { - protoregistry.ExtensionTypeResolver - RangeExtensionsByMessage(message protoreflect.FullName, f func(protoreflect.ExtensionType) bool) -} - -// ServerOptions represents the options used to construct a reflection server. -// -// # Experimental -// -// Notice: This type is EXPERIMENTAL and may be changed or removed in a -// later release. -type ServerOptions struct { - // The source of advertised RPC services. If not specified, the reflection - // server will report an empty list when asked to list services. - // - // This value will typically be a *grpc.Server. But the set of advertised - // services can be customized by wrapping a *grpc.Server or using an - // alternate implementation that returns a custom set of service names. - Services ServiceInfoProvider - // Optional resolver used to load descriptors. If not specified, - // protoregistry.GlobalFiles will be used. - DescriptorResolver protodesc.Resolver - // Optional resolver used to query for known extensions. If not specified, - // protoregistry.GlobalTypes will be used. - ExtensionResolver ExtensionResolver -} - -// NewServer returns a reflection server implementation using the given options. -// This can be used to customize behavior of the reflection service. Most usages -// should prefer to use Register instead. For backwards compatibility reasons, -// this returns the v1alpha version of the reflection server. For a v1 version -// of the reflection server, see NewServerV1. -// -// # Experimental -// -// Notice: This function is EXPERIMENTAL and may be changed or removed in a -// later release. -func NewServer(opts ServerOptions) v1alphareflectiongrpc.ServerReflectionServer { - return asV1Alpha(NewServerV1(opts)) -} - -// NewServerV1 returns a reflection server implementation using the given options. -// This can be used to customize behavior of the reflection service. Most usages -// should prefer to use Register instead. -// -// # Experimental -// -// Notice: This function is EXPERIMENTAL and may be changed or removed in a -// later release. -func NewServerV1(opts ServerOptions) v1reflectiongrpc.ServerReflectionServer { - if opts.DescriptorResolver == nil { - opts.DescriptorResolver = protoregistry.GlobalFiles - } - if opts.ExtensionResolver == nil { - opts.ExtensionResolver = protoregistry.GlobalTypes - } - return &internal.ServerReflectionServer{ - S: opts.Services, - DescResolver: opts.DescriptorResolver, - ExtResolver: opts.ExtensionResolver, - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 34d90f1a..34b08b52 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -806,10 +806,6 @@ google.golang.org/grpc/internal/transport/networktype google.golang.org/grpc/keepalive google.golang.org/grpc/metadata google.golang.org/grpc/peer -google.golang.org/grpc/reflection -google.golang.org/grpc/reflection/grpc_reflection_v1 -google.golang.org/grpc/reflection/grpc_reflection_v1alpha -google.golang.org/grpc/reflection/internal google.golang.org/grpc/resolver google.golang.org/grpc/resolver/dns google.golang.org/grpc/resolver/manual