FAI_DiskConfig

Parses disk_config files for FAI

Author: Raphael Pinson rap.nosp@m.hink@gmai.nosp@m.l.com

Summary
FAI_DiskConfigParses disk_config files for FAI
Referencehttp://wiki.fai-project.org/wiki/Setup-storage#New_configuration_file_syntax
LicenseThis file is licensed under the LGPL v2+, like the rest of Augeas.
ExamplesThe Test_FAI_DiskConfig file contains various examples and tests.
USEFUL PRIMITIVES
Generic primitives
eol
space
empty
comment
tagA generic tag beginning with a colon
generic_optA generic key/value option
generic_opt_listA generic key/list option
RECORDS
volume
mountpoint_kw
encryptencrypt tag
mountpoint
resizeresize tag
size_kwRegexps for size
size
filesystem_kwRegexps for filesystem
filesystem
mount_option_value
mount_optionCounting options
mount_optionsAn array of mount_options
fs_option
fs_optionsAn array of fs_options
volume_full
nameLVM volume group name
partitionAn optional partition number for disk
disk
vg_optionAn option for volume_vg
volume_vg
spare_missing
disk_with_optA disk with a spare/missing option for raids
disk_listA list of disk_with_opts
type_label_lv
volume_tmpfs
volume_lvm
volume_raid
device
volume_cryptsetup
volume
volume_or_commentA succesion of volumes and comments
disk_config_entry
lvmoption
raidoption
option
disk_config
lnsThe disk_config lens

Reference

This lens tries to keep as close as possible to the FAI wiki where possible

http://wiki.fai-project.org/wiki/Setup-storage#New_configuration_file_syntax

License

This file is licensed under the LGPL v2+, like the rest of Augeas.

Examples

The Test_FAI_DiskConfig file contains various examples and tests.

USEFUL PRIMITIVES

Generic primitives

eol

let eol = Util.eol

space

let space = Sep.space

empty

let empty = Util.empty

comment

let comment = Util.comment

tag

let tag (re:regexp) = [ Util.del_str ":" . key re ]

A generic tag beginning with a colon

generic_opt

let generic_opt (type:string) (kw:regexp) = [ key type . Util.del_str ":" . store kw ]

A generic key/value option

generic_opt_list

let generic_opt_list (type:string) (kw:regexp) = [ key type . Util.del_str ":" . counter "locallist" . Build.opt_list [seq "locallist" . store kw] Sep.comma ]

A generic key/list option

RECORDS

volume

mountpoint_kw

let mountpoint_kw = "-" (* do not mount *) | "swap" (* swap space *)

encrypt

let encrypt = tag "encrypt"

encrypt tag

mountpoint

resize

let resize = tag "resize"

resize tag

size_kw

let size_kw = /[0-9]+[kMGTP%]?(-([0-9]+[kMGTP%]?)?)?/ | /-[0-9]+[kMGTP%]?/

Regexps for size

size

let size = [ label "size" . store size_kw . resize? ]

filesystem_kw

let filesystem_kw = "-" | "swap"

Regexps for filesystem

filesystem

let filesystem = [ label "filesystem" . store filesystem_kw ]

mount_option_value

let mount_option_value = [ label "value" . Util.del_str "=" . store /[^,= \t\n]+/ ]

mount_option

let mount_option = [ seq "mount_option" . store /[^,= \t\n]+/ . mount_option_value? ]

Counting options

mount_options

let mount_options = [ label "mount_options" . counter "mount_option" . Build.opt_list mount_option Sep.comma ]

An array of mount_options

fs_option

let fs_option = [ key /createopts|tuneopts/ . Util.del_str "=\"" . store /[^"\n]*/ . Util.del_str "\"" ]

fs_options

let fs_options =

An array of fs_options

volume_full

let volume_full (type:lens) (third_field:lens) =

name

let name = [ label "name" . store /[^\/ \t\n]+/ ]

LVM volume group name

partition

let partition = [ label "partition" . Util.del_str "." . store /[0-9]+/ ]

An optional partition number for disk

disk

let disk = [ label "disk" . store /[^., \t\n]+/ . partition? ]

vg_option

let vg_option = [ key "pvcreateopts" . Util.del_str "=\"" . store /[^"\n]*/ . Util.del_str "\"" ]

An option for volume_vg

volume_vg

let volume_vg = [ key "vg" . space . name . space . disk . (space . vg_option)? . eol ]

spare_missing

let spare_missing = tag /spare|missing/

disk_with_opt

let disk_with_opt = [ label "disk" . store /[^:., \t\n]+/ . partition? . spare_missing* ]

A disk with a spare/missing option for raids

disk_list

let disk_list = Build.opt_list disk_with_opt Sep.comma

A list of disk_with_opts

type_label_lv

let type_label_lv = label "lv" . [ label "vg" . store (/[^# \t\n-]+/ - "raw") ] . Util.del_str "-" . [ label "name" . store /[^ \t\n]+/ ]

volume_tmpfs

let volume_tmpfs = [ key "tmpfs" . space . mountpoint .space . size . space . mount_options . (space . fs_options)? . eol ]

volume_lvm

let volume_lvm = volume_full type_label_lv size (* lvm logical volume: vg name and lv name *) | volume_vg

volume_raid

let volume_raid = volume_full (key /raid[0156]/) disk_list (* raid level *)

device

let device = [ label "device" . store Rx.fspath ]

volume_cryptsetup

let volume_cryptsetup = volume_full (key ("swap"|"tmp"|"luks")) device

volume

let volume = volume_full (key "primary") size (* for physical disks only *) | volume_full (key "logical") size (* for physical disks only *) | volume_full (key "raw-disk") size

volume_or_comment

let volume_or_comment (vol:lens) = (vol|empty|comment)* . vol

A succesion of volumes and comments

disk_config_entry

let disk_config_entry (kw:regexp) (opt:lens) (vol:lens) = [ key "disk_config" . space . store kw . (space . opt)* . eol . (volume_or_comment vol)? ]

lvmoption

let lvmoption =

raidoption

let raidoption =

option

let option =

disk_config

let disk_config = let excludes = "lvm" | "raid" | "end" | /disk[0-9]+/ | "cryptsetup" | "tmpfs" in let other_label = Rx.fspath - excludes in disk_config_entry "lvm" lvmoption volume_lvm | disk_config_entry "raid" raidoption volume_raid | disk_config_entry "tmpfs" option volume_tmpfs | disk_config_entry "end" option volume (* there shouldn't be an option here *) | disk_config_entry /disk[0-9]+/ option volume | disk_config_entry "cryptsetup" cryptoption volume_cryptsetup | disk_config_entry other_label option volume

lns

let lns = (disk_config|comment|empty)*

The disk_config lens

Provides unit tests and examples for the FAI_DiskConfig lens.
let eol = Util.eol
let space = Sep.space
let empty = Util.empty
let comment = Util.comment
let tag (re:regexp) = [ Util.del_str ":" . key re ]
A generic tag beginning with a colon
let generic_opt (type:string) (kw:regexp) = [ key type . Util.del_str ":" . store kw ]
A generic key/value option
let generic_opt_list (type:string) (kw:regexp) = [ key type . Util.del_str ":" . counter "locallist" . Build.opt_list [seq "locallist" . store kw] Sep.comma ]
A generic key/list option
let mountpoint_kw = "-" (* do not mount *) | "swap" (* swap space *)
let encrypt = tag "encrypt"
encrypt tag
let resize = tag "resize"
resize tag
let size_kw = /[0-9]+[kMGTP%]?(-([0-9]+[kMGTP%]?)?)?/ | /-[0-9]+[kMGTP%]?/
Regexps for size
let size = [ label "size" . store size_kw . resize? ]
let filesystem_kw = "-" | "swap"
Regexps for filesystem
let filesystem = [ label "filesystem" . store filesystem_kw ]
let mount_option_value = [ label "value" . Util.del_str "=" . store /[^,= \t\n]+/ ]
let mount_option = [ seq "mount_option" . store /[^,= \t\n]+/ . mount_option_value? ]
Counting options
let mount_options = [ label "mount_options" . counter "mount_option" . Build.opt_list mount_option Sep.comma ]
An array of mount_options
let fs_option = [ key /createopts|tuneopts/ . Util.del_str "=\"" . store /[^"\n]*/ . Util.del_str "\"" ]
let fs_options =
An array of fs_options
let volume_full (type:lens) (third_field:lens) =
let name = [ label "name" . store /[^\/ \t\n]+/ ]
LVM volume group name
let partition = [ label "partition" . Util.del_str "." . store /[0-9]+/ ]
An optional partition number for disk
let disk = [ label "disk" . store /[^., \t\n]+/ . partition? ]
let vg_option = [ key "pvcreateopts" . Util.del_str "=\"" . store /[^"\n]*/ . Util.del_str "\"" ]
An option for volume_vg
let volume_vg = [ key "vg" . space . name . space . disk . (space . vg_option)? . eol ]
let spare_missing = tag /spare|missing/
let disk_with_opt = [ label "disk" . store /[^:., \t\n]+/ . partition? . spare_missing* ]
A disk with a spare/missing option for raids
let disk_list = Build.opt_list disk_with_opt Sep.comma
A list of disk_with_opts
let type_label_lv = label "lv" . [ label "vg" . store (/[^# \t\n-]+/ - "raw") ] . Util.del_str "-" . [ label "name" . store /[^ \t\n]+/ ]
let volume_tmpfs = [ key "tmpfs" . space . mountpoint .space . size . space . mount_options . (space . fs_options)? . eol ]
let volume_lvm = volume_full type_label_lv size (* lvm logical volume: vg name and lv name *) | volume_vg
let volume_raid = volume_full (key /raid[0156]/) disk_list (* raid level *)
let device = [ label "device" . store Rx.fspath ]
let volume_cryptsetup = volume_full (key ("swap"|"tmp"|"luks")) device
let volume = volume_full (key "primary") size (* for physical disks only *) | volume_full (key "logical") size (* for physical disks only *) | volume_full (key "raw-disk") size
let volume_or_comment (vol:lens) = (vol|empty|comment)* . vol
A succesion of volumes and comments
let disk_config_entry (kw:regexp) (opt:lens) (vol:lens) = [ key "disk_config" . space . store kw . (space . opt)* . eol . (volume_or_comment vol)? ]
let lvmoption =
let raidoption =
let option =
let disk_config = let excludes = "lvm" | "raid" | "end" | /disk[0-9]+/ | "cryptsetup" | "tmpfs" in let other_label = Rx.fspath - excludes in disk_config_entry "lvm" lvmoption volume_lvm | disk_config_entry "raid" raidoption volume_raid | disk_config_entry "tmpfs" option volume_tmpfs | disk_config_entry "end" option volume (* there shouldn't be an option here *) | disk_config_entry /disk[0-9]+/ option volume | disk_config_entry "cryptsetup" cryptoption volume_cryptsetup | disk_config_entry other_label option volume
let lns = (disk_config|comment|empty)*
The disk_config lens
Close