Skip to content

Commit

Permalink
Merge branch 'v1.4.0' into test/mango_cutoff_test/#3621
Browse files Browse the repository at this point in the history
  • Loading branch information
ygcyao authored Mar 26, 2024
2 parents 6c2bbd0 + 044b378 commit 19ffa4f
Show file tree
Hide file tree
Showing 251 changed files with 8,342 additions and 2,460 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package manage
import (
"encoding/json"
"fmt"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -270,6 +271,7 @@ func transHostInfoToDbModule(h *cc.Host, bkCloudId, bkBizId int, rstp, biz, labe
OsType: model.ConvertOsTypeToHuman(osType),
OsBit: h.BkOsBit,
OsVerion: h.BkOsVersion,
OsName: strings.TrimSpace(strings.ToLower(strings.ReplaceAll(h.OSName, " ", ""))),
UpdateTime: time.Now(),
CreateTime: time.Now(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type TbRpDetail struct {
OsType string `gorm:"column:os_type;type:varchar(32);not null;comment:'操作系统类型'" json:"os_type"` // 操作系统类型 Liunx,Windows
OsBit string `gorm:"column:os_bit;type:varchar(32);not null;comment:'操作系统位数'" json:"os_bit"`
OsVerion string `gorm:"column:os_version;type:varchar(64);not null;comment:'操作系统版本'" json:"os_version"` // 操作系统版本
OsName string `gorm:"column:os_name;type:varchar(64);not null;comment:'操作系统名称'" json:"os_name"` // 操作系统名称
Raid string `gorm:"column:raid;type:varchar(20);not null" json:"raid"` // 磁盘Raid
CityID string `gorm:"column:city_id;type:varchar(64);not null" json:"city_id"` // 实际城市ID
City string `gorm:"column:city;type:varchar(128);not null" json:"city"` // 实际城市名称
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type TbRpDetailArchive struct {
OsType string `gorm:"column:os_type;type:varchar(32);not null;comment:'操作系统类型'" json:"os_type"` // 操作系统类型 Liunx,Windows
OsBit string `gorm:"column:os_bit;type:varchar(32);not null;comment:'操作系统位数'" json:"os_bit"`
OsVerion string `gorm:"column:os_version;type:varchar(64);not null;comment:'操作系统版本'" json:"os_version"` // 操作系统版本
OsName string `gorm:"column:os_name;type:varchar(64);not null;comment:'操作系统名称'" json:"os_name"` // 操作系统名称
Raid string `gorm:"column:raid;type:varchar(20);not null" json:"raid"` // 磁盘Raid
CityID string `gorm:"column:city_id;type:varchar(64);not null" json:"city_id"` // 实际城市ID
City string `gorm:"column:city;type:varchar(128);not null" json:"city"` // 实际城市名称
Expand Down
5 changes: 3 additions & 2 deletions dbm-services/common/db-resource/internal/svr/apply/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ type ApplyObjectDetail struct {
// NONE: 无需亲和性处理
Affinity string `json:"affinity"`
// Windows,Linux
OsType string `json:"os_type"`
Count int `json:"count" binding:"required,min=1"` // 申请数量
OsType string `json:"os_type"`
OsNames []string `json:"os_names"`
Count int `json:"count" binding:"required,min=1"` // 申请数量
}

// GetDiskMatchInfo TODO
Expand Down
14 changes: 14 additions & 0 deletions dbm-services/common/db-resource/internal/svr/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"path"
"sort"
"strconv"
"strings"

"dbm-services/common/db-resource/internal/config"
"dbm-services/common/db-resource/internal/model"
Expand All @@ -26,6 +27,7 @@ import (
"dbm-services/common/go-pubpkg/logger"

"gorm.io/gorm"
"gorm.io/gorm/clause"
)

// SearchContext TODO
Expand Down Expand Up @@ -132,6 +134,18 @@ func (o *SearchContext) pickBase(db *gorm.DB) {
}
db.Where("os_type = ? ", os_type)

// match os name like Windows Server 2012
if len(o.ApplyObjectDetail.OsNames) > 0 {
conditions := []clause.Expression{}
for _, osname := range o.ApplyObjectDetail.OsNames {
conditions = append(conditions, clause.Like{
Column: "os_name",
Value: "%" + strings.TrimSpace(strings.ToLower(osname)) + "%",
})
}
db.Clauses(clause.OrConditions{Exprs: conditions})
}

// 如果没有指定资源类型,表示只能选择无资源类型标签的资源
// 没有资源类型标签的资源可以被所有其他类型使用
if cmutil.IsEmpty(o.RsType) {
Expand Down
1 change: 1 addition & 0 deletions dbm-services/common/db-resource/internal/svr/bk/cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func init() {
"bk_os_type",
"bk_os_bit",
"bk_os_version",
"bk_os_name",
}
}

Expand Down
27 changes: 5 additions & 22 deletions dbm-services/common/db-resource/internal/svr/bk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ type DiskInfo struct {
type WindowDiskDetail struct {
DriveLetter string `json:"DriveLetter"`
TotalSize uint64 `json:"TotalSize"`
FileSystem string `json:"FileSystem"`
}

func diskFormartTrans(windisks []WindowDiskDetail) (commDisk []DiskInfo) {
for _, v := range windisks {
commDisk = append(commDisk, DiskInfo{
MountPoint: v.DriveLetter,
DiskDetail: DiskDetail{
Size: int(v.TotalSize / 1024 / 1024 / 1024),
Size: int(v.TotalSize / 1024 / 1024 / 1024),
FileType: v.FileSystem,
},
})
}
Expand Down Expand Up @@ -222,7 +224,7 @@ func GetWindowsDiskInfo(hosts []IPList, bk_biz_id int) (ipFailedLogMap map[strin
ScriptContent: base64.StdEncoding.EncodeToString(GetWinDiskInfoShellContent),
ScriptTimeout: 300,
ScriptLanguage: 5,
AccountAlias: "Administrator",
AccountAlias: "system",
TargetServer: TargetServer{
IPList: hosts,
},
Expand All @@ -235,17 +237,7 @@ func getDiskInfoBase(hosts []IPList, bk_biz_id int, param *FastExecuteScriptPara
jober := JobV3{
Client: EsbClient,
}
job, err := jober.ExecuteJob(&FastExecuteScriptParam{
BkBizID: bk_biz_id,
ScriptContent: base64.StdEncoding.EncodeToString(GetDiskInfoShellContent),
ScriptTimeout: 300,
ScriptLanguage: 1,
AccountAlias: "root",
TargetServer: TargetServer{
IPList: hosts,
},
},
)
job, err := jober.ExecuteJob(param)
if err != nil {
logger.Error("call execute job failed %s", err.Error())
return nil, BatchGetJobInstanceIpLogRpData{}, err
Expand Down Expand Up @@ -290,15 +282,6 @@ func getDiskInfoBase(hosts []IPList, bk_biz_id int, param *FastExecuteScriptPara
StepInstanceID: job.StepInstanceID,
IPList: hosts,
})
// resp.IpLogContentMap = make(map[string]*ShellResCollection)
// for _, d := range ipLogs.ScriptTaskLogs {
// var dl ShellResCollection
// if err = json.Unmarshal([]byte(d.LogContent), &dl); err != nil {
// logger.Error("unmarshal log content failed %s", err.Error())
// continue
// }
// resp.IpLogContentMap[d.Ip] = &dl
// }
return ipFailedLogMap, ipLogs, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ $diskInfo = Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" | ForEa
[PSCustomObject]@{
DriveLetter = $_.DeviceID
TotalSize = $_.Size
FileSystem = $_.FileSystem
}
}


$cpuInfo = (Get-WmiObject -Class Win32_Processor).NumberOfCores
$cpuInfo = (Get-WmiObject -Query "SELECT * FROM Win32_Processor").NumberOfCores

$memoryInfo = (Get-WmiObject -Class Win32_OperatingSystem).TotalVisibleMemorySize

Expand Down
Loading

0 comments on commit 19ffa4f

Please sign in to comment.