build(deps): bump github.com/vmware/govmomi from 0.23.0 to 0.26.1
Bumps [github.com/vmware/govmomi](https://github.com/vmware/govmomi) from 0.23.0 to 0.26.1. - [Release notes](https://github.com/vmware/govmomi/releases) - [Changelog](https://github.com/vmware/govmomi/blob/master/CHANGELOG.md) - [Commits](https://github.com/vmware/govmomi/compare/v0.23.0...v0.26.1) --- updated-dependencies: - dependency-name: github.com/vmware/govmomi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
974c258382
commit
137819b9cd
77 changed files with 7610 additions and 486 deletions
151
vendor/github.com/vmware/govmomi/object/virtual_machine.go
generated
vendored
151
vendor/github.com/vmware/govmomi/object/virtual_machine.go
generated
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2015-2017 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2015-2021 VMware, Inc. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/vmware/govmomi/nfc"
|
||||
"github.com/vmware/govmomi/property"
|
||||
|
|
@ -40,6 +41,34 @@ type VirtualMachine struct {
|
|||
Common
|
||||
}
|
||||
|
||||
// extractDiskLayoutFiles is a helper function used to extract file keys for
|
||||
// all disk files attached to the virtual machine at the current point of
|
||||
// running.
|
||||
func extractDiskLayoutFiles(diskLayoutList []types.VirtualMachineFileLayoutExDiskLayout) []int {
|
||||
var result []int
|
||||
|
||||
for _, layoutExDisk := range diskLayoutList {
|
||||
for _, link := range layoutExDisk.Chain {
|
||||
for i := range link.FileKey { // diskDescriptor, diskExtent pairs
|
||||
result = append(result, int(link.FileKey[i]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// removeKey is a helper function for removing a specific file key from a list
|
||||
// of keys associated with disks attached to a virtual machine.
|
||||
func removeKey(l *[]int, key int) {
|
||||
for i, k := range *l {
|
||||
if k == key {
|
||||
*l = append((*l)[:i], (*l)[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewVirtualMachine(c *vim25.Client, ref types.ManagedObjectReference) *VirtualMachine {
|
||||
return &VirtualMachine{
|
||||
Common: NewCommon(c, ref),
|
||||
|
|
@ -181,6 +210,20 @@ func (v VirtualMachine) Clone(ctx context.Context, folder *Folder, name string,
|
|||
return NewTask(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) InstantClone(ctx context.Context, config types.VirtualMachineInstantCloneSpec) (*Task, error) {
|
||||
req := types.InstantClone_Task{
|
||||
This: v.Reference(),
|
||||
Spec: config,
|
||||
}
|
||||
|
||||
res, err := methods.InstantClone_Task(ctx, v.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) Customize(ctx context.Context, spec types.CustomizationSpec) (*Task, error) {
|
||||
req := types.CustomizeVM_Task{
|
||||
This: v.Reference(),
|
||||
|
|
@ -291,7 +334,9 @@ func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...str
|
|||
devices := VirtualDeviceList(c.Val.(types.ArrayOfVirtualDevice).VirtualDevice)
|
||||
for _, d := range devices {
|
||||
if nic, ok := d.(types.BaseVirtualEthernetCard); ok {
|
||||
mac := nic.GetVirtualEthernetCard().MacAddress
|
||||
// Convert to lower so that e.g. 00:50:56:83:3A:5D is treated the
|
||||
// same as 00:50:56:83:3a:5d
|
||||
mac := strings.ToLower(nic.GetVirtualEthernetCard().MacAddress)
|
||||
if mac == "" {
|
||||
return false
|
||||
}
|
||||
|
|
@ -327,7 +372,9 @@ func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...str
|
|||
|
||||
nics := c.Val.(types.ArrayOfGuestNicInfo).GuestNicInfo
|
||||
for _, nic := range nics {
|
||||
mac := nic.MacAddress
|
||||
// Convert to lower so that e.g. 00:50:56:83:3A:5D is treated the
|
||||
// same as 00:50:56:83:3a:5d
|
||||
mac := strings.ToLower(nic.MacAddress)
|
||||
if mac == "" || nic.IpConfig == nil {
|
||||
continue
|
||||
}
|
||||
|
|
@ -469,6 +516,41 @@ func (v VirtualMachine) RemoveDevice(ctx context.Context, keepFiles bool, device
|
|||
return v.configureDevice(ctx, types.VirtualDeviceConfigSpecOperationRemove, fop, device...)
|
||||
}
|
||||
|
||||
// AttachDisk attaches the given disk to the VirtualMachine
|
||||
func (v VirtualMachine) AttachDisk(ctx context.Context, id string, datastore *Datastore, controllerKey int32, unitNumber int32) error {
|
||||
req := types.AttachDisk_Task{
|
||||
This: v.Reference(),
|
||||
DiskId: types.ID{Id: id},
|
||||
Datastore: datastore.Reference(),
|
||||
ControllerKey: controllerKey,
|
||||
UnitNumber: &unitNumber,
|
||||
}
|
||||
|
||||
res, err := methods.AttachDisk_Task(ctx, v.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task := NewTask(v.c, res.Returnval)
|
||||
return task.Wait(ctx)
|
||||
}
|
||||
|
||||
// DetachDisk detaches the given disk from the VirtualMachine
|
||||
func (v VirtualMachine) DetachDisk(ctx context.Context, id string) error {
|
||||
req := types.DetachDisk_Task{
|
||||
This: v.Reference(),
|
||||
DiskId: types.ID{Id: id},
|
||||
}
|
||||
|
||||
res, err := methods.DetachDisk_Task(ctx, v.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task := NewTask(v.c, res.Returnval)
|
||||
return task.Wait(ctx)
|
||||
}
|
||||
|
||||
// BootOptions returns the VirtualMachine's config.bootOptions property.
|
||||
func (v VirtualMachine) BootOptions(ctx context.Context) (*types.VirtualMachineBootOptions, error) {
|
||||
var o mo.VirtualMachine
|
||||
|
|
@ -579,6 +661,63 @@ func (m snapshotMap) add(parent string, tree []types.VirtualMachineSnapshotTree)
|
|||
}
|
||||
}
|
||||
|
||||
// SnapshotSize calculates the size of a given snapshot in bytes. If the
|
||||
// snapshot is current, disk files not associated with any parent snapshot are
|
||||
// included in size calculations. This allows for measuring and including the
|
||||
// growth from the last fixed snapshot to the present state.
|
||||
func SnapshotSize(info types.ManagedObjectReference, parent *types.ManagedObjectReference, vmlayout *types.VirtualMachineFileLayoutEx, isCurrent bool) int {
|
||||
var fileKeyList []int
|
||||
var parentFiles []int
|
||||
var allSnapshotFiles []int
|
||||
|
||||
diskFiles := extractDiskLayoutFiles(vmlayout.Disk)
|
||||
|
||||
for _, layout := range vmlayout.Snapshot {
|
||||
diskLayout := extractDiskLayoutFiles(layout.Disk)
|
||||
allSnapshotFiles = append(allSnapshotFiles, diskLayout...)
|
||||
|
||||
if layout.Key.Value == info.Value {
|
||||
fileKeyList = append(fileKeyList, int(layout.DataKey)) // The .vmsn file
|
||||
fileKeyList = append(fileKeyList, diskLayout...) // The .vmdk files
|
||||
} else if parent != nil && layout.Key.Value == parent.Value {
|
||||
parentFiles = append(parentFiles, diskLayout...)
|
||||
}
|
||||
}
|
||||
|
||||
for _, parentFile := range parentFiles {
|
||||
removeKey(&fileKeyList, parentFile)
|
||||
}
|
||||
|
||||
for _, file := range allSnapshotFiles {
|
||||
removeKey(&diskFiles, file)
|
||||
}
|
||||
|
||||
fileKeyMap := make(map[int]types.VirtualMachineFileLayoutExFileInfo)
|
||||
for _, file := range vmlayout.File {
|
||||
fileKeyMap[int(file.Key)] = file
|
||||
}
|
||||
|
||||
size := 0
|
||||
|
||||
for _, fileKey := range fileKeyList {
|
||||
file := fileKeyMap[fileKey]
|
||||
if parent != nil ||
|
||||
(file.Type != string(types.VirtualMachineFileLayoutExFileTypeDiskDescriptor) &&
|
||||
file.Type != string(types.VirtualMachineFileLayoutExFileTypeDiskExtent)) {
|
||||
size += int(file.Size)
|
||||
}
|
||||
}
|
||||
|
||||
if isCurrent {
|
||||
for _, diskFile := range diskFiles {
|
||||
file := fileKeyMap[diskFile]
|
||||
size += int(file.Size)
|
||||
}
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
// FindSnapshot supports snapshot lookup by name, where name can be:
|
||||
// 1) snapshot ManagedObjectReference.Value (unique)
|
||||
// 2) snapshot name (may not be unique)
|
||||
|
|
@ -855,8 +994,10 @@ func (v VirtualMachine) UUID(ctx context.Context) string {
|
|||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return o.Config.Uuid
|
||||
if o.Config != nil {
|
||||
return o.Config.Uuid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (v VirtualMachine) QueryChangedDiskAreas(ctx context.Context, baseSnapshot, curSnapshot *types.ManagedObjectReference, disk *types.VirtualDisk, offset int64) (types.DiskChangeInfo, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue