Skip to content

Commit

Permalink
Reduced code - solves issue #4 and #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Cernin committed Jun 19, 2017
1 parent 6322b10 commit 0d7072d
Show file tree
Hide file tree
Showing 32 changed files with 115 additions and 700 deletions.
87 changes: 28 additions & 59 deletions citellus
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ PYTHON="/usr/bin/python"
TMPFILE="$(mktemp /tmp/cittelus-script.XXXXXX)"
# Check if we are running openstack plugin if empty by default to openstack
get_version

PLUGIN="$(echo ${PLUGIN} | tr ',' ' ')"
if [ -n "${PLUGIN}" ]
then
Expand All @@ -152,67 +153,35 @@ then
if [[ "${FOUND}" -eq "1" ]]
then
if [ "${plugin}" = "openstack" ]
then
discover_node
print_version
then
discover_node
print_version
fi
# Go thru the all existing .conf files inside DISCOVERED_NODE.d directory/.
for FILE in ./plugins/"${plugin}"/generic/all/* ./plugins/"${plugin}"/generic/"${DISCOVERED_NODE}"/* ./plugins/"${plugin}"/"${VERSION}"/generic/* ./plugins/"${plugin}"/"${VERSION}"/"${DISCOVERED_NODE}"/*
for FILE in ./plugins/"${plugin}"/*
do
[ -f "$FILE" ] || continue
EXTENSION=${FILE##*.}
case ${EXTENSION} in
sh)
source "${FILE}" > "${TMPFILE}"

PASS=$(grep ".*\[OK\]" "${TMPFILE}" | wc -l)
FAIL=$(grep ".*\[WRONG\]" "${TMPFILE}" | wc -l)
WARNING=$(grep ".*\[WARN\]" "${TMPFILE}" | wc -l)

if [[ "${FAIL}" -eq "0" ]] && [[ "${WARNING}" -eq "0" ]]
then
RESULT=$(
tput setaf 2
printf "%s" "PASSED "
tput sgr0
)
elif [[ "${FAIL}" -eq "0" ]] && [[ ! "${WARNING}" -eq "0" ]]
then
RESULT=$(
tput setaf 3
printf "%s" "WARNING"
tput sgr0
)
else
RESULT=$(
tput setaf 1
printf "%s" "FAILED "
tput sgr0
)
fi

if [[ ${RESULT} =~ "PASS" ]] && [[ ${verbose_good} -eq "0" ]]
then
continue
else
printf -v line "+%*s+" "77"
echo ${line// /-}
printf "| %-75s %s\n" "${REFNAME}" "|"
printf -v line "+%*s+ %-30s |" "44"
echo ${line// /-}
printf "| PASS: %-9s FAILED: %-6s WARNING: %-2s %-16s Result: %s %s\n" \
"${PASS}" "${FAIL}" "${WARNING}" "|" "${RESULT}" "|"
printf -v line "+%*s+" "77"
echo ${line// /-}

$(which cat) "${TMPFILE}"
$(which rm) -f "${TMPFILE}"
fi
;;

py) ${PYTHON} ${FILE} ${DIRECTORY} ;;
*) echo "File: ${FILE}. Usupported format." ;;
esac
[ -f "${FILE}" ] || continue
EXTENSION=${FILE##*.}
if [ "${plugin}" = "openstack" ]
then
if grep -q "^REFOSP_VERSION=.*${VERSION}.*$" "${FILE}" && grep -q "^REFNODE_TYPE=.*${DISCOVERED_NODE}.*$" "${FILE}"
then
case ${EXTENSION} in
sh)
run_sh
;;
py) ${PYTHON} ${FILE} ${DIRECTORY} ;;
*) echo "File: ${FILE}. Usupported format." ;;
esac
fi
else
case ${EXTENSION} in
sh)
run_sh
;;
py) ${PYTHON} ${FILE} ${DIRECTORY} ;;
*) echo "File: ${FILE}. Usupported format." ;;
esac
fi
done
fi
done
Expand Down
53 changes: 53 additions & 0 deletions load_functions
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,64 @@ get_version(){
}

print_version(){

echo "Discovered node: ${DISCOVERED_NODE}"
echo "Version: ${VERSION}"
if [ -n "${PACKSTACK}" ]
then echo "Type: POC-type environment installed with Packstack"
fi

}

run_sh(){

source "${FILE}" > "${TMPFILE}"

PASS=$(grep ".*\[OK\]" "${TMPFILE}" | wc -l)
FAIL=$(grep ".*\[WRONG\]" "${TMPFILE}" | wc -l)
WARNING=$(grep ".*\[WARN\]" "${TMPFILE}" | wc -l)

if [[ "${FAIL}" -eq "0" ]] && [[ "${WARNING}" -eq "0" ]]
then
RESULT=$(
tput setaf 2
printf "%s" "PASSED "
tput sgr0
)
elif [[ "${FAIL}" -eq "0" ]] && [[ ! "${WARNING}" -eq "0" ]]
then
RESULT=$(
tput setaf 3
printf "%s" "WARNING"
tput sgr0
)
else
RESULT=$(
tput setaf 1
printf "%s" "FAILED "
tput sgr0
)
fi

if [[ ${RESULT} =~ "PASS" ]] && [[ ${verbose_good} -eq "0" ]]
then
continue
else
printf -v line "+%*s+" "77"
echo ${line// /-}
printf "| %-75s %s\n" "${REFNAME}" "|"
printf -v line "+%*s+ %-30s |" "44"
echo ${line// /-}
printf "| PASS: %-9s FAILED: %-6s WARNING: %-2s %-16s Result: %s %s\n" \
"${PASS}" "${FAIL}" "${WARNING}" "|" "${RESULT}" "|"
printf -v line "+%*s+" "77"
echo ${line// /-}

$(which cat) "${TMPFILE}"
$(which rm) -f "${TMPFILE}"
fi


}

good(){
Expand Down
24 changes: 0 additions & 24 deletions plugins/openstack/generic/controller/cronjob.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking Hardware Requirements
# Ref: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_openstack_platform/7/html/director_installation_and_usage/sect-overcloud_requirements#sect-Controller_Node_Requirements
REFNAME="Checking Hardware Requirements"
REFOSP_VERSION="kilo"
REFNODE_TYPE="controller"

# A minimum of 6 GB of RAM.
if [ -e "${DIRECTORY}/proc/meminfo" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking Hardware Requirements
# Ref: https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/10/html/director_installation_and_usage/chap-requirements#sect-Compute_Node_Requirements
REFNAME="Checking Hardware Requirements"
REFOSP_VERSION="kilo liberty mitaka newton ocata"
REFNODE_TYPE="compute"

# A minimum of 6 GB of RAM.
if [ -e "${DIRECTORY}/proc/meminfo" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# Ref: https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/8/html-single/director_installation_and_usage/#sect-Controller_Node_Requirements
# Red Hat Enterprise Linux 7.2 or later installed as the host operating system.
REFNAME="Checking Hardware Requirements"
REFOSP_VERSION="liberty"
REFNODE_TYPE="controller"

# A minimum of 32 GB of RAM.
if [ -e "${DIRECTORY}/proc/meminfo" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

# Red Hat Enterprise Linux 7.2 or later installed as the host operating system.
REFNAME="Checking Hardware Requirements"
REFOSP_VERSION="liberty mitaka"
REFNODE_TYPE="director"

# A minimum of 16 GB of RAM.
if [ -e "${DIRECTORY}/proc/meminfo" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking Tracebacks
# Ref: None
REFNAME="Kernel Module"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="controller director compute"

# Looks for the Kernel Out of Memory, panics and soft locks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking Tracebacks
# Ref: None
REFNAME="SELinux Module"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="controller director compute"

# SELinux is enabled on the host.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking Tracebacks
# Ref: None
REFNAME="Traceback Module"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="controller director compute"

# Tracebacks everywhere

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking cronjob
# Ref: https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/8/html-single/director_installation_and_usage/#sect-Tuning_the_Undercloud
REFNAME="Checking cronjob"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="director controller"

# Crontab check
grep_file "${DIRECTORY}/var/spool/cron/keystone" "keystone-manage token_flush"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Cluster check
# Ref:
REFNAME="Checking HA Cluster"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="controller"

# Checking the number of nodes in the cluster.
# Check which directory for cluster exists it's either cluster or pacemaker
Expand Down Expand Up @@ -54,8 +56,8 @@ else
fi

# Check packages version
VERSION=$(sed -n -r -e 's/^pacemaker.*-1.1.([0-9]+)-.*$/\1/p' "${DIRECTORY}/installed-rpms")
for package in ${VERSION}
PCS_VERSION=$(sed -n -r -e 's/^pacemaker.*-1.1.([0-9]+)-.*$/\1/p' "${DIRECTORY}/installed-rpms")
for package in ${PCS_VERSION}
do
if [[ "${package}" -lt "15" ]]
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking ERRORS
# Ref: None
REFNAME="My Custom Module"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="controller"


# https://bugs.launchpad.net/keystone/+bug/1649616/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# Checking httpd
# Ref: None
REFNAME="httpd Module"


REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="controller"

count_lines "${DIRECTORY}/var/log/httpd/error_log" "MaxRequestWorkers" \
" \_ Check /etc/httpd/prefork.conf values MaxClients and ServerLimit are set to value 512 - Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1163516"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# RabbitMQ Module
# Ref:
REFNAME="Checking RabbitMQ"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="controller"

# RabbitMQ

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# Checking ERRORS
# Ref: None
REFNAME="My Custom Module"

REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="director"

# Check for iptables -t nat -j REDIRECT rule for metadata server exists.
# Happens that when deployment is stuck without any FAILURE might be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Checking Tuned Undercloud options
# Ref: https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/8/html-single/director_installation_and_usage/#sect-Tuning_the_Undercloud
REFNAME="Checking Tuning options"
REFOSP_VERSION="liberty mitaka newton ocata"
REFNODE_TYPE="director"

# Checking /etc/heat/heat.conf

Expand Down
Loading

0 comments on commit 0d7072d

Please sign in to comment.