LXC_RESET to ynh_lxc_reset

This commit is contained in:
yalh76 2022-10-24 00:17:19 +02:00
parent 01a6a7572f
commit b134ed4f86
4 changed files with 19 additions and 19 deletions

View file

@ -254,7 +254,7 @@ run_all_tests() {
# Reset and create a fresh container to work with
check_lxd_setup
LXC_RESET
ynh_lxc_reset
ynh_lxc_pc_create
# Be sure that the container is running
ynh_lxc_pc_exec "true"

View file

@ -39,3 +39,20 @@ ynh_lxc_snapshot_load () {
_LXC_START_AND_WAIT $LXC_NAME
}
ynh_lxc_reset () {
# If the container exists
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
# Remove swap files before deletting the continer
CLEAN_SWAPFILES
fi
ynh_lxc_stop $LXC_NAME
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null
fi
lxc delete $LXC_NAME --force 2>/dev/null
}

View file

@ -175,23 +175,6 @@ ynh_lxc_pc_snapshot_create () {
stop_timer 1
}
LXC_RESET () {
# If the container exists
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
# Remove swap files before deletting the continer
CLEAN_SWAPFILES
fi
ynh_lxc_stop $LXC_NAME
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null
fi
lxc delete $LXC_NAME --force 2>/dev/null
}
_LXC_START_AND_WAIT() {

View file

@ -124,7 +124,7 @@ parse_args
function cleanup()
{
trap '' SIGINT # Disable ctrl+c in this function
LXC_RESET
ynh_lxc_reset
[ -n "$TEST_CONTEXT" ] && rm -rf "$TEST_CONTEXT"
[ -n "$lock_file" ] && rm -f "$lock_file"