Skip to content

Commit

Permalink
fix(region): hostname length (#17866)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito authored Aug 29, 2023
1 parent 11fe9bf commit 69e18ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/cloudcommon/db/standalone_anon.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type SStandaloneAnonResourceBase struct {
Id string `width:"128" charset:"ascii" primary:"true" list:"user" create:"optional" json:"id"`

// 资源描述信息
Description string `width:"256" charset:"utf8" get:"user" list:"user" update:"user" create:"optional" json:"description"`
Description string `length:"0" charset:"utf8" get:"user" list:"user" update:"user" create:"optional" json:"description"`

// 是否是模拟资源, 部分从公有云上同步的资源并不真实存在, 例如宿主机
// list 接口默认不会返回这类资源,除非显示指定 is_emulate=true 过滤参数
Expand Down
3 changes: 3 additions & 0 deletions pkg/compute/models/guests.go
Original file line number Diff line number Diff line change
Expand Up @@ -2967,6 +2967,9 @@ func (self *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.Token
}
}
hostname := pinyinutils.Text2Pinyin(extVM.GetHostname())
if len(hostname) > 128 {
hostname = hostname[:128]
}
if extVM.GetName() != hostname {
self.Hostname = hostname
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/compute/models/hostnameresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

type SHostnameResourceBase struct {
Hostname string `width:"60" charset:"ascii" nullable:"true" list:"user" create:"optional" update:"user"`
Hostname string `width:"128" charset:"ascii" nullable:"true" list:"user" create:"optional" update:"user"`
}

type SHostnameResourceBaseManager struct {
Expand Down

0 comments on commit 69e18ba

Please sign in to comment.