mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
LXC_SNAPSHOT_EXISTS to ynh_lxc_snapshot_exists
This commit is contained in:
parent
9f5cf5bdb6
commit
efb7367e2e
3 changed files with 11 additions and 11 deletions
|
@ -126,7 +126,7 @@ _LOAD_SNAPSHOT_OR_INSTALL_APP () {
|
|||
local _install_type="$(path_to_install_type $check_path)"
|
||||
local snapname="snap_${_install_type}install"
|
||||
|
||||
if ! LXC_SNAPSHOT_EXISTS $snapname
|
||||
if ! ynh_lxc_snapshot_exists $snapname
|
||||
then
|
||||
log_warning "Expected to find an existing snapshot $snapname but it doesn't exist yet .. will attempt to create it"
|
||||
LOAD_LXC_SNAPSHOT snap0 \
|
||||
|
@ -370,7 +370,7 @@ TEST_INSTALL () {
|
|||
|
||||
# Create the snapshot that'll be used by other tests later
|
||||
[ "$install_type" != "private" ] \
|
||||
&& ! LXC_SNAPSHOT_EXISTS $snapname \
|
||||
&& ! ynh_lxc_snapshot_exists $snapname \
|
||||
&& log_debug "Create a snapshot after app install" \
|
||||
&& ynh_lxc_pc_snapshot_create $snapname
|
||||
|
||||
|
|
|
@ -4,3 +4,11 @@
|
|||
# LXD HELPERS
|
||||
#=================================================
|
||||
|
||||
ynh_lxc_snapshot_exists () {
|
||||
local snapname=$1
|
||||
lxc list --format json \
|
||||
| jq -e --arg LXC_NAME $LXC_NAME --arg snapname $snapname \
|
||||
'.[] | select(.name==$LXC_NAME) | .snapshots[] | select(.name==$snapname)' \
|
||||
>/dev/null
|
||||
}
|
||||
|
||||
|
|
|
@ -148,14 +148,6 @@ ynh_lxc_pc_create () {
|
|||
lxc snapshot $LXC_NAME snap0
|
||||
}
|
||||
|
||||
LXC_SNAPSHOT_EXISTS() {
|
||||
local snapname=$1
|
||||
lxc list --format json \
|
||||
| jq -e --arg LXC_NAME $LXC_NAME --arg snapname $snapname \
|
||||
'.[] | select(.name==$LXC_NAME) | .snapshots[] | select(.name==$snapname)' \
|
||||
>/dev/null
|
||||
}
|
||||
|
||||
ynh_lxc_pc_snapshot_create () {
|
||||
# Create a temporary snapshot
|
||||
|
||||
|
@ -172,7 +164,7 @@ ynh_lxc_pc_snapshot_create () {
|
|||
LXC_STOP $LXC_NAME
|
||||
|
||||
# Check if the snapshot already exist
|
||||
if ! LXC_SNAPSHOT_EXISTS "$snapname"
|
||||
if ! ynh_lxc_snapshot_exists "$snapname"
|
||||
then
|
||||
log_info "(Creating snapshot $snapname ...)"
|
||||
lxc snapshot $LXC_NAME $snapname
|
||||
|
|
Loading…
Add table
Reference in a new issue