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:
parent
4c3b1ef276
commit
35dbf4e6c2
|
@ -12,13 +12,13 @@ VIRTLOGD_CONTAINER=$(${CLI} ps -a --filter name="^${NAME}$" --format '{{.ID}}:{{
|
||||||
|
|
||||||
CONTAINER_ID=$(echo $VIRTLOGD_CONTAINER | awk -F: '{print $1}')
|
CONTAINER_ID=$(echo $VIRTLOGD_CONTAINER | awk -F: '{print $1}')
|
||||||
CONTAINER_STATUS=$(echo $VIRTLOGD_CONTAINER | awk -F: '{print $2}')
|
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
|
case ${CONTAINER_STATUS_SHORT} in
|
||||||
Up | up | UP)
|
up)
|
||||||
echo "Container ${NAME} with id ${CONTAINER_ID} is already running!"
|
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}"
|
echo "Removing orphaned ${NAME} container ${CONTAINER_ID}"
|
||||||
$CLI stop ${CONTAINER_ID} || true
|
$CLI stop ${CONTAINER_ID} || true
|
||||||
$CLI rm -f ${CONTAINER_ID} || true
|
$CLI rm -f ${CONTAINER_ID} || true
|
||||||
|
|
Loading…
Reference in New Issue