The nova.virt.disk.vfs.api Module

class VFS(image, partition)

Bases: object

Interface for manipulating disk image.

The VFS class defines an interface for manipulating files within a virtual disk image filesystem. This allows file injection code to avoid the assumption that the virtual disk image can be mounted in the host filesystem.

All paths provided to the APIs in this class should be relative to the root of the virtual disk image filesystem. Subclasses will translate paths as required by their implementation.

append_file(path, content)

Appends @content to the end of the file.

Append @content to the end of the file identified by @path, creating the file if it does not already exist.

get_image_fs()

Returns the filesystem type or an empty string.

Determine the filesystem type whether the disk image is partition less.

guestfs_ready = False
has_file(path)

Returns a True if the file identified by @path exists.

static instance_for_image(image, partition)

Get a VFS instance for the image

Parameters:
  • image – instance of nova.virt.image.model.Image
  • partition – the partition number to access
make_path(path)

Creates a directory @path.

Create a directory @path, including all intermedia path components if they do not already exist.

read_file(path)

Returns the entire contents of the file identified by @path.

replace_file(path, content)

Replaces contents of the file.

Replace the entire contents of the file identified by @path, with @content, creating the file if it does not already exist.

set_ownership(path, user, group)

Sets the ownership on the file.

Set the ownership on the file identified by @path to the username @user and groupname @group. Either of @user or @group may be None, in which case the current ownership will be left unchanged. The ownership must be passed in string form, allowing subclasses to translate to uid/gid form as required. The file must exist prior to this call.

set_permissions(path, mode)

Sets the permissions on the file.

Set the permissions on the file identified by @path to @mode. The file must exist prior to this call.

setup(mount=True)

Performs any one-time setup.

Perform any one-time setup tasks to make the virtual filesystem available to future API calls.

teardown()

Releases all resources initialized in the setup method.

Previous topic

The nova.virt.disk.mount.nbd Module

Next topic

The nova.virt.disk.vfs.guestfs Module

Project Source

This Page