Reduce script verbosity

Currently the verbose shell builtin is used, resulting in the entire
scripts contents being output in the logs. The instance information is
also output to stdout. This is unnecessarily verbose and prone to
failure. To ensure that the instance information is correctly rendered
failures from within the instance information commands will now always
return true and be logged within the `/openstack/log/ansible-logging`
directory. Each time that the function is called a new log will be
created tagged with the datecode in seconds. This commit also removes
the verbose builtin from the scripts, removes the unused
os-ansible-aio-check script.

Partial-Bug: #1425482
Change-Id: I59952d077a1a8dda12278e57a165d4bac272ed5f
This commit is contained in:
Jesse Pretorius 2015-03-13 12:51:24 +00:00 committed by Kevin Carter
parent af64fa9f1f
commit f611600fd4
9 changed files with 42 additions and 41 deletions

View File

@ -15,7 +15,7 @@
# limitations under the License.
## Shell Opts ----------------------------------------------------------------
set -e -u -v -x
set -e -u -x
## Vars ----------------------------------------------------------------------
@ -55,6 +55,9 @@ if ! [ -d $SYMLINK_DIR ] ; then
exit_fail
fi
# Log some data about the instance and the rest of the system
log_instance_info
# Ensure that the current kernel can support vxlan
if ! modprobe vxlan; then
MINIMUM_KERNEL_VERSION=$(awk '/openstack_host_required_kernel/ {print $2}' playbooks/inventory/group_vars/all.yml)
@ -265,5 +268,7 @@ if [ "${DEPLOY_SWIFT}" == "yes" ]; then
sed -i "s/glance_swift_store_user:.*/glance_swift_store_user: '{{ keystone_admin_user_name }}:{{ keystone_admin_tenant_name }}'/" /etc/openstack_deploy/user_secrets.yml
fi
set +x +v
# Log some data about the instance and the rest of the system
log_instance_info
info_block "The system has been prepared for an all-in-one build."

View File

@ -16,7 +16,7 @@
# (c) 2014, Kevin Carter <kevin.carter@rackspace.com>
## Shell Opts ----------------------------------------------------------------
set -e -u -v -x
set -e -u -x
## Vars ----------------------------------------------------------------------

View File

@ -14,7 +14,7 @@
# limitations under the License.
## Shell Opts ----------------------------------------------------------------
set -e -u -v +x
set -e -u +x
## Variables -----------------------------------------------------------------
export ANSIBLE_DISABLE_COLOR=${ANSIBLE_DISABLE_COLOR:-"yes"}
@ -48,8 +48,6 @@ export TESTR_OPTS=${TESTR_OPTS:-''}
info_block "Checking for required libraries." 2> /dev/null || source $(dirname ${0})/scripts-library.sh
## Main ----------------------------------------------------------------------
# Get initial host information and reset verbosity
set +x && get_instance_info && set -x
# Remove color options
if [ "${ANSIBLE_DISABLE_COLOR}" == "yes" ]; then
@ -68,9 +66,6 @@ if [ "${BOOTSTRAP_ANSIBLE}" == "yes" ]; then
source $(dirname ${0})/bootstrap-ansible.sh
fi
# Get initial host information and reset verbosity
set +x && get_instance_info && set -x
# Run the ansible playbooks if required
if [ "${RUN_PLAYBOOKS}" == "yes" ]; then
# Set-up our tiny awk script.

View File

@ -14,7 +14,7 @@
# limitations under the License.
## Shell Opts ----------------------------------------------------------------
set -e -u -v -x
set -e -u -x
## Library Check -------------------------------------------------------------

View File

@ -1,9 +0,0 @@
#!/bin/bash
# This is a placeholder until we change the macro for the
# os-ansible-deployment gate check script to use the
# newly split script set.
set -e -u -v -x
source $(dirname ${0})/gate-check-commit.sh

View File

@ -15,7 +15,7 @@
## Shell Opts ----------------------------------------------------------------
set -e -u -v +x
set -e -u +x
## Variables -----------------------------------------------------------------
export REPO_URL=${REPO_URL:-"https://github.com/stackforge/os-ansible-deployment.git"}

View File

@ -14,7 +14,7 @@
# limitations under the License.
## Shell Opts ----------------------------------------------------------------
set -e -u -v -x
set -e -u -x
## Variables -----------------------------------------------------------------
@ -57,8 +57,8 @@ pushd "playbooks"
# This is good when using a host with multiple times, IE: Rebuilding.
ansible hosts -m shell -a 'lxc-system-manage flush-net-cache'
# Get host information post initial setup and reset verbosity
set +x && get_instance_info && set -x
# Log some data about the instance and the rest of the system
log_instance_info
fi
if [ "${DEPLOY_LB}" == "yes" ]; then

View File

@ -14,7 +14,7 @@
# limitations under the License.
## Shell Opts ----------------------------------------------------------------
set -e -u -v +x
set -e -u +x
## Vars ----------------------------------------------------------------------

View File

@ -204,19 +204,29 @@ function info_block(){
echo "${LINE}"
}
function log_instance_info() {
set +x
# Get host information post initial setup and reset verbosity
if [ ! -d "/openstack/log/instance-info" ];then
mkdir -p "/openstack/log/instance-info"
fi
get_instance_info &> /openstack/log/instance-info/host_info_$(date +%s).log
set -x
}
# Get instance info
function get_instance_info() {
set +x
info_block 'Available Memory'
free -mt
free -mt || true
info_block 'Available Disk Space'
df -h
df -h || true
info_block 'Mounted Devices'
mount
mount || true
info_block 'Block Devices'
lsblk
lsblk || true
info_block 'Block Devices Information'
blkid
blkid || true
info_block 'Block Device Partitions'
for i in /dev/xv* /dev/sd* /dev/vd*; do
if [ -b "$i" ];then
@ -224,27 +234,27 @@ function get_instance_info() {
fi
done
info_block 'PV Information'
pvs
pvs || true
info_block 'VG Information'
vgs
vgs || true
info_block 'LV Information'
lvs
lvs || true
info_block 'CPU Information'
which lscpu && lscpu
which lscpu && lscpu || true
info_block 'Kernel Information'
uname -a
uname -a || true
info_block 'Container Information'
which lxc-ls && lxc-ls --fancy
which lxc-ls && lxc-ls --fancy || true
info_block 'Firewall Information'
iptables -vnL
iptables -t nat -vnL
iptables -t mangle -vnL
iptables -vnL || true
iptables -t nat -vnL || true
iptables -t mangle -vnL || true
info_block 'Network Devices'
ip a
ip a || true
info_block 'Network Routes'
ip r
ip r || true
info_block 'Trace Path from google'
tracepath 8.8.8.8 -m 5
tracepath 8.8.8.8 -m 5 || true
info_block 'XEN Server Information'
if (which xenstore-read);then
xenstore-read vm-data/provider_data/provider || echo "\nxenstore Read Failed - Skipping\n"