From f6de6d895732e7857be401ef621880fa30b40990 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 19 Sep 2012 21:29:44 +0200 Subject: [PATCH] begin type __qemu_img Signed-off-by: Nico Schottelius --- conf/type/__qemu_img/explorer/exists | 28 +++++++++++++++++++++++++ conf/type/__qemu_img/gencode-remote | 20 ++++++++++++++++++ conf/type/__qemu_img/manifest | 14 +++++++++++++ conf/type/__qemu_img/parameter/optional | 1 + conf/type/__qemu_img/parameter/required | 1 + 5 files changed, 64 insertions(+) create mode 100755 conf/type/__qemu_img/explorer/exists create mode 100644 conf/type/__qemu_img/gencode-remote create mode 100644 conf/type/__qemu_img/manifest create mode 100644 conf/type/__qemu_img/parameter/optional create mode 100644 conf/type/__qemu_img/parameter/required 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/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