mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-30 18:23:35 +08:00
fix(region): sync hostname (#20123)
This commit is contained in:
@@ -89,7 +89,7 @@ require (
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
k8s.io/cri-api v0.22.17
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240423080301-f3d434d413c4
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240424091412-88cd35a379f2
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20240203102553-4096f103b401
|
||||
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91
|
||||
|
||||
@@ -1209,8 +1209,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240423080301-f3d434d413c4 h1:/CY5NV5Bw8g5sLkgFO+LcEYX8XfOO8zcark59smHdZo=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240423080301-f3d434d413c4/go.mod h1:dsUESXIbXJ+/ywbNClhldOrbPOiBi2udrgOnB/ffoWk=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240424091412-88cd35a379f2 h1:1k9Dcojz2CI+UKnTQJsPG5qiISd+c/YWiwXVnS6912k=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240424091412-88cd35a379f2/go.mod h1:dsUESXIbXJ+/ywbNClhldOrbPOiBi2udrgOnB/ffoWk=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
@@ -3041,6 +3041,16 @@ func (g *SGuest) SyncOsInfo(ctx context.Context, userCred mcclient.TokenCredenti
|
||||
return g.GetDriver().SyncOsInfo(ctx, userCred, g, extVM)
|
||||
}
|
||||
|
||||
func (g *SGuest) SyncHostname(ext cloudprovider.ICloudVM) {
|
||||
hostname := pinyinutils.Text2Pinyin(ext.GetHostname())
|
||||
if len(hostname) > 128 {
|
||||
hostname = hostname[:128]
|
||||
}
|
||||
if len(hostname) > 0 {
|
||||
g.Hostname = hostname
|
||||
}
|
||||
}
|
||||
|
||||
func (g *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.TokenCredential, provider cloudprovider.ICloudProvider, host *SHost, extVM cloudprovider.ICloudVM, syncOwnerId mcclient.IIdentityProvider, syncStatus bool) error {
|
||||
recycle := false
|
||||
|
||||
@@ -3055,13 +3065,9 @@ func (g *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.TokenCre
|
||||
g.Name = newName
|
||||
}
|
||||
}
|
||||
hostname := pinyinutils.Text2Pinyin(extVM.GetHostname())
|
||||
if len(hostname) > 128 {
|
||||
hostname = hostname[:128]
|
||||
}
|
||||
if extVM.GetName() != hostname {
|
||||
g.Hostname = hostname
|
||||
}
|
||||
|
||||
g.SyncHostname(extVM)
|
||||
|
||||
if !g.IsFailureStatus() && syncStatus {
|
||||
g.Status = extVM.GetStatus()
|
||||
g.PowerStates = extVM.GetPowerStates()
|
||||
@@ -3176,7 +3182,11 @@ func (manager *SGuestManager) newCloudVM(ctx context.Context, userCred mcclient.
|
||||
guest.Bios = string(extVM.GetBios())
|
||||
guest.Machine = extVM.GetMachine()
|
||||
guest.Hypervisor = extVM.GetHypervisor()
|
||||
guest.Hostname = pinyinutils.Text2Pinyin(extVM.GetHostname())
|
||||
hostname := extVM.GetHostname()
|
||||
if len(hostname) == 0 {
|
||||
hostname = extVM.GetName()
|
||||
}
|
||||
guest.Hostname = pinyinutils.Text2Pinyin(hostname)
|
||||
guest.InternetMaxBandwidthOut = extVM.GetInternetMaxBandwidthOut()
|
||||
guest.Throughput = extVM.GetThroughput()
|
||||
guest.Description = extVM.GetDescription()
|
||||
|
||||
Vendored
+1
-1
@@ -1476,7 +1476,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240423080301-f3d434d413c4
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240424091412-88cd35a379f2
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+1
-1
@@ -223,7 +223,7 @@ func (self *SInstance) GetName() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.GetName()
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetGlobalId() string {
|
||||
|
||||
+1
-1
@@ -803,7 +803,7 @@ func (self *SInstance) GetName() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.Name
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetGlobalId() string {
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ func (i *SInstance) GetName() string {
|
||||
}
|
||||
|
||||
func (i *SInstance) GetHostname() string {
|
||||
return i.Name
|
||||
return ""
|
||||
}
|
||||
|
||||
func (i *SInstance) GetGlobalId() string {
|
||||
|
||||
+1
-1
@@ -220,7 +220,7 @@ func (svm *SVirtualMachine) GetGlobalId() string {
|
||||
}
|
||||
|
||||
func (svm *SVirtualMachine) GetHostname() string {
|
||||
return svm.GetName()
|
||||
return ""
|
||||
}
|
||||
|
||||
func (svm *SVirtualMachine) GetDescription() string {
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ func (region *SRegion) GetInstance(id string) (*SInstance, error) {
|
||||
}
|
||||
|
||||
func (instance *SInstance) GetHostname() string {
|
||||
return instance.GetName()
|
||||
return ""
|
||||
}
|
||||
|
||||
func (instance *SInstance) fetchMachineType() error {
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ func (self *SInstance) GetError() error {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.Name
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHypervisor() string {
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ func (self *SInstance) GetName() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.DisplayName
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetGlobalId() string {
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@ func (self *SInstance) GetError() error {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.GetName()
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHypervisor() string {
|
||||
|
||||
+1
-1
@@ -198,7 +198,7 @@ func (self *SInstance) GetName() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.GetName()
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetGlobalId() string {
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ func (self *SInstance) GetName() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHostname() string {
|
||||
return self.GetName()
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SInstance) GetGlobalId() string {
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ func (instance *SInstance) GetName() string {
|
||||
}
|
||||
|
||||
func (instance *SInstance) GetHostname() string {
|
||||
return instance.Name
|
||||
return ""
|
||||
}
|
||||
|
||||
func (instance *SInstance) GetGlobalId() string {
|
||||
|
||||
Reference in New Issue
Block a user