mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
LXC_RESET to ynh_lxc_reset
This commit is contained in:
parent
01a6a7572f
commit
b134ed4f86
4 changed files with 19 additions and 19 deletions
|
@ -254,7 +254,7 @@ run_all_tests() {
|
||||||
|
|
||||||
# Reset and create a fresh container to work with
|
# Reset and create a fresh container to work with
|
||||||
check_lxd_setup
|
check_lxd_setup
|
||||||
LXC_RESET
|
ynh_lxc_reset
|
||||||
ynh_lxc_pc_create
|
ynh_lxc_pc_create
|
||||||
# Be sure that the container is running
|
# Be sure that the container is running
|
||||||
ynh_lxc_pc_exec "true"
|
ynh_lxc_pc_exec "true"
|
||||||
|
|
17
lib/ynh_lxd
17
lib/ynh_lxd
|
@ -39,3 +39,20 @@ ynh_lxc_snapshot_load () {
|
||||||
_LXC_START_AND_WAIT $LXC_NAME
|
_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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,23 +175,6 @@ ynh_lxc_pc_snapshot_create () {
|
||||||
stop_timer 1
|
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() {
|
_LXC_START_AND_WAIT() {
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ parse_args
|
||||||
function cleanup()
|
function cleanup()
|
||||||
{
|
{
|
||||||
trap '' SIGINT # Disable ctrl+c in this function
|
trap '' SIGINT # Disable ctrl+c in this function
|
||||||
LXC_RESET
|
ynh_lxc_reset
|
||||||
|
|
||||||
[ -n "$TEST_CONTEXT" ] && rm -rf "$TEST_CONTEXT"
|
[ -n "$TEST_CONTEXT" ] && rm -rf "$TEST_CONTEXT"
|
||||||
[ -n "$lock_file" ] && rm -f "$lock_file"
|
[ -n "$lock_file" ] && rm -f "$lock_file"
|
||||||
|
|
Loading…
Add table
Reference in a new issue