vSphere Cloud Provider: update vmware/gomvomi godeps

This commit is contained in:
Doug MacEachern
2018-05-14 14:09:20 -07:00
parent 83768d286c
commit c340f6f9a4
55 changed files with 8733 additions and 596 deletions

View File

@@ -17,11 +17,13 @@ limitations under the License.
package simulator
import (
"bytes"
"fmt"
"log"
"net"
"os"
"path"
"strconv"
"strings"
"sync/atomic"
"time"
@@ -63,7 +65,7 @@ func NewVirtualMachine(parent types.ManagedObjectReference, spec *types.VirtualM
MemoryAllocation: &rspec.MemoryAllocation,
CpuAllocation: &rspec.CpuAllocation,
}
vm.Snapshot = &types.VirtualMachineSnapshotInfo{}
vm.Snapshot = nil // intentionally set to nil until a snapshot is created
vm.Storage = &types.VirtualMachineStorageInfo{
Timestamp: time.Now(),
}
@@ -420,6 +422,28 @@ func (vm *VirtualMachine) generateMAC() string {
return mac.String()
}
func numberToString(n int64, sep rune) string {
buf := &bytes.Buffer{}
if n < 0 {
n = -n
buf.WriteRune('-')
}
s := strconv.FormatInt(n, 10)
pos := 3 - (len(s) % 3)
for i := 0; i < len(s); i++ {
if pos == 3 {
if i != 0 {
buf.WriteRune(sep)
}
pos = 0
}
pos++
buf.WriteByte(s[i])
}
return buf.String()
}
func (vm *VirtualMachine) configureDevice(devices object.VirtualDeviceList, spec *types.VirtualDeviceConfigSpec) types.BaseMethodFault {
device := spec.Device
d := device.GetVirtualDevice()
@@ -469,6 +493,7 @@ func (vm *VirtualMachine) configureDevice(devices object.VirtualDeviceList, spec
c.MacAddress = vm.generateMAC()
}
case *types.VirtualDisk:
summary = fmt.Sprintf("%s KB", numberToString(x.CapacityInKB, ','))
switch b := d.Backing.(type) {
case types.BaseVirtualDeviceFileBackingInfo:
info := b.GetVirtualDeviceFileBackingInfo()
@@ -991,8 +1016,7 @@ func (vm *VirtualMachine) RemoveAllSnapshotsTask(req *types.RemoveAllSnapshots_T
refs := allSnapshotsInTree(vm.Snapshot.RootSnapshotList)
vm.Snapshot.CurrentSnapshot = nil
vm.Snapshot.RootSnapshotList = nil
vm.Snapshot = nil
for _, ref := range refs {
Map.Remove(ref)