dbinstance.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 remotefile
  15. import (
  16. "context"
  17. "yunion.io/x/cloudmux/pkg/cloudprovider"
  18. "yunion.io/x/pkg/errors"
  19. )
  20. type SDBInstance struct {
  21. SResourceBase
  22. region *SRegion
  23. RegionId string
  24. SecurityGroupIds []string
  25. Port int
  26. Engine string
  27. EngineVersion string
  28. InstanceType string
  29. VcpuCount int
  30. VmemSizeMb int
  31. DiskSizeGb int
  32. DiskSizeUsedGb int
  33. Category string
  34. StorageType string
  35. MaintainTime string
  36. ConnectionStr string
  37. InternalConnectionStr string
  38. Zone1Id string
  39. Zone2Id string
  40. Zone3Id string
  41. VpcId string
  42. Iops int
  43. }
  44. func (self *SDBInstance) Reboot() error {
  45. return cloudprovider.ErrNotSupported
  46. }
  47. func (self *SDBInstance) GetMasterInstanceId() string {
  48. return ""
  49. }
  50. func (self *SDBInstance) GetSecurityGroupIds() ([]string, error) {
  51. return self.SecurityGroupIds, nil
  52. }
  53. func (self *SDBInstance) SetSecurityGroups(ids []string) error {
  54. return cloudprovider.ErrNotSupported
  55. }
  56. func (self *SDBInstance) GetPort() int {
  57. return self.Port
  58. }
  59. func (self *SDBInstance) GetEngine() string {
  60. return self.Engine
  61. }
  62. func (self *SDBInstance) GetEngineVersion() string {
  63. return self.EngineVersion
  64. }
  65. func (self *SDBInstance) GetInstanceType() string {
  66. return self.InstanceType
  67. }
  68. func (self *SDBInstance) GetVcpuCount() int {
  69. return self.VcpuCount
  70. }
  71. func (self *SDBInstance) GetVmemSizeMB() int {
  72. return self.VmemSizeMb
  73. }
  74. func (self *SDBInstance) GetDiskSizeGB() int {
  75. return self.DiskSizeGb
  76. }
  77. func (self *SDBInstance) GetDiskSizeUsedMB() int {
  78. return self.DiskSizeUsedGb
  79. }
  80. func (self *SDBInstance) GetCategory() string {
  81. return self.Category
  82. }
  83. func (self *SDBInstance) GetStorageType() string {
  84. return self.StorageType
  85. }
  86. func (self *SDBInstance) GetMaintainTime() string {
  87. return self.MaintainTime
  88. }
  89. func (self *SDBInstance) GetConnectionStr() string {
  90. return self.ConnectionStr
  91. }
  92. func (self *SDBInstance) GetInternalConnectionStr() string {
  93. return self.InternalConnectionStr
  94. }
  95. func (self *SDBInstance) GetZone1Id() string {
  96. return self.Zone1Id
  97. }
  98. func (self *SDBInstance) GetZone2Id() string {
  99. return self.Zone2Id
  100. }
  101. func (self *SDBInstance) GetZone3Id() string {
  102. return self.Zone3Id
  103. }
  104. func (self *SDBInstance) GetIVpcId() string {
  105. return self.VpcId
  106. }
  107. func (self *SDBInstance) GetIops() int {
  108. return self.Iops
  109. }
  110. func (self *SDBInstance) GetDBNetworks() ([]cloudprovider.SDBInstanceNetwork, error) {
  111. return nil, cloudprovider.ErrNotImplemented
  112. }
  113. func (self *SDBInstance) GetIDBInstanceParameters() ([]cloudprovider.ICloudDBInstanceParameter, error) {
  114. return nil, cloudprovider.ErrNotImplemented
  115. }
  116. func (self *SDBInstance) GetIDBInstanceDatabases() ([]cloudprovider.ICloudDBInstanceDatabase, error) {
  117. return nil, cloudprovider.ErrNotSupported
  118. }
  119. func (self *SDBInstance) GetIDBInstanceAccounts() ([]cloudprovider.ICloudDBInstanceAccount, error) {
  120. return nil, cloudprovider.ErrNotSupported
  121. }
  122. func (self *SDBInstance) GetIDBInstanceBackups() ([]cloudprovider.ICloudDBInstanceBackup, error) {
  123. return nil, cloudprovider.ErrNotSupported
  124. }
  125. func (self *SDBInstance) ChangeConfig(ctx context.Context, config *cloudprovider.SManagedDBInstanceChangeConfig) error {
  126. return cloudprovider.ErrNotSupported
  127. }
  128. func (self *SDBInstance) OpenPublicConnection() error {
  129. return cloudprovider.ErrNotSupported
  130. }
  131. func (self *SDBInstance) ClosePublicConnection() error {
  132. return cloudprovider.ErrNotSupported
  133. }
  134. func (self *SDBInstance) CreateDatabase(conf *cloudprovider.SDBInstanceDatabaseCreateConfig) error {
  135. return cloudprovider.ErrNotSupported
  136. }
  137. func (self *SDBInstance) CreateAccount(conf *cloudprovider.SDBInstanceAccountCreateConfig) error {
  138. return cloudprovider.ErrNotSupported
  139. }
  140. func (self *SDBInstance) CreateIBackup(conf *cloudprovider.SDBInstanceBackupCreateConfig) (string, error) {
  141. return "", cloudprovider.ErrNotSupported
  142. }
  143. func (self *SDBInstance) RecoveryFromBackup(conf *cloudprovider.SDBInstanceRecoveryConfig) error {
  144. return cloudprovider.ErrNotSupported
  145. }
  146. func (self *SDBInstance) Delete() error {
  147. return cloudprovider.ErrNotSupported
  148. }
  149. func (self *SRegion) GetIDBInstances() ([]cloudprovider.ICloudDBInstance, error) {
  150. res, err := self.client.GetDBInstances()
  151. if err != nil {
  152. return nil, err
  153. }
  154. ret := []cloudprovider.ICloudDBInstance{}
  155. for i := range res {
  156. if res[i].RegionId != self.GetId() {
  157. continue
  158. }
  159. res[i].region = self
  160. ret = append(ret, &res[i])
  161. }
  162. return ret, nil
  163. }
  164. func (self *SRegion) GetIDBInstanceById(id string) (cloudprovider.ICloudDBInstance, error) {
  165. res, err := self.GetIDBInstances()
  166. if err != nil {
  167. return nil, err
  168. }
  169. for i := range res {
  170. if res[i].GetGlobalId() == id {
  171. return res[i], nil
  172. }
  173. }
  174. return nil, cloudprovider.ErrNotFound
  175. }
  176. func (instance *SDBInstance) Update(ctx context.Context, input cloudprovider.SDBInstanceUpdateOptions) error {
  177. return errors.ErrNotImplemented
  178. }