storage_const.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package compute
  15. import (
  16. "yunion.io/x/cloudmux/pkg/apis/compute"
  17. "yunion.io/x/onecloud/pkg/apis"
  18. )
  19. const (
  20. STORAGE_LOCAL = compute.STORAGE_LOCAL
  21. STORAGE_BAREMETAL = "baremetal"
  22. STORAGE_SHEEPDOG = "sheepdog"
  23. STORAGE_RBD = compute.STORAGE_RBD
  24. STORAGE_DOCKER = "docker"
  25. STORAGE_NAS = compute.STORAGE_NAS
  26. STORAGE_VSAN = "vsan"
  27. STORAGE_NFS = compute.STORAGE_NFS
  28. STORAGE_GPFS = "gpfs"
  29. STORAGE_CIFS = compute.STORAGE_CIFS
  30. STORAGE_NVME_PT = "nvme_pt" // nvme passthrough
  31. STORAGE_NVME = "nvme" // nvme sriov
  32. STORAGE_LVM = "lvm"
  33. STORAGE_CLVM = "clvm" // clustered lvm
  34. STORAGE_SLVM = "slvm" // shared lvm
  35. STORAGE_PUBLIC_CLOUD = compute.STORAGE_PUBLIC_CLOUD
  36. STORAGE_CLOUD_EFFICIENCY = compute.STORAGE_CLOUD_EFFICIENCY
  37. STORAGE_CLOUD_SSD = compute.STORAGE_CLOUD_SSD
  38. STORAGE_CLOUD_ESSD_PL0 = compute.STORAGE_CLOUD_ESSD_PL0 // 增强型(Enhanced)SSD 云盘, 单盘最高随机读写IOPS 1万
  39. STORAGE_CLOUD_ESSD = compute.STORAGE_CLOUD_ESSD // 增强型(Enhanced)SSD 云盘, 单盘最高随机读写IOPS 5万
  40. STORAGE_CLOUD_ESSD_PL2 = compute.STORAGE_CLOUD_ESSD_PL2 // 单盘最高随机读写IOPS 10万
  41. STORAGE_CLOUD_ESSD_PL3 = compute.STORAGE_CLOUD_ESSD_PL3 // 单盘最高随机读写IOPS 100万
  42. STORAGE_CLOUD_AUTO = compute.STORAGE_CLOUD_AUTO // ESSD AutoPL
  43. STORAGE_CLOUD_ESSD_ENTRY = "cloud_essd_entry" // ESSD Entry云盘
  44. STORAGE_EPHEMERAL_SSD = compute.STORAGE_EPHEMERAL_SSD // 单块本地SSD盘, 容量最大不能超过800 GiB
  45. STORAGE_LOCAL_HDD_PRO = compute.STORAGE_LOCAL_HDD_PRO // 实例规格族d1ne和d1搭载的SATA HDD本地盘
  46. STORAGE_LOCAL_SSD_PRO = compute.STORAGE_LOCAL_SSD_PRO // 实例规格族i2、i2g、i1、ga1和gn5等搭载的NVMe
  47. //Azure hdd and ssd storagetype
  48. STORAGE_STANDARD_LRS = compute.STORAGE_STANDARD_LRS
  49. STORAGE_STANDARDSSD_LRS = compute.STORAGE_STANDARDSSD_LRS
  50. STORAGE_PREMIUM_LRS = compute.STORAGE_PREMIUM_LRS
  51. STORAGE_AZURE_BASIC = compute.STORAGE_AZURE_BASIC
  52. STORAGE_AZURE_GENERAL_PURPOSE = compute.STORAGE_AZURE_GENERAL_PURPOSE
  53. // aws storage type
  54. STORAGE_GP2_SSD = compute.STORAGE_GP2_SSD // aws general purpose ssd
  55. STORAGE_GP3_SSD = compute.STORAGE_GP3_SSD // aws General Purpose SSD (gp3)
  56. STORAGE_IO1_SSD = compute.STORAGE_IO1_SSD // aws Provisioned IOPS SSD
  57. STORAGE_IO2_SSD = compute.STORAGE_IO2_SSD // aws Provisioned IOPS 2 SSD
  58. STORAGE_ST1_HDD = compute.STORAGE_ST1_HDD // aws Throughput Optimized HDD
  59. STORAGE_SC1_HDD = compute.STORAGE_SC1_HDD // aws Cold HDD
  60. STORAGE_STANDARD_HDD = compute.STORAGE_STANDARD_HDD // aws Magnetic volumes
  61. // qcloud storage type
  62. // STORAGE_CLOUD_SSD ="cloud_ssd"
  63. STORAGE_LOCAL_BASIC = compute.STORAGE_LOCAL_BASIC
  64. STORAGE_LOCAL_SSD = compute.STORAGE_LOCAL_SSD
  65. STORAGE_LOCAL_PRO = compute.STORAGE_LOCAL_PRO
  66. STORAGE_CLOUD_BASIC = compute.STORAGE_CLOUD_BASIC
  67. STORAGE_CLOUD_PREMIUM = compute.STORAGE_CLOUD_PREMIUM //高性能云硬盘
  68. STORAGE_CLOUD_HSSD = compute.STORAGE_CLOUD_HSSD //增强型SSD云硬盘
  69. STORAGE_CLOUD_BSSD = compute.STORAGE_CLOUD_BSSD //增强型SSD云硬盘
  70. STORAGE_CLOUD_TSSD = compute.STORAGE_CLOUD_TSSD //极速型SSD云硬盘
  71. // huawei storage type
  72. STORAGE_HUAWEI_SSD = compute.STORAGE_HUAWEI_SSD // 超高IO云硬盘
  73. STORAGE_HUAWEI_SAS = compute.STORAGE_HUAWEI_SAS // 高IO云硬盘
  74. STORAGE_HUAWEI_SATA = compute.STORAGE_HUAWEI_SATA // 普通IO云硬盘
  75. STORAGE_HUAWEI_GPSSD = compute.STORAGE_HUAWEI_GPSSD // 通用型SSD
  76. STORAGE_HUAWEI_ESSD = compute.STORAGE_HUAWEI_ESSD // 急速型SSD
  77. // openstack
  78. STORAGE_OPENSTACK_ISCSI = compute.STORAGE_OPENSTACK_ISCSI
  79. STORAGE_OPENSTACK_NOVA = compute.STORAGE_OPENSTACK_NOVA
  80. // Ucloud storage type
  81. STORAGE_UCLOUD_CLOUD_NORMAL = compute.STORAGE_UCLOUD_CLOUD_NORMAL // 普通云盘
  82. STORAGE_UCLOUD_CLOUD_SSD = compute.STORAGE_UCLOUD_CLOUD_SSD // SSD云盘
  83. STORAGE_UCLOUD_LOCAL_NORMAL = compute.STORAGE_UCLOUD_LOCAL_NORMAL // 普通本地盘
  84. STORAGE_UCLOUD_LOCAL_SSD = compute.STORAGE_UCLOUD_LOCAL_SSD // SSD本地盘
  85. STORAGE_UCLOUD_EXCLUSIVE_LOCAL_DISK = compute.STORAGE_UCLOUD_EXCLUSIVE_LOCAL_DISK // 独享本地盘
  86. // VolcEngine storage types
  87. STORAGE_VOLC_CLOUD_FLEXPL = compute.STORAGE_VOLCENGINE_FlexPL // 极速型SSD云盘, FlexPL规格
  88. STORAGE_VOLC_CLOUD_PL0 = compute.STORAGE_VOLCENGINE_PL0 //极速型SSD云盘, PL0规格
  89. STORAGE_VOLC_CLOUD_PTSSD = compute.STORAGE_VOLCENGINE_PTSSD // 性能型SSD, 上一代产品
  90. // Zstack storage type
  91. STORAGE_ZSTACK_LOCAL_STORAGE = compute.STORAGE_ZSTACK_LOCAL_STORAGE
  92. STORAGE_ZSTACK_CEPH = compute.STORAGE_ZSTACK_CEPH
  93. STORAGE_ZSTACK_SHARED_BLOCK = compute.STORAGE_ZSTACK_SHARED_BLOCK
  94. // Google storage type
  95. STORAGE_GOOGLE_LOCAL_SSD = compute.STORAGE_GOOGLE_LOCAL_SSD //本地SSD暂存盘 (最多8个)
  96. STORAGE_GOOGLE_PD_STANDARD = compute.STORAGE_GOOGLE_PD_STANDARD //标准永久性磁盘
  97. STORAGE_GOOGLE_PD_SSD = compute.STORAGE_GOOGLE_PD_SSD //SSD永久性磁盘
  98. STORAGE_GOOGLE_PD_BALANCED = compute.STORAGE_GOOGLE_PD_BALANCED //平衡永久性磁盘
  99. STORAGE_GOOGLE_PD_EXTREME = compute.STORAGE_GOOGLE_PD_EXTREME //极端永久性磁盘
  100. STORAGE_GOOGLE_HYPERDISK_BALANCED = compute.STORAGE_GOOGLE_HYPERDISK_BALANCED //平衡 Hyperdisk
  101. STORAGE_GOOGLE_HYPERDISK_EXTREME = compute.STORAGE_GOOGLE_HYPERDISK_EXTREME //Hyperdisk Extreme
  102. STORAGE_GOOGLE_HYPERDISK_THROUGHPUT = compute.STORAGE_GOOGLE_HYPERDISK_THROUGHPUT //Hyperdisk Throughput
  103. STORAGE_GOOGLE_HYPERDISK_ML = compute.STORAGE_GOOGLE_HYPERDISK_ML //Hyperdisk ML
  104. // ctyun storage type
  105. STORAGE_CTYUN_SSD = compute.STORAGE_CTYUN_SSD // 超高IO云硬盘
  106. STORAGE_CTYUN_SAS = compute.STORAGE_CTYUN_SAS // 高IO云硬盘
  107. STORAGE_CTYUN_SATA = compute.STORAGE_CTYUN_SATA // 普通IO云硬盘
  108. // jd cloud storage type
  109. STORAGE_JDCLOUD_GP1 = compute.STORAGE_JDCLOUD_GP1 // 通用型SSD云硬盘
  110. STORAGE_JDCLOUD_IO1 = compute.STORAGE_JDCLOUD_IO1 // 性能型SSD云硬盘
  111. STORAGE_JDCLOUD_STD = compute.STORAGE_JDCLOUD_STD // 容量型HDD云硬盘
  112. STORAGE_JDCLOUD_SSD = compute.STORAGE_JDCLOUD_SSD // SSD云硬盘
  113. STORAGE_JDCLOUD_PHD = compute.STORAGE_JDCLOUD_PHD // HDD云硬盘
  114. STORAGE_ECLOUD_CAPEBS = compute.STORAGE_ECLOUD_CAPEBS // 容量盘
  115. STORAGE_ECLOUD_EBS = compute.STORAGE_ECLOUD_EBS // 性能盘
  116. STORAGE_ECLOUD_SSD = compute.STORAGE_ECLOUD_SSD // 高性能盘
  117. STORAGE_ECLOUD_SSDEBS = compute.STORAGE_ECLOUD_SSDEBS // 性能优化盘
  118. STORAGE_ECLOUD_SYSTEM = compute.STORAGE_ECLOUD_SYSTEM // 系统盘
  119. STORAGE_BAIDU_SSD = compute.STORAGE_BAIDU_SSD
  120. STORAGE_BAIDU_PREMIUM_SSD = compute.STORAGE_BAIDU_PREMIUM_SSD
  121. STORAGE_BAIDU_HDD = compute.STORAGE_BAIDU_HDD
  122. STORAGE_BAIDU_ENHANCED_SSD_PL1 = compute.STORAGE_BAIDU_ENHANCED_SSD_PL1
  123. STORAGE_BAIDU_ENHANCED_SSD_PL2 = compute.STORAGE_BAIDU_ENHANCED_SSD_PL2
  124. STORAGE_BAIDU_ENHANCED_SSD_PL3 = compute.STORAGE_BAIDU_ENHANCED_SSD_PL3
  125. // ksyun storage type
  126. STORAGE_KSYUN_ESSD_AUTO_PL = compute.STORAGE_KSYUN_ESSD_AUTO_PL
  127. STORAGE_KSYUN_SSD3_0 = compute.STORAGE_KSYUN_SSD3_0
  128. STORAGE_KSYUN_EHDD = compute.STORAGE_KSYUN_EHDD
  129. STORAGE_KSYUN_ESSD_PL1 = compute.STORAGE_KSYUN_ESSD_PL1
  130. STORAGE_KSYUN_ESSD_PL2 = compute.STORAGE_KSYUN_ESSD_PL2
  131. STORAGE_KSYUN_ESSD_PL3 = compute.STORAGE_KSYUN_ESSD_PL3
  132. // zettakit
  133. STORAGE_ZETTAKIT_NORMAL = compute.STORAGE_ZETTAKIT_NORMAL
  134. // cnware storage type
  135. STORAGE_CNWARE_FCSAN = compute.STORAGE_CNWARE_FC_SAN
  136. STORAGE_CNWARE_IPSAN = compute.STORAGE_CNWARE_IP_SAN
  137. STORAGE_CNWARE_NAS = compute.STORAGE_CNWARE_NAS
  138. STORAGE_CNWARE_CEPH = compute.STORAGE_CNWARE_CEPH
  139. STORAGE_CNWARE_LOCAL = compute.STORAGE_CNWARE_LOCAL
  140. STORAGE_CNWARE_NVME = compute.STORAGE_CNWARE_NVME
  141. )
  142. const (
  143. STORAGE_ENABLED = "enabled"
  144. // STORAGE_DISABLED = "disabled"
  145. STORAGE_OFFLINE = compute.STORAGE_OFFLINE // 离线
  146. STORAGE_ONLINE = compute.STORAGE_ONLINE // 在线
  147. STORAGE_UNMOUNT = "unmount" // 待挂载
  148. DISK_TYPE_ROTATE = compute.DISK_TYPE_ROTATE
  149. DISK_TYPE_SSD = compute.DISK_TYPE_SSD
  150. DISK_TYPE_HYBRID = compute.DISK_TYPE_HYBRID
  151. )
  152. const (
  153. RBD_DEFAULT_MON_TIMEOUT = 5 //5 seconds 连接超时时间
  154. RBD_DEFAULT_OSD_TIMEOUT = 20 * 60 //20 minute 操作超时时间
  155. RBD_DEFAULT_MOUNT_TIMEOUT = 2 * 60 //CephFS挂载超时时间, 目前未使用
  156. )
  157. var (
  158. DISK_TYPES = []string{DISK_TYPE_ROTATE, DISK_TYPE_SSD, DISK_TYPE_HYBRID}
  159. STORAGE_LOCAL_TYPES = []string{
  160. STORAGE_LOCAL, STORAGE_NVME_PT, STORAGE_NVME, STORAGE_LVM,
  161. STORAGE_BAREMETAL, STORAGE_UCLOUD_LOCAL_NORMAL, STORAGE_UCLOUD_LOCAL_SSD, STORAGE_UCLOUD_EXCLUSIVE_LOCAL_DISK,
  162. STORAGE_EPHEMERAL_SSD, STORAGE_LOCAL_BASIC, STORAGE_LOCAL_SSD, STORAGE_LOCAL_PRO, STORAGE_OPENSTACK_NOVA,
  163. STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_GOOGLE_LOCAL_SSD,
  164. }
  165. STORAGE_SUPPORT_TYPES = STORAGE_LOCAL_TYPES
  166. STORAGE_ALL_TYPES = []string{
  167. STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_SHEEPDOG,
  168. STORAGE_RBD, STORAGE_DOCKER, STORAGE_NAS, STORAGE_VSAN,
  169. STORAGE_NFS, STORAGE_GPFS, STORAGE_CIFS, STORAGE_NVME_PT, STORAGE_NVME, STORAGE_LVM,
  170. }
  171. STORAGE_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_SHEEPDOG,
  172. STORAGE_RBD, STORAGE_DOCKER, STORAGE_NAS, STORAGE_VSAN, STORAGE_NFS,
  173. STORAGE_PUBLIC_CLOUD, STORAGE_CLOUD_SSD, STORAGE_CLOUD_ESSD_PL0, STORAGE_CLOUD_ESSD, STORAGE_CLOUD_ESSD_PL2, STORAGE_CLOUD_ESSD_PL3,
  174. STORAGE_EPHEMERAL_SSD, STORAGE_CLOUD_EFFICIENCY,
  175. STORAGE_STANDARD_LRS, STORAGE_STANDARDSSD_LRS, STORAGE_PREMIUM_LRS,
  176. STORAGE_GP2_SSD, STORAGE_GP3_SSD, STORAGE_IO1_SSD, STORAGE_ST1_HDD, STORAGE_SC1_HDD, STORAGE_STANDARD_HDD,
  177. STORAGE_LOCAL_BASIC, STORAGE_LOCAL_SSD, STORAGE_CLOUD_BASIC, STORAGE_CLOUD_PREMIUM,
  178. STORAGE_HUAWEI_SSD, STORAGE_HUAWEI_SAS, STORAGE_HUAWEI_SATA,
  179. STORAGE_OPENSTACK_ISCSI, STORAGE_UCLOUD_CLOUD_NORMAL, STORAGE_UCLOUD_CLOUD_SSD,
  180. STORAGE_UCLOUD_LOCAL_NORMAL, STORAGE_UCLOUD_LOCAL_SSD, STORAGE_UCLOUD_EXCLUSIVE_LOCAL_DISK,
  181. STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_ZSTACK_CEPH, STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_GPFS, STORAGE_CIFS,
  182. STORAGE_NVME_PT, STORAGE_NVME, STORAGE_LVM, STORAGE_CLVM, STORAGE_SLVM,
  183. }
  184. HOST_STORAGE_LOCAL_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_OPENSTACK_NOVA}
  185. STORAGE_LIMITED_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_NAS, STORAGE_RBD,
  186. STORAGE_NFS, STORAGE_GPFS, STORAGE_VSAN, STORAGE_CIFS, STORAGE_CLVM, STORAGE_SLVM}
  187. SHARED_FILE_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS}
  188. FIEL_STORAGE = []string{STORAGE_LOCAL, STORAGE_NFS, STORAGE_GPFS, STORAGE_LVM, STORAGE_CLVM, STORAGE_SLVM}
  189. // supported shared storage types
  190. SHARED_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS, STORAGE_RBD, STORAGE_CLVM, STORAGE_SLVM}
  191. SUPPORTED_FS = []string{"swap", "ext2", "ext3", "ext4", "xfs", "f2fs"}
  192. )
  193. func IsDiskTypeMatch(t1, t2 string) bool {
  194. switch t1 {
  195. case DISK_TYPE_ROTATE:
  196. if t2 == DISK_TYPE_SSD {
  197. return false
  198. } else {
  199. return true
  200. }
  201. case DISK_TYPE_SSD:
  202. if t2 == DISK_TYPE_ROTATE {
  203. return false
  204. } else {
  205. return true
  206. }
  207. default:
  208. return true
  209. }
  210. }
  211. const (
  212. STORAGE_METADATA_VENDOR = "vendor"
  213. STORAGE_METADATA_MODEL = "model"
  214. STORAGE_METADATA_BANDWIDTH = "bandwidth"
  215. )
  216. type StorageResourceInput struct {
  217. // 存储(ID或Name)
  218. StorageId string `json:"storage_id"`
  219. // swagger:ignore
  220. // Deprecated
  221. // filter by storage_id
  222. Storage string `json:"storage" yunion-deprecated-by:"storage_id"`
  223. }
  224. type StorageFilterListInputBase struct {
  225. StorageResourceInput
  226. // 以host过滤
  227. StorageHostId string `json:"storage_host_id"`
  228. // 以存储名称排序
  229. // pattern:asc|desc
  230. OrderByStorage string `json:"order_by_storage"`
  231. }
  232. type StorageFilterListInput struct {
  233. StorageFilterListInputBase
  234. StorageShareFilterListInput
  235. ZonalFilterListInput
  236. ManagedResourceListInput
  237. }
  238. type StorageShareFilterListInput struct {
  239. // filter shared storage
  240. Share *bool `json:"share"`
  241. // filter local storage
  242. Local *bool `json:"local"`
  243. }
  244. type StorageListInput struct {
  245. apis.EnabledStatusInfrasResourceBaseListInput
  246. apis.ExternalizedResourceBaseListInput
  247. SchedtagResourceInput
  248. ManagedResourceListInput
  249. ZonalFilterListInput
  250. UsableResourceListInput
  251. StorageShareFilterListInput
  252. // filter by host schedtag
  253. HostSchedtagId string `json:"host_schedtag_id"`
  254. // filter by cachedimage
  255. ImageId string `json:"image_id"`
  256. // filter storages which attached the specified host
  257. HostId string `json:"host_id"`
  258. // filter storages which server can change disks to
  259. ServerId string `json:"server_id"`
  260. // filter storages of baremetal host
  261. IsBaremetal *bool `json:"is_baremetal"`
  262. // filter by storage type
  263. StorageType string `json:"storage_type"`
  264. }