mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
Merge pull request #11931 from ioito/hotfix/qx-azure-dtu
fix(region): azure sqlserver dtu
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user