b9-0.5.17: A tool and library for building virtual machine images.

Safe HaskellNone
LanguageHaskell2010

B9.DiskImages

Contents

Description

Data types that describe all B9 relevant elements of virtual machine disk images.

Synopsis

Data types for disk image description, e.g. ImageTarget,

data ImageTarget Source

Build target for disk images; the destination, format and size of the image to generate, as well as how to create or obtain the image before a VmScript is executed with the image mounted at a MountPoint.

data ImageDestination Source

The destination of an image.

Constructors

Share String ImageType ImageResize

Create the image and some meta data so that other builds can use them as ImageSources via From.

LiveInstallerImage String FilePath ImageResize

DEPRECATED Export a raw image that can directly be booted.

LocalFile Image ImageResize

Write an image file to the path in the first argument., possible resizing it,

Transient

Do not export the image. Usefule if the main objective of the b9 build is not an image file, but rather some artifact produced by executing by a containerize build.

data ImageSource Source

Specification of how the image to build is obtained.

Constructors

EmptyImage String FileSystem ImageType ImageSize

Create an empty image file having a file system label (first parameter), a file system type (e.g. Ext4) and an ImageSize

CopyOnWrite Image

DEPRECATED

SourceImage Image Partition ImageResize

Clone an existing image file; if the image file contains partitions, select the partition to use, b9 will extract that partition by reading the offset of the partition from the partition table and extract it using dd.

From String ImageResize

Use an image previously shared by via Share.

data Partition Source

The partition to extract.

Constructors

NoPT

There is no partition table on the image

Partition Int

Extract partition n n must be in 0..3

data Image Source

A vm disk image file consisting of a path to the image file, and the type and file system.

data ImageType Source

An image type defines the actual file format of a file containing file systems. These are like virtual harddrives

Constructors

Raw 
QCow2 
Vmdk 

data ImageSize Source

A data type for image file or file system size; instead of passing Ints around this also captures a size unit so that the Int can be kept small

Constructors

ImageSize Int SizeUnit 

data SizeUnit Source

Enumeration of size multipliers. The exact semantics may vary depending on what external tools look at these. E.g. the size unit is convert to a size parameter of the qemu-img command line tool.

Constructors

B 
KB 
MB 
GB 

data ImageResize Source

How to resize an image file.

Constructors

ResizeImage ImageSize

Resize the image but not the file system. Note that a file system contained in the image file might be corrupted by this operation. To not only resize the image file but also the fil system contained in it, use Resize.

Resize ImageSize

Resize an image and the contained file system.

ShrinkToMinimum

Resize an image and the contained file system to the smallest size to fit the contents of the file system.

KeepSize

Do not change the image size.

type Mounted a = (a, MountPoint) Source

A type alias that indicates that something of type a is mount at a MountPoint

Shared Images

data SharedImage Source

SharedImage holds all data necessary to describe an instance of a shared image identified by a SharedImageName. Shared images are stored in Repositorys.

newtype SharedImageName Source

The name of the image is the de-facto identifier for push, pull, From and Share. B9 always selects the newest version the shared image identified by that name when using a shared image as an ImageSource. This is a wrapper around a string that identifies a SharedImage

Constructors

SharedImageName String 

newtype SharedImageDate Source

The exact time that build job started. This is a wrapper around a string contains the build date of a SharedImage; this is purely additional convenience and typesafety

Constructors

SharedImageDate String 

newtype SharedImageBuildId Source

Every B9 build running in a B9Monad contains a random unique id that is generated once per build (no matter how many artifacts are created in that build) This field contains the build id of the build that created the shared image instance. This is A wrapper around a string contains the build id of a SharedImage; this is purely additional convenience and typesafety

Constroctor and accessors for Image ImageTarget ImageSource

imageFileName :: Image -> FilePath Source

Return the name of the file corresponding to an Image

getImageDestinationOutputFiles :: ImageTarget -> [FilePath] Source

Return the files generated for a LocalFile or a LiveInstallerImage; SharedImage and Transient are treated like they have no ouput files because the output files are manged by B9.

imageDestinationSharedImageName :: ImageDestination -> Maybe SharedImageName Source

Return the name of a shared image, if the ImageDestination is a Share destination

imageSourceSharedImageName :: ImageSource -> Maybe SharedImageName Source

Return the name of a shared source image, if the ImageSource is a From source

isPartitioned :: Partition -> Bool Source

Return true if a Partition parameter is actually refering to a partition, false if it is NoPT

getPartition :: Partition -> Int Source

Return the Partition index or throw a runtime error if aplied to NoPT

imageFileExtension :: ImageType -> String Source

Return the file name extension of an image file with a specific image format.

changeImageFormat :: ImageType -> Image -> Image Source

Change the image file format and also rename the image file name to have the appropriate file name extension. See imageFileExtension and replaceExtension

Constructors and accessors for ImageSources

Constructors and accessors for SharedImages

siName :: SharedImage -> SharedImageName Source

Return the name of a shared image.

siDate :: SharedImage -> SharedImageDate Source

Return the date of a shared image.

siBuildId :: SharedImage -> SharedImageBuildId Source

Return the build id of a shared image.

prettyPrintSharedImages :: [SharedImage] -> String Source

Print the contents of the shared image in one line

sharedImageImage :: SharedImage -> Image Source

Return the disk image of an sharedImage

sharedImageFileName :: SharedImage -> FilePath Source

Calculate the path to the text file holding the serialized SharedImage relative to the directory of shared images in a repository.

sharedImageDefaultImageType :: ImageType Source

The internal image type to use as best guess when dealing with a From value.

Constructors for ImageTargets

transientCOWImage :: FilePath -> FilePath -> ImageTarget Source

Use a QCow2 image with an Ext4 file system

shareSharedImage :: SharedImageName -> SharedImageName -> FilePath -> ImageTarget Source

Share an image based on a shared image

cowToLocalImage :: FilePath -> FilePath -> FilePath -> ImageTarget Source

Export a QCow2 image file with Ext4 fs as a local file

localToLocalImage :: FilePath -> FilePath -> FilePath -> ImageTarget Source

Export a QCow2 image file with Ext4 fs as a local file

partition1ToLocalImage :: FilePath -> FilePath -> FilePath -> ImageTarget Source

Create a local image file from the contents of the first partition of a local QCow2 image.

ImageTarget Transformations

splitToIntermediateSharedImage :: ImageTarget -> SharedImageName -> (ImageTarget, ImageTarget) Source

Split any image target into two image targets, one for creating an intermediate shared image and one from the intermediate shared image to the output image.

Arbitrary instances for quickcheck