disk

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2018 License: Apache-2.0 Imports: 26 Imported by: 40

Documentation

Index

Constants

View Source
const (
	DiskBackendKey = "msg.disk.noBackEnd"
	LockedFileKey  = "msg.fileio.lock"
)
View Source
const (
	// You can assign the device to (1:z ), where 1 is SCSI controller 1 and z is a virtual device node from 0 to 15.
	// https://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-5872D173-A076-42FE-8D0B-9DB0EB0E7362.html
	MaxAttachedDisks = 16
)

Variables

This section is empty.

Functions

func IsLockedError

func IsLockedError(err error) bool

IsLockedError will determine if the error received is: a. related to a vmdk b. due to the vmdk being locked It will return false in absence of confirmation, meaning incomplete vim errors will return false

func LockedDisks

func LockedDisks(err error) []string

LockedDisks returns locked devices path in the error if it's device lock error

func LockedVMDKFilter

func LockedVMDKFilter(vm *mo.VirtualMachine) bool

Types

type Filesystem

type Filesystem interface {
	Mkfs(op trace.Operation, devPath, label string) error
	SetLabel(op trace.Operation, devPath, labelName string) error
	Mount(op trace.Operation, devPath, targetPath string, options []string) error
	Unmount(op trace.Operation, path string) error
}

Filesystem defines the interface for handling an attached virtual disk

type FilesystemType

type FilesystemType uint8

FilesystemType represents the filesystem in use by a virtual disk

const (
	// Ext4 represents the ext4 file system
	Ext4 FilesystemType = iota + 1

	// Xfs represents the XFS file system
	Xfs

	// Ntfs represents the NTFS file system
	Ntfs

	// used to isolate applications from the lost+found in the root of ext4
	VolumeDataDir = "/.vic.vol.data"
)

type InUseError

type InUseError struct {
	// contains filtered or unexported fields
}

InUseError is returned when a detach is attempted on a disk that is still in use

type Manager

type Manager struct {

	// map of URIs to VirtualDisk structs so that we can return the same instance to the caller, required for ref counting
	Disks map[uint64]*VirtualDisk
	// contains filtered or unexported fields
}

Manager manages disks for the vm it runs on. The expectation is this is run from a VM on a vsphere instance. This VM creates disks on ESX, attaches them to itself, writes to them, then detaches them.

func NewDiskManager

func NewDiskManager(op trace.Operation, session *session.Session, v *view.ContainerView) (*Manager, error)

NewDiskManager creates a new Manager instance associated with the caller VM

func (*Manager) AttachAndMount

func (m *Manager) AttachAndMount(op trace.Operation, datastoreURI *object.DatastorePath, persistent bool) (string, error)

AttachAndMount creates and attaches a vmdk as a non-persistent disk, mounts it, and returns the mount path.

func (*Manager) Create

func (m *Manager) Create(op trace.Operation, config *VirtualDiskConfig) (*VirtualDisk, error)

Create creates a disk without a parent (and doesn't attach it).

func (*Manager) CreateAndAttach

func (m *Manager) CreateAndAttach(op trace.Operation, config *VirtualDiskConfig) (*VirtualDisk, error)

CreateAndAttach creates a new VMDK, attaches it and ensures that the device becomes visible to the caller. Returns a VirtualDisk corresponding to the created and attached disk.

func (*Manager) Detach

func (m *Manager) Detach(op trace.Operation, config *VirtualDiskConfig) error

Detach attempts to detach a virtual disk

func (*Manager) DetachAll

func (m *Manager) DetachAll(op trace.Operation) error

func (*Manager) DiskFinder

func (m *Manager) DiskFinder(op trace.Operation, filter func(p string) bool) (string, error)

func (*Manager) DiskParent

func (m *Manager) DiskParent(op trace.Operation, config *VirtualDiskConfig) (*object.DatastorePath, error)

DiskParent returns the parent for an existing disk, based on the disk datastore URI in the config, and ignoring any parent specified in the config. datastore path will be nil if the disk has no parent

func (*Manager) Get

func (m *Manager) Get(op trace.Operation, config *VirtualDiskConfig) (*VirtualDisk, error)

Gets a disk given a datastore path URI to the vmdk

func (*Manager) InUse

func (m *Manager) InUse(op trace.Operation, config *VirtualDiskConfig, filter func(vm *mo.VirtualMachine) bool) ([]*vm.VirtualMachine, error)

func (*Manager) Owners

func (m *Manager) Owners(op trace.Operation, url *url.URL, filter func(vm *mo.VirtualMachine) bool) ([]*vm.VirtualMachine, error)

func (*Manager) UnmountAndDetach

func (m *Manager) UnmountAndDetach(op trace.Operation, datastoreURI *object.DatastorePath, persistent bool) error

UnmountAndDetach unmounts and detaches a disk, subsequently cleaning the mount path

type Semaphore

type Semaphore struct {
	// contains filtered or unexported fields
}

Semaphore represents the number of references to a disk

func NewSemaphore

func NewSemaphore(r, n string) *Semaphore

NewSemaphore creates and returns a Semaphore initialized to 0

func (*Semaphore) Count

func (r *Semaphore) Count() uint64

Count returns the current reference count

func (*Semaphore) Decrement

func (r *Semaphore) Decrement() uint64

Decrement decreases the reference count by one

func (*Semaphore) Increment

func (r *Semaphore) Increment() uint64

Increment increases the reference count by one

type VirtualDisk

type VirtualDisk struct {
	*VirtualDiskConfig

	// The device node the disk is attached to
	DevicePath string
	// contains filtered or unexported fields
}

VirtualDisk represents a VMDK in the datastore, the device node it may be attached at (if it's attached), the mountpoint it is mounted at (if mounted), and other configuration.

func NewVirtualDisk

func NewVirtualDisk(op trace.Operation, config *VirtualDiskConfig, disks map[uint64]*VirtualDisk) (*VirtualDisk, error)

NewVirtualDisk creates and returns a new VirtualDisk object associated with the given datastore formatted with the specified FilesystemType

func (*VirtualDisk) Attached

func (d *VirtualDisk) Attached() bool

Attached returns true if this disk is attached, false otherwise

func (*VirtualDisk) AttachedByOther

func (d *VirtualDisk) AttachedByOther() bool

AttachedByOther returns true if the attached references are > 1

func (*VirtualDisk) DiskPath

func (d *VirtualDisk) DiskPath() url.URL

DiskPath returns a URL referencing the path of the virtual disk on the datastore

func (*VirtualDisk) InUseByOther

func (d *VirtualDisk) InUseByOther() bool

InUseByOther returns true if the disk is currently attached or mounted by someone else

func (*VirtualDisk) Mkfs

func (d *VirtualDisk) Mkfs(op trace.Operation, labelName string) error

Mkfs formats the disk with Filesystem and sets the disk label

func (*VirtualDisk) Mount

func (d *VirtualDisk) Mount(op trace.Operation, options []string) (string, error)

Mount attempts to mount this disk. A NOP occurs if the disk is already mounted It returns the path at which the disk is mounted Enhancement: allow provision of mount path and refcount for:

specific mount point and options

func (*VirtualDisk) MountPath

func (d *VirtualDisk) MountPath() (string, error)

MountPath returns the path on which the virtual disk is mounted, or an error if the disk is not mounted

func (*VirtualDisk) Mounted

func (d *VirtualDisk) Mounted() bool

Mounted returns true if the virtual disk is mounted, false otherwise

func (*VirtualDisk) MountedByOther

func (d *VirtualDisk) MountedByOther() bool

MountedByOther returns true if the mounted references are > 1

func (*VirtualDisk) SetLabel

func (d *VirtualDisk) SetLabel(op trace.Operation, labelName string) error

SetLabel sets this disk's label

func (*VirtualDisk) Unmount

func (d *VirtualDisk) Unmount(op trace.Operation) error

Unmount attempts to unmount a virtual disk

type VirtualDiskConfig

type VirtualDiskConfig struct {
	// The URI in the datastore this disk can be found with
	DatastoreURI *object.DatastorePath

	// The URI in the datastore to the parent of this disk
	ParentDatastoreURI *object.DatastorePath

	// The size of the disk
	CapacityInKB int64

	// Underlying filesystem
	Filesystem Filesystem

	DiskMode types.VirtualDiskMode
}

func NewNonPersistentDisk

func NewNonPersistentDisk(URI *object.DatastorePath) *VirtualDiskConfig

func NewPersistentDisk

func NewPersistentDisk(URI *object.DatastorePath) *VirtualDiskConfig

func (*VirtualDiskConfig) Hash

func (d *VirtualDiskConfig) Hash() uint64

func (*VirtualDiskConfig) IsPersistent

func (d *VirtualDiskConfig) IsPersistent() bool

func (*VirtualDiskConfig) WithCapacity

func (d *VirtualDiskConfig) WithCapacity(capacity int64) *VirtualDiskConfig

func (*VirtualDiskConfig) WithFilesystem

func (d *VirtualDiskConfig) WithFilesystem(ftype FilesystemType) *VirtualDiskConfig

func (*VirtualDiskConfig) WithParent

func (d *VirtualDiskConfig) WithParent(parent *object.DatastorePath) *VirtualDiskConfig

type Vmdk

type Vmdk struct {
	*Manager
	*datastore.Helper
	*session.Session
}

Vmdk is intended to be embedded by stores that manage VMDK-based data resources

func (*Vmdk) Mount

func (v *Vmdk) Mount(op trace.Operation, uri *url.URL, persistent bool) (string, func(), error)

Mount mounts the disk, returning the mount path and the function used to unmount/detaches when no longer in use

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL