From 0be259f2a9159ba54ec1f40031ef1c2097b4d4df Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Fri, 16 May 2025 13:56:39 +0200 Subject: [PATCH] move volumes Signed-off-by: GnomeZworc --- agent.sh | 19 +------------------ lib/prime/volumes.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 lib/prime/volumes.sh diff --git a/agent.sh b/agent.sh index f59e09a..c0bbeb7 100644 --- a/agent.sh +++ b/agent.sh @@ -12,6 +12,7 @@ . ./lib/colors.sh . ./lib/qemu.sh . ./lib/metadata.sh +. ./lib/prime/volumes.sh DRY_RUN="1" SIMULATION="1" @@ -75,31 +76,13 @@ function stop_vm { } -function create_volume { - DEFINE_string 'volume_name' '-' 'Volume Name' 'v' - DEFINE_string 'backind_volume' '-' 'Volume Back' 'b' - DEFINE_string 'volume_size' '-' 'Volume Size' 's' - DEFINE_boolean 'dryrun' false 'Enable dry-run mode' 'd' - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - qemu-img create \ - -f qcow2 -b "${FLAGS_backind_volume}" \ - -F qcow2 "${FLAGS_volume_name}" \ - "${FLAGS_volume_size}" -} - -function delete_volume { - DEFINE_string 'volume_name' '-' 'Volume Name' 'v' - DEFINE_boolean 'dryrun' false 'Enable dry-run mode' 'd' FLAGS "$@" || exit $? eval set -- "${FLAGS_ARGV}" rm -rf "${FLAGS_backind_volume}" -} function main { fonction="${1}" diff --git a/lib/prime/volumes.sh b/lib/prime/volumes.sh new file mode 100644 index 0000000..031d8fe --- /dev/null +++ b/lib/prime/volumes.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +function create_volume { + [[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)" + + DEFINE_string 'volume_name' '-' 'Volume Name' 'v' + DEFINE_string 'backind_volume' '-' 'Volume Back' 'b' + DEFINE_string 'volume_size' '-' 'Volume Size' 's' + DEFINE_boolean 'dryrun' false 'Enable dry-run mode' 'd' + + FLAGS "$@" || exit $? + eval set -- "${FLAGS_ARGV}" + + qemu-img create \ + -f qcow2 -b "${FLAGS_backind_volume}" \ + -F qcow2 "${FLAGS_volume_name}" \ + "${FLAGS_volume_size}" +} + +function delete_volume { + [[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)" + + DEFINE_string 'volume_name' '-' 'Volume Name' 'v' + DEFINE_boolean 'dryrun' false 'Enable dry-run mode' 'd' + + FLAGS "$@" || exit $? + eval set -- "${FLAGS_ARGV}" + + rm -rf "${FLAGS_backind_volume}" + +} \ No newline at end of file