mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-24 23:41:52 +08:00
fix(esxi-agent): create vmware vm with suitable version (#19726)
This commit is contained in:
@@ -88,7 +88,7 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240308095624-f1aeca8dcd51
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240314033848-3931fce566be
|
||||
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
|
||||
|
||||
@@ -1204,8 +1204,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.20240308095624-f1aeca8dcd51 h1:9a58ALsmGgjtFRKELyenb0Hb7lKoMmAZ2QbfMYIOWG0=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240308095624-f1aeca8dcd51/go.mod h1:dsUESXIbXJ+/ywbNClhldOrbPOiBi2udrgOnB/ffoWk=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240314033848-3931fce566be h1:Wo/4U9bJHzgE/aeHgGJUCHJJW0cbZBtFNknBTasTy+I=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240314033848-3931fce566be/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=
|
||||
|
||||
Vendored
+1
-1
@@ -1473,7 +1473,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.20240308095624-f1aeca8dcd51
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240314033848-3931fce566be
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+37
-4
@@ -1052,10 +1052,7 @@ func (host *SHost) DoCreateVM(ctx context.Context, ds *SDatastore, params SCreat
|
||||
guestId = "windows7Server64Guest"
|
||||
}
|
||||
|
||||
version := "vmx-10"
|
||||
if host.isVersion50() {
|
||||
version = "vmx-08"
|
||||
}
|
||||
version := host.getVmVersion()
|
||||
|
||||
if params.CpuSockets == 0 {
|
||||
params.CpuSockets = 1
|
||||
@@ -1433,6 +1430,19 @@ func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, snapshot
|
||||
return vm, nil
|
||||
}
|
||||
}
|
||||
|
||||
task, err = vm.getVmObj().UpgradeVM(ctx, host.getVmVersion())
|
||||
if err != nil {
|
||||
log.Errorf("upgrade vm %s error: %v", vm.GetName(), err)
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
err = task.Wait(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("wait vm %s upgrade error: %v", vm.GetName(), err)
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
@@ -1457,6 +1467,29 @@ func (host *SHost) isVersion50() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (host *SHost) getVmVersion() string {
|
||||
ver := func() string {
|
||||
version := host.GetVersion()
|
||||
if len(version) >= 3 {
|
||||
return version[:3]
|
||||
}
|
||||
return version
|
||||
}()
|
||||
version, ok := map[string]string{
|
||||
"5.0": "vmx-08",
|
||||
"5.1": "vmx-09",
|
||||
"5.5": "vmx-10",
|
||||
"6.0": "vmx-11",
|
||||
"6.5": "vmx-13",
|
||||
"6.7": "vmx-14",
|
||||
"7.0": "vmx-17",
|
||||
}[ver]
|
||||
if ok {
|
||||
return version
|
||||
}
|
||||
return "vmx-10"
|
||||
}
|
||||
|
||||
func (host *SHost) GetIHostNics() ([]cloudprovider.ICloudHostNetInterface, error) {
|
||||
nics, err := host.GetIHostNicsInternal(false)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user