From 5b7fd4986b5fcde42443b38d39d66d2f46f7363e Mon Sep 17 00:00:00 2001 From: Bastian Date: Thu, 23 Mar 2023 16:07:18 +0100 Subject: [PATCH] Add preflight check: pool_exists --- crossover | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crossover b/crossover index f721155..e681187 100755 --- a/crossover +++ b/crossover @@ -433,6 +433,11 @@ function mirror() { map_vmids_to_host map_vmids_to_dsthost "$opt_destination" + if [ $(check_pool_exist "$opt_pool") -eq 0 ]; then + log error "Preflight check: Destination RBD-Pool $opt_pool does not exist." + end_process 255 + fi + for vm_id in $svmids; do (( vmcount++ )) local file_config; file_config=$(get_config_file) @@ -816,6 +821,18 @@ function get_ha_status() { echo "$ha_status" } +function check_pool_exist() { + local poolname="$1" + local -i exists=255 + pool_status=$(ssh $opt_destination pvesm status|grep rbd|cut -d " " -f 1|grep $poolname) + if [ "$pool_status" == "$poolname" ]; then + exists=1 + else + exists=0 + fi + echo $exists +} + function main(){ [ $# = 0 ] && usage;