mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #11579 from ioito/hotfix/qx-jd-rds-port
fix(region): update jdcloud rds port
This commit is contained in:
@@ -102,6 +102,7 @@ const (
|
||||
DBINSTANCE_TYPE_MARIADB = "MariaDB"
|
||||
DBINSTANCE_TYPE_ORACLE = "Oracle"
|
||||
DBINSTANCE_TYPE_PPAS = "PPAS"
|
||||
DBINSTANCE_TYPE_PERCONA = "Percona"
|
||||
|
||||
//阿里云实例类型
|
||||
ALIYUN_DBINSTANCE_CATEGORY_BASIC = "basic" //基础版
|
||||
|
||||
@@ -76,6 +76,14 @@ func (self *SDBInstance) GetIVpcId() string {
|
||||
return self.VpcId
|
||||
}
|
||||
|
||||
func (self *SDBInstance) Refresh() error {
|
||||
rds, err := self.region.GetDBInstance(self.InstanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, rds)
|
||||
}
|
||||
|
||||
func (self *SDBInstance) GetMaintainTime() string {
|
||||
return ""
|
||||
}
|
||||
@@ -85,6 +93,9 @@ func (self *SDBInstance) GetMasterInstanceId() string {
|
||||
}
|
||||
|
||||
func (self *SDBInstance) GetPort() int {
|
||||
if len(self.InstancePort) == 0 {
|
||||
self.Refresh()
|
||||
}
|
||||
port, _ := strconv.Atoi(self.InstancePort)
|
||||
return int(port)
|
||||
}
|
||||
@@ -163,6 +174,10 @@ func (self *SDBInstance) GetInternalConnectionStr() string {
|
||||
return self.InternalDomainName
|
||||
}
|
||||
|
||||
func (self *SDBInstance) Delete() error {
|
||||
return self.region.DeleteDBInstance(self.InstanceId)
|
||||
}
|
||||
|
||||
func (self *SRegion) GetIDBInstances() ([]cloudprovider.ICloudDBInstance, error) {
|
||||
rds := []SDBInstance{}
|
||||
n := 1
|
||||
@@ -210,6 +225,20 @@ func (self *SRegion) GetDBInstance(id string) (*SDBInstance, error) {
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) DeleteDBInstance(id string) error {
|
||||
req := apis.NewDeleteInstanceRequest(self.ID, id)
|
||||
client := client.NewRdsClient(self.Credential)
|
||||
client.Logger = Logger{}
|
||||
resp, err := client.DeleteInstance(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.Error.Code == 404 {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) GetDBInstances(pageNumber int, pageSize int) ([]SDBInstance, int, error) {
|
||||
req := apis.NewDescribeInstancesRequestWithAllParams(self.ID, &pageNumber, &pageSize, []commodels.Filter{}, []commodels.TagFilter{})
|
||||
client := client.NewRdsClient(self.Credential)
|
||||
|
||||
@@ -34,11 +34,11 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceShowOptions struct {
|
||||
type DBInstanceIdOptions struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
shellutils.R(&DBInstanceShowOptions{}, "dbinstance-show", "Show rds", func(cli *jdcloud.SRegion, args *DBInstanceShowOptions) error {
|
||||
shellutils.R(&DBInstanceIdOptions{}, "dbinstance-show", "Show rds", func(cli *jdcloud.SRegion, args *DBInstanceIdOptions) error {
|
||||
rds, err := cli.GetDBInstance(args.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -47,6 +47,10 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
shellutils.R(&DBInstanceIdOptions{}, "dbinstance-delete", "Delete rds", func(cli *jdcloud.SRegion, args *DBInstanceIdOptions) error {
|
||||
return cli.DeleteDBInstance(args.ID)
|
||||
})
|
||||
|
||||
type DBInstanceAccountListOptions struct {
|
||||
PageNumber int `default:"1"`
|
||||
PageSize int `default:"100"`
|
||||
|
||||
Reference in New Issue
Block a user