3. vixDisk

This package wraps up the vix-disklib library from vmware, and creates binding for python.

class vixDiskLib.vixDisk.VixDisk

Bases: vixDiskLib.vixDiskBase.VixDiskBase

A file IO interface to the vixDiskLib SDK

iter(nblocks=1)

Returns an iterator that will read from the currently open disk using nblocks

class vixDiskLib.vixDiskBase.VixDiskBase

Bases: vixDiskLib.vixBase.VixBase

A file IO interface to the vixDiskLib SDK

attach

Attaches the child disk chain to the parent disk chain. Parent handle is invalid after attaching and child represents the combined disk chain.

available_modes

Returns a list of available transport modes.

Returns:The list of available transport modes
block_size

The block size.

clone

Copies a disk with proper conversion.

close

Closes the disk.

create

Creates a disk.

Parameters:
  • path – The path where the disk will be created.
  • create_params – The :py:class:VixDiskLib_CreateParams that will be used to create the disk.
  • local_path – The path for the local disk, if creating a local disk.
createChild

Creates a redo log from a parent disk.

defragment

Defragments an existing disk.

getAvailableTransportModes

Returns a list of available transport modes.

Returns:The list of available transport modes
getMetadata

Retrieves the metadata for the drive.

getTransportMode

Returns the current transport mode. Must be connected.

Returns:The transport mode
grow

Grows an existing disk, only local disks are grown.

info

Retrieves information about a disk.

needs_repair

Check a sparse disk for internal consistency.

open

Open a vmdk for editing or reading (see readonly)

Parameters:
  • path – Path to the vmdk. Example: [System-Disk] DEV-BOX-01/DEV-BOX-01.vmdk
  • single – Open the disk in single mode.
read

Reads a sector range.

Parameters:
  • offset – Absolute offset.
  • nblocks – Number of blocks to read.
Returns:

np.ndarray of bytes

Note: SECTORS_PER_BLOCK = DEFAULT_BLOCK_SIZE (1048576 or 1MB) / VIXDISKLIB_SECTOR_SIZE (512)
SECTORS_PER_BLOCK = 2048 sectors 1 block = 1048576 byts or 1MB
rename

Renames a virtual disk.

reopen

Closes and re-opens the current disk.

setMetadata

Writes the metadata to the drive.

Parameters:metadata – The metadata to be written to the drive.
shrink

Shrinks an existing disk, only local disks are shrunk.

transport_mode

Returns the current transport mode. Must be connected.

Returns:The transport mode

Deletes all extents of the specified disk link. If the path refers to a parent disk, the child (redo log) will be orphaned. Unlinking the child does not affect the parent.

write

Writes a sector range.

Parameters:
  • offset – Absolute offset.
  • nblocks – Number of blocks to read.
  • buff – np.ndarray of bytes
Note: SECTORS_PER_BLOCK = DEFAULT_BLOCK_SIZE (1048576 or 1MB) / VIXDISKLIB_SECTOR_SIZE (512)
SECTORS_PER_BLOCK = 2048 sectors 1 block = 1048576 bytes or 1MB
class vixDiskLib.vixBase.VixBase

Bases: object

cleanup

Perform a cleanup after an unclean shutdown of an application using vix-disklib.

config

The location of the vix-disklib configuration file.

connect

Connects the library to the drive using the snapshot reference if provided.

Parameters:
  • snapshotRef – The reference to a snapshot. This is only needed if we are connecting to a remote disk.
  • transport – The transport to use. If not provided, the best match will be selected.
  • readonly – If true, opens the disk in read only mode. This is the default.
disconnect

Disconnects the library from the drive. This will call :py:meth:VixBase.cleanup.

finalize

Frees any memory that we maybe hanging on too.

initialize

Initialize the vix-disklib library and setup logging

libdir

The location of the vix-disklib libraries.

readonly

The read only flag upon connection.

reset

Closes any open connections, cleans up, and then reconnects.

class vixDiskLib.VixCredentials(vmxSpec, host, username, password)

Bases: object

VixDiskLib Credentials to log into a vcenter or ESX server

class vixDiskLib.VixDiskLib_CreateParams(disk_type, adapter_type, hw_version, blocks)

Bases: object

Disk creation parameters

Previous topic

1. Requirements

Next topic

4. Exceptions

This Page