fix(esxiagent): Cancel devKeys's cache of vm

This commit is contained in:
Rain
2020-01-19 11:03:13 +08:00
parent 7524141e49
commit b301bb01b7
2 changed files with 7 additions and 12 deletions
-1
View File
@@ -988,7 +988,6 @@ func (host *SHost) CloneVM(ctx context.Context, from *SVirtualMachine, ds *SData
}
return NewVirtualMachine(host.manager, &moVM, host.datacenter), nil
return nil, nil
}
func (host *SHost) changeNic(device types.BaseVirtualDevice, update types.BaseVirtualDevice) {
+7 -11
View File
@@ -56,8 +56,6 @@ type SVirtualMachine struct {
ihost cloudprovider.ICloudHost
guestIps map[string]string
devKeys []int32
}
type byDiskType []SVirtualDisk
@@ -1128,16 +1126,14 @@ func (self *SVirtualMachine) FindMinDiffKey(limit int32) int32 {
if self.devs == nil {
self.fetchHardwareInfo()
}
if self.devKeys == nil {
self.devKeys = make([]int32, 0, len(self.devs))
for key, _ := range self.devs {
self.devKeys = append(self.devKeys, key)
}
sort.Slice(self.devKeys, func(i int, j int) bool {
return self.devKeys[i] < self.devKeys[j]
})
devKeys := make([]int32, 0, len(self.devs))
for key := range self.devs {
devKeys = append(devKeys, key)
}
for _, key := range self.devKeys {
sort.Slice(devKeys, func(i int, j int) bool {
return devKeys[i] < devKeys[j]
})
for _, key := range devKeys {
switch {
case key < limit:
case key == limit: