forked from ungleich-public/cdist
begin type __qemu_img
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
16ac158c41
commit
f6de6d8957
5 changed files with 64 additions and 0 deletions
28
conf/type/__qemu_img/explorer/exists
Executable file
28
conf/type/__qemu_img/explorer/exists
Executable file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Check whether file exists or not
|
||||||
|
#
|
||||||
|
|
||||||
|
destination="/$__object_id"
|
||||||
|
|
||||||
|
if [ -e "$destination" ]; then
|
||||||
|
echo yes
|
||||||
|
fi
|
20
conf/type/__qemu_img/gencode-remote
Normal file
20
conf/type/__qemu_img/gencode-remote
Normal file
|
@ -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\"
|
14
conf/type/__qemu_img/manifest
Normal file
14
conf/type/__qemu_img/manifest
Normal file
|
@ -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
|
1
conf/type/__qemu_img/parameter/optional
Normal file
1
conf/type/__qemu_img/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
format
|
1
conf/type/__qemu_img/parameter/required
Normal file
1
conf/type/__qemu_img/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
size
|
Loading…
Reference in a new issue