diff --git a/conf/type/__qemu_img/explorer/exists b/conf/type/__qemu_img/explorer/exists new file mode 100755 index 00000000..c80b1181 --- /dev/null +++ b/conf/type/__qemu_img/explorer/exists @@ -0,0 +1,28 @@ +#!/bin/sh +# +# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Check whether file exists or not +# + +destination="/$__object_id" + +if [ -e "$destination" ]; then + echo yes +fi diff --git a/conf/type/__qemu_img/gencode-remote b/conf/type/__qemu_img/gencode-remote new file mode 100644 index 00000000..acadcef0 --- /dev/null +++ b/conf/type/__qemu_img/gencode-remote @@ -0,0 +1,20 @@ +################################################################################ +# State: absent is handled by manifest - we need only to do stuff if image is +# not existing and state != absent +# +[ -f "$__object/parameter/state" ] && state="$(cat "$__object/parameter/state")" +[ "$state" = "absent" ] && exit 0 + +exists="$(cat "$__object/explorer/exists")" +[ "$exists" ] && exit 0 + +################################################################################ +# Still there? Create image +# + +format=qcow2 +[ -f "$__object/parameter/format" ] && format="$(cat "$__object/parameter/format")" +size="$(cat "$__object/parameter/size")" +vm="/$__object_id" + +echo qemu-img create -f \"$format\" \"$vm\" \"$size\" diff --git a/conf/type/__qemu_img/man.text b/conf/type/__qemu_img/man.text new file mode 100644 index 00000000..e2442172 --- /dev/null +++ b/conf/type/__qemu_img/man.text @@ -0,0 +1,51 @@ +cdist-type__qemu_img(7) +======================== +Nico Schottelius + + +NAME +---- +cdist-type__qemu_img - Manage VM disk images + + +DESCRIPTION +----------- +The qemu-img program is used to create qemu images for +qemu and (qemu-)kvm. + + +REQUIRED PARAMETERS +------------------- +size:: + Size of the image in qemu-img compatible units. + See qemu-img(1). + + +OPTIONAL PARAMETERS +------------------- +state:: + The state of the image file: either "present" or "absent". + Defaults to "present". + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh in installed +__qemu_img /home/services/kvm/vm/myvmname/system-disk --size 50G + +# Remove image +__qemu_img /home/services/kvm/vm/myoldvm/system-disk --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__qemu_img/manifest b/conf/type/__qemu_img/manifest new file mode 100644 index 00000000..d343e188 --- /dev/null +++ b/conf/type/__qemu_img/manifest @@ -0,0 +1,14 @@ +################################################################################ +# Default settings +# + +format=qcow2 +[ -f "$__object/parameter/format" ] && format="$(cat "$__object/parameter/format")" +[ -f "$__object/parameter/state" ] && state="$(cat "$__object/parameter/state")" + +vm="/$__object_id" + +# Absent is ensured by __file, present by gencode-remote +if [ "$state" = "absent" ]; then + __file "$vm" --state absent +fi diff --git a/conf/type/__qemu_img/parameter/optional b/conf/type/__qemu_img/parameter/optional new file mode 100644 index 00000000..0e8469e7 --- /dev/null +++ b/conf/type/__qemu_img/parameter/optional @@ -0,0 +1 @@ +format diff --git a/conf/type/__qemu_img/parameter/required b/conf/type/__qemu_img/parameter/required new file mode 100644 index 00000000..2a613ba5 --- /dev/null +++ b/conf/type/__qemu_img/parameter/required @@ -0,0 +1 @@ +size diff --git a/doc/changelog b/doc/changelog index af693bba..76019235 100644 --- a/doc/changelog +++ b/doc/changelog @@ -6,6 +6,7 @@ Changelog 2.0.15: * Core: Make variable __object_name available in type explorers (Steven Armtrong) + * New Type: __qemu_img 2.0.14: 2012-09-07 * Bugfix Type: __jail: Use correct variable (Jake Guffey)