yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/remotefile/dbinstance.go (about)

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