cluster.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package model
  2. import (
  3. "net/http"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. )
  7. //ClusterItems cluster items
  8. type ClusterItems struct {
  9. Items map[string]interface{} `json:"items"`
  10. }
  11. //RmTokenPost get token
  12. type RmTokenPost = struct {
  13. APIToken string `json:"api_token"`
  14. PlatformID string `json:"platform_id"`
  15. }
  16. //ClusterResponse json body
  17. type ClusterResponse struct {
  18. ExcludeDataResponse
  19. Count int `json:"count"`
  20. Data *ClusterResponseItems `json:"data"`
  21. }
  22. //ClusterResponseItems json body
  23. type ClusterResponseItems struct {
  24. Items []*ClusterResponseItemsSon `json:"items"`
  25. }
  26. //ClusterResponseItemsSon json body
  27. type ClusterResponseItemsSon struct {
  28. Configuration ClusterConfiguration `json:"configuration"`
  29. Resources ClusterPoolResourcesUsage `json:"resources"`
  30. PoolResourcesUsage PoolResourcesUsageSon `json:"pool_resources_usage"`
  31. }
  32. //PoolResourcesUsageSon json body
  33. type PoolResourcesUsageSon struct {
  34. Ep ClusterPoolResourcesUsage `json:"ep"`
  35. Melloi ClusterPoolResourcesUsage `json:"melloi"`
  36. Public ClusterPoolResourcesUsage `json:"public"`
  37. }
  38. //ClusterConf visit PaaS
  39. type ClusterConf struct {
  40. TestHost string
  41. UatHost string
  42. QueryJobCPUHost string
  43. }
  44. // ClusterRmTokenResponse query token response.
  45. type ClusterRmTokenResponse struct {
  46. ExcludeDataResponse
  47. Data AuthData `json:"data"`
  48. }
  49. // ExcludeDataResponse no data field response.
  50. type ExcludeDataResponse struct {
  51. Status int `json:"status"`
  52. Message string `json:"message"`
  53. }
  54. // CheckStatus check status.
  55. func (e *ExcludeDataResponse) CheckStatus() (err error) {
  56. if e.Status >= http.StatusMultipleChoices || e.Status < http.StatusOK {
  57. log.Error("The status(%d) of paas may represent a request error(%s)", e.Status, e.Message)
  58. err = ecode.MelloiPaasRequestErr
  59. }
  60. return
  61. }
  62. //AuthData AuthData stuct
  63. type AuthData struct {
  64. Token string `json:"token"`
  65. PlatformID string `json:"platform_id"`
  66. UserName string `json:"user_name"`
  67. Secret string `json:"secret"`
  68. Expired int `json:"expired"`
  69. Admin bool `json:"admin"`
  70. }
  71. //ClusterPoolResourcesUsage ClusterPoolResourcesUsage stuct
  72. type ClusterPoolResourcesUsage struct {
  73. CPURequest int `json:"cpu_request"`
  74. CPULimit int `json:"cpu_limit"`
  75. CPUCapacity int `json:"cpu_capacity"`
  76. CPUAllocatable int `json:"cpu_allocatable"`
  77. MemoryRequest int `json:"memory_request"`
  78. MemoryLimit int `json:"memory_limit"`
  79. MemoryCapacity int `json:"memory_capacity"`
  80. MemoryAllocatable int `json:"memory_allocatable"`
  81. PodRunning int `json:"pod_running"`
  82. PodTotal int `json:"pod_total"`
  83. PodCapacity int `json:"pod_capacity"`
  84. PodAllocatable int `json:"pod_allocatable"`
  85. NodesNum int `json:"nodes_num"`
  86. }
  87. //ClusterConfiguration ClusterConfiguration stuct
  88. type ClusterConfiguration struct {
  89. ID int `json:"id"`
  90. Name string `json:"name"`
  91. Desc string `json:"desc"`
  92. Region string `json:"region"`
  93. Zone string `json:"zone"`
  94. Idc string `json:"idc"`
  95. Envs string `json:"envs"`
  96. CloudProvider string `json:"cloud_provider"`
  97. Orchestrator string `json:"orchestrator"`
  98. APITarget string `json:"api_target"`
  99. Register string `json:"register"`
  100. DefaultRegistry string `json:"default_registry"`
  101. Ctime string `json:"ctime"`
  102. Mtime string `json:"mtime"`
  103. }