Merge pull request #11931 from ioito/hotfix/qx-azure-dtu

fix(region): azure sqlserver dtu
This commit is contained in:
Zexi Li
2021-08-18 10:25:14 +08:00
committed by GitHub
2 changed files with 49 additions and 2 deletions
+30 -1
View File
@@ -15,6 +15,7 @@
package azure
import (
"fmt"
"net/url"
"strings"
@@ -162,7 +163,35 @@ func (self *SSQLServer) GetVcpuCount() int {
}
func (self *SSQLServer) GetVmemSizeMB() int {
return self.GetVcpuCount() * 3 * 1023
dbs, err := self.fetchDatabase()
if err != nil {
return 0
}
mem := 0
for _, db := range dbs {
mem += db.GetVmemSizeMb()
}
return mem
}
func (self *SSQLServer) GetSysTags() map[string]string {
dtu := self.GetDTU()
if dtu > 0 {
return map[string]string{"DTU": fmt.Sprintf("%d", dtu)}
}
return nil
}
func (self *SSQLServer) GetDTU() int {
dbs, err := self.fetchDatabase()
if err != nil {
return 0
}
dtu := 0
for _, db := range dbs {
dtu += db.GetDTU()
}
return dtu
}
func (self *SSQLServer) GetZone1Id() string {
+19 -1
View File
@@ -56,6 +56,7 @@ type SSQLServerDatabase struct {
Name string `json:"name"`
Tier string `json:"tier"`
Capacity int `json:"capacity"`
Family string `json:"family"`
} `json:"currentSku"`
} `json:"properties"`
Location string `json:"location"`
@@ -88,7 +89,24 @@ func (self *SSQLServerDatabase) GetDiskSizeMb() int {
}
func (self *SSQLServerDatabase) GetVcpuCount() int {
return self.Properties.Currentsku.Capacity
if len(self.Properties.Currentsku.Family) > 0 {
return self.Properties.Currentsku.Capacity
}
return 0
}
func (self *SSQLServerDatabase) GetVmemSizeMb() int {
if len(self.Properties.Currentsku.Family) > 0 {
return int(5.2 * 1024 * float32(self.Properties.Currentsku.Capacity))
}
return 0
}
func (self *SSQLServerDatabase) GetDTU() int {
if len(self.Properties.Currentsku.Family) == 0 {
return self.Properties.Currentsku.Capacity
}
return 0
}
func (self *SSQLServerDatabase) GetGlobalId() string {