mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(region): add ip_addr for rds.GetShortDesc (#19022)
Co-authored-by: 马鸿飞 <mahongfei@yunion.cn>
This commit is contained in:
@@ -1153,6 +1153,15 @@ func (self *SDBInstance) GetShortDesc(ctx context.Context) *jsonutils.JSONDict {
|
||||
desc := self.SVirtualResourceBase.GetShortDesc(ctx)
|
||||
region, _ := self.GetRegion()
|
||||
provider := self.GetCloudprovider()
|
||||
|
||||
ipAddr := func() string {
|
||||
rdsNetwrok := SDBInstanceNetwork{}
|
||||
err := DBInstanceNetworkManager.Query("ip_addr").Equals("dbinstance_id", self.Id).IsNotNull("ip_addr").IsNotEmpty("ip_addr").First(&rdsNetwrok)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return rdsNetwrok.IpAddr
|
||||
}()
|
||||
info := MakeCloudProviderInfo(region, nil, provider)
|
||||
desc.Set("engine", jsonutils.NewString(self.Engine))
|
||||
desc.Set("storage_type", jsonutils.NewString(self.StorageType))
|
||||
@@ -1161,6 +1170,7 @@ func (self *SDBInstance) GetShortDesc(ctx context.Context) *jsonutils.JSONDict {
|
||||
desc.Set("vmem_size_mb", jsonutils.NewInt(int64(self.VmemSizeMb)))
|
||||
desc.Set("disk_size_gb", jsonutils.NewInt(int64(self.DiskSizeGB)))
|
||||
desc.Set("iops", jsonutils.NewInt(int64(self.Iops)))
|
||||
desc.Set("ip_addr", jsonutils.NewString(ipAddr))
|
||||
desc.Update(jsonutils.Marshal(&info))
|
||||
return desc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user