package vmdk

import "github.com/vmware/govmomi/vmdk"

Index

Variables

var (
	ErrInvalidFormat = errors.New("vmdk: invalid format (must be streamOptimized)")
)

Functions

func Import

func Import(ctx context.Context, c *vim25.Client, name string, datastore *object.Datastore, p ImportParams) error

Import uploads a local vmdk file specified by name to the given datastore.

Types

type Descriptor

type Descriptor struct {
	Encoding  string            `json:"encoding"`
	Version   int               `json:"version"`
	CID       DiskContentID     `json:"cid"`
	ParentCID DiskContentID     `json:"parentCID"`
	Type      string            `json:"type"`
	Extent    []Extent          `json:"extent"`
	DDB       map[string]string `json:"ddb"`
}

func NewDescriptor

func NewDescriptor(extent ...Extent) *Descriptor

func ParseDescriptor

func ParseDescriptor(r io.Reader) (*Descriptor, error)

func (*Descriptor) Write

func (d *Descriptor) Write(w io.Writer) error

type DiskContentID

type DiskContentID uint32

func (DiskContentID) String

func (cid DiskContentID) String() string

type Extent

type Extent struct {
	Type       string `json:"type"`
	Permission string `json:"permission"`
	Size       uint64 `json:"size"`
	Info       string `json:"info"`
}

type ImportParams

type ImportParams struct {
	Path       string
	Logger     progress.Sinker
	Type       types.VirtualDiskType
	Force      bool
	Datacenter *object.Datacenter
	Pool       *object.ResourcePool
	Folder     *object.Folder
	Host       *object.HostSystem
}

ImportParams contains the set of optional params to the Import function. Note that "optional" may depend on environment, such as ESX or vCenter.

type Info

type Info struct {
	Header struct {
		MagicNumber uint32
		Version     uint32
		Flags       uint32
		Capacity    uint64
	}

	Capacity   uint64
	Size       int64
	Name       string
	ImportName string
}

Info is used to inspect a vmdk and generate an ovf template

func Stat

func Stat(name string) (*Info, error)

Stat looks at the vmdk header to make sure the format is streamOptimized and extracts the disk capacity required to properly generate the ovf descriptor.

func (*Info) OVF

func (di *Info) OVF() (string, error)

OVF returns an expanded descriptor template

type VirtualDiskCryptoKey

type VirtualDiskCryptoKey struct {
	KeyID      string
	ProviderID string
}

type VirtualDiskInfo

type VirtualDiskInfo struct {
	CapacityInBytes int64
	DeviceKey       int32
	FileName        string
	Size            int64
	UniqueSize      int64
	CryptoKey       VirtualDiskCryptoKey
}

func GetVirtualDiskInfoByUUID

func GetVirtualDiskInfoByUUID(
	ctx context.Context,
	client *vim25.Client,
	mo mo.VirtualMachine,
	fetchProperties bool,
	diskUUID string) (VirtualDiskInfo, error)

GetVirtualDiskInfoByUUID returns information about a virtual disk identified by the provided UUID. This method is valid for the following backing types:

- VirtualDiskFlatVer2BackingInfo - VirtualDiskSeSparseBackingInfo - VirtualDiskRawDiskMappingVer1BackingInfo - VirtualDiskSparseVer2BackingInfo - VirtualDiskRawDiskVer2BackingInfo

These are the only backing types that have a UUID property for comparing the provided value.

Source Files

descriptor.go disk_info.go import.go

Version
v0.48.1 (latest)
Published
Feb 11, 2025
Platform
linux/amd64
Imports
21 packages
Last checked
2 months ago

Tools for package owners.