Skip to content

Commit

Permalink
revert --output-version v0 due v1 is not stable
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps committed May 24, 2019
1 parent 58ad549 commit 238dfe1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions datastore/linstor_un/linstor_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#------------------------------------------------------------------------------ #

#--------------------------------------------------------------------------------
# Parse the output of linstor -m --output-version v1 storagepools list in json
# Parse the output of linstor -m --output-version v0 storagepools list in json
# format and generates a monitor string for linstor pool.
# You **MUST** define JQ util before using this function
# @param $1 the json output of the command
Expand All @@ -27,16 +27,16 @@ linstor_monitor_storpool() {
}

#--------------------------------------------------------------------------------
# Parse the output of linstor -m --output-version v1 resource-definition list in
# Parse the output of linstor -m --output-version v0 resource-definition list in
# json format and generates a monitor strings for every VM.
# You **MUST** define JQ util before using this function
# @param $1 the json output of the command
# @param $2 the ID of system datastore (to monitor)
#--------------------------------------------------------------------------------
linstor_monitor_resources() {
local DS_ID=$2
local RES_SIZES_DATA=$($LINSTOR -m --output-version v1 resource list-volumes | \
$JQ '.[].resources[]? | {res: .name, size: .vlms[0].allocated_size}' )
local RES_SIZES_DATA=$($LINSTOR -m --output-version v0 resource list-volumes | \
$JQ '.[].resources[]? | {res: .name, size: .vlms[0].allocated}' )
RES_SIZES_STATUS=$?
if [ $RES_SIZES_STATUS -ne 0 ]; then
echo "$RES_SIZES_DATA"
Expand Down Expand Up @@ -89,7 +89,7 @@ linstor_monitor_resources() {
# @return volume size in kilobytes
#--------------------------------------------------------------------------------
linstor_vd_size() {
$LINSTOR -m --output-version v1 volume-definition list | \
$LINSTOR -m --output-version v0 volume-definition list | \
$JQ -r ".[].rsc_dfns[]? |
select(.rsc_name==\"${1}\").vlm_dfns[] | select(.vlm_nr==0).vlm_size"
}
Expand Down Expand Up @@ -148,7 +148,7 @@ linstor_load_keys() {
#-------------------------------------------------------------------------------
function linstor_get_hosts_for_res {
local RES="$1"
$LINSTOR -m --output-version v1 resource list -r $RES | \
$LINSTOR -m --output-version v0 resource list -r $RES | \
$JQ -r '.[].resources[]?.node_name' | \
xargs
}
Expand All @@ -160,7 +160,7 @@ function linstor_get_hosts_for_res {
#-------------------------------------------------------------------------------
function linstor_get_diskless_hosts_for_res {
local RES="$1"
$LINSTOR -m --output-version v1 resource list -r $RES | \
$LINSTOR -m --output-version v0 resource list -r $RES | \
$JQ -r '.[].resources[]? | select(.rsc_flags[]? |
contains("DISKLESS")) | .node_name' | \
xargs
Expand All @@ -179,7 +179,7 @@ function linstor_get_snaps_for_res {
*) local SORT_FLAGS=n ;;
esac

$LINSTOR -m --output-version v1 snapshot list | \
$LINSTOR -m --output-version v0 snapshot list | \
$JQ -r ".[].snapshot_dfns[]? | \
select(.rsc_name==\"${RES}\") | .snapshot_name" | \
$AWK -F- '$1 == "snapshot" && $2 ~ /^[0-9]+$/ {print $2}' | \
Expand Down Expand Up @@ -242,7 +242,7 @@ function linstor_get_res_for_property {
local PROPERTY="$1"
local VALUE="$2"

local RD_DATA="$($LINSTOR -m --output-version v1 resource-definition list)"
local RD_DATA="$($LINSTOR -m --output-version v0 resource-definition list)"
if [ $? -ne 0 ]; then
echo "Error getting resource-definition list"
exit -1
Expand All @@ -263,7 +263,7 @@ function linstor_get_res_for_property {
# @param $2 - error message (optional)
#-------------------------------------------------------------------------------
function linstor_exec_and_log_no_error {
EXEC_LOG=`exec $LINSTOR -m --output-version v1 $1 2>&1`
EXEC_LOG=`exec $LINSTOR -m --output-version v0 $1 2>&1`
EXEC_LOG_RC=$?

EXEC_LOG_ERR=$(echo "$EXEC_LOG" | \
Expand Down
2 changes: 1 addition & 1 deletion datastore/linstor_un/monitor
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ linstor_load_keys
# ------------ Compute datastore usage -------------

MONITOR_SCRIPT=$(cat <<EOF
$LINSTOR -m --output-version v1 storage-pool list --storpools "$STORAGE_POOL"
$LINSTOR -m --output-version v0 storage-pool list --storpools "$STORAGE_POOL"
EOF
)

Expand Down
4 changes: 2 additions & 2 deletions tm/linstor_un/delete
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if [ `is_disk $DST_PATH` -eq 0 ]; then
CHECKPOINT_RES="one-vm-${VM_ID}-checkpoint"

# Check if vm have checkpoint resource
$LINSTOR -m --output-version v1 resource-definition list | \
$LINSTOR -m --output-version v0 resource-definition list | \
$JQ -er ".[].rsc_dfns[]? | select(.rsc_name==\"$CHECKPOINT_RES\")" >/dev/null

# Remove checkpoint resource
Expand Down Expand Up @@ -140,7 +140,7 @@ ssh_exec_and_log "$DST_HOST" "rm -f $DST_PATH" \
"Error unlinking $DST_PATH"

# Check if source image have snapshot (CLONE_MODE=snapshot)
$LINSTOR -m --output-version v1 snapshot list | \
$LINSTOR -m --output-version v0 snapshot list | \
$JQ -er ".[].snapshot_dfns[]? |
select(.rsc_name==\"${SRC_RES}\" and .snapshot_name==\"${DST_RES}\")" >/dev/null

Expand Down
4 changes: 2 additions & 2 deletions tm/linstor_un/monitor
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ linstor_load_keys
# ------------ Compute datastore usage -------------

MONITOR_SCRIPT=$(cat <<EOF
$LINSTOR -m --output-version v1 storage-pool list --storpools "$STORAGE_POOL"
$LINSTOR -m --output-version v0 storage-pool list --storpools "$STORAGE_POOL"
EOF
)

Expand All @@ -81,7 +81,7 @@ fi
# ------------ Compute VM disks usage -------------

MONITOR_SCRIPT=$(cat <<EOF
$LINSTOR -m --output-version v1 resource-definition list
$LINSTOR -m --output-version v0 resource-definition list
EOF
)

Expand Down
2 changes: 1 addition & 1 deletion tm/linstor_un/snap_create
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ linstor_exec_and_log \
"snapshot create $SRC_RES $SNAPSHOT"

# Add snapshot to monitoring
DISK_SIZE=$($LINSTOR -m --output-version v1 resource list-volumes -r "$SRC_RES" | $JQ -r '.[].resources[] | .vlms[0].allocated_size' | sort -n | tail -n1)
DISK_SIZE=$($LINSTOR -m --output-version v0 resource list-volumes -r "$SRC_RES" | $JQ -r '.[].resources[] | .vlms[0].allocated' | sort -n | tail -n1)
linstor_exec_and_log_no_error \
"resource-definition set-property $SRC_RES Aux/one/SNAPSHOT_${SNAP_ID}/DISK_SIZE $DISK_SIZE"

Expand Down
2 changes: 1 addition & 1 deletion tm/linstor_un/snap_create_live
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ linstor_exec_and_log \
"snapshot create $SRC_RES $SNAPSHOT"

# Add snapshot to monitoring
DISK_SIZE=$($LINSTOR -m --output-version v1 resource list-volumes -r "$SRC_RES" | $JQ -r '.[].resources[] | .vlms[0].allocated_size' | sort -n | tail -n1)
DISK_SIZE=$($LINSTOR -m --output-version v0 resource list-volumes -r "$SRC_RES" | $JQ -r '.[].resources[] | .vlms[0].allocated' | sort -n | tail -n1)
linstor_exec_and_log_no_error \
"resource-definition set-property $SRC_RES Aux/one/SNAPSHOT_${SNAP_ID}/DISK_SIZE $DISK_SIZE"

Expand Down

0 comments on commit 238dfe1

Please sign in to comment.