nova_virtlogd_wrapper: Simplify string matching

Currently the nova_virtlogd_wrapper script has some lower/upper case
patterns to match strings to identify container status, but this
requires redundant but careful definitions.

This change "lowercase"s status string so that we can define status
more simply.

Change-Id: Ia3f9679b7a43d3ab7315b5d87b31c87ba9c14109
This commit is contained in:
Takashi Kajinami 2021-07-22 23:31:44 +09:00
parent 4c3b1ef276
commit 35dbf4e6c2
1 changed files with 3 additions and 3 deletions

View File

@ -12,13 +12,13 @@ VIRTLOGD_CONTAINER=$(${CLI} ps -a --filter name="^${NAME}$" --format '{{.ID}}:{{
CONTAINER_ID=$(echo $VIRTLOGD_CONTAINER | awk -F: '{print $1}')
CONTAINER_STATUS=$(echo $VIRTLOGD_CONTAINER | awk -F: '{print $2}')
CONTAINER_STATUS_SHORT=$(echo $CONTAINER_STATUS | awk '{print $1}')
CONTAINER_STATUS_SHORT=$(echo $CONTAINER_STATUS | awk '{print $1}' | tr '[A-Z]' '[a-z]' )
case ${CONTAINER_STATUS_SHORT} in
Up | up | UP)
up)
echo "Container ${NAME} with id ${CONTAINER_ID} is already running!"
;;
Exited| exited| EXITED| Created| created| CREATED)
exited| created)
echo "Removing orphaned ${NAME} container ${CONTAINER_ID}"
$CLI stop ${CONTAINER_ID} || true
$CLI rm -f ${CONTAINER_ID} || true