backup.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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/jsonutils"
  17. "yunion.io/x/onecloud/pkg/apis"
  18. )
  19. type TBackupStorageType string
  20. const (
  21. BACKUPSTORAGE_TYPE_NFS = TBackupStorageType("nfs")
  22. BACKUPSTORAGE_TYPE_OBJECT_STORAGE = TBackupStorageType("object")
  23. BACKUPSTORAGE_STATUS_ONLINE = "online"
  24. BACKUPSTORAGE_STATUS_OFFLINE = "offline"
  25. BACKUP_STATUS_CREATING = "creating"
  26. BACKUP_STATUS_CREATE_FAILED = "create_failed"
  27. BACKUP_STATUS_SNAPSHOT = "snapshot"
  28. BACKUP_STATUS_SNAPSHOT_FAILED = "snapshot_failed"
  29. BACKUP_STATUS_SAVING = "saving"
  30. BACKUP_STATUS_SAVE_FAILED = "save_failed"
  31. BACKUP_STATUS_CLEANUP_SNAPSHOT = "clean_snapshot"
  32. BACKUP_STATUS_CLEANUP_SNAPSHOT_FAILED = "clean_snapshot_failed"
  33. BACKUP_STATUS_DELETING = "deleting"
  34. BACKUP_STATUS_DELETE_FAILED = "delete_failed"
  35. BACKUP_STATUS_READY = "ready"
  36. BACKUP_STATUS_RECOVERY = "recovery"
  37. BACKUP_STATUS_RECOVERY_FAILED = "recovery_failed"
  38. BACKUP_STATUS_UNKNOWN = "unknown"
  39. BACKUP_STATUS_START_IMPORT = "start_import"
  40. BACKUP_STATUS_IMPORTING = "importing"
  41. BACKUP_STATUS_IMPORT_FAILED = "import_failed"
  42. BACKUP_EXIST = "exist"
  43. BACKUP_NOT_EXIST = "not_exist"
  44. )
  45. const (
  46. BackupStorageOffline = "backup storage offline"
  47. )
  48. type BackupStorageCreateInput struct {
  49. apis.EnabledStatusInfrasResourceBaseCreateInput
  50. // description: storage type
  51. // enum: ["nfs"]
  52. StorageType string `json:"storage_type"`
  53. SBackupStorageAccessInfo
  54. // description: Capacity size in MB
  55. CapacityMb int `json:"capacity_mb"`
  56. }
  57. type BackupStorageUpdateInput struct {
  58. apis.EnabledStatusInfrasResourceBaseUpdateInput
  59. SBackupStorageAccessInfo
  60. }
  61. /*type BackupStorageAccessInfo struct {
  62. AccessUrl string
  63. }*/
  64. type BackupStorageDetails struct {
  65. apis.EnabledStatusInfrasResourceBaseDetails
  66. SBackupStorageAccessInfo
  67. }
  68. type BackupStorageListInput struct {
  69. apis.EnabledStatusInfrasResourceBaseListInput
  70. // filter by server_id
  71. ServerId string `json:"server_id"`
  72. // filter by disk_id
  73. DiskId string `json:"disk_id"`
  74. }
  75. type DiskBackupListInput struct {
  76. apis.VirtualResourceListInput
  77. ManagedResourceListInput
  78. RegionalFilterListInput
  79. apis.MultiArchResourceBaseListInput
  80. // description: disk id
  81. DiskId string `json:"disk_id"`
  82. // description: backup storage id
  83. BackupStorageId string `json:"backup_storage_id"`
  84. // description: 是否为主机备份的一部分
  85. IsInstanceBackup *bool `json:"is_instance_backup"`
  86. // 按硬盘名称排序
  87. OrderByDiskName string `json:"order_by_disk_name"`
  88. }
  89. type DiskBackupDetails struct {
  90. apis.VirtualResourceDetails
  91. ManagedResourceInfo
  92. CloudregionResourceInfo
  93. apis.EncryptedResourceDetails
  94. // description: disk name
  95. DiskName string `json:"disk_name"`
  96. // description: backup storage name
  97. BackupStorageName string `json:"backup_storage_name"`
  98. // description: 是否是子备份
  99. IsSubBackup bool `json:"is_sub_backup"`
  100. SDiskBackup
  101. }
  102. type DiskBackupAsTarInput struct {
  103. IncludeFiles []string `json:"include_files"`
  104. IncludePatterns []string `json:"include_patterns"`
  105. ExcludeFiles []string `json:"exclude_files"`
  106. ContainerId string `json:"container_id"`
  107. IgnoreNotExistFile bool `json:"ignore_not_exist_file"`
  108. }
  109. type DiskBackupCreateInput struct {
  110. apis.VirtualResourceCreateInput
  111. apis.EncryptedResourceCreateInput
  112. // description: disk id
  113. DiskId string `json:"disk_id"`
  114. // swagger:ignore
  115. BackStorageId string `json:"back_storage_id" yunion-deprecated-by:"backup_storage_id"`
  116. // description: backup storage id
  117. BackupStorageId string `json:"backup_storage_id"`
  118. // swagger:ignore
  119. CloudregionId string `json:"cloudregion_id"`
  120. // swagger:ignore
  121. ManagerId string `json:"manager_id"`
  122. BackupAsTar *DiskBackupAsTarInput `json:"backup_as_tar"`
  123. }
  124. type DiskBackupRecoveryInput struct {
  125. // description: name of disk
  126. Name string `json:"name"`
  127. }
  128. type DiskBackupSyncstatusInput struct {
  129. }
  130. type DiskBackupPackMetadata struct {
  131. OsArch string `json:"os_arch"`
  132. SizeMb int `json:"size_mb"`
  133. DiskSizeMb int `json:"disk_size_mb"`
  134. DiskType string `json:"disk_type"`
  135. // 操作系统类型
  136. OsType string `json:"os_type"`
  137. DiskConfig *SBackupDiskConfig `json:"disk_config"`
  138. }
  139. type DiskBackupExportInfo struct {
  140. DiskBackupPackMetadata
  141. DiskBackupImportTaskInput
  142. }
  143. type DiskBackupImportTaskInput struct {
  144. AccessUrl string `json:"access_url"`
  145. }
  146. type InstanceBackupPackMetadata struct {
  147. OsArch string `json:"os_arch"`
  148. ServerConfig jsonutils.JSONObject `json:"server_config"`
  149. ServerMetadata jsonutils.JSONObject `json:"server_metadata"`
  150. SecGroups jsonutils.JSONObject `json:"sec_groups"`
  151. KeypairId string `json:"keypair_id"`
  152. OsType string `json:"os_type"`
  153. InstanceType string `json:"instance_type"`
  154. SizeMb int `json:"size_mb"`
  155. DiskMetadatas []DiskBackupPackMetadata `json:"disk_metadatas"`
  156. // 加密密钥ID
  157. EncryptKeyId string `json:"encrypt_key_id"`
  158. // Instance Backup metadata
  159. Metadata map[string]string `json:"metadata"`
  160. }
  161. type InstanceBackupManagerSyncstatusInput struct {
  162. }
  163. type SBackupStorageAccessInfo struct {
  164. // description: host of nfs, storage_type 为 nfs 时, 此参数必传
  165. // example: 192.168.222.2
  166. NfsHost string `json:"nfs_host"`
  167. // description: shared dir of nfs, storage_type 为 nfs 时, 此参数必传
  168. // example: /nfs_root/
  169. NfsSharedDir string `json:"nfs_shared_dir"`
  170. // description: access url of object storage bucket
  171. // example: https://qxxxxxo.tos-cn-beijing.volces.com
  172. ObjectBucketUrl string `json:"object_bucket_url"`
  173. // description: access key of object storage
  174. ObjectAccessKey string `json:"object_access_key"`
  175. // description: secret of object storage
  176. ObjectSecret string `json:"object_secret"`
  177. // description: signing version, can be v2/v4, default is v4
  178. ObjectSignVer string `json:"object_sign_ver"`
  179. // description: external access url of object storage bucket
  180. ObjectBucketUrlExt string `json:"object_bucket_url_ext"`
  181. }
  182. func (ba *SBackupStorageAccessInfo) String() string {
  183. return jsonutils.Marshal(ba).String()
  184. }
  185. func (ba *SBackupStorageAccessInfo) IsZero() bool {
  186. return ba == nil
  187. }
  188. type ServerCreateInstanceBackupInput struct {
  189. // 主机备份名称
  190. Name string `json:"name"`
  191. // 主机备份的生成名称
  192. GenerateName string `json:"generate_name"`
  193. // 备份存储ID
  194. BackupStorageId string `json:"backup_storage_id"`
  195. }
  196. type DiskBackupImportInput struct {
  197. Name string `json:"name"`
  198. GenerateName string `json:"generate_name"`
  199. apis.ProjectizedResourceCreateInput
  200. DiskBackupExportInfo
  201. BackupStorageId string `json:"backup_storage_id"`
  202. }