From c0416e41b233aa406507a5631018ee8c3088c9bc Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Wed, 31 Aug 2011 08:32:25 -0400 Subject: [PATCH 01/33] changed lines from 200 to 500 for logging --- src/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib.sh b/src/testlib.sh index 790b64d..10ac2d5 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -824,7 +824,7 @@ function open_bugzilla() function bugzilla_comments() { echo "Adding log file contents to bugzilla" - split ${LOGFILE} -l 200 splitValid.log + split ${LOGFILE} -l 500 splitValid.log for part in $(ls splitValid.log*);do BUG_COMMENTS=`cat $part` From d40e60d257d8931dd4b00b0cb76562b329d03ca9 Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Wed, 7 Sep 2011 10:36:41 -0400 Subject: [PATCH 02/33] asdf --- src/image_validation.sh~ | 171 ------ src/image_validation_postreboot.sh~ | 131 ----- src/testlib.sh~ | 882 ---------------------------- 3 files changed, 1184 deletions(-) delete mode 100755 src/image_validation.sh~ delete mode 100755 src/image_validation_postreboot.sh~ delete mode 100755 src/testlib.sh~ diff --git a/src/image_validation.sh~ b/src/image_validation.sh~ deleted file mode 100755 index 10b26b0..0000000 --- a/src/image_validation.sh~ +++ /dev/null @@ -1,171 +0,0 @@ -#!/bin/bash -# Copyright (c) 2010 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public License, -# version 2 (GPLv2). There is NO WARRANTY for this software, express or -# implied, including the implied warranties of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 -# along with this software; if not, see -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. -# -# Red Hat trademarks are not licensed under GPLv2. No permission is -# granted to use or replicate Red Hat trademarks that are incorporated -# in this software or its documentation. -# -# written by whayutin@redhat.com -# modified by kbidarka@redhat.com for RHEL 6 - -FAILURES=0 -MEM_HWP=0 - -function usage() -{ - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " - echo "Please use all options" - echo "" - echo " This script will run through some basic sanity tests for a Red Hat Enterprise Linux image " - echo " A valid Red Hat bugzilla username and password will be required at the end of the script " - echo " http://bugzilla.redhat.com/ " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " - echo "" - echo "Available options are:" - echo "--imageID= :: Please provide a unique id for the image" - echo "--RHEL= :: Please specify the correct FULL rhel version eg: --RHEL=5.7 or --RHEL=6.1" - echo "--full-yum-suite= :: Please input the value "yes" OR "no"" - echo "--skip-questions= :: Please input the value "yes" or "no"" - echo "--bugzilla-username :: Please specify your bugzilla username@email.com" - echo "--bugzilla-password :: Please specify your bugzilla password" - echo "--bugzilla-num :: If a bug has already been opened you can specify the number here " - echo "--memory :: Minium total memory the system *should* have available" -} - - -#cli -for i in $* - do - case $i in - --imageID=*) - IMAGEID="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --RHEL=*) - RHELV="`echo $i | sed 's/[-A-Z]*=//'`" - ;; - --full-yum-suite=*) - yum_test="`echo $i | sed 's/[-a-zA-Z]*=//'`" - if [ "$yum_test" == "yes" ] || [ "$yum_test" == "no" ]; then - : - else - usage - exit 1 - fi - ;; - --skip-questions=*) - QUESTIONS="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --bugzilla-username=*) - BUG_USERNAME="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --bugzilla-password=*) - BUG_PASSWORD="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --bugzilla-num=*) - BUG_NUM="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --memory=*) - MEM_HWP="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - *) - # unknown option - usage - exit 1 - ;; - esac -done - - -if [[ -z $IMAGEID ]] || [[ -z $RHELV ]] || [[ -z $yum_test ]] || [[ -z $BUG_USERNAME ]] || [[ -z $BUG_PASSWORD ]] || [[ -z $MEM_HWP ]]; then - usage - exit 1 -fi - - - -pushd /root/valid/src -source $PWD/testlib.sh - -echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " -echo " This script will run through some basic sanity tests for a Red Hat Enterprise Linux image " -echo " A valid Red Hat bugzilla username and password will be required at the end of the script " -echo " http://bugzilla.redhat.com/ " -echo "" -echo "***************** DETAILED RESULTS LOGGED TO validate.log ********************************" -echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " -echo "" -echo "" -test_rhel_version -echo "" -if [ $QUESTIONS == "no" ];then - userInput_CloudProvider - userInput_Filesystem - userInput_Errata_Notification - userInput_Availability -fi -echo "##### START TESTS #####" -echo "" -test_uname -test_disk_format -test_disk_size -test_swap_file -test_selinux -test_package_set -test_verify_rpms -test_gpg_keys -#test_repos #remarking this out for now.. until additional repo's land. the yum tests should be sufficient -test_yum_plugin -if [ $yum_test == "yes" ];then - test_yum_full_test -else - test_yum_general_test -fi -test_bash_history -test_system_id -test_cloud-firstboot -test_nameserver -test_group -test_passwd -test_inittab -test_shells -#test_IPv6 no longer needed -test_networking -test_iptables -test_sshd -test_chkconfig -test_syslog -test_auditd -test_sshSettings -test_libc6-xen.conf -test_grub -#installTestKernel -resize2fs - - -### DONT REMOVE OR COMMENT OUT ### -show_failures -open_bugzilla -bugzilla_comments -setup_rc.local -#sos_report -echo "REBOOTING" -sleep 1 -echo "REBOOTING" -sleep 1 -echo "REBOOTING" -reboot -#im_exit -################################## - - - - - - diff --git a/src/image_validation_postreboot.sh~ b/src/image_validation_postreboot.sh~ deleted file mode 100755 index 0e2e5e6..0000000 --- a/src/image_validation_postreboot.sh~ +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# Copyright (c) 2010 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public License, -# version 2 (GPLv2). There is NO WARRANTY for this software, express or -# implied, including the implied warranties of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 -# along with this software; if not, see -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. -# -# Red Hat trademarks are not licensed under GPLv2. No permission is -# granted to use or replicate Red Hat trademarks that are incorporated -# in this software or its documentation. -# -# written by whayutin@redhat.com -# modified by kbidarka@redhat.com for RHEL 6 - -FAILURES=0 - -function usage() -{ - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " - echo "Please use all options" - echo "" - echo " This script will run through some basic sanity tests for a Red Hat Enterprise Linux image " - echo " A valid Red Hat bugzilla username and password will be required at the end of the script " - echo " http://bugzilla.redhat.com/ " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " - echo "" - echo "Available options are:" - echo "--imageID= :: Please provide a unique id for the image" - echo "--RHEL= :: Please specify the correct FULL rhel version eg: --RHEL=5.7 or --RHEL=6.1" - echo "--full-yum-suite= :: Please input the value "yes" OR "no"" - echo "--skip-questions= :: Please input the value "yes" or "no"" - echo "--bugzilla-username :: Please specify your bugzilla username@email.com" - echo "--bugzilla-password :: Please specify your bugzilla password" - echo "--bugzilla-num :: If a bug has already been opened you can specify the number here " - echo "--memory :: Minium total kb of memory the system *should* have available " -} - - -#cli -for i in $* - do - case $i in - --imageID=*) - IMAGEID="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --RHEL=*) - RHELV="`echo $i | sed 's/[-A-Z]*=//'`" - ;; - --full-yum-suite=*) - yum_test="`echo $i | sed 's/[-a-zA-Z]*=//'`" - if [ "$yum_test" == "yes" ] || [ "$yum_test" == "no" ]; then - : - else - usage - exit 1 - fi - ;; - --skip-questions=*) - QUESTIONS="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --bugzilla-username=*) - BUG_USERNAME="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --bugzilla-password=*) - BUG_PASSWORD="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --bugzilla-num=*) - BUG_NUM="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --failures=*) - FAILURES="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - --memory=*) - MEM_HWP="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" - ;; - *) - # unknown option - usage - exit 1 - ;; - esac -done - - -if [[ -z $IMAGEID ]] || [[ -z $RHELV ]] || [[ -z $yum_test ]] || [[ -z $BUG_USERNAME ]] || [[ -z $BUG_PASSWORD ]] ; then - usage - exit 1 -fi - - - - -source $PWD/testlib.sh - -echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " -echo " This script will run through some basic sanity tests for a Red Hat Enterprise Linux image " -echo " A valid Red Hat bugzilla username and password will be required at the end of the script " -echo " http://bugzilla.redhat.com/ " -echo "" -echo "***************** DETAILED RESULTS LOGGED TO validate.log ********************************" -echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " -echo "" -echo "" -postReboot -echo "" -echo "##### START TESTS #####" -echo "" -test_yum_plugin -test_uname -test_memory -print_rhel_version -#installTestKernel - - -### DONT REMOVE OR COMMENT OUT ### -show_failures -open_bugzilla -bugzilla_comments() -verify_bugzilla -#sos_report -im_exit -################################## - - - - - - diff --git a/src/testlib.sh~ b/src/testlib.sh~ deleted file mode 100755 index 98caf1a..0000000 --- a/src/testlib.sh~ +++ /dev/null @@ -1,882 +0,0 @@ -#!/bin/bash -# Copyright (c) 2010 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public License, -# version 2 (GPLv2). There is NO WARRANTY for this software, express or -# implied, including the implied warranties of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 -# along with this software; if not, see -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. -# -# Red Hat trademarks are not licensed under GPLv2. No permission is -# granted to use or replicate Red Hat trademarks that are incorporated -# in this software or its documentation. -# -# written by whayutin@redhat.com -# modified by kbidarka@redhat.com - -LOGFILE=$PWD/validate.log -DLOG=" tee -a ${LOGFILE} " #Display and log output -cat /dev/null > $LOGFILE -RSLT="" -LOGRESULT="echo ${RSLT} 1>>$LOGFILE 2>>$LOGFILE" -DIFFDIR=$PWD -SYSDATE=$( /bin/date '+%Y-%m-%d %H:%M' ) -UNAMEI=$( /bin/uname -i ) -BETA=0 - - -echo "" -echo "" - -txtred=$(tput setaf 1) # Red -txtgrn=$(tput setaf 2) # Green -txtrst=$(tput sgr0) # Text reset - -### Begin: Create a list of partitions -rm -Rf disk_partitions -rm -Rf swap_partitions -mount | grep ^/dev | awk '{print $1}' >> disk_partitions -parted -l | grep -B 5 swap | grep ^Disk | awk '{print $2}' | sed '$s/.$//' >> swap_partitions - -rm -Rf tmp1_partitions tmp2_partitions -### End: Create a list of partitions - -RHEL=`cat /etc/redhat-release | awk '{print $7}' | awk -F. '{print $1}'` -RHELU=`cat /etc/redhat-release | awk '{print $7}' | awk -F. '{print $2}'` -RHEL_FOUND=$RHEL.$RHELU -KERNEL="" -KERNEL_UPDATED="" -TEST_CURRENT="" -TEST_FAILED="" -echo "IMAGE ID= ${IMAGEID}" >> $LOGFILE - - - -function new_test() -{ - echo -n $1 - echo "######################################################################################" >> $LOGFILE - echo "# NEW TEST: $1" >> $LOGFILE - TEST_CURRENT=$1 - echo "######################################################################################" >> $LOGFILE -} - -#rus a basic command -function rc() -{ - echo "COMMAND: $1" >>$LOGFILE - RSLT=`eval $1 2>>${LOGFILE}` - rc=$? - echo "RETURN CODE: $rc" >>$LOGFILE -} - -function rq() -{ - echo "QUESTION: $1" -} - -#runs a basic command and redirects stdout to file $2 -function rc_outFile() -{ - echo "COMMAND: $1 $2" >>$LOGFILE - `eval $1 1>>${LOGFILE}` - rc=$? - echo "RETURN CODE: $rc" >>$LOGFILE -} - -#runs a basic command and asserts its return code -function assert() -{ - args=("$@") - cmd=${args[0]} - option=${args[1]} - option2=${args[2]} - echo "COMMAND: $1" >>$LOGFILE - RSLT=`eval $cmd 2>>$LOGFILE` - rc=$? - echo "RESULT: $RSLT " >>$LOGFILE - if [ -z $option2 ];then - echo "EXPECTED RESULT: $option" >>$LOGFILE - option2="zzz###zzz" - else - echo "EXPECTED RESULT: $option OR $option2 " >>$LOGFILE - fi - echo "RETURN CODE: $rc" >>$LOGFILE - - if [[ "$RSLT" == "$option" ]] || [[ "$RSLT" == $option2 ]] && [[ "$option" != "" ]];then - #echo "IN FIRST TEST" >>$LOGFILE - echo "${txtgrn}PASS${txtrst}" - echo "PASS" >> $LOGFILE - elif [ -z "$option" ] && [ "$rc" == 0 ];then - #echo "IN SECOND TEST" >>$LOGFILE - echo "${txtgrn}PASS${txtrst}" - echo "PASS" >> $LOGFILE - elif [[ "$rc" == "$option" ]];then - echo "${txtgrn}PASS${txtrst}" - echo "PASS" >> $LOGFILE - elif [[ "$RSLT" != "$option" ]] && [[ "$RSLT" != "$option2" ]] && [[ "$rc" != 0 ]] ;then - #echo "IN THIRD TEST" >>$LOGFILE - echo "${txtred}FAIL${txtrst}" - echo "FAIL" >> $LOGFILE - echo ${RSLT} >>${LOGFILE} - TEST_FAILED="$TEST_FAILED $TEST_CURRENT" - let FAILURES++ - else - echo "${txtred}FAIL${txtrst}" - echo "FAIL" >> $LOGFILE - echo ${RSLT} >>${LOGFILE} - TEST_FAILED="$TEST_FAILED $TEST_CURRENT" - let FAILURES++ - fi -} - -function test_rhel_version() -{ - pwd >> $LOGFILE - hostname >> $LOGFILE - echo `cat /etc/redhat-release` >> $LOGFILE - if [ $RHELV == $RHEL_FOUND ]; then - new_test "The selected image has the version RHEL $RHELV" - else - echo "Version Mismatched !!!!, The input version RHEL$RHELV should be similar to the selected Ami's version RHEL$RHEL_FOUND" - exit - fi - BETA=`cat /etc/redhat-release | grep -i beta | wc -l` - if [ $BETA == 1 ]; then - echo "ami is a BETA" >> $LOGFILE - fi -} - -function print_rhel_version() -{ - echo hostname >> $LOGFILE - echo `cat /etc/redhat-release` - if [ $RHELV == $RHEL_FOUND ]; then - new_test "The selected image has the version RHEL $RHELV" - else - echo "Version Mismatched !!!!, The input version RHEL$RHELV should be similar to the selected Ami's version RHEL$RHEL_FOUND" - echo "Version Mismatched !!!!, Check the logs to see if yum update changed the RHEL version" - fi -} - - -function userInput_CloudProvider() -{ - echo "" - echo "******** Please answer the following questions *********" - new_test "Cloud Provider Basic Information.." - echo "" - rq "What is the cloud providers company name?" - read answer - echo $answer >>$LOGFILE - rq "What is your full name?" - read answer - echo $answer >>$LOGFILE - rq "What is your email address?" - read email - echo $email >>$LOGFILE -} - -function userInput_Filesystem() -{ - echo "" - echo "******** Please answer the following questions *********" - new_test "Non-Standard Image Layout or Filesystem Types.." - echo "" - rq "If this image contains a non standard partition or filesystem, please describe it" - read answer - echo $answer >>$LOGFILE -} - -function userInput_Errata_Notification() -{ - echo "" - echo "******** Please answer the following questions *********" - new_test "Description of Errata Notification Procedure/Process to be Used to Notify Cloud Users" - echo "" - rq "Please describe the process to be used in order to notify Cloud Users of errata and critical updates." - read answer - echo $answer >>$LOGFILE -} - -function userInput_Availability() -{ - echo "" - echo "******** Please answer the following questions *********" - new_test "Description of Policy for Availability of Updated Starter Images" - echo "" - rq "Please clearly define the policy for making starter images available." - read answer - echo $answer >>$LOGFILE - new_test "Description of Policy for retiring starter images" - echo "" - rq "Please clearly define the policy for retiring " - read answer - echo $answer >>$LOGFILE -} - -function test_disk_size() -{ - new_test "## Partition Size ..." - for part in $(cat disk_partitions);do - echo "size=`df -k $part | awk '{ print $2 }' | tail -n 1`" >> $LOGFILE - size=`df -k $part | awk '{ print $2 }' | tail -n 1` - if [ "$size" -gt "3937219" ] - then - echo "$part is 4gb or greater" - assert "echo true" true - else - echo "$part is NOT 4gb or greater" - assert "echo false" true - fi - done -} - -function test_disk_format() -{ - new_test "## Partition Format ..." - for part in $(cat disk_partitions);do - echo "mount | grep $part | awk '{ print $5 }'" >> $LOGFILE - result=`mount | grep $part | awk '{ print $5 }'` - - if [ $RHEL == 5 ] ; then - assert "echo $result" ext3 - else - ext=`mount | grep $part | awk '{print $3}'` - if [ "$ext" == "/" ] ; then - assert "echo $result" "ext4" - else - assert "echo $result" "ext3" - fi - fi - done -} - - -function test_selinux() -{ - echo "## SELINUX TESTS" - new_test "## /sbin/getenforce ... " - assert "/usr/sbin/getenforce" "Enforcing" - - new_test "## Verify SELINUX enforcing ... " - assert "grep ^SELINUX= /etc/sysconfig/selinux | cut -d\= -f2" enforcing - - new_test "## Verify SELINUXTYPE targeted ... " - assert "grep ^SELINUXTYPE= /etc/sysconfig/selinux | cut -d\= -f2" targeted - - new_test "## Flip Selinux Permissive ... " - assert "/usr/sbin/setenforce Permissive && /usr/sbin/getenforce" Permissive - - new_test "## Flip Selinux Enforcing ... " - assert "/usr/sbin/setenforce Enforcing && /usr/sbin/getenforce" Enforcing - -} - - -function test_package_set() -{ - new_test "## Verify no missing packages ... " - file=/tmp/rpmqa - rc "/bin/rpm -qa --queryformat='%{NAME}\n' > ${file}.tmp" - #/bin/rpm -qa --queryformat="%{NAME}.%{ARCH}\n" > ${file}.tmp - cat ${file}.tmp | sort -f > ${file} - if [ $RHEL == 5 ] ; then - rc "comm -23 packages_5 ${file}" - comm -23 packages_5 ${file} > /tmp/package_diff - elif [ $RHEL_FOUND == "6.0" ]; then - rc "comm -23 packages_6 ${file}" - comm -23 packages_6 ${file} > /tmp/package_diff - elif [ $RHEL_FOUND == "6.1" ]; then - rc "comm -23 packages_61 ${file}" - comm -23 packages_61 ${file} > /tmp/package_diff - else - echo "VERSION NOT FOUND" - fi - - cat /tmp/package_diff >>$LOGFILE - COUNT=`cat /tmp/package_diff | wc -l` - echo "COUNT = `cat /tmp/package_diff | wc -l`" >> $LOGFILE - if [ $BETA == 1 ]; then - if [ $COUNT == 1 ]; then - assert "cat /tmp/package_diff | wc -l" 1 - else - assert "echo test failed" 1 - fi - else - if [ $COUNT -gt 0 ]; then - assert "echo test failed" 1 - else - assert "echo test passed" 0 - fi - fi -} - -function test_verify_rpms() -{ - THIS_RHEL=`echo $RHELV | cut -d . -f 1` - if [ $THIS_RHEL == 5 ] ; then - file=/tmp/rpmqaV.txt - new_test "## Verify RPMs ... " - /bin/rpm -Va --nomtime --nosize --nomd5 2>> $LOGFILE | sort -fu > ${file} - echo "/bin/rpm -Va --nomtime --nosize --nomd5" >> $LOGFILE - cat $file >> $LOGFILE - cat rpmVerifyTable >> $LOGFILE - assert "cat ${file} | wc -l" "2" - new_test "## Verify Version 2 ... " - assert "/bin/rpm -q --queryformat '%{RELEASE}\n' redhat-release | cut -d. -f1,2" $RHELV # to-do, pass this in - else - file=/tmp/rpmqaV.txt - new_test "## Verify RPMs ... " - /bin/rpm -Va --nomtime --nosize --nomd5 2>> $LOGFILE | sort -fu > ${file} - cat $file >> $LOGFILE - cat rpmVerifyTable >> $LOGFILE - if [[ $RHEL_FOUND == "6.1" ]] && [[ $UNAMEI == "x86_64" ]] ; then - assert "cat ${file} | wc -l" "5" - else - assert "cat ${file} | wc -l" "4" - fi - new_test "## Verify Version 2 ... " - assert "/bin/rpm -q --queryformat '%{RELEASE}\n' redhat-release-server | cut -d. -f1,2" $RHELV # to-do, pass this in - fi - - new_test "## Verify packager ... " - file=/tmp/Packager - `cat /dev/null > $file` - #echo "for x in $file ;do echo -n $x >> $file; rpm -qi $x | grep Packager >> $file;done" >>$LOGFILE - for x in $(cat /tmp/rpmqa);do - echo -n $x >>$file - rpm -qi $x | grep Packager >>$file - done - assert "cat $file | grep -v 'Red Hat, Inc.' | grep -v crash-trace-commandPackager| wc -l" 0 - cat $file | grep -v 'Red Hat, Inc.' >>$LOGFILE -} - -function test_yum_full_test() -{ - #echo "Invoking more rigorous yum tests" - new_test "## List the configured repositories..." - assert "/usr/bin/yum repolist" - - new_test "## Search zsh..." - assert "/usr/bin/yum search zsh" - - new_test "## install zsh ... " - rc "/usr/bin/yum -y install zsh" - assert "/bin/rpm -q --queryformat '%{NAME}\n' zsh" zsh - - new_test "## List available groups.." - assert "/usr/bin/yum grouplist" - - new_test "## Install Development tools group..." - assert "/usr/bin/yum -y groupinstall 'Development tools'" - - new_test "## Verify yum update ... " - assert "/usr/bin/yum -y update" - - new_test "## Verify no fa1lures in rpm package ... " - assert "cat $LOGFILE | grep 'failure in rpm package' | wc -l" "1" - - new_test "## Verify no rpm scriplet fa1lures ... " - assert "cat $LOGFILE | grep 'scriptlet failed, exit status 1' | wc -l" "1" - - new_test "## Verify package removal... " - rc "/bin/rpm -e zsh" - assert "/bin/rpm -q zsh" "package zsh is not installed" - -} - -function test_yum_general_test() -{ - new_test "## install zsh ... " - rc "/usr/bin/yum -y install zsh" - assert "/bin/rpm -q --queryformat '%{NAME}\n' zsh" zsh - - new_test "## Verify package removal ... " - rc "/bin/rpm -e zsh" - assert "/bin/rpm -q zsh" "package zsh is not installed" - - new_test "## Verify yum update ... " - assert "/usr/bin/yum -y update" -} - -function test_bash_history() -{ - new_test "## Verify bash_history ... " - assert "cat ~/.bash_history | wc -l " 0 -} - - -function test_swap_file() -{ - new_test "## Verify turning on/off swap file ... " - if [ $UNAMEI == "x86_64" ]; then - swap=`cat swap_partitions` - assert "/sbin/swapoff $swap && /sbin/swapon $swap" - fi - - new_test "## Verify swap size ... " - if [ $UNAMEI == "x86_64" ]; then - size=`free | grep Swap | awk '{print $2}'` - echo "free | grep Swap | awk '{print $2}'" >> $LOGFILE - echo "swap size = $size" >> LOGFILE - if [ $size -gt 0 ]; then - assert "echo true" - else - assert "echo false" "1" - fi - fi - - if [ $UNAMEI == "i386" ]; then - echo "no swap for i386 is expected" >> $LOGFILE - fi - -} - -function test_system_id() -{ - new_test "## Verify no systemid file ... " - if [ ! -f /etc/sysconfig/rhn/systemid ]; then - assert "echo true" - else - assert "/bin/asdf" - fi -} - -function test_cloud-firstboot() -{ - if [ $RHELV == 6.0 ]; then - echo "WAIVED TESTS FOR BUGZILLA 704821" - else - new_test "## Verify rh-cloud-firstboot is on ... " - assert "chkconfig --list | grep rh-cloud | grep 3:off | wc -l" "1" - if [ -f /etc/sysconfig/rh-cloud-firstboot ]; then - echo "/etc/sysconfig/rh-cloud-firstboot FOUND" >> $LOGFILE - assert "echo true" - else - echo "/etc/sysconfig/rh-cloud-firstboot NOT FOUND" >> $LOGFILE - assert "/bin/asdf" - fi - assert "cat /etc/sysconfig/rh-cloud-firstboot" "RUN_FIRSTBOOT=NO" - fi -} - -function test_nameserver() -{ - new_test "## Verify nameserver ... " - assert "/usr/bin/dig clock.redhat.com 2>> $LOGFILE | grep 66.187.233.4 | wc -l" -} - -function test_group() -{ - new_test "## Verify group file ... " - assert "cat /etc/group | grep root:x:0" "root:x:0:root" - assert "cat /etc/group | grep bin:x:1" "bin:x:1:root,bin,daemon" - assert "cat /etc/group | grep daemon:x:2" "daemon:x:2:root,bin,daemon" - assert "cat /etc/group | grep nobody:x:99" "nobody:x:99:" -} - -function test_passwd() -{ - new_test "## Verify new passwd file ... " - assert "cat /etc/passwd | grep root:x:0" "root:x:0:0:root:/root:/bin/bash" - assert "cat /etc/passwd | grep nobody:x:99" "nobody:x:99:99:Nobody:/:/sbin/nologin" - assert "cat /etc/passwd | grep sshd" "sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin" -} - -function test_inittab() -{ - if [ $RHEL == 5 ] ;then - new_test "## Verify runlevel ... " - assert "cat /etc/inittab | grep id:" "id:3:initdefault:" - assert "cat /etc/inittab | grep si:" "si::sysinit:/etc/rc.d/rc.sysinit" - else - new_test "## Verify runlevel ... " - assert "cat /etc/inittab | grep id:" "id:3:initdefault:" - fi -} - - -function test_shells() -{ - new_test "## Verify new shells file ... " - assert "cat /etc/shells | grep bash" "/bin/bash" - assert "cat /etc/shells | grep nologin" "/sbin/nologin" -} - -function test_repos() -{ - - if [ $RHEL == 5 ]; then - new_test "## test repo files ... " - assert "ls /etc/yum.repos.d/ | wc -l " 6 - assert "ls /etc/yum.repos.d/redhat* | wc -l" 4 - assert "ls /etc/yum.repos.d/rhel* | wc -l" 2 - else - new_test "## test repo files ... " - assert "ls /etc/yum.repos.d/ | wc -l " 4 - assert "ls /etc/yum.repos.d/redhat* | wc -l" 4 - assert "ls /etc/yum.repos.d/rhel* | wc -l" 0 - fi -} - -function test_yum_plugin() -{ - new_test "## Verify disabled yum plugin ... " - assert "grep ^enabled /etc/yum/pluginconf.d/rhnplugin.conf | grep -v '^#' | cut -d\= -f2 | awk '{print $1}' | sort -f | uniq" -} - -function test_gpg_keys() -{ - new_test "## Verify GPG checking ... " - assert "grep '^gpgcheck=1' /etc/yum.repos.d/redhat-*.repo | cut -d\= -f2 | sort -f | uniq" 1 - - new_test "## Verify GPG Keys ... " - if [ $BETA == 1 ]; then - assert "rpm -qa gpg-pubkey* | wc -l " 3 - elif [ $RHEL_FOUND == "6.1" ]; then - assert "rpm -qa gpg-pubkey* | wc -l " 2 - else - assert "rpm -qa gpg-pubkey* | wc -l " 2 - fi - - - if [ $BETA == 1 ]; then - echo "SKIPPING TEST, BETA DETECTED" >> $LOGFILE - elif [[ $RHEL == 5 ]] && [[ $BETA == 0 ]]; then - new_test "## Verify GPG RPMS ... " - assert "rpm -qa gpg-pubkey* | sort -f | tail -n 1" "gpg-pubkey-37017186-45761324" - assert "rpm -qa gpg-pubkey* | grep 2fa6" "gpg-pubkey-2fa658e0-45700c69" - elif [[ $RHEL_FOUND == "6.1" ]] && [[ $BETA == 0 ]]; then - assert "rpm -qa gpg-pubkey* | sort -f | tail -n 1" "gpg-pubkey-fd431d51-4ae0493b" - assert "rpm -qa gpg-pubkey* | sort -f | head -n 1" "gpg-pubkey-2fa658e0-45700c69" - else - new_test "## Verify GPG RPMS ... " - assert "rpm -qa gpg-pubkey* | sort -f | tail -n 1" "gpg-pubkey-fd431d51-4ae0493b" - assert "rpm -qa gpg-pubkey* | grep 2fa6" "gpg-pubkey-2fa658e0-45700c69" - fi -} - -function test_IPv6() -{ - new_test "## Verify IPv6 disabled ... " - assert "grep ^NETWORKING_IPV6= /etc/sysconfig/network" "NETWORKING_IPV6=no" -} - -function test_networking() -{ - new_test "## Verify networking ... " - assert "grep ^NETWORKING= /etc/sysconfig/network | cut -d\= -f2" yes - - new_test "## Verify device ... " - assert "grep ^DEVICE= /etc/sysconfig/network-scripts/ifcfg-eth0 | cut -d\= -f2" eth0 -} - -function test_sshd() -{ - new_test "## Verify sshd ..." - assert "chkconfig --list | grep sshd" "sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off" - assert "/etc/init.d/sshd status | grep running | wc -l" 1 -} - - -function test_iptables() -{ - if [ $RHEL == 5 ]; then - new_test "## Verify iptables ... " - rc_outFile "/etc/init.d/iptables status | grep REJECT" - assert "/etc/init.d/iptables status | grep :22 | grep ACCEPT | wc -l " "1" - assert "/etc/init.d/iptables status | grep "dpt:631" | grep ACCEPT | wc -l " "2" -# assert "/etc/init.d/iptables status | grep "icmp type" | grep ACCEPT | wc -l" "1" - assert "/etc/init.d/iptables status | grep "dpt:5353" | grep ACCEPT | wc -l" "1" - assert "/etc/init.d/iptables status | grep "RELATED,ESTABLISHED" | grep ACCEPT | wc -l" "1" - assert "/etc/init.d/iptables status | grep -e esp -e ah | grep ACCEPT | wc -l" "2" -# assert "/etc/init.d/iptables status | grep :80 | grep ACCEPT | wc -l " "1" -# assert "/etc/init.d/iptables status | grep :443 | grep ACCEPT | wc -l " "1" - assert "/etc/init.d/iptables status | grep REJECT | grep all | grep 0.0.0.0/0 | grep icmp-host-prohibited | wc -l" "1" - else - new_test "## Verify iptables ... " - rc_outFile "/etc/init.d/iptables status | grep REJECT" - assert "/etc/init.d/iptables status | grep :22 | grep ACCEPT | wc -l " "1" -# assert "/etc/init.d/iptables status | grep "dpt:631" | grep ACCEPT | wc -l " "2" -# assert "/etc/init.d/iptables status | grep "icmp type" | grep ACCEPT | wc -l" "1" -# assert "/etc/init.d/iptables status | grep "dpt:5353" | grep ACCEPT | wc -l" "1" -# assert "/etc/init.d/iptables status | grep "ESTABLISHED,RELATED" | grep ACCEPT | wc -l" "1" -# assert "/etc/init.d/iptables status | grep -e esp -e ah | grep ACCEPT | wc -l" "2" -# assert "/etc/init.d/iptables status | grep :80 | grep ACCEPT | wc -l " "1" -# assert "/etc/init.d/iptables status | grep :443 | grep ACCEPT | wc -l " "1" -# assert "/etc/init.d/iptables status | grep REJECT | grep all | grep 0.0.0.0/0 | grep icmp-host-prohibited | wc -l" "1" - fi -} - -function test_chkconfig() -{ - - if [ $RHEL == 5 ]; then - new_test "## Verify chkconfig ... " - assert "chkconfig --list | grep crond | cut -f 5" "3:on" - assert "chkconfig --list | grep iptables | cut -f 5" "3:on" - assert "chkconfig --list | grep yum-updatesd | cut -f 5" "3:on" - else - new_test "## Verify chkconfig ... " - assert "chkconfig --list | grep crond | cut -f 5" "3:on" - assert "chkconfig --list | grep iptables | cut -f 5" "3:on" - fi -} - -function test_sshSettings() -{ - new_test "## Verify sshd_config settings ..." - assert "cat /etc/ssh/sshd_config | grep PasswordAuthentication | grep no | wc -l" "1" -} - -function test_libc6-xen.conf() -{ - new_test "## Verify /etc/ld.so.conf.d/libc6-xen.conf is not present ... " - if [ $UNAMEI == "x86_64" ]; then - assert "ls /etc/ld.so.conf.d/libc6-xen.conf" "2" - else - assert "ls /etc/ld.so.conf.d/libc6-xen.conf" "2" - fi -} - -function test_syslog() -{ - new_test "## Verify rsyslog is on ... " - assert "chkconfig --list | grep rsyslog | cut -f 5" "3:on" - new_test "## Verify rsyslog config ... " - if [ $RHEL == 5 ] ; then - assert "md5sum /etc/rsyslog.conf | cut -f 1 -d \" \"" "bd4e328df4b59d41979ef7202a05e074" "15936b6fe4e8fadcea87b54de495f975" - #assert "md5sum /etc/rsyslog.conf | cut -f 1 -d \" \"" "15936b6fe4e8fadcea87b54de495f975" - else - assert "md5sum /etc/rsyslog.conf | cut -f 1 -d \" \"" "dd356958ca9c4e779f7fac13dde3c1b5" - fi -} - -function test_auditd() -{ - new_test "## Verify auditd is on ... " - assert "/sbin/chkconfig --list auditd | grep 3:on" - assert "/sbin/chkconfig --list auditd | grep 5:on" - - new_test "## Verify audit.rules ... " - assert "md5sum /etc/audit/audit.rules | cut -f 1 -d \" \"" "f9869e1191838c461f5b9051c78a638d" - - new_test "## Verify auditd.conf ... " - assert "md5sum /etc/audit/auditd.conf | cut -f 1 -d \" \"" "612ddf28c3916530d47ef56a1b1ed1ed" - - new_test "## Verify auditd sysconfig ... " - assert "md5sum /etc/sysconfig/auditd | cut -f 1 -d \" \"" "123beb3a97a32d96eba4f11509e39da2" -} - -function test_uname() -{ - new_test "## Verify kernel name ... " - assert "/bin/uname -s" Linux - - new_test "## Verify latest installed kernel is running ... " - if [ $RHEL == 5 ] ; then - echo "LATEST_RPM_KERNEL_VERSION=`rpm -q kernel-xen | tail -n 1 | cut -c 12-50| sed 's/\(.*\)..../\1/'`" >> $LOGFILE - LATEST_RPM_KERNEL_VERSION=`rpm -q kernel-xen | tail -n 1 | cut -c 12-50| sed 's/\(.*\)..../\1/'` - echo "CURRENT_UNAME_KERNAL_VERSION=`uname -r | sed 's/\(.*\)......./\1/'`" >> $LOGFILE - CURRENT_UNAME_KERNAL_VERSION=`uname -r | sed 's/\(.*\)......./\1/'` - echo "assert latest rpm kernel = uname -r" >> $LOGFILE - #assert "rpm -q kernel-xen | sort -n | tail -n 1 | cut -c 12-50| sed 's/\(.*\)..../\1/'" $CURRENT_UNAME_KERNAL_VERSION - assert "uname -r | sed 's/\(.*\)......./\1/'" $LATEST_RPM_KERNEL_VERSION - elif [[ $RHEL == 6 ]] && [[ $UNAMEI == "i386" ]] ; then - echo "RHEL VERSION IS $RHEL" >> $LOGFILE - echo "LATEST_RPM_KERNEL_VERSION=rpm -q kernel --last | head -n 1 | cut -c 8-60 | cut -d ' ' -f 1" >> $LOGFILE - LATEST_RPM_KERNEL_VERSION=`rpm -q kernel --last | head -n 1 | cut -c 8-60 | cut -d ' ' -f 1` - echo "CURRENT_UNAME_KERNAL_VERSION=`uname -r | sed 's/\(.*\)...../\1/'`" >> $LOGFILE - CURRENT_UNAME_KERNAL_VERSION=`uname -r | sed 's/\(.*\)...../\1/'` - echo "assert latest rpm kernel = uname -r" >> $LOGFILE - #assert "rpm -q kernel-xen | sort -n | tail -n 1 | cut -c 12-50| sed 's/\(.*\)..../\1/'" $CURRENT_UNAME_KERNAL_VERSION - assert "uname -r | sed 's/\(.*\)...../\1/'" $LATEST_RPM_KERNEL_VERSION - elif [[ $RHEL == 6 ]] && [[ $UNAMEI == "x86_64" ]] ; then - echo "RHEL VERSION IS $RHEL" >> $LOGFILE - echo "LATEST_RPM_KERNEL_VERSION=rpm -q kernel --last | head -n 1 | cut -c 8-60 | cut -d ' ' -f 1" >> $LOGFILE - LATEST_RPM_KERNEL_VERSION=`rpm -q kernel --last | head -n 1 | cut -c 8-60 | cut -d ' ' -f 1` - echo "CURRENT_UNAME_KERNAL_VERSION=`uname -r | sed 's/\(.*\)......./\1/'`" >> $LOGFILE - CURRENT_UNAME_KERNAL_VERSION=`uname -r | sed 's/\(.*\)......./\1/'` - echo "assert latest rpm kernel = uname -r" >> $LOGFILE - #assert "rpm -q kernel-xen | sort -n | tail -n 1 | cut -c 12-50| sed 's/\(.*\)..../\1/'" $CURRENT_UNAME_KERNAL_VERSION - assert "uname -r | sed 's/\(.*\)......./\1/'" $LATEST_RPM_KERNEL_VERSION - fi - - new_test "## Verify latest kenerl is in /boot/grub/menu.1st ... " - assert "cat /boot/grub/menu.lst | grep $LATEST_RPM_KERNEL_VERSION" - - new_test "## Verify operating system ... " - assert "/bin/uname -o" GNU/Linux - - new_test "## Verify /etc/sysconfig/kernel ... " - assert "ls /etc/sysconfig/kernel" - - new_test "## Verify /etc/sysconfig/kernel contains UPDATEDEFAULT ... " - assert "cat /etc/sysconfig/kernel | grep UPDATEDEFAULT=yes" - - new_test "## Verify /etc/sysconfig/kernel contains DEFAULTKERNEL ... " - assert "cat /etc/sysconfig/kernel | grep DEFAULTKERNEL=kernel" - -} - -function resize2fs() -{ - new_test "## Verify resize2fs ... " - if [ $RHEL == 6 ] ; then - rc "resize2fs -p /dev/xvde1 15000M" - fi - if [ $RHEL == 5 ] ; then - rc "resize2fs -p /dev/sda1 15000M" - fi - assert "df -h | grep 13G | wc -l" "1" -} - -function installTestKernel() -{ - new_test "## install custom kernel" - #cat /proc/cpuinfo | grep nonstop_tsc >> $LOGFILE - echo "yumlocalinstall -y /root/kernel/*" >> $LOGFILE - rc "yum localinstall -y /root/kernel/* --nogpgcheck" - - #cat /boot/grub/grub.conf > /boot/grub/menu.lst - #/bin/sed -i -e 's/(hd0,0)/(hd0)/' /boot/grub/menu.lst -} - -function test_grub() -{ - new_test "##test menu.lst ... " - assert "file /boot/grub/menu.lst | grep symbolic | wc -l" "1" - assert "file /boot/grub/menu.lst | grep grub.conf | wc -l" "1" - assert "cat /boot/grub/grub.conf | grep \"(hd0,0)\" | wc -l" "0" -} - -function test_memory() -{ - new_test "##Verify memory match hwp ... " - echo "cat /proc/meminfo | grep MemTotal: | awk '{print $2}'" >> $LOGFILE - MEM=`cat /proc/meminfo | grep "MemTotal:" | awk '{print $2}'` - echo "EXPECTED MINIMUM MEMORY = $MEM_HWP" - echo "MEMORY FOUND = $MEM" - if [[ $MEM -gt $MEM_HWP ]]; then - echo "FOUND MEMORY OF $MEM > hwp MEMORY of $MEM_HWP" >> $LOGFILE - assert "echo true" - else - echo "FAILED!! FOUND MEMORY OF $MEM > hwp MEMORY of $MEM_HWP" >> $LOGFILE - assert "echo false" "1" - fi -} - -function sos_report() -{ - echo "## Create a sosreport ... " - echo "This may take 5 - 10 minutes" - sosreport -a --batch --ticket-number=${BUGZILLA} 1>/dev/null - echo "" - #echo "Please attach the sosreport bz2 in file /tmp to https://bugzilla.redhat.com/show_bug.cgi?id=$BUGZILLA" - -} - -function open_bugzilla() -{ - #echo "######### /etc/rc.local ########" >> $LOGFILE - #cat /etc/rc.local >> $LOGFILE - #echo "######### /etc/rc.local ########" >> $LOGFILE - - BUGZILLACOMMAND=$DIFFDIR/bugzilla-command - new_test "## Open a bugzilla" - echo "" - echo "Logging into bugilla" - echo "" - $BUGZILLACOMMAND --bugzilla=https://bugzilla.redhat.com/xmlrpc.cgi --user=$BUG_USERNAME --password=$BUG_PASSWORD login - if [ -z $BUG_NUM ]; then - BUGZILLA=`$BUGZILLACOMMAND new -p"Cloud Image Validation" -v"RHEL$RHELV" -a"$UNAMEI" -c"images" -l"initial bug opening" -s"$IMAGEID $RHELV $UNAMEI " | cut -b "2-8"` - echo "" - echo "new bug created: $BUGZILLA https://bugzilla.redhat.com/show_bug.cgi?id=$BUGZILLA" - echo "" - else - BUGZILLA=$BUG_NUM - echo $BUGZILLA > /tmp/bugzilla - fi -} - -function bugzilla_comments() -{ - echo "Adding log file contents to bugzilla" - BUG_COMMENTS01=`head -n $(expr $(cat ${LOGFILE} | wc -l ) / 2) ${LOGFILE}` - BUG_COMMENTS02=`tail -n $(expr $(cat ${LOGFILE} | wc -l ) / 2) ${LOGFILE}` - $BUGZILLACOMMAND modify $BUGZILLA -l "${BUG_COMMENTS01}" - $BUGZILLACOMMAND modify $BUGZILLA -l "${BUG_COMMENTS02}" - - echo "Finished with the bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=$BUGZILLA" - -} - -function verify_bugzilla() -{ - echo "If no failures found move bug to verified" - if [ $FAILURES == 0 ];then - echo "MOVING BUG TO VERIFIED: test has $FAILURES failures" - $BUGZILLACOMMAND modify --status="VERIFIED" $BUGZILLA - else - echo "MOVING BUG TO ON_QA: test has $FAILURES failures" - $BUGZILLACOMMAND modify --status="ON_QA" $BUGZILLA - fi - -} - - -function remove_bugzilla_rpms() -{ - echo "" - echo "Removing epel-release and python-bugzilla" - rpm -e epel-release python-bugzilla - rpm -e gpg-pubkey-0608b895-4bd22942 gpg-pubkey-217521f6-45e8a532 - echo "" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Please attach the sosreport bz2 in file /tmp to https://bugzilla.redhat.com/show_bug.cgi?id=$BUGZILLA" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" -} - -function setup_rc.local() -{ - echo "####################### cat of /etc/rc.local ##################" >> $LOGFILE - echo "cd /root/valid/src" >> /etc/rc.local - echo "./image_validation_postreboot.sh --imageID=asdf --RHEL=$RHELV --full-yum-suite=no --skip-questions=yes --bugzilla-username=$BUG_USERNAME --bugzilla-password=$BUG_PASSWORD --bugzilla-num=$BUGZILLA --failures=$FAILURES --memory=$MEM_HWP >> /var/log/messages" >> /etc/rc.local - cat /etc/rc.local >> $LOGFILE - -echo "####################### cat of /etc/rc.local ##################" >> $LOGFILE -} - -function postReboot() -{ - echo "###### TEST KERNEL AFTER REBOOT #### " >> $LOGFILE -} - - - -function show_failures() -{ - echo "" | $DLOG - echo "## Summary ##" | $DLOG - echo "FAILURES = ${FAILURES}" | $DLOG - echo $TEST_FAILED >> $PWD/failed_tests - FAILED=`cat $PWD/failed_tests` - echo "FAILED TESTS = ${FAILED}" | $DLOG - echo "LOG FILE = ${LOGFILE}" | $DLOG - echo "## Summary ##" | $DLOG - echo "" | $DLOG -} - -function im_exit() -{ - echo "" - echo "## Summary ##" - echo "FAILURES = ${FAILURES}" - echo "FAILED TESTS = ${FAILED}" - echo "LOG FILE = ${LOGFILE}" - echo "## Summary ##" - echo "" - exit ${FAILURES} -} From 2c9ab3c752a8f75eb0206de37d03cadf5f18e4f3 Mon Sep 17 00:00:00 2001 From: Jay Greguske Date: Wed, 7 Sep 2011 13:17:05 -0400 Subject: [PATCH 03/33] fixed syntax error --- src/bugzilla/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bugzilla/util.py b/src/bugzilla/util.py index 1580d9c..14a4f34 100644 --- a/src/bugzilla/util.py +++ b/src/bugzilla/util.py @@ -28,7 +28,7 @@ def open_without_clobber(name, *args): while fd is None: try: fd = os.open(name, os.O_CREAT|os.O_EXCL, 0666) - except OSError as e: + except OSError, e: if e.errno == os.errno.EEXIST: name = "%s.%i" % (orig_name, count) count += 1 From 3672b4247fb93d37f8e35d192faa616367a3e773 Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Wed, 7 Sep 2011 17:35:59 -0400 Subject: [PATCH 04/33] fixed hard code bug entry --- src/getAmiDetails.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getAmiDetails.py b/src/getAmiDetails.py index 70c587b..80690d3 100755 --- a/src/getAmiDetails.py +++ b/src/getAmiDetails.py @@ -66,7 +66,7 @@ print "**** No bugzilla # was passed, will open one here ****" bugzilla=Bugzilla36(url='https://bugzilla.redhat.com/xmlrpc.cgi',user=BZUSER,password=BZPASS) mySummary=AMI+" "+RHEL+" "+ARCH+" "+REGION - BZ_Object=bugzilla.createbug(product="Cloud Image Validation",component="images",version="RHEL6.1",rep_platform="x86_64",summary=mySummary) + BZ_Object=bugzilla.createbug(product="Cloud Image Validation",component="images",version=RHEL,rep_platform=ARCH,summary=mySummary) BZ = str(BZ_Object.bug_id) print "Buzilla # = https://bugzilla.redhat.com/show_bug.cgi?id="+ BZ else: From e4dd3de56a2002bd6b5f3a7ef7f02c7f4d42b060 Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Thu, 8 Sep 2011 08:00:46 -0400 Subject: [PATCH 05/33] fixed noGit option --- src/getAmiDetails.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getAmiDetails.py b/src/getAmiDetails.py index 80690d3..f40b650 100755 --- a/src/getAmiDetails.py +++ b/src/getAmiDetails.py @@ -31,7 +31,7 @@ parser.add_option('-z','--bugzilla_password', type='string',dest='BZPASS',help='bugzilla password') parser.add_option('-m','--arch', dest='ARCH', default='x86_64', help='arch = i386, or x86_64') parser.add_option('-x','--ignore', dest='IGNORE', default='IGNORE', help='If set.. ignore the generated bug') #c1.medium -parser.add_option('-g','--noGit',dest='NOGIT', default=False, help='If set.. do not pull valid src from git, scp to each instance' ) +parser.add_option('-g','--noGit',action="store_true", default=True, help='If set.. do not pull valid src from git, scp to each instance' ) parser.add_option('-d','--baseDir',dest='BASEDIR',type='string',help='the dir of the src checkout ie.. ~/workspace/valid/src') From 8126d91b7d188f394e9b2fd658c559dd98d6a796 Mon Sep 17 00:00:00 2001 From: Sachin Ghai Date: Fri, 9 Sep 2011 16:15:51 +0530 Subject: [PATCH 06/33] Added -dest attribute for NOGIT --- src/getAmiDetails.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/getAmiDetails.py b/src/getAmiDetails.py index f40b650..9b91ad8 100755 --- a/src/getAmiDetails.py +++ b/src/getAmiDetails.py @@ -31,7 +31,8 @@ parser.add_option('-z','--bugzilla_password', type='string',dest='BZPASS',help='bugzilla password') parser.add_option('-m','--arch', dest='ARCH', default='x86_64', help='arch = i386, or x86_64') parser.add_option('-x','--ignore', dest='IGNORE', default='IGNORE', help='If set.. ignore the generated bug') #c1.medium -parser.add_option('-g','--noGit',action="store_true", default=True, help='If set.. do not pull valid src from git, scp to each instance' ) +parser.add_option('-g','--noGit',dest="NOGIT", default=True, help='If set.. do not pull valid src from git, scp to each instance' ) +#parser.add_option('-g','--noGit',action="store_true", default=True, help='If set.. do not pull valid src from git, scp to each instance' ) parser.add_option('-d','--baseDir',dest='BASEDIR',type='string',help='the dir of the src checkout ie.. ~/workspace/valid/src') From 48fc3520dbc8fc4da34420f523e0b21ec387cd8d Mon Sep 17 00:00:00 2001 From: Sachin Ghai Date: Fri, 9 Sep 2011 18:05:26 +0530 Subject: [PATCH 07/33] In BZ, Cloud image validation product requires version changes --- src/getAmiDetails.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/getAmiDetails.py b/src/getAmiDetails.py index 9b91ad8..e161bda 100755 --- a/src/getAmiDetails.py +++ b/src/getAmiDetails.py @@ -67,7 +67,8 @@ print "**** No bugzilla # was passed, will open one here ****" bugzilla=Bugzilla36(url='https://bugzilla.redhat.com/xmlrpc.cgi',user=BZUSER,password=BZPASS) mySummary=AMI+" "+RHEL+" "+ARCH+" "+REGION - BZ_Object=bugzilla.createbug(product="Cloud Image Validation",component="images",version=RHEL,rep_platform=ARCH,summary=mySummary) + RHV="RHEL"+RHEL + BZ_Object=bugzilla.createbug(product="Cloud Image Validation",component="images",version=RHV,rep_platform=ARCH,summary=mySummary) BZ = str(BZ_Object.bug_id) print "Buzilla # = https://bugzilla.redhat.com/show_bug.cgi?id="+ BZ else: From 2e0aa20ded9bed2e6a3399d8e3e7f162b1d47fb0 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Fri, 9 Sep 2011 18:41:29 +0530 Subject: [PATCH 08/33] Added 2 files for CSV usage, also getAmiDetails_withCSV uses rhui_lib, polls and puts file on remote host, removes long sleeps --- src/getAmiDetails_withCSV.py | 314 +++++++++++++++++++++++++++++++++++ src/rhui_lib.py | 128 ++++++++++++++ 2 files changed, 442 insertions(+) create mode 100755 src/getAmiDetails_withCSV.py create mode 100755 src/rhui_lib.py diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py new file mode 100755 index 0000000..f1ec05a --- /dev/null +++ b/src/getAmiDetails_withCSV.py @@ -0,0 +1,314 @@ +#!/usr/bin/python -tt + +from pprint import pprint +from boto import ec2 +import boto, thread +import sys, time, optparse, os +import csv +#from boto.ec2.blockdevicemapping import BlockDeviceMapping +from boto.ec2.blockdevicemapping import EBSBlockDeviceType, BlockDeviceMapping +from bugzilla.bugzilla3 import Bugzilla36 +import rhui_lib + +#def main(argv): +# try: +# opts, args = getopt.getopt(argv, "hr:vb:a:", ["help","region", "version","bugzilla","ami-number"]) +# except getopt.GetoptError: +# usage() +# sys.exit(2) +CSVFILE = "test1.csv" +parser = optparse.OptionParser() + +desc="ami test script" + +parser.add_option('-c','--csv', dest='CSV', default=False, help='If set.. will use a csv file as an input') +parser.add_option('-r','--region', type='string', dest='REGION', help='specify ec2 region') +parser.add_option('-v','--RHEL_Version', type='string', dest='RHEL', help='RHEL version') +parser.add_option('-b', '--bugzilla_number', type='string', dest='BZ', help='optional bugzilla number') +parser.add_option('-a','--ami_number', type='string', dest='AMI', help='ami id number') +parser.add_option('-s','--ssh-key-path', type='string',dest='SSHKEY',help='full path to ssh key for the ec2 region') +parser.add_option('-k','--ssh-key-name', type='string',dest='SSHKEYNAME',help='name of the key pair') +parser.add_option('-i','--ec2-key', type='string',dest='AWS_ACCESS_KEY_ID',help='EC2 Access Key ID') +parser.add_option('-p','--ec2-secret-key', type='string',dest='AWS_SECRET_ACCESS_KEY',help='EC2 Secret Access Key ID') +parser.add_option('-y','--bugzilla_username', type='string',dest='BZUSER',help='bugzilla username') +parser.add_option('-z','--bugzilla_password', type='string',dest='BZPASS',help='bugzilla password') +parser.add_option('-m','--arch', dest='ARCH', default='x86_64', help='arch = i386, or x86_64') +parser.add_option('-x','--ignore', dest='IGNORE', default='IGNORE', help='If set.. ignore the generated bug') #c1.medium +parser.add_option('-g','--noGit',dest='NOGIT', default=False, help='If set.. do not pull valid src from git, scp to each instance' ) +parser.add_option('-d','--baseDir',dest='BASEDIR',type='string',help='the dir of the src checkout ie.. ~/workspace/valid/src') + + +(opts, args) = parser.parse_args() +AMI = opts.AMI +REGION = opts.REGION +RHEL = opts.RHEL +BZ = opts.BZ +SSHKEY = opts.SSHKEY +SSHKEYNAME = opts.SSHKEYNAME +AWS_ACCESS_KEY_ID = opts.AWS_ACCESS_KEY_ID +AWS_SECRET_ACCESS_KEY = opts.AWS_SECRET_ACCESS_KEY +BZUSER = opts.BZUSER +BZPASS = opts.BZPASS +ARCH = opts.ARCH +IGNORE = opts.IGNORE +NOGIT = opts.NOGIT +BASEDIR = opts.BASEDIR +CSV = opts.CSV + +if CSV: + mandatories = ['BASEDIR','AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'] + for m in mandatories: + if not opts.__dict__[m]: + print "mandatory option is missing\n" + parser.print_help() + exit(-1) +else: + mandatories = ['BASEDIR','AMI','REGION','SSHKEY','RHEL','AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'ARCH'] + for m in mandatories: + if not opts.__dict__[m]: + print "mandatory option is missing\n" + parser.print_help() + exit(-1) + +def addBugzilla(BZ, AMI, RHEL, ARCH, REGION): + if BZ is None: + print "**** No bugzilla # was passed, will open one here ****" + bugzilla=Bugzilla36(url='https://bugzilla.redhat.com/xmlrpc.cgi',user=BZUSER,password=BZPASS) + mySummary=AMI+" "+RHEL+" "+ARCH+" "+REGION + RHV = "RHEL"+RHEL + BZ_Object=bugzilla.createbug(product="Cloud Image Validation",component="images",version=RHV,rep_platform="x86_64",summary=mySummary) + BZ = str(BZ_Object.bug_id) + print "Buzilla # = https://bugzilla.redhat.com/show_bug.cgi?id="+ BZ + return BZ + else: + mySummary=AMI+" "+RHEL+" "+ARCH+" "+REGION + print "Already opened Buzilla # = https://bugzilla.redhat.com/show_bug.cgi?id="+ BZ + return BZ + + file = open('/tmp/bugzilla',"a") + file.write("\n") + file.write(BZ) + file.write("\t") + file.write(mySummary) + file.close() + os.system("cp "+BASEDIR+"/nohup.out "+BASEDIR+"/nohup_"+AMI+".out ; cat /dev/null > "+BASEDIR+"/nohup.out") + +if CSV is None: + BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) + + +def getConnection(key, secret, region): + """establish a connection with ec2""" + reg = boto.ec2.get_region(region, aws_access_key_id=key, aws_secret_access_key=secret) + return reg.connect(aws_access_key_id=key, aws_secret_access_key=secret) + +#east# reservation = ec2conn.run_instances('ami-8c8a7de5', instance_type='t1.micro', key_name='cloude-key') +#block_device_map +#'/dev/sda=:20' + +def startInstance(ec2connection, hardwareProfile, ARCH, RHEL, AMI, SSHKEYNAME): + conn_region = ec2connection + map = BlockDeviceMapping() + t = EBSBlockDeviceType() + t.size = '15' + #map = {'DeviceName':'/dev/sda','VolumeSize':'15'} + map['/dev/sda1'] = t + + #blockDeviceMap = [] + #blockDeviceMap.append( {'DeviceName':'/dev/sda', 'Ebs':{'VolumeSize' : '100'} }) + + if ARCH == 'i386' and RHEL == '6.1': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'x86_64' and RHEL == '6.1': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'i386': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'x86_64': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map) + else: + print "arch type is neither i386 or x86_64.. will exit" + exit(1) + + myinstance = reservation.instances[0] + + time.sleep(5) + while(not myinstance.update() == 'running'): + time.sleep(5) + print myinstance.update() + + instanceDetails = myinstance.__dict__ + pprint(instanceDetails) + #region = instanceDetails['placement'] + #print 'region =' + region + publicDNS = instanceDetails['public_dns_name'] + print 'public hostname = ' + publicDNS + # check for console output here to make sure ssh is up + return publicDNS + +def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): + filepath = BASEDIR + serverpath = "/root/valid" + commandPath = "/root/valid/src" + + if NOGIT: + time.sleep(5) + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") + print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" + os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) + else: + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" yum -y install git") + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" git clone git://github.com/weshayutin/valid.git") + + # COPY KERNEL if there + serverpath = "/root/kernel" + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/kernel") + if ARCH == 'i386': + filepath = BASEDIR+"/kernel/i386/*" + print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" + os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) + if ARCH == 'x86_64': + filepath = BASEDIR+"/kernel/x86_64/*" + print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" + os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) + + + +# command = commandPath+"/image_validation.sh --imageID="+IGNORE+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"] + command = commandPath+"/image_validation.sh --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS + + print "nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command + print "" + os.system("nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command) + + + +def printValues(hwp): + print "+++++++" + print AMI + print REGION + print SSHKEY + print RHEL + print hwp + print "+++++++\n" + +def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): + #entering critical section + lock.acquire() + print string," Now Sleeping after Lock acquired for ",sleeptime + time.sleep(sleeptime) + + print string," Now releasing lock and then sleeping again" + lock.release() + + #exiting critical section + time.sleep(sleeptime) # why? + +# Define hwp +m1Small = {"name":"m1.small","memory":"1700000","cpu":"1","arch":"i386"} +m1Large = {"name":"m1.large","memory":"7500000","cpu":"2","arch":"x86_64"} +m1Xlarge = {"name":"m1.xlarge","memory":"15000000","cpu":"4","arch":"x86_64"} +t1Micro = {"name":"t1.micro","memory":"600000","cpu":"1","arch":"both"} +m2Xlarge = {"name":"m2.2xlarge","memory":"17100000","cpu":"2","arch":"x86_64"} +m22Xlarge = {"name":"m2.2xlarge","memory":"34200000","cpu":"4","arch":"x86_64"} +m24Xlarge = {"name":"m2.4xlarge","memory":"68400000","cpu":"8","arch":"x86_64"} +c1Medium = {"name":"c1.medium","memory":"1700000","cpu":"2","arch":"i386"} +c1Xlarge = {"name":"c1.xlarge","memory":"7000000","cpu":"8","arch":"x86_64"} + + +#Use all hwp types for ec2 memory tests, other hwp tests +hwp_i386 = [c1Medium, t1Micro , m1Small ] +#hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge , m22Xlarge , m24Xlarge , c1Xlarge] +hwp_x86_64 = [m1Large , m1Xlarge] + +#Use just one hwp for os tests +#hwp_i386 = [c1Medium] +#hwp_x86_64 = [m1Xlarge,m22Xlarge] +if CSV: + reader = csv.reader(open(CSVFILE,"rb")) + fields = reader.next() + ami = [(row[0], row[1], row[2], row[3], row[4], row[5]) for row in reader] + for x in range(len(ami)): + myRow = ami[x] + print myRow + ARCH = myRow[0] + REGION = myRow[1] + RHEL = myRow[2] +# BZ = myRow[3] + AMI = myRow[5] + + BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) + + if REGION == "us-east-1": + SSHKEY = "/home/kbidarka/cloud-keyuseast-new.pem" + SSHKEYNAME = "cloud-keyuseast-new" + elif REGION == "us-west-1": + SSHKEY = "/home/kbidarka/cloud-keyuswest-new.pem" + SSHKEYNAME = "cloud-keyuswest-new" + elif REGION == "eu-west-1": + SSHKEY = "/home/kbidarka/cloud-keyeuwest-new.pem" + SSHKEYNAME = "cloud-keyeuwest-new" + elif REGION == "ap-southeast-1": + SSHKEY = "/home/kbidarka/cloud-keyapnorth-new.pem" + SSHKEYNAME = "cloud-keyapnorth-new" + elif REGION == "ap-northeast-1": + SSHKEY = "/home/kbidarka/cloud-keyapsouth-new.pem" + SSHKEYNAME = "cloud-keyapsouth-new" + + + publicDNS = [] + if ARCH == 'i386': + for hwp in hwp_i386: + printValues(hwp) + myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) + this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME) + map = {"hostname":this_hostname,"hwp":hwp} + publicDNS.append(map) + elif ARCH == 'x86_64': + for hwp in hwp_x86_64: + printValues(hwp) + myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) + this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME) + map = {"hostname":this_hostname,"hwp":hwp} + publicDNS.append(map) + + lock = thread.allocate_lock() +# print "sleep for 130 seconds" +# time.sleep(130) + print "Trying to fetch a file to make sure the SSH works, before proceeding ahead." + f_path = "/tmp/network" + l_path = "/etc/init.d/network" + for host in publicDNS: + keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path) + if not keystat: + executeValidScript(SSHKEY, host["hostname"], host["hwp"], BID, ARCH, AMI, REGION, RHEL) + else: + print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" +else: + publicDNS = [] + if ARCH == 'i386': + for hwp in hwp_i386: + printValues(hwp) + myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) + this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME) + map = {"hostname":this_hostname,"hwp":hwp} + publicDNS.append(map) + elif ARCH == 'x86_64': + for hwp in hwp_x86_64: + printValues(hwp) + myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) + this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME) + map = {"hostname":this_hostname,"hwp":hwp} + publicDNS.append(map) + + lock = thread.allocate_lock() +# print "sleep for 130 seconds" +# time.sleep(130) + print "Trying to fetch a file and make sure the SSH works, before proceeding ahead." + f_path = "/tmp/network" + l_path = "/etc/init.d/network" + for host in publicDNS: + keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path) + if not keystat: + executeValidScript(SSHKEY, host["hostname"],host["hwp"], BID, ARCH, AMI, REGION, RHEL) + else: + print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" diff --git a/src/rhui_lib.py b/src/rhui_lib.py new file mode 100755 index 0000000..e170d4c --- /dev/null +++ b/src/rhui_lib.py @@ -0,0 +1,128 @@ +try: + import paramiko +except ImportError: + print "Sorry, you don't have the paramiko module installed, and this" + print "script relies on it. Please install or reconfigure paramiko" + print "and try again." + +import re +import os +import sys +import time + + +#def putfile(hostname, pkey_file, localpath, filepath): +# username = 'root' +# key = paramiko.RSAKey.from_private_key_file(pkey_file) +# tr = paramiko.Transport((hostname, 22)) +# tr.connect(username=username, pkey=key) +# sftp = paramiko.SFTPClient.from_transport(tr) +# print "\n\nPlease wait, Trying to upload the file ", localpath, " to hostname : ", hostname +# sftp.put(localpath,filepath) +# print "Uploading the file : ", localpath, " to ", hostname, " completed" +# sftp.close() +# tr.close() + +def putfile(hostname, pkey_file, localpath, filepath): + username = 'root' + num = 7 + while num > 1: + try: + key = paramiko.RSAKey.from_private_key_file(pkey_file) + tr = paramiko.Transport((hostname, 22)) + tr.connect(username=username, pkey=key) + sftp = paramiko.SFTPClient.from_transport(tr) + break + except: + print "\n\nError, re-trying in 30 secs" + print "The Hostname is :", hostname + print "The key is :", pkey_file + print "The Local and REmote path is :", localpath, " ", filepath + num = num - 1 + print "Number of attempts left", num + time.sleep(30) + continue + if num == 1: + return 1 + print "\n\nPlease wait, Trying to upload the file ", localpath, " to hostname : ", hostname + sftp.put(localpath,filepath) + print "Uploading the file : ", localpath, " to ", hostname, " completed" + sftp.close() + tr.close() + + +#def getfile(hostname, pkey_file, localpath, filepath): +# username = 'root' +# key = paramiko.RSAKey.from_private_key_file(pkey_file) +# tr = paramiko.Transport((hostname, 22)) +# tr.connect(username=username, pkey=key) +# sftp = paramiko.SFTPClient.from_transport(tr) +# print "\n\nPlease wait, Trying to download the file ", filepath, " from hostname : ", hostname +# sftp.get(filepath,localpath) +# print "Downloading the file : ", filepath, " from ", hostname, " completed" +# sftp.close() +# tr.close() + + +def getfile(hostname, pkey_file, localpath, filepath): + username = 'root' + num = 7 + while num > 1: + try: + key = paramiko.RSAKey.from_private_key_file(pkey_file) + tr = paramiko.Transport((hostname, 22)) + tr.connect(username=username, pkey=key) + sftp = paramiko.SFTPClient.from_transport(tr) + break + except: + print "\nError, re-trying in 30 secs" + print "\nThe Hostname is :", hostname + print "\nThe key is :", pkey_file + print "\nThe Local and Remote path is :", localpath, " ", filepath + num = num - 1 + print "Number of attempts left", num + time.sleep(30) + continue + if num == 1: + return 1 + print "\n\nPlease wait, Trying to download the file ", filepath, " from hostname : ", hostname + sftp.get(filepath,localpath) + print "Downloading the file : ", filepath, " from ", hostname, " completed" + sftp.close() + tr.close() + +def remote_exe(hostname, pkey_file, cmd): + user = 'root' + key = paramiko.RSAKey.from_private_key_file(pkey_file) + s = paramiko.SSHClient() + s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + s.connect(hostname, username=user, pkey=key) + stdin, stdout, stderr = s.exec_command(cmd) + print stdout.read() + s.close() + +def answers_replace(stext, dtext, input_file): + print "\nReplacing", stext, " with ", dtext, "in file : ", input_file + data = open(input_file).read() + o = open(input_file,"w") + o.write( re.sub(stext, dtext ,data) ) + o.close() + +def chek_files(fil_list, lis_sz): + print "\n\nChecking for the pre-requisites : \n" + home_dir = os.path.expanduser("~") + file_not = [] + for kde in range(lis_sz): + file = home_dir + "/" + fil_list[kde] + stat = os.path.exists(file) + if stat == False: + file_not.append(file) + elif stat == True: + print file + " : Present" + + if file_not: + print "\n\nFollowing files are not present in your home-directory : \n" + for disp in file_not: + print disp + print "\nPlease include the above files." + sys.exit() From feb2a540aec706bced466de783b313c033a59d87 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Mon, 12 Sep 2011 17:07:35 +0530 Subject: [PATCH 09/33] Added Install wget, validate signature for fetch_host_details function --- src/getAmiDetails_withCSV.py | 10 +++++----- src/testlib.sh | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index f1ec05a..2714df9 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -34,7 +34,7 @@ parser.add_option('-z','--bugzilla_password', type='string',dest='BZPASS',help='bugzilla password') parser.add_option('-m','--arch', dest='ARCH', default='x86_64', help='arch = i386, or x86_64') parser.add_option('-x','--ignore', dest='IGNORE', default='IGNORE', help='If set.. ignore the generated bug') #c1.medium -parser.add_option('-g','--noGit',dest='NOGIT', default=False, help='If set.. do not pull valid src from git, scp to each instance' ) +parser.add_option('-g','--noGit',dest='NOGIT', default=True, help='If set.. do not pull valid src from git, scp to each instance' ) parser.add_option('-d','--baseDir',dest='BASEDIR',type='string',help='the dir of the src checkout ie.. ~/workspace/valid/src') @@ -217,8 +217,8 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): #Use all hwp types for ec2 memory tests, other hwp tests hwp_i386 = [c1Medium, t1Micro , m1Small ] -#hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge , m22Xlarge , m24Xlarge , c1Xlarge] -hwp_x86_64 = [m1Large , m1Xlarge] +hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge , m22Xlarge , m24Xlarge , c1Xlarge] +#hwp_x86_64 = [m1Large , m1Xlarge] #Use just one hwp for os tests #hwp_i386 = [c1Medium] @@ -232,8 +232,8 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): print myRow ARCH = myRow[0] REGION = myRow[1] - RHEL = myRow[2] -# BZ = myRow[3] + RHEL = myRow[4] + BZ = myRow[3] AMI = myRow[5] BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) diff --git a/src/testlib.sh b/src/testlib.sh index 10ac2d5..6b5f50b 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -162,6 +162,7 @@ function print_rhel_version() function test_fetch_host_details() { + yum install -y wget > /dev/null BP_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i billingProducts | gawk -F":" '{print $NF}' | gawk -F"\"" '{print $2}'` if [ $BP_ID == "bp-6fa54006" ]; then HOSTNAME=`hostname` @@ -170,9 +171,11 @@ function test_fetch_host_details() INS_TYP=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceType | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` ARCH=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i architecture | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` REG=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i zone | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + SIGN1=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/signature` new_test "Fetching Host Details " echo "This Host => $PUB_DNS with Image Id : $IMG_ID, is launched with Instance Id : $INS_ID , Instance Type : $INS_TYP and Arch : $ARCH in the Region : $REG" >> $LOGFILE echo "This is a Hourly image" >> $LOGFILE + echo "The Validate Signature is : $SIGN1" >> $LOGFILE else new_test "Fetching Host Details " echo "This is not a Hourly image" >> $LOGFILE From e65f136648699958cffecee4494130545527276c Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Mon, 12 Sep 2011 18:38:01 +0530 Subject: [PATCH 10/33] Changed 13G to 15G for resize2fs --- src/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib.sh b/src/testlib.sh index 6b5f50b..32982f7 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -753,7 +753,7 @@ function test_resize2fs() rc "resize2fs -p /dev/sda1 15000M" fi sleep 10 - assert "df -h | grep 13G | wc -l " 1 + assert "df -h | grep 15G | wc -l " 1 } function installTestKernel() From 3c86318a5b5beac4a0c6ba7f805feba17ef0b5fe Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Tue, 13 Sep 2011 12:21:13 +0530 Subject: [PATCH 11/33] Modified m2xlarge hwp profile --- src/getAmiDetails_withCSV.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index 2714df9..4edfe29 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -208,7 +208,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): m1Large = {"name":"m1.large","memory":"7500000","cpu":"2","arch":"x86_64"} m1Xlarge = {"name":"m1.xlarge","memory":"15000000","cpu":"4","arch":"x86_64"} t1Micro = {"name":"t1.micro","memory":"600000","cpu":"1","arch":"both"} -m2Xlarge = {"name":"m2.2xlarge","memory":"17100000","cpu":"2","arch":"x86_64"} +m2Xlarge = {"name":"m2.xlarge","memory":"17100000","cpu":"2","arch":"x86_64"} m22Xlarge = {"name":"m2.2xlarge","memory":"34200000","cpu":"4","arch":"x86_64"} m24Xlarge = {"name":"m2.4xlarge","memory":"68400000","cpu":"8","arch":"x86_64"} c1Medium = {"name":"c1.medium","memory":"1700000","cpu":"2","arch":"i386"} @@ -217,7 +217,8 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): #Use all hwp types for ec2 memory tests, other hwp tests hwp_i386 = [c1Medium, t1Micro , m1Small ] -hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge , m22Xlarge , m24Xlarge , c1Xlarge] +#hwp_i386 = [c1Medium] +hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge, m22Xlarge, m24Xlarge , c1Xlarge] #hwp_x86_64 = [m1Large , m1Xlarge] #Use just one hwp for os tests From 1b09941162d86e60b43301567263c79bebb93738 Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Tue, 13 Sep 2011 16:59:23 -0400 Subject: [PATCH 12/33] fixed firstboot title --- src/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib.sh b/src/testlib.sh index 32982f7..27c5ba5 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -471,7 +471,7 @@ function test_cloud-firstboot() if [ $RHELV == 6.0 ]; then echo "WAIVED TESTS FOR BUGZILLA 704821" else - new_test "## Verify rh-cloud-firstboot is on ... " + new_test "## Verify rh-cloud-firstboot is OFF ... " assert "chkconfig --list | grep rh-cloud | grep 3:off | wc -l" "1" if [ -f /etc/sysconfig/rh-cloud-firstboot ]; then echo "/etc/sysconfig/rh-cloud-firstboot FOUND" >> $LOGFILE From 58b37b9781ccc2b807b177919e8d5495edfb43bb Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Wed, 14 Sep 2011 14:25:19 +0530 Subject: [PATCH 13/33] added imageid to postreboot, modified resize2fs, swap functions for 729586 bug, done needed changes for verify bugzilla --- src/getAmiDetails_withCSV.py | 4 ++-- src/image_validation_postreboot.sh | 3 ++- src/testlib.sh | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index 4edfe29..6f33621 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -219,7 +219,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): hwp_i386 = [c1Medium, t1Micro , m1Small ] #hwp_i386 = [c1Medium] hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge, m22Xlarge, m24Xlarge , c1Xlarge] -#hwp_x86_64 = [m1Large , m1Xlarge] +#hwp_x86_64 = [c1Xlarge] #Use just one hwp for os tests #hwp_i386 = [c1Medium] @@ -234,7 +234,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): ARCH = myRow[0] REGION = myRow[1] RHEL = myRow[4] - BZ = myRow[3] +# BZ = myRow[3] AMI = myRow[5] BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) diff --git a/src/image_validation_postreboot.sh b/src/image_validation_postreboot.sh index 0bfb837..249cddd 100755 --- a/src/image_validation_postreboot.sh +++ b/src/image_validation_postreboot.sh @@ -118,7 +118,8 @@ print_rhel_version ### DONT REMOVE OR COMMENT OUT ### show_failures -bugzilla_comments() +sleep 360 +bugzilla_comments verify_bugzilla #sos_report im_exit diff --git a/src/testlib.sh b/src/testlib.sh index 32982f7..d64d67c 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -434,6 +434,9 @@ function test_swap_file() new_test "## Verify turning on/off swap file ... " if [ $UNAMEI == "i386" ]; then swap=`cat swap_partitions` + fst=`cat /etc/fstab | grep swap | awk '{print $1}'` + [ $swap != $fst ] && [ -b /dev/xvde3] && sed -i 's/\/dev\/xvda3/\/dev\/xvde3/' /etc/fstab + [ $swap != $fst ] && [ -b /dev/xvda3] && sed -i 's/\/dev\/xvde3/\/dev\/xvda3/' /etc/fstab assert "/sbin/swapoff $swap && /sbin/swapon $swap" fi @@ -747,7 +750,8 @@ function test_resize2fs() { new_test "## Verify resize2fs ... " if [ $RHEL == 6 ] ; then - rc "resize2fs -p /dev/xvde1 15000M" + [ -b /dev/xvde1 ] && rc "resize2fs -p /dev/xvde1 15000M" + [ -b /dev/xvda1 ] && rc "resize2fs -p /dev/xvda1 15000M" fi if [ $RHEL == 5 ] ; then rc "resize2fs -p /dev/sda1 15000M" @@ -873,7 +877,7 @@ function setup_rc.local() { echo "####################### cat of /etc/rc.local ##################" >> $LOGFILE echo "cd /root/valid/src" >> /etc/rc.local - echo "./image_validation_postreboot.sh --imageID=asdf --RHEL=$RHELV --full-yum-suite=no --skip-questions=yes --bugzilla-username=$BUG_USERNAME --bugzilla-password=$BUG_PASSWORD --bugzilla-num=$BUGZILLA --failures=$FAILURES --memory=$MEM_HWP >> /var/log/messages" >> /etc/rc.local + echo "./image_validation_postreboot.sh --imageID=${IMAGEID} --RHEL=$RHELV --full-yum-suite=no --skip-questions=yes --bugzilla-username=$BUG_USERNAME --bugzilla-password=$BUG_PASSWORD --bugzilla-num=$BUGZILLA --failures=$FAILURES --memory=$MEM_HWP >> /var/log/messages" >> /etc/rc.local cat /etc/rc.local >> $LOGFILE echo "####################### cat of /etc/rc.local ##################" >> $LOGFILE From 329d506fcc9ac9fd992749a6cc51b9bd0d8e39a9 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Wed, 14 Sep 2011 15:45:28 +0530 Subject: [PATCH 14/33] added open bugzilla function to postreboot --- src/image_validation_postreboot.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/image_validation_postreboot.sh b/src/image_validation_postreboot.sh index 249cddd..583bfa8 100755 --- a/src/image_validation_postreboot.sh +++ b/src/image_validation_postreboot.sh @@ -119,6 +119,7 @@ print_rhel_version ### DONT REMOVE OR COMMENT OUT ### show_failures sleep 360 +open_bugzilla bugzilla_comments verify_bugzilla #sos_report From 24a2a9be558609a3218e482b9fd03fda49f1df4a Mon Sep 17 00:00:00 2001 From: Sachin Ghai Date: Wed, 14 Sep 2011 17:02:31 +0530 Subject: [PATCH 15/33] Removed sleep from resize2fs --- src/testlib.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/testlib.sh b/src/testlib.sh index 5e78a24..d30624a 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -756,7 +756,6 @@ function test_resize2fs() if [ $RHEL == 5 ] ; then rc "resize2fs -p /dev/sda1 15000M" fi - sleep 10 assert "df -h | grep 15G | wc -l " 1 } From 9e839aa9a39989ccef1966cff63d95d9670b125a Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Wed, 14 Sep 2011 19:35:42 +0530 Subject: [PATCH 16/33] if t1.micro no swap tests, after yum update reset default --- src/getAmiDetails_withCSV.py | 8 +++++++- src/image_validation.sh | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index 6f33621..bcbc456 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -150,12 +150,18 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): serverpath = "/root/valid" commandPath = "/root/valid/src" + if NOGIT: time.sleep(5) - os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") + if hwp["name"] == 't1.imcro': + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid ; touch /root/noswap") + else: + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) else: + if hwp["name"] == 't1.imcro': + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" yum -y install git") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" git clone git://github.com/weshayutin/valid.git") diff --git a/src/image_validation.sh b/src/image_validation.sh index b742922..769a450 100755 --- a/src/image_validation.sh +++ b/src/image_validation.sh @@ -125,7 +125,7 @@ echo "" test_uname test_disk_format test_disk_size -test_swap_file +[ ! -f /root/noswap ] && test_swap_file || echo "t1.micro doesn't require swap" test_selinux test_package_set test_verify_rpms @@ -163,6 +163,7 @@ test_fetch_host_details show_failures open_bugzilla bugzilla_comments +sed -i 's/default=1/default=0/' /boot/grub/grub.conf setup_rc.local #sos_report echo "REBOOTING" From ff818b78405b52e8995b7b63402a3edf12f094ff Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Wed, 14 Sep 2011 20:41:26 +0530 Subject: [PATCH 17/33] rectified improper if else syntax --- src/getAmiDetails_withCSV.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index bcbc456..cf599a8 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -155,7 +155,7 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): time.sleep(5) if hwp["name"] == 't1.imcro': os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid ; touch /root/noswap") - else: + else: os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) From ac558eae893dfa017c725f6f82a5e9058c4b385d Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Thu, 15 Sep 2011 00:19:58 +0530 Subject: [PATCH 18/33] t1.micro rectified --- src/getAmiDetails_withCSV.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index cf599a8..1e7d74f 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -153,14 +153,15 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): if NOGIT: time.sleep(5) - if hwp["name"] == 't1.imcro': - os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid ; touch /root/noswap") + if hwp["name"] == 't1.micro': + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") else: os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) else: - if hwp["name"] == 't1.imcro': + if hwp["name"] == 't1.micro': os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" yum -y install git") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" git clone git://github.com/weshayutin/valid.git") From b93fbc1be59f9aef27f5f81944107aeb90af891b Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Tue, 27 Sep 2011 15:13:38 +0530 Subject: [PATCH 19/33] modified fetch_host_details function, to verify cloud access ami's --- src/testlib.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/testlib.sh b/src/testlib.sh index d30624a..be76176 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -172,13 +172,26 @@ function test_fetch_host_details() ARCH=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i architecture | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` REG=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i zone | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` SIGN1=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/signature` + [ ! -z SIGN1 ] && SIGNAT=1 || SIGNAT=0 + assert "echo $SIGNAT" "1" new_test "Fetching Host Details " echo "This Host => $PUB_DNS with Image Id : $IMG_ID, is launched with Instance Id : $INS_ID , Instance Type : $INS_TYP and Arch : $ARCH in the Region : $REG" >> $LOGFILE echo "This is a Hourly image" >> $LOGFILE echo "The Validate Signature is : $SIGN1" >> $LOGFILE - else + elif [ $BP_ID == "bp-63a5400a" ]; then + HOSTNAME=`hostname` + INS_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + IMG_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i imageId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + INS_TYP=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceType | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + ARCH=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i architecture | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + REG=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i zone | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + SIGN1=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/signature` + [ ! -z SIGN1 ] && SIGNAT=1 || SIGNAT=0 + assert "echo $SIGNAT" "1" new_test "Fetching Host Details " - echo "This is not a Hourly image" >> $LOGFILE + echo "This Host => $PUB_DNS with Image Id : $IMG_ID, is launched with Instance Id : $INS_ID , Instance Type : $INS_TYP and Arch : $ARCH in the Region : $REG" >> $LOGFILE + echo "This is a Cloud Access image" >> $LOGFILE + echo "The Validate Signature is : $SIGN1" >> $LOGFILE fi } From 49cf0cc398a68dc06068848883925a0aafcab3a9 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Fri, 7 Oct 2011 17:27:28 +0530 Subject: [PATCH 20/33] The script now uses validation.cfg file instead of cli arg, added further tests for identity doc --- src/getAmiDetails_withCSV.py | 136 ++++++++++++++--------------- src/image_validation.sh | 8 ++ src/image_validation_postreboot.sh | 1 - src/testlib.sh | 43 ++++----- 4 files changed, 95 insertions(+), 93 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index 1e7d74f..47c8dbf 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -9,6 +9,7 @@ from boto.ec2.blockdevicemapping import EBSBlockDeviceType, BlockDeviceMapping from bugzilla.bugzilla3 import Bugzilla36 import rhui_lib +import ConfigParser #def main(argv): # try: @@ -16,59 +17,59 @@ # except getopt.GetoptError: # usage() # sys.exit(2) -CSVFILE = "test1.csv" -parser = optparse.OptionParser() +config = ConfigParser.ConfigParser() +config.read('/etc/validation.cfg') -desc="ami test script" +SSHKEY_NAME_AP_S = config.get('SSH-Info', 'ssh-key-name_apsouth') +SSHKEY_AP_S = config.get('SSH-Info', 'ssh-key-path_apsouth') +SSHKEY_NAME_AP_N = config.get('SSH-Info', 'ssh-key-name_apnorth') +SSHKEY_AP_N = config.get('SSH-Info', 'ssh-key-path_apnorth') +SSHKEY_NAME_EU_W = config.get('SSH-Info', 'ssh-key-name_euwest') +SSHKEY_EU_W = config.get('SSH-Info', 'ssh-key-path_euwest') +SSHKEY_NAME_US_W = config.get('SSH-Info', 'ssh-key-name_uswest') +SSHKEY_US_W = config.get('SSH-Info', 'ssh-key-path_uswest') +SSHKEY_NAME_US_E = config.get('SSH-Info', 'ssh-key-name_useast') +SSHKEY_US_E = config.get('SSH-Info', 'ssh-key-path_useast') -parser.add_option('-c','--csv', dest='CSV', default=False, help='If set.. will use a csv file as an input') -parser.add_option('-r','--region', type='string', dest='REGION', help='specify ec2 region') -parser.add_option('-v','--RHEL_Version', type='string', dest='RHEL', help='RHEL version') -parser.add_option('-b', '--bugzilla_number', type='string', dest='BZ', help='optional bugzilla number') -parser.add_option('-a','--ami_number', type='string', dest='AMI', help='ami id number') -parser.add_option('-s','--ssh-key-path', type='string',dest='SSHKEY',help='full path to ssh key for the ec2 region') -parser.add_option('-k','--ssh-key-name', type='string',dest='SSHKEYNAME',help='name of the key pair') -parser.add_option('-i','--ec2-key', type='string',dest='AWS_ACCESS_KEY_ID',help='EC2 Access Key ID') -parser.add_option('-p','--ec2-secret-key', type='string',dest='AWS_SECRET_ACCESS_KEY',help='EC2 Secret Access Key ID') -parser.add_option('-y','--bugzilla_username', type='string',dest='BZUSER',help='bugzilla username') -parser.add_option('-z','--bugzilla_password', type='string',dest='BZPASS',help='bugzilla password') -parser.add_option('-m','--arch', dest='ARCH', default='x86_64', help='arch = i386, or x86_64') -parser.add_option('-x','--ignore', dest='IGNORE', default='IGNORE', help='If set.. ignore the generated bug') #c1.medium -parser.add_option('-g','--noGit',dest='NOGIT', default=True, help='If set.. do not pull valid src from git, scp to each instance' ) -parser.add_option('-d','--baseDir',dest='BASEDIR',type='string',help='the dir of the src checkout ie.. ~/workspace/valid/src') +BZUSER = config.get('Bugzilla-Info', 'bugzilla_usr') +BZPASS = config.get('Bugzilla-Info', 'bugzilla_pwd') +AWS_ACCESS_KEY_ID = config.get('EC2-Keys', 'ec2-key') +AWS_SECRET_ACCESS_KEY = config.get('EC2-Keys', 'ec2-secret-key') -(opts, args) = parser.parse_args() -AMI = opts.AMI -REGION = opts.REGION -RHEL = opts.RHEL -BZ = opts.BZ -SSHKEY = opts.SSHKEY -SSHKEYNAME = opts.SSHKEYNAME -AWS_ACCESS_KEY_ID = opts.AWS_ACCESS_KEY_ID -AWS_SECRET_ACCESS_KEY = opts.AWS_SECRET_ACCESS_KEY -BZUSER = opts.BZUSER -BZPASS = opts.BZPASS -ARCH = opts.ARCH -IGNORE = opts.IGNORE -NOGIT = opts.NOGIT -BASEDIR = opts.BASEDIR -CSV = opts.CSV +CSV = config.get('Misc-Info', 'csv') +NOGIT = config.get('Misc-Info', 'git') +BASEDIR = config.get('Misc-Info', 'basedir') -if CSV: - mandatories = ['BASEDIR','AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'] - for m in mandatories: - if not opts.__dict__[m]: - print "mandatory option is missing\n" - parser.print_help() - exit(-1) -else: - mandatories = ['BASEDIR','AMI','REGION','SSHKEY','RHEL','AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'ARCH'] - for m in mandatories: - if not opts.__dict__[m]: - print "mandatory option is missing\n" - parser.print_help() - exit(-1) +BZ = None + +val1 = { + 'SSHKEY_US_E': SSHKEY_US_E, + 'SSHKEY_NAME_US_E': SSHKEY_NAME_US_E, + 'SSHKEY_US_W': SSHKEY_US_W, + 'SSHKEY_NAME_US_W': SSHKEY_NAME_US_W, + 'SSHKEY_EU_W': SSHKEY_EU_W, + 'SSHKEY_NAME_EU_W': SSHKEY_NAME_EU_W, + 'SSHKEY_AP_N': SSHKEY_AP_N, + 'SSHKEY_NAME_AP_N': SSHKEY_NAME_AP_N, + 'SSHKEY_AP_S': SSHKEY_AP_S, + 'SSHKEY_NAME_AP_S': SSHKEY_NAME_AP_S, + 'BZUSER': BZUSER, + 'BZPASS': BZPASS, + 'AWS_ACCESS_KEY_ID': AWS_ACCESS_KEY_ID, + 'AWS_SECRET_ACCESS_KEY': AWS_SECRET_ACCESS_KEY, + 'CSV': CSV, + 'NOGIT': NOGIT, + 'BASEDIR': BASEDIR, +} + +for v in val1: + if not val1[v]: + print "The value ", v, "is missing in .cfg file." + sys.exit() + +CSVFILE = "test1.csv" +parser = optparse.OptionParser() def addBugzilla(BZ, AMI, RHEL, ARCH, REGION): if BZ is None: @@ -76,14 +77,14 @@ def addBugzilla(BZ, AMI, RHEL, ARCH, REGION): bugzilla=Bugzilla36(url='https://bugzilla.redhat.com/xmlrpc.cgi',user=BZUSER,password=BZPASS) mySummary=AMI+" "+RHEL+" "+ARCH+" "+REGION RHV = "RHEL"+RHEL - BZ_Object=bugzilla.createbug(product="Cloud Image Validation",component="images",version=RHV,rep_platform="x86_64",summary=mySummary) + BZ_Object=bugzilla.createbug(product="Cloud Image Validation",component="images",version=RHV,rep_platform=ARCH,summary=mySummary) BZ = str(BZ_Object.bug_id) print "Buzilla # = https://bugzilla.redhat.com/show_bug.cgi?id="+ BZ return BZ else: - mySummary=AMI+" "+RHEL+" "+ARCH+" "+REGION + mySummary=AMI+" "+RHEL+" "+ARCH+" "+REGION print "Already opened Buzilla # = https://bugzilla.redhat.com/show_bug.cgi?id="+ BZ - return BZ + return BZ file = open('/tmp/bugzilla',"a") file.write("\n") @@ -93,7 +94,7 @@ def addBugzilla(BZ, AMI, RHEL, ARCH, REGION): file.close() os.system("cp "+BASEDIR+"/nohup.out "+BASEDIR+"/nohup_"+AMI+".out ; cat /dev/null > "+BASEDIR+"/nohup.out") -if CSV is None: +if CSV == 'false': BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) @@ -151,16 +152,15 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): commandPath = "/root/valid/src" - if NOGIT: - time.sleep(5) + if NOGIT == 'false': if hwp["name"] == 't1.micro': os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") - else: + else: os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) - else: + elif NOGIT == 'true': if hwp["name"] == 't1.micro': os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" yum -y install git") @@ -181,7 +181,7 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): # command = commandPath+"/image_validation.sh --imageID="+IGNORE+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"] - command = commandPath+"/image_validation.sh --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS + command = commandPath+"/image_validation.sh --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS+" --ami-id="+AMI+" --arch-id="+ARCH print "nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command print "" @@ -231,7 +231,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): #Use just one hwp for os tests #hwp_i386 = [c1Medium] #hwp_x86_64 = [m1Xlarge,m22Xlarge] -if CSV: +if CSV == 'true': reader = csv.reader(open(CSVFILE,"rb")) fields = reader.next() ami = [(row[0], row[1], row[2], row[3], row[4], row[5]) for row in reader] @@ -247,20 +247,20 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) if REGION == "us-east-1": - SSHKEY = "/home/kbidarka/cloud-keyuseast-new.pem" - SSHKEYNAME = "cloud-keyuseast-new" + SSHKEY = SSHKEY_US_E + SSHKEYNAME = SSHKEY_NAME_US_E elif REGION == "us-west-1": - SSHKEY = "/home/kbidarka/cloud-keyuswest-new.pem" - SSHKEYNAME = "cloud-keyuswest-new" + SSHKEY = SSHKEY_US_W + SSHKEYNAME = SSHKEY_NAME_US_W elif REGION == "eu-west-1": - SSHKEY = "/home/kbidarka/cloud-keyeuwest-new.pem" - SSHKEYNAME = "cloud-keyeuwest-new" + SSHKEY = SSHKEY_EU_W + SSHKEYNAME = SSHKEY_NAME_EU_W elif REGION == "ap-southeast-1": - SSHKEY = "/home/kbidarka/cloud-keyapnorth-new.pem" - SSHKEYNAME = "cloud-keyapnorth-new" + SSHKEY = SSHKEY_AP_S + SSHKEYNAME = SSHKEY_NAME_AP_S elif REGION == "ap-northeast-1": - SSHKEY = "/home/kbidarka/cloud-keyapsouth-new.pem" - SSHKEYNAME = "cloud-keyapsouth-new" + SSHKEY = SSHKEY_AP_N + SSHKEYNAME = SSHKEY_NAME_AP_N publicDNS = [] diff --git a/src/image_validation.sh b/src/image_validation.sh index 769a450..bb4c3b7 100755 --- a/src/image_validation.sh +++ b/src/image_validation.sh @@ -38,6 +38,8 @@ function usage() echo "--bugzilla-num :: If a bug has already been opened you can specify the number here " echo "--memory :: Minium total memory the system *should* have available" echo "--public-dns :: The Public-DNS Host name of the machine" + echo "--ami-id :: The AMI ID" + echo "--arch-id :: The Architecture i386 or x86_64 for the launched instance" } @@ -78,6 +80,12 @@ for i in $* --public-dns=*) PUB_DNS="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" ;; + --ami-id=*) + AMI_ID="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" + ;; + --arch-id=*) + ARCH_ID="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" + ;; *) # unknown option usage diff --git a/src/image_validation_postreboot.sh b/src/image_validation_postreboot.sh index 583bfa8..3fa3f02 100755 --- a/src/image_validation_postreboot.sh +++ b/src/image_validation_postreboot.sh @@ -111,7 +111,6 @@ echo "" test_yum_plugin test_uname test_memory -test_fetch_host_details print_rhel_version #installTestKernel diff --git a/src/testlib.sh b/src/testlib.sh index be76176..62103cc 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -164,34 +164,29 @@ function test_fetch_host_details() { yum install -y wget > /dev/null BP_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i billingProducts | gawk -F":" '{print $NF}' | gawk -F"\"" '{print $2}'` + INS_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + IMG_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i imageId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + INS_TYP=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceType | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + ARCH=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i architecture | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + REG=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i zone | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` + SIGN1=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/signature` + new_test "Fetching the identity doc Details" + echo "Verifying that signature exists" >> $LOGFILE + [ ! -z SIGN1 ] && SIGNAT=1 || SIGNAT=0 + assert "echo $SIGNAT" "1" + echo "Verifying the IMAGE ID" >> $LOGFILE + [ $AMI_ID == $IMG_ID ] && IMGID=1 || IMGID=0 + assert "echo $IMGID" "1" + echo "Verifying the Architecture" >> $LOGFILE + [ $ARCH_ID == $ARCH ] && ARCHID=1 || ARCHID=0 + assert "echo $ARCHID" "1" + echo "This Host => $PUB_DNS with Image Id : $IMG_ID, is launched with Instance Id : $INS_ID , Instance Type : $INS_TYP and Arch : $ARCH in the Region : $REG" >> $LOGFILE + echo "The Validate Signature is : $SIGN1" >> $LOGFILE + if [ $BP_ID == "bp-6fa54006" ]; then - HOSTNAME=`hostname` - INS_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - IMG_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i imageId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - INS_TYP=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceType | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - ARCH=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i architecture | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - REG=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i zone | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - SIGN1=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/signature` - [ ! -z SIGN1 ] && SIGNAT=1 || SIGNAT=0 - assert "echo $SIGNAT" "1" - new_test "Fetching Host Details " - echo "This Host => $PUB_DNS with Image Id : $IMG_ID, is launched with Instance Id : $INS_ID , Instance Type : $INS_TYP and Arch : $ARCH in the Region : $REG" >> $LOGFILE echo "This is a Hourly image" >> $LOGFILE - echo "The Validate Signature is : $SIGN1" >> $LOGFILE elif [ $BP_ID == "bp-63a5400a" ]; then - HOSTNAME=`hostname` - INS_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - IMG_ID=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i imageId | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - INS_TYP=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i instanceType | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - ARCH=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i architecture | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - REG=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep -i zone | gawk '{print $NF}'| gawk -F"\"" '{print $2}'` - SIGN1=`wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/signature` - [ ! -z SIGN1 ] && SIGNAT=1 || SIGNAT=0 - assert "echo $SIGNAT" "1" - new_test "Fetching Host Details " - echo "This Host => $PUB_DNS with Image Id : $IMG_ID, is launched with Instance Id : $INS_ID , Instance Type : $INS_TYP and Arch : $ARCH in the Region : $REG" >> $LOGFILE echo "This is a Cloud Access image" >> $LOGFILE - echo "The Validate Signature is : $SIGN1" >> $LOGFILE fi } From 0ade0ad18794687b0c0bc052cfb5d9dc95838e5c Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Fri, 7 Oct 2011 17:29:00 +0530 Subject: [PATCH 21/33] Added a sample cfg file --- src/validation.cfg | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/validation.cfg diff --git a/src/validation.cfg b/src/validation.cfg new file mode 100644 index 0000000..60a94dd --- /dev/null +++ b/src/validation.cfg @@ -0,0 +1,24 @@ +[SSH-Info] +ssh-key-path_useast = /home/kbidarka/cloud-keyuseast-new.pem +ssh-key-name_useast = cloud-keyuseast-new +ssh-key-path_uswest = /home/kbidarka/cloud-keyuswest-new.pem +ssh-key-name_uswest = cloud-keyuswest-new +ssh-key-path_euwest = /home/kbidarka/cloud-keyeuwest-new.pem +ssh-key-name_euwest = cloud-keyeuwest-new +ssh-key-path_apnorth = /home/kbidarka/cloud-keyapnorth-new.pem +ssh-key-name_apnorth = cloud-keyapnorth-new +ssh-key-path_apsouth = /home/kbidarka/cloud-keyapsouth-new.pem +ssh-key-name_apsouth = cloud-keyapsouth-new + +[EC2-Keys] +ec2-key = +ec2-secret-key = + +[Bugzilla-Info] +bugzilla_usr = kbidarka@redhat.com +bugzilla_pwd = + +[Misc-Info] +csv = true +git = false +basedir = /home/kbidarka/full123/valid/src From f0a11194e0208dae8eed31c1933e5110102e591b Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Tue, 11 Oct 2011 11:41:43 +0530 Subject: [PATCH 22/33] Solved some weired indentation issues --- src/getAmiDetails_withCSV.py | 107 +++++++++++++++++------------------ 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index 47c8dbf..c38ef70 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -20,15 +20,15 @@ config = ConfigParser.ConfigParser() config.read('/etc/validation.cfg') -SSHKEY_NAME_AP_S = config.get('SSH-Info', 'ssh-key-name_apsouth') +SSHKEY_NAME_AP_S = config.get('SSH-Info', 'ssh-key-name_apsouth') SSHKEY_AP_S = config.get('SSH-Info', 'ssh-key-path_apsouth') -SSHKEY_NAME_AP_N = config.get('SSH-Info', 'ssh-key-name_apnorth') +SSHKEY_NAME_AP_N = config.get('SSH-Info', 'ssh-key-name_apnorth') SSHKEY_AP_N = config.get('SSH-Info', 'ssh-key-path_apnorth') -SSHKEY_NAME_EU_W = config.get('SSH-Info', 'ssh-key-name_euwest') +SSHKEY_NAME_EU_W = config.get('SSH-Info', 'ssh-key-name_euwest') SSHKEY_EU_W = config.get('SSH-Info', 'ssh-key-path_euwest') -SSHKEY_NAME_US_W = config.get('SSH-Info', 'ssh-key-name_uswest') +SSHKEY_NAME_US_W = config.get('SSH-Info', 'ssh-key-name_uswest') SSHKEY_US_W = config.get('SSH-Info', 'ssh-key-path_uswest') -SSHKEY_NAME_US_E = config.get('SSH-Info', 'ssh-key-name_useast') +SSHKEY_NAME_US_E = config.get('SSH-Info', 'ssh-key-name_useast') SSHKEY_US_E = config.get('SSH-Info', 'ssh-key-path_useast') BZUSER = config.get('Bugzilla-Info', 'bugzilla_usr') @@ -44,28 +44,28 @@ BZ = None val1 = { - 'SSHKEY_US_E': SSHKEY_US_E, - 'SSHKEY_NAME_US_E': SSHKEY_NAME_US_E, - 'SSHKEY_US_W': SSHKEY_US_W, - 'SSHKEY_NAME_US_W': SSHKEY_NAME_US_W, - 'SSHKEY_EU_W': SSHKEY_EU_W, - 'SSHKEY_NAME_EU_W': SSHKEY_NAME_EU_W, - 'SSHKEY_AP_N': SSHKEY_AP_N, - 'SSHKEY_NAME_AP_N': SSHKEY_NAME_AP_N, - 'SSHKEY_AP_S': SSHKEY_AP_S, - 'SSHKEY_NAME_AP_S': SSHKEY_NAME_AP_S, - 'BZUSER': BZUSER, - 'BZPASS': BZPASS, - 'AWS_ACCESS_KEY_ID': AWS_ACCESS_KEY_ID, - 'AWS_SECRET_ACCESS_KEY': AWS_SECRET_ACCESS_KEY, - 'CSV': CSV, - 'NOGIT': NOGIT, + 'SSHKEY_US_E': SSHKEY_US_E, + 'SSHKEY_NAME_US_E': SSHKEY_NAME_US_E, + 'SSHKEY_US_W': SSHKEY_US_W, + 'SSHKEY_NAME_US_W': SSHKEY_NAME_US_W, + 'SSHKEY_EU_W': SSHKEY_EU_W, + 'SSHKEY_NAME_EU_W': SSHKEY_NAME_EU_W, + 'SSHKEY_AP_N': SSHKEY_AP_N, + 'SSHKEY_NAME_AP_N': SSHKEY_NAME_AP_N, + 'SSHKEY_AP_S': SSHKEY_AP_S, + 'SSHKEY_NAME_AP_S': SSHKEY_NAME_AP_S, + 'BZUSER': BZUSER, + 'BZPASS': BZPASS, + 'AWS_ACCESS_KEY_ID': AWS_ACCESS_KEY_ID, + 'AWS_SECRET_ACCESS_KEY': AWS_SECRET_ACCESS_KEY, + 'CSV': CSV, + 'NOGIT': NOGIT, 'BASEDIR': BASEDIR, } for v in val1: if not val1[v]: - print "The value ", v, "is missing in .cfg file." + print "The value ", v, "is missing in .cfg file." sys.exit() CSVFILE = "test1.csv" @@ -94,7 +94,7 @@ def addBugzilla(BZ, AMI, RHEL, ARCH, REGION): file.close() os.system("cp "+BASEDIR+"/nohup.out "+BASEDIR+"/nohup_"+AMI+".out ; cat /dev/null > "+BASEDIR+"/nohup.out") -if CSV == 'false': +if CSV == 'false': BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) @@ -109,11 +109,11 @@ def getConnection(key, secret, region): def startInstance(ec2connection, hardwareProfile, ARCH, RHEL, AMI, SSHKEYNAME): conn_region = ec2connection - map = BlockDeviceMapping() + map = BlockDeviceMapping() t = EBSBlockDeviceType() t.size = '15' #map = {'DeviceName':'/dev/sda','VolumeSize':'15'} - map['/dev/sda1'] = t + map['/dev/sda1'] = t #blockDeviceMap = [] #blockDeviceMap.append( {'DeviceName':'/dev/sda', 'Ebs':{'VolumeSize' : '100'} }) @@ -129,14 +129,14 @@ def startInstance(ec2connection, hardwareProfile, ARCH, RHEL, AMI, SSHKEYNAME): else: print "arch type is neither i386 or x86_64.. will exit" exit(1) - + myinstance = reservation.instances[0] - + time.sleep(5) while(not myinstance.update() == 'running'): time.sleep(5) print myinstance.update() - + instanceDetails = myinstance.__dict__ pprint(instanceDetails) #region = instanceDetails['placement'] @@ -146,14 +146,13 @@ def startInstance(ec2connection, hardwareProfile, ARCH, RHEL, AMI, SSHKEYNAME): # check for console output here to make sure ssh is up return publicDNS -def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): +def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): filepath = BASEDIR serverpath = "/root/valid" commandPath = "/root/valid/src" - if NOGIT == 'false': - if hwp["name"] == 't1.micro': + if hwp["name"] == 't1.micro': os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") else: @@ -161,11 +160,12 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) elif NOGIT == 'true': - if hwp["name"] == 't1.micro': + if hwp["name"] == 't1.micro': os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" yum -y install git") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" git clone git://github.com/weshayutin/valid.git") - + + # COPY KERNEL if there serverpath = "/root/kernel" os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/kernel") @@ -177,8 +177,8 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): filepath = BASEDIR+"/kernel/x86_64/*" print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"\n" os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) - - + + # command = commandPath+"/image_validation.sh --imageID="+IGNORE+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"] command = commandPath+"/image_validation.sh --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS+" --ami-id="+AMI+" --arch-id="+ARCH @@ -186,8 +186,7 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): print "nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command print "" os.system("nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command) - - + def printValues(hwp): print "+++++++" @@ -200,13 +199,13 @@ def printValues(hwp): def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): #entering critical section - lock.acquire() + lock.acquire() print string," Now Sleeping after Lock acquired for ",sleeptime - time.sleep(sleeptime) - + time.sleep(sleeptime) + print string," Now releasing lock and then sleeping again" lock.release() - + #exiting critical section time.sleep(sleeptime) # why? @@ -219,7 +218,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): m22Xlarge = {"name":"m2.2xlarge","memory":"34200000","cpu":"4","arch":"x86_64"} m24Xlarge = {"name":"m2.4xlarge","memory":"68400000","cpu":"8","arch":"x86_64"} c1Medium = {"name":"c1.medium","memory":"1700000","cpu":"2","arch":"i386"} -c1Xlarge = {"name":"c1.xlarge","memory":"7000000","cpu":"8","arch":"x86_64"} +c1Xlarge = {"name":"c1.xlarge","memory":"7000000","cpu":"8","arch":"x86_64"} #Use all hwp types for ec2 memory tests, other hwp tests @@ -243,9 +242,9 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): RHEL = myRow[4] # BZ = myRow[3] AMI = myRow[5] - + BID = addBugzilla(BZ, AMI, RHEL, ARCH, REGION) - + if REGION == "us-east-1": SSHKEY = SSHKEY_US_E SSHKEYNAME = SSHKEY_NAME_US_E @@ -262,7 +261,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): SSHKEY = SSHKEY_AP_N SSHKEYNAME = SSHKEY_NAME_AP_N - + publicDNS = [] if ARCH == 'i386': for hwp in hwp_i386: @@ -283,14 +282,14 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): # print "sleep for 130 seconds" # time.sleep(130) print "Trying to fetch a file to make sure the SSH works, before proceeding ahead." - f_path = "/tmp/network" - l_path = "/etc/init.d/network" + f_path = "/tmp/network" + l_path = "/etc/init.d/network" for host in publicDNS: keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path) - if not keystat: + if not keystat: executeValidScript(SSHKEY, host["hostname"], host["hwp"], BID, ARCH, AMI, REGION, RHEL) - else: - print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" + else: + print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" else: publicDNS = [] if ARCH == 'i386': @@ -299,7 +298,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME) map = {"hostname":this_hostname,"hwp":hwp} - publicDNS.append(map) + publicDNS.append(map) elif ARCH == 'x86_64': for hwp in hwp_x86_64: printValues(hwp) @@ -307,7 +306,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): this_hostname = startInstance(myConn, hwp["name"], ARCH, RHEL, AMI, SSHKEYNAME) map = {"hostname":this_hostname,"hwp":hwp} publicDNS.append(map) - + lock = thread.allocate_lock() # print "sleep for 130 seconds" # time.sleep(130) @@ -316,7 +315,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): l_path = "/etc/init.d/network" for host in publicDNS: keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path) - if not keystat: + if not keystat: executeValidScript(SSHKEY, host["hostname"],host["hwp"], BID, ARCH, AMI, REGION, RHEL) else: - print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" + print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" From b525d8b9144d2aee2f0f393da0496e5cc106eae1 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Tue, 11 Oct 2011 16:56:32 +0530 Subject: [PATCH 23/33] resolved swap function issues --- src/testlib.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/testlib.sh b/src/testlib.sh index 62103cc..25bce08 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -443,12 +443,14 @@ function test_swap_file() if [ $UNAMEI == "i386" ]; then swap=`cat swap_partitions` fst=`cat /etc/fstab | grep swap | awk '{print $1}'` - [ $swap != $fst ] && [ -b /dev/xvde3] && sed -i 's/\/dev\/xvda3/\/dev\/xvde3/' /etc/fstab - [ $swap != $fst ] && [ -b /dev/xvda3] && sed -i 's/\/dev\/xvde3/\/dev\/xvda3/' /etc/fstab + [ $swap != $fst ] && [ -b /dev/xvde3 ] && sed -i 's/\/dev\/xvda3/\/dev\/xvde3/' /etc/fstab + [ $swap != $fst ] && [ -b /dev/xvda3 ] && sed -i 's/\/dev\/xvde3/\/dev\/xvda3/' /etc/fstab + swapon `cat swap_partitions` 2> /dev/null assert "/sbin/swapoff $swap && /sbin/swapon $swap" fi -# The below logic needs to be reversed, after checking the actual images. Actual images have swap partitions only for i386 and not for x86_64. +# The below logic was reversed, after checking the images. +# The images have swap partitions only for i386(not for t1.micro) and not for x86_64. new_test "## Verify swap size ... " if [ $UNAMEI == "i386" ]; then size=`free | grep Swap | awk '{print $2}'` From d856128b96ec6d9419e639e644137c476d5c5b29 Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Thu, 13 Oct 2011 11:41:44 -0400 Subject: [PATCH 24/33] added utility script for dc --- src/rebootAmi.py | 189 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100755 src/rebootAmi.py diff --git a/src/rebootAmi.py b/src/rebootAmi.py new file mode 100755 index 0000000..0a87ffa --- /dev/null +++ b/src/rebootAmi.py @@ -0,0 +1,189 @@ +#!/usr/bin/python -tt + +from pprint import pprint +from boto import ec2 +import boto, thread +import sys, time, optparse, os +#from boto.ec2.blockdevicemapping import BlockDeviceMapping +from boto.ec2.blockdevicemapping import EBSBlockDeviceType, BlockDeviceMapping +from bugzilla.bugzilla3 import Bugzilla36 + +#def main(argv): +# try: +# opts, args = getopt.getopt(argv, "hr:vb:a:", ["help","region", "version","bugzilla","ami-number"]) +# except getopt.GetoptError: +# usage() +# sys.exit(2) + +parser = optparse.OptionParser() + +desc="ami test script" + +parser.add_option('-r','--region', type='string', dest='REGION', help='specify ec2 region') +parser.add_option('-v','--RHEL_Version', type='string', dest='RHEL', help='RHEL version') +parser.add_option('-b', '--bugzilla_number', type='string', dest='BZ', help='optional bugzilla number') +parser.add_option('-a','--ami_number', type='string', dest='AMI', help='ami id number') +parser.add_option('-s','--ssh-key-path', type='string',dest='SSHKEY',help='full path to ssh key for the ec2 region') +parser.add_option('-k','--ssh-key-name', type='string',dest='SSHKEYNAME',help='name of the key pair') +parser.add_option('-i','--ec2-key', type='string',dest='AWS_ACCESS_KEY_ID',help='EC2 Access Key ID') +parser.add_option('-p','--ec2-secret-key', type='string',dest='AWS_SECRET_ACCESS_KEY',help='EC2 Secret Access Key ID') +parser.add_option('-m','--arch', dest='ARCH', default='x86_64', help='arch = i386, or x86_64') + + + + +(opts, args) = parser.parse_args() +AMI = opts.AMI +REGION = opts.REGION +RHEL = opts.RHEL +SSHKEY = opts.SSHKEY +SSHKEYNAME = opts.SSHKEYNAME +AWS_ACCESS_KEY_ID = opts.AWS_ACCESS_KEY_ID +AWS_SECRET_ACCESS_KEY = opts.AWS_SECRET_ACCESS_KEY +ARCH = opts.ARCH + + + + + +mandatories = ['AMI','REGION','SSHKEY','RHEL','AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'ARCH'] +for m in mandatories: + if not opts.__dict__[m]: + print "mandatory option is missing\n" + parser.print_help() + exit(-1) + + + +def getConnection(key, secret, region): + """establish a connection with ec2""" + reg = boto.ec2.get_region(region, aws_access_key_id=key, + aws_secret_access_key=secret) + return reg.connect( + aws_access_key_id=key, aws_secret_access_key=secret) + +#east# reservation = ec2conn.run_instances('ami-8c8a7de5', instance_type='t1.micro', key_name='cloude-key') +#block_device_map +#'/dev/sda=:20' + +def startInstance(ec2connection, hardwareProfile): + conn_region = ec2connection + map = BlockDeviceMapping() + t = EBSBlockDeviceType() + t.size = '15' + #map = {'DeviceName':'/dev/sda','VolumeSize':'15'} + map['/dev/sda1'] = t + + #blockDeviceMap = [] + #blockDeviceMap.append( {'DeviceName':'/dev/sda', 'Ebs':{'VolumeSize' : '100'} }) + + if ARCH == 'i386' and RHEL == '6.1': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'x86_64' and RHEL == '6.1': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'i386': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'x86_64': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map) + else: + print "arch type is neither i386 or x86_64.. will exit" + exit(1) + + myinstance = reservation.instances[0] + + time.sleep(5) + while(not myinstance.update() == 'running'): + time.sleep(5) + print myinstance.update() + + instanceDetails = myinstance.__dict__ + pprint(instanceDetails) + #region = instanceDetails['placement'] + #print 'region =' + region + publicDNS = instanceDetails['public_dns_name'] + print 'public hostname = ' + publicDNS + + + # check for console output here to make sure ssh is up + return myinstance + + + + +def printValues(hwp): + print "+++++++" + print AMI + print REGION + print SSHKEY + print RHEL + print hwp + print "+++++++\n" + +def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): + #entering critical section + lock.acquire() + print string," Now Sleeping after Lock acquired for ",sleeptime + time.sleep(sleeptime) + + print string," Now releasing lock and then sleeping again" + lock.release() + + #exiting critical section + time.sleep(sleeptime) # why? + +def startAndReboot(hwp): + printValues(hwp) + myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) + this_hostname = startInstance(myConn, hwp["name"]) + print "sleep for 60 seconds" + time.sleep(60) + print 'SSH into running instance NOW' + print "sleep for 30 seconds" + time.sleep(30) + print this_hostname.update() + + print 'REBOOTING' + print this_hostname.reboot(); + + print this_hostname.update() + time.sleep(130) + print this_hostname.update() + +# Define hwp +m1Small = {"name":"m1.small","memory":"1700000","cpu":"1","arch":"i386"} +m1Large = {"name":"m1.large","memory":"7500000","cpu":"2","arch":"x86_64"} +m1Xlarge = {"name":"m1.xlarge","memory":"15000000","cpu":"4","arch":"x86_64"} +t1Micro = {"name":"t1.micro","memory":"600000","cpu":"1","arch":"both"} +m2Xlarge = {"name":"m2.2xlarge","memory":"17100000","cpu":"2","arch":"x86_64"} +m22Xlarge = {"name":"m2.2xlarge","memory":"34200000","cpu":"4","arch":"x86_64"} +m24Xlarge = {"name":"m2.4xlarge","memory":"68400000","cpu":"8","arch":"x86_64"} +c1Medium = {"name":"c1.medium","memory":"1700000","cpu":"2","arch":"i386"} +c1Xlarge = {"name":"c1.xlarge","memory":"7000000","cpu":"8","arch":"x86_64"} + + +#Use all hwp types for ec2 memory tests, other hwp tests +#hwp_i386 = [c1Medium, t1Micro , m1Small ] +#hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge , m22Xlarge , m24Xlarge , c1Xlarge] +#hwp_x86_64 = [m1Large , m1Xlarge] + +#Use just one hwp for os tests +hwp_i386 = [c1Medium] +hwp_x86_64 = [m1Xlarge] + + + +publicDNS = [] + +if ARCH == 'i386': + for hwp in hwp_i386: + startAndReboot(hwp) + + +if ARCH == 'x86_64': + for hwp in hwp_x86_64: + startAndReboot(hwp) + + + + + From 44545a04790097b83ae649f5872e300b7008b9e7 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Wed, 19 Oct 2011 15:01:42 +0530 Subject: [PATCH 25/33] few modifications for RHEL 6.2 --- src/testlib.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/testlib.sh b/src/testlib.sh index 25bce08..5318331 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -355,7 +355,7 @@ function test_verify_rpms() assert "cat ${file} | wc -l" "2" new_test "## Verify Version 2 ... " assert "/bin/rpm -q --queryformat '%{RELEASE}\n' redhat-release | cut -d. -f1,2" $RHELV # to-do, pass this in - else + else file=/tmp/rpmqaV.txt new_test "## Verify RPMs ... " /bin/rpm -Va --nomtime --nosize --nomd5 2>> $LOGFILE | sort -fu > ${file} @@ -569,7 +569,7 @@ function test_gpg_keys() new_test "## Verify GPG Keys ... " if [ $BETA == 1 ]; then - assert "rpm -qa gpg-pubkey* | wc -l " 3 + assert "rpm -qa gpg-pubkey* | wc -l " 4 elif [ $RHEL_FOUND == "6.1" ]; then assert "rpm -qa gpg-pubkey* | wc -l " 2 else @@ -699,10 +699,17 @@ function test_auditd() assert "md5sum /etc/audit/audit.rules | cut -f 1 -d \" \"" "f9869e1191838c461f5b9051c78a638d" new_test "## Verify auditd.conf ... " - assert "md5sum /etc/audit/auditd.conf | cut -f 1 -d \" \"" "612ddf28c3916530d47ef56a1b1ed1ed" - + if [ $RHEL_FOUND == 6.2 ] ; then + assert "md5sum /etc/audit/auditd.conf | cut -f 1 -d \" \"" "e1886162554c18906df2ecd258aa4794" + else + assert "md5sum /etc/audit/auditd.conf | cut -f 1 -d \" \"" "612ddf28c3916530d47ef56a1b1ed1ed" + fi new_test "## Verify auditd sysconfig ... " - assert "md5sum /etc/sysconfig/auditd | cut -f 1 -d \" \"" "123beb3a97a32d96eba4f11509e39da2" + if [ $RHEL_FOUND == 6.2 ] ; then + assert "md5sum /etc/sysconfig/auditd | cut -f 1 -d \" \"" "d4d43637708e30418c30003e212f76fc" + else + assert "md5sum /etc/sysconfig/auditd | cut -f 1 -d \" \"" "123beb3a97a32d96eba4f11509e39da2" + fi } function test_uname() From f8d7f624a7ab6c1baf7342ee75a33c29541e3aeb Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Mon, 21 Nov 2011 17:23:46 +0530 Subject: [PATCH 26/33] package_62 added, modified scripts for new region --- src/getAmiDetails_withCSV.py | 12 +++++++++++- src/testlib.sh | 11 +++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index c38ef70..d08208d 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -20,6 +20,9 @@ config = ConfigParser.ConfigParser() config.read('/etc/validation.cfg') +#us-west-2 has been used as SSHKEY_US_O and SSHKEY_NAME_US_O, O stands for +#Oregon + SSHKEY_NAME_AP_S = config.get('SSH-Info', 'ssh-key-name_apsouth') SSHKEY_AP_S = config.get('SSH-Info', 'ssh-key-path_apsouth') SSHKEY_NAME_AP_N = config.get('SSH-Info', 'ssh-key-name_apnorth') @@ -30,6 +33,8 @@ SSHKEY_US_W = config.get('SSH-Info', 'ssh-key-path_uswest') SSHKEY_NAME_US_E = config.get('SSH-Info', 'ssh-key-name_useast') SSHKEY_US_E = config.get('SSH-Info', 'ssh-key-path_useast') +SSHKEY_NAME_US_O = config.get('SSH-Info', 'ssh-key-name_uswest-oregon') +SSHKEY_US_O = config.get('SSH-Info', 'ssh-key-path_uswest-oregon') BZUSER = config.get('Bugzilla-Info', 'bugzilla_usr') BZPASS = config.get('Bugzilla-Info', 'bugzilla_pwd') @@ -46,6 +51,8 @@ val1 = { 'SSHKEY_US_E': SSHKEY_US_E, 'SSHKEY_NAME_US_E': SSHKEY_NAME_US_E, + 'SSHKEY_US_O': SSHKEY_US_O, + 'SSHKEY_NAME_US_O': SSHKEY_NAME_US_O, 'SSHKEY_US_W': SSHKEY_US_W, 'SSHKEY_NAME_US_W': SSHKEY_NAME_US_W, 'SSHKEY_EU_W': SSHKEY_EU_W, @@ -225,7 +232,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): hwp_i386 = [c1Medium, t1Micro , m1Small ] #hwp_i386 = [c1Medium] hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge, m22Xlarge, m24Xlarge , c1Xlarge] -#hwp_x86_64 = [c1Xlarge] +#hwp_x86_64 = [m24Xlarge] #Use just one hwp for os tests #hwp_i386 = [c1Medium] @@ -248,6 +255,9 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): if REGION == "us-east-1": SSHKEY = SSHKEY_US_E SSHKEYNAME = SSHKEY_NAME_US_E + elif REGION == "us-west-2": + SSHKEY = SSHKEY_US_O + SSHKEYNAME = SSHKEY_NAME_US_O elif REGION == "us-west-1": SSHKEY = SSHKEY_US_W SSHKEYNAME = SSHKEY_NAME_US_W diff --git a/src/testlib.sh b/src/testlib.sh index 5318331..5fcc32a 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -309,7 +309,7 @@ function test_package_set() new_test "## Verify no missing packages ... " file=/tmp/rpmqa rc "/bin/rpm -qa --queryformat='%{NAME}\n' > ${file}.tmp" - #/bin/rpm -qa --queryformat="%{NAME}.%{ARCH}\n" > ${file}.tmp + #/bin/rpm -qa --queryformat="%{NAME}.%{ARCH}\n" > ${file}.tmp cat ${file}.tmp | sort -f > ${file} if [ $RHEL == 5 ] ; then rc "comm -23 packages_5 ${file}" @@ -317,9 +317,12 @@ function test_package_set() elif [ $RHEL_FOUND == "6.0" ]; then rc "comm -23 packages_6 ${file}" comm -23 packages_6 ${file} > /tmp/package_diff - elif [ $RHEL_FOUND == "6.1" ]; then - rc "comm -23 packages_61 ${file}" + elif [ $RHEL_FOUND == "6.1" ]; then + rc "comm -23 packages_61 ${file}" comm -23 packages_61 ${file} > /tmp/package_diff + elif [ $RHEL_FOUND == "6.2" ]; then + rc "comm -23 packages_62 ${file}" + comm -23 packages_62 ${file} > /tmp/package_diff else echo "VERSION NOT FOUND" fi @@ -569,7 +572,7 @@ function test_gpg_keys() new_test "## Verify GPG Keys ... " if [ $BETA == 1 ]; then - assert "rpm -qa gpg-pubkey* | wc -l " 4 + assert "rpm -qa gpg-pubkey* | wc -l " 2 elif [ $RHEL_FOUND == "6.1" ]; then assert "rpm -qa gpg-pubkey* | wc -l " 2 else From 70e4a3e078c9ec098e0eaab23118ce6c31ec43ed Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Mon, 21 Nov 2011 17:26:53 +0530 Subject: [PATCH 27/33] modified the validation.cfg template --- src/validation.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/validation.cfg b/src/validation.cfg index 60a94dd..0d68ada 100644 --- a/src/validation.cfg +++ b/src/validation.cfg @@ -3,6 +3,8 @@ ssh-key-path_useast = /home/kbidarka/cloud-keyuseast-new.pem ssh-key-name_useast = cloud-keyuseast-new ssh-key-path_uswest = /home/kbidarka/cloud-keyuswest-new.pem ssh-key-name_uswest = cloud-keyuswest-new +ssh-key-path_uswest-oregon = /home/kbidarka/cloud-keyuswest-oregon.pem +ssh-key-name_uswest-oregon = cloud-keyuswest-oregon ssh-key-path_euwest = /home/kbidarka/cloud-keyeuwest-new.pem ssh-key-name_euwest = cloud-keyeuwest-new ssh-key-path_apnorth = /home/kbidarka/cloud-keyapnorth-new.pem From 4f88cd62b4f268fd9dbe88eadf1459e6c57d0bf6 Mon Sep 17 00:00:00 2001 From: Kedar Bidarkar Date: Wed, 30 Nov 2011 00:06:51 +0530 Subject: [PATCH 28/33] removed abrt packages from packages_62 file --- src/packages_62 | 549 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 549 insertions(+) create mode 100644 src/packages_62 diff --git a/src/packages_62 b/src/packages_62 new file mode 100644 index 0000000..703cf39 --- /dev/null +++ b/src/packages_62 @@ -0,0 +1,549 @@ +abrt +abrt-addon-ccpp +abrt-addon-kerneloops +abrt-addon-python +abrt-cli +abrt-libs +acl +acpid +aic94xx-firmware +alsa-lib +alsa-utils +at +atk +atlas +atmel-firmware +attr +audit +audit-libs +authconfig +autofs +avahi-libs +b43-fwcutter +b43-openfwwf +basesystem +bash +bc +bfa-firmware +bind-libs +bind-utils +binutils +blktrace +bridge-utils +busybox +bzip2 +bzip2-libs +ca-certificates +cairo +c-ares +cas +cdparanoia-libs +certmonger +checkpolicy +chkconfig +cifs-utils +ConsoleKit +ConsoleKit-libs +coreutils +coreutils-libs +cpio +cpuspeed +cracklib +cracklib-dicts +crash +crash-trace-command +crda +cronie +cronie-anacron +crontabs +cups +cups-libs +curl +cvs +cyrus-sasl +cyrus-sasl-gssapi +cyrus-sasl-lib +cyrus-sasl-plain +dash +db4 +db4-utils +dbus +dbus-glib +dbus-libs +dbus-python +dejavu-fonts-common +dejavu-sans-fonts +desktop-file-utils +device-mapper +device-mapper-event +device-mapper-event-libs +device-mapper-libs +dhclient +diffutils +dosfstools +dracut +dracut-kernel +dstat +e2fsprogs +e2fsprogs-libs +ed +efibootmgr +eggdbus +eject +elfutils +elfutils-libelf +elfutils-libs +elinks +ethtool +expat +file +file-libs +filesystem +findutils +fipscheck +fipscheck-lib +fontconfig +fontpackages-filesystem +foomatic +foomatic-db +foomatic-db-filesystem +foomatic-db-ppds +fprintd +fprintd-pam +freetype +gamin +gawk +gdb +gdbm +gettext +ghostscript +ghostscript-fonts +giflib +glib2 +glibc +glibc-common +gmp +gnupg2 +gnutls +gpgme +gpg-pubkey +gpg-pubkey +gpm-libs +grep +groff +grub +grubby +gstreamer +gstreamer-plugins-base +gstreamer-tools +gtk2 +gzip +hesiod +hicolor-icon-theme +hwdata +info +initscripts +iotop +ipa-client +ipa-python +iproute +iptables +iptables-ipv6 +iputils +ipw2100-firmware +ipw2200-firmware +irqbalance +iso-codes +ivtv-firmware +iw +iwl1000-firmware +iwl3945-firmware +iwl4965-firmware +iwl5000-firmware +iwl5150-firmware +iwl6050-firmware +jasper-libs +java-1.6.0-openjdk +jline +jpackage-utils +kbd +kbd-misc +kernel +kernel-firmware +kexec-tools +keyutils +keyutils-libs +kpartx +krb5-libs +krb5-workstation +latencytop +latrace +lcms-libs +less +libacl +libaio +libasyncns +libattr +libblkid +libcap +libcap-ng +libcollection +libcom_err +libcurl +libdhash +libdrm +libedit +libertas-usb8388-firmware +libffi +libfontenc +libfprint +libgcc +libgcrypt +libgfortran +libgomp +libgpg-error +libgssglue +libgudev1 +libhugetlbfs +libhugetlbfs-utils +libICE +libicu +libidn +libini_config +libjpeg +libldb +libmng +libnih +libnl +libogg +liboil +libpath_utils +libpcap +libpng +libref_array +libselinux +libselinux-utils +libsemanage +libsepol +libSM +libsndfile +libss +libssh2 +libstdc++ +libtalloc +libtar +libtasn1 +libtdb +libtevent +libthai +libtheora +libtiff +libtirpc +libtopology +libudev +libusb +libusb1 +libuser +libutempter +libuuid +libvisual +libvorbis +libX11 +libX11-common +libXau +libxcb +libXcomposite +libXcursor +libXdamage +libXext +libXfixes +libXfont +libXft +libXi +libXinerama +libxml2 +libxml2-python +libXrandr +libXrender +libxslt +libXt +libXtst +libXv +libXxf86vm +logrotate +lsof +ltrace +lua +lvm2 +lvm2-libs +m2crypto +m4 +mailcap +mailx +make +MAKEDEV +man +man-pages +man-pages-overrides +mdadm +mesa-dri-drivers +mesa-libGL +mesa-libGLU +microcode_ctl +mingetty +mlocate +module-init-tools +mtr +mysql-libs +nano +ncurses +ncurses-base +ncurses-libs +net-tools +newt +newt-python +nfs4-acl-tools +nspr +nss +nss_compat_ossl +nss-softokn +nss-softokn-freebl +nss-sysinit +nss-tools +nss-util +ntp +ntpdate +ntsysv +numactl +numpy +oddjob +oddjob-mkhomedir +openjpeg-libs +openldap +openssh +openssh-clients +openssh-server +openssl +oprofile +pam +pam_krb5 +pam_passwdqc +pango +parted +passwd +patch +pax +pciutils +pciutils-libs +pcmciautils +pcre +perf +perl +perl-Archive-Extract +perl-Archive-Tar +perl-CGI +perl-Compress-Raw-Zlib +perl-Compress-Zlib +perl-core +perl-CPAN +perl-CPANPLUS +perl-Crypt-SSLeay +perl-DBD-SQLite +perl-DBI +perl-DBIx-Simple +perl-devel +perl-Digest-SHA +perl-ExtUtils-CBuilder +perl-ExtUtils-Embed +perl-ExtUtils-MakeMaker +perl-ExtUtils-ParseXS +perl-File-Fetch +perl-HTML-Parser +perl-HTML-Tagset +perl-IO-Compress-Base +perl-IO-Compress-Zlib +perl-IO-Zlib +perl-IPC-Cmd +perl-libs +perl-libwww-perl +perl-libxml-perl +perl-Locale-Maketext-Simple +perl-Log-Message +perl-Log-Message-Simple +perl-Module-Build +perl-Module-CoreList +perl-Module-Load +perl-Module-Load-Conditional +perl-Module-Loaded +perl-Module-Pluggable +perl-Object-Accessor +perl-Package-Constants +perl-Params-Check +perl-parent +perl-Parse-CPAN-Meta +perl-Pod-Escapes +perl-Pod-Simple +perl-Term-UI +perl-Test-Harness +perl-Test-Simple +perl-Time-HiRes +perl-Time-Piece +perl-URI +perl-version +perl-XML-Dumper +perl-XML-Grove +perl-XML-Parser +perl-XML-Twig +phonon-backend-gstreamer +pinentry +pinfo +pixman +pkgconfig +plymouth +plymouth-core-libs +plymouth-scripts +policycoreutils +polkit +poppler +poppler-data +poppler-utils +popt +portreserve +powertop +prelink +procps +psacct +psmisc +pth +pulseaudio-libs +pycairo +pygobject2 +pygpgme +pyOpenSSL +python +python-crypto +python-dateutil +python-dmidecode +python-ethtool +python-gudev +python-iniparse +python-iwlib +python-kerberos +python-ldap +python-libs +python-lxml +python-matplotlib +python-netaddr +python-nose +python-nss +python-paramiko +python-pycurl +python-setuptools +python-urlgrabber +pytz +ql2100-firmware +ql2200-firmware +ql23xx-firmware +ql2400-firmware +ql2500-firmware +qt +qt3 +qt-sqlite +qt-x11 +quota +rdate +readahead +readline +Red_Hat_Enterprise_Linux-Release_Notes-6-en-US +redhat-indexhtml +redhat-logos +redhat-lsb +redhat-lsb-graphics +redhat-lsb-printing +redhat-release-server +rfkill +rhino +rhn-check +rhn-client-tools +rhnlib +rhnsd +rhn-setup +rng-tools +rootfiles +rpm +rpm-libs +rpm-python +rsync +rsyslog +rt61pci-firmware +rt73usb-firmware +samba-client +samba-common +samba-winbind-clients +SDL +sed +seekwatcher +selinux-policy +selinux-policy-targeted +setserial +setup +shadow-utils +slang +smartmontools +sos +sqlite +sssd +sssd-client +strace +sudo +sysstat +system-config-firewall-base +system-config-firewall-tui +system-config-network-tui +systemtap-runtime +sysvinit-tools +tar +tcpdump +tcp_wrappers +tcp_wrappers-libs +tcsh +theora-tools +time +tmpwatch +trace-cmd +traceroute +tzdata +tzdata-java +udev +unzip +upstart +urw-fonts +usbutils +usermode +ustr +util-linux-ng +valgrind +vconfig +vim-common +vim-enhanced +vim-minimal +wget +which +wireless-tools +words +xdg-utils +xml-common +xmlrpc-c +xmlrpc-c-client +xorg-x11-drv-ati-firmware +xorg-x11-font-utils +xz +xz-libs +xz-lzma-compat +yum +yum-metadata-parser +yum-rhn-plugin +yum-utils +zd1211-firmware +zip +zlib From a2f5a1cf7ffe0f7f66dc3bafe33c4e761f37e937 Mon Sep 17 00:00:00 2001 From: milan k Date: Tue, 13 Dec 2011 15:29:52 +0100 Subject: [PATCH 29/33] init skip test --- src/bugzilla/__init__.pyc | Bin 2674 -> 2638 bytes src/bugzilla/base.pyc | Bin 61265 -> 60212 bytes src/bugzilla/bugzilla3.pyc | Bin 9051 -> 8869 bytes src/bugzilla/nvlbugzilla.pyc | Bin 7143 -> 7017 bytes src/bugzilla/rhbugzilla.pyc | Bin 24480 -> 24093 bytes src/bugzilla/util.pyc | Bin 760 -> 1672 bytes src/image_validation.sh | 104 +++++++++++++++++++---------------- src/testlib.sh | 86 ++++++++++++++++------------- src/validation.cfg | 38 ++++++------- validate.spec | 12 ++-- 10 files changed, 131 insertions(+), 109 deletions(-) diff --git a/src/bugzilla/__init__.pyc b/src/bugzilla/__init__.pyc index 89e466a910e7364ff841e74f02fe2542893bace8..767b816256e3a01071ccf5425236948814fb6ef6 100644 GIT binary patch delta 125 zcmew)a!!Pu`7~C3w^%xi!^fU5vQ}uH*a}x9Pi;I#cPvnr_tk3Gkj6<># Thq%IIH_qcYn@=1i9`7hG|P>~C3Q%o!LM^fU5vQ}xR;5-UqfGV}Dy^NX^J3lfu4C)abx cZ&qV4OT95JR-Q!z@vQ&>(nlcp4s{C9i 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 delta 12195 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 delta 535 zcmaE9_S~GE`7hG|P?859aRtyXb`WgATsruy^iIt@#nR)u<`9;~q1&PV2lLL5_ zCi}C85mKZ)`8InFK}DNuIpP@!sZyFO$mLE*k@Dm|u4{x9&EmdDSkXeBId~Oq4&eRC xidO|VlsG9C z2icS+tFSdM=XsKG$`$Z7;gmDrtHmS7vH3IKBSvfrHh&c0#3})H z%~=_a$qquhv1tU!Z?+UJXT~KtIY5tf@@KK*IONqg{}ngJZLocxtV{q-H*JnqILL&YJGj z{BS$0-*^FTdx0UjxybA>R--o;TDV}>dC_VoE{B4>de&M2tBK&42YPj~fi3pL&1iQH ztHFZO>YIh^PvSPzfRA;voa1_&3N~{)t6-M|=C#eaE)Cf84M^{q|OJ20n z-Tcj$8@nVhfiJfA$1Vr7a&c_{_HYL|XLryZoEkT84LN{Sa`VJ6f9xp)WTaeFEKbSE aJ7c$DjS`^7$!p`LVU-h(}%FSD) zVu(=XCKEu|1Dj9FA7mozgM&)52&z)wJXQ5JJ7Key>J|`oJt#6a`|JA=;e$&?3kbSR zY4dW^7lduye8gOduvtL2aZgsW>LKja=T@o&EmfcFWE+AQL* zg$PxD9aRXZ0v0@*!<-uk6c->>+@AA@FzcSzG6JeVr5G^qHy`ogCaiKXiyr|+K&LIX z^d}JEAou45?jdZ{=J?q7q(Z9-W3bG$O7>?udm*`7w5sy_C!de# zIg;zNZqTYuD@D^9*;85}!~%7CxagCwUIur3jV=PR-(AHMq%^pY0&J6TXWgU~z70x) zmuegp#L;Gt?gX28oSm3LM|zm0db~`H9xl@tS)NCFu{8Evf7XAxqpk5vTR6ZrlSvkP z?Z=VVaa1%lo}tn6$T^efC@+gt`x5Vseso!^BYEw2^vw8inRFZk=5tddZSK^EFsP3UN1O82#bbkV3@nV#%ec=NiBUe9IlskNK0|3>WTSLu z3NIz5VozkfGEYw0fRY&ZF1+rzoSE({%cG*}Y}`GG@+=YW>T=#DMU$!kt2C+66pa0f zB>*j~LK+2hdkr#*<{n_-#Seso+9a_B^2$zc9vmBW1Rj{3R>%N9L1fxOC5;rUSOojcUEI0Zz^W&H1W@TbN(Aj81b4DUVGqu5=Z?Ywt)=hAy0p7C)t9~Rwf>Nr)dFf1>my`xXJ1n=zrcM+#N;bF>I~7%xHcJPB zk;mIGl noME3k>fd1VHq1XAiT7VM$H(>%{8;AZLl(Vb(X~`7Xk7mbj{ka& delta 306 zcmeC+{lS{Z{F#^QzfOv8G6NJa0ci&yE>;B+DL}-?ki)x1Q2Sl0C^?sKq9|buOP7`BM9W3Adstqc!31Me4;IhW>e+> Knaab+!vp|TB|Sj^ diff --git a/src/image_validation.sh b/src/image_validation.sh index bb4c3b7..913ed4b 100755 --- a/src/image_validation.sh +++ b/src/image_validation.sh @@ -14,10 +14,43 @@ # # written by whayutin@redhat.com # modified by kbidarka@redhat.com for RHEL 6 +# mkovacik@redhat.com FAILURES=0 MEM_HWP=0 +# try to pushd to a `valid' source tree +[ -z $BASEDIR ] && BASEDIR=/root/valid/src +[ -d $BASEDIR ] || BASEDIR=$PWD +set -e +pushd $BASEDIR +source testlib.sh +set +e + +function list_tests(){ + # return the list of defined tests + declare -F | cut -d\ -f3,3 | grep "^test_.*" +} + +function filter_tests(){ + # produces the list of tests to execute + # args: + # list of skip expressions to use with egrep + # return: + # list of passing function names + + # @ is an identity element; hopefully, it won't ever match ;) + local skip="@,${@}" + skip="${skip%,}" # cut off trailing spaces; takes care of empty $@, too + # convert the coma or space separated list to an expression of elements + # separated by `|' + shopt -s extglob + skip="${skip//*([[:space:]])[,[:space:]]*([[:space:]])/|}" + shopt -u extglob + # figure out all test functions passing the skip list + list_tests | egrep -v "${skip}" +} + function usage() { echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " @@ -40,9 +73,12 @@ function usage() echo "--public-dns :: The Public-DNS Host name of the machine" echo "--ami-id :: The AMI ID" echo "--arch-id :: The Architecture i386 or x86_64 for the launched instance" + echo "--skip-list :: A list of coma-separated expressions specifying test names + to skip. A skip-list might contain: + test_repos,test_yum_full_test,test_IPv6" + echo "--list-tests :: list available tests" } - #cli for i in $* do @@ -86,14 +122,28 @@ for i in $* --arch-id=*) ARCH_ID="`echo $i | sed 's/[-a-zA-Z0-9]*=//'`" ;; + --skip-list=*) + SKIP_LIST="${i#*=}" + ;; + --list-tests) + list_tests + exit 0 + ;; + *) - # unknown option + # unknown option usage exit 1 ;; esac done +# initialize testlib +set -e +set -x +_testlib_init +set +x +set +e if [[ -z $IMAGEID ]] || [[ -z $RHELV ]] || [[ -z $yum_test ]] || [[ -z $BUG_USERNAME ]] || [[ -z $BUG_PASSWORD ]] || [[ -z $MEM_HWP ]]; then usage @@ -102,8 +152,6 @@ fi -pushd /root/valid/src -source $PWD/testlib.sh ### DONT REMOVE OR COMMENT OUT ### echo "opening a bugzilla for logging purposes" @@ -130,42 +178,12 @@ if [ $QUESTIONS == "no" ];then fi echo "##### START TESTS #####" echo "" -test_uname -test_disk_format -test_disk_size -[ ! -f /root/noswap ] && test_swap_file || echo "t1.micro doesn't require swap" -test_selinux -test_package_set -test_verify_rpms -test_gpg_keys -#test_repos #remarking this out for now.. until additional repo's land. the yum tests should be sufficient -test_yum_plugin -if [ $yum_test == "yes" ];then - test_yum_full_test -else - test_yum_general_test -fi -test_bash_history -test_system_id -test_cloud-firstboot -test_nameserver -test_group -test_passwd -test_inittab -test_shells -#test_IPv6 no longer needed -test_networking -test_iptables -test_sshd -test_chkconfig -test_syslog -test_auditd -test_sshSettings -test_libc6-xen.conf -test_grub -#installTestKernel -test_resize2fs -test_fetch_host_details +# skip-list might contain +# installTestKernel,test_repos,test_yum_full_test,test_IPv6, + +for f in $( filter_tests $SKIP_LIST ) ; do + $f +done ### DONT REMOVE OR COMMENT OUT ### show_failures @@ -182,9 +200,3 @@ echo "REBOOTING" reboot #im_exit ################################## - - - - - - diff --git a/src/testlib.sh b/src/testlib.sh index 5fcc32a..9e49ba0 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -14,44 +14,50 @@ # # written by whayutin@redhat.com # modified by kbidarka@redhat.com - -LOGFILE=$PWD/validate.log -DLOG=" tee -a ${LOGFILE} " #Display and log output -cat /dev/null > $LOGFILE -RSLT="" -LOGRESULT="echo ${RSLT} 1>>$LOGFILE 2>>$LOGFILE" -DIFFDIR=$PWD -SYSDATE=$( /bin/date '+%Y-%m-%d %H:%M' ) -UNAMEI=$( /bin/uname -i ) -BETA=0 - - -echo "" -echo "" - -txtred=$(tput setaf 1) # Red -txtgrn=$(tput setaf 2) # Green -txtrst=$(tput sgr0) # Text reset - -### Begin: Create a list of partitions -rm -Rf disk_partitions -rm -Rf swap_partitions -mount | grep ^/dev | awk '{print $1}' >> disk_partitions -parted -l | grep -B 5 swap | grep ^Disk | awk '{print $2}' | sed '$s/.$//' >> swap_partitions - -rm -Rf tmp1_partitions tmp2_partitions -### End: Create a list of partitions - -RHEL=`cat /etc/redhat-release | awk '{print $7}' | awk -F. '{print $1}'` -RHELU=`cat /etc/redhat-release | awk '{print $7}' | awk -F. '{print $2}'` -RHEL_FOUND=$RHEL.$RHELU -KERNEL="" -KERNEL_UPDATED="" -TEST_CURRENT="" -TEST_FAILED="" -echo "IMAGE ID= ${IMAGEID}" >> $LOGFILE - - +# mkovacik@redhat.com + +[ -n __TESTLIB__ ] && return 0 +__TESTLIB__=loaded + +function _testlib_init(){ + [ -n $__TESTLIB_INIT__] && return 0 + LOGFILE=$PWD/validate.log + DLOG=" tee -a ${LOGFILE} " #Display and log output + cat /dev/null > $LOGFILE + RSLT="" + LOGRESULT="echo ${RSLT} 1>>$LOGFILE 2>>$LOGFILE" + DIFFDIR=$PWD + SYSDATE=$( /bin/date '+%Y-%m-%d %H:%M' ) + UNAMEI=$( /bin/uname -i ) + BETA=0 + + + echo "" + echo "" + + txtred=$(tput setaf 1) # Red + txtgrn=$(tput setaf 2) # Green + txtrst=$(tput sgr0) # Text reset + + ### Begin: Create a list of partitions + rm -Rf disk_partitions + rm -Rf swap_partitions + mount | grep ^/dev | awk '{print $1}' >> disk_partitions + parted -l | grep -B 5 swap | grep ^Disk | awk '{print $2}' | sed '$s/.$//' >> swap_partitions + + rm -Rf tmp1_partitions tmp2_partitions + ### End: Create a list of partitions + + RHEL=`cat /etc/redhat-release | awk '{print $7}' | awk -F. '{print $1}'` + RHELU=`cat /etc/redhat-release | awk '{print $7}' | awk -F. '{print $2}'` + RHEL_FOUND=$RHEL.$RHELU + KERNEL="" + KERNEL_UPDATED="" + TEST_CURRENT="" + TEST_FAILED="" + echo "IMAGE ID= ${IMAGEID}" >> $LOGFILE + __TESTLIB_INIT__=initialized +} function new_test() { @@ -442,6 +448,10 @@ function test_bash_history() function test_swap_file() { + if [ -f /root/noswap ] ; then + echo "/root/noswap present -- this machine doesn't require swap" >> $LOGFILE + return 0 + fi new_test "## Verify turning on/off swap file ... " if [ $UNAMEI == "i386" ]; then swap=`cat swap_partitions` diff --git a/src/validation.cfg b/src/validation.cfg index 0d68ada..9568e16 100644 --- a/src/validation.cfg +++ b/src/validation.cfg @@ -1,26 +1,26 @@ [SSH-Info] -ssh-key-path_useast = /home/kbidarka/cloud-keyuseast-new.pem -ssh-key-name_useast = cloud-keyuseast-new -ssh-key-path_uswest = /home/kbidarka/cloud-keyuswest-new.pem -ssh-key-name_uswest = cloud-keyuswest-new -ssh-key-path_uswest-oregon = /home/kbidarka/cloud-keyuswest-oregon.pem -ssh-key-name_uswest-oregon = cloud-keyuswest-oregon -ssh-key-path_euwest = /home/kbidarka/cloud-keyeuwest-new.pem -ssh-key-name_euwest = cloud-keyeuwest-new -ssh-key-path_apnorth = /home/kbidarka/cloud-keyapnorth-new.pem -ssh-key-name_apnorth = cloud-keyapnorth-new -ssh-key-path_apsouth = /home/kbidarka/cloud-keyapsouth-new.pem -ssh-key-name_apsouth = cloud-keyapsouth-new +ssh-key-path_useast=/home/kbidarka/cloud-keyuseast-new.pem +ssh-key-name_useast=cloud-keyuseast-new +ssh-key-path_uswest=/home/kbidarka/cloud-keyuswest-new.pem +ssh-key-name_uswest=cloud-keyuswest-new +ssh-key-path_uswest-oregon=/home/kbidarka/cloud-keyuswest-oregon.pem +ssh-key-name_uswest-oregon=cloud-keyuswest-oregon +ssh-key-path_euwest=/home/kbidarka/cloud-keyeuwest-new.pem +ssh-key-name_euwest=cloud-keyeuwest-new +ssh-key-path_apnorth=/home/kbidarka/cloud-keyapnorth-new.pem +ssh-key-name_apnorth=cloud-keyapnorth-new +ssh-key-path_apsouth=/home/kbidarka/cloud-keyapsouth-new.pem +ssh-key-name_apsouth=cloud-keyapsouth-new [EC2-Keys] -ec2-key = -ec2-secret-key = +ec2-key= +ec2-secret-key= [Bugzilla-Info] -bugzilla_usr = kbidarka@redhat.com -bugzilla_pwd = +bugzilla_usr=kbidarka@redhat.com +bugzilla_pwd= [Misc-Info] -csv = true -git = false -basedir = /home/kbidarka/full123/valid/src +csv=true +git=false +basedir=/home/kbidarka/full123/valid/src diff --git a/validate.spec b/validate.spec index 3dbc9c8..b1972be 100644 --- a/validate.spec +++ b/validate.spec @@ -1,20 +1,20 @@ Name: validate -Version: 6.1 +Version: 6.1 Release: 1 -Summary: Validates a cloud providers image of Red Hat Enterprise Linux +Summary: Validates a cloud providers image of Red Hat Enterprise Linux Group: Development/Libraries License: GPL -URL: http://github.com/weshayutin/valid +URL: http://github.com/weshayutin/valid Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name} BuildArch: noarch -# BuildRequires: -# Requires: +# BuildRequires: +# Requires: %description -A shell script that will run tests to validate that the image of Red Hat Enterprise Linux meets or exceeds the minimum requirements as defined by Red Hat. +A shell script that will run tests to validate that the image of Red Hat Enterprise Linux meets or exceeds the minimum requirements as defined by Red Hat. %prep From bcf2d547e3979946e2e5c3caf7259f835421367f Mon Sep 17 00:00:00 2001 From: milan Date: Wed, 14 Dec 2011 10:11:24 +0100 Subject: [PATCH 30/33] fix loading testlib --- src/getAmiDetails_withCSV.py | 4 ++-- src/testlib.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index d08208d..5e1c0e4 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -170,7 +170,7 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): if hwp["name"] == 't1.micro': os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" touch /root/noswap") os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" yum -y install git") - os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" git clone git://github.com/weshayutin/valid.git") + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" git clone git://github.com/dparalen/valid.git") # COPY KERNEL if there @@ -188,7 +188,7 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): # command = commandPath+"/image_validation.sh --imageID="+IGNORE+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"] - command = commandPath+"/image_validation.sh --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS+" --ami-id="+AMI+" --arch-id="+ARCH + command = commandPath+"/image_validation.sh --skip-list="IPv6,full_test" --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS+" --ami-id="+AMI+" --arch-id="+ARCH print "nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command print "" diff --git a/src/testlib.sh b/src/testlib.sh index 9e49ba0..a7cc4c5 100755 --- a/src/testlib.sh +++ b/src/testlib.sh @@ -16,11 +16,11 @@ # modified by kbidarka@redhat.com # mkovacik@redhat.com -[ -n __TESTLIB__ ] && return 0 +[ -n "$__TESTLIB__" ] && return 0 __TESTLIB__=loaded function _testlib_init(){ - [ -n $__TESTLIB_INIT__] && return 0 + [ -n "$__TESTLIB_INIT__" ] && return 0 LOGFILE=$PWD/validate.log DLOG=" tee -a ${LOGFILE} " #Display and log output cat /dev/null > $LOGFILE From 670145538b09d6d5afafa626130372bb2dfdb9e1 Mon Sep 17 00:00:00 2001 From: milan Date: Wed, 14 Dec 2011 17:42:00 +0100 Subject: [PATCH 31/33] bug fixes... --- src/getAmiDetails_withCSV.py | 34 ++++++++++++++++++++++------------ src/image_validation.sh | 9 +-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/getAmiDetails_withCSV.py b/src/getAmiDetails_withCSV.py index 5e1c0e4..82b8f65 100755 --- a/src/getAmiDetails_withCSV.py +++ b/src/getAmiDetails_withCSV.py @@ -3,7 +3,7 @@ from pprint import pprint from boto import ec2 import boto, thread -import sys, time, optparse, os +import sys, time, argparse, os import csv #from boto.ec2.blockdevicemapping import BlockDeviceMapping from boto.ec2.blockdevicemapping import EBSBlockDeviceType, BlockDeviceMapping @@ -11,15 +11,26 @@ import rhui_lib import ConfigParser -#def main(argv): -# try: -# opts, args = getopt.getopt(argv, "hr:vb:a:", ["help","region", "version","bugzilla","ami-number"]) -# except getopt.GetoptError: -# usage() -# sys.exit(2) config = ConfigParser.ConfigParser() config.read('/etc/validation.cfg') +argparser = argparse.ArgumentParser(description=\ + 'Remotely execute validation testcases') +argparser.add_argument('--skip-tests', metavar='',nargs="*", + help="space-separated expressions describing tests to skip") +argparser.add_argument('--list-tests', action='store_const', const=True, + default=False, help='display available test names and exit') +args = argparser.parse_args() + +if args.skip_tests: + SKIPLIST=",".join(args.skip_tests) +else: + SKIPLIST="" + +if args.list_tests: + os.system("./image_validation.sh --list-tests") + sys.exit() + #us-west-2 has been used as SSHKEY_US_O and SSHKEY_NAME_US_O, O stands for #Oregon @@ -76,7 +87,6 @@ sys.exit() CSVFILE = "test1.csv" -parser = optparse.OptionParser() def addBugzilla(BZ, AMI, RHEL, ARCH, REGION): if BZ is None: @@ -153,7 +163,7 @@ def startInstance(ec2connection, hardwareProfile, ARCH, RHEL, AMI, SSHKEYNAME): # check for console output here to make sure ssh is up return publicDNS -def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): +def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL, SKIPLIST=""): filepath = BASEDIR serverpath = "/root/valid" commandPath = "/root/valid/src" @@ -188,7 +198,7 @@ def executeValidScript(SSHKEY, publicDNS, hwp, BZ, ARCH, AMI, REGION, RHEL): # command = commandPath+"/image_validation.sh --imageID="+IGNORE+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"] - command = commandPath+"/image_validation.sh --skip-list="IPv6,full_test" --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS+" --ami-id="+AMI+" --arch-id="+ARCH + command = commandPath+"/image_validation.sh --skip-list='"+SKIPLIST+"' --imageID="+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password='"+BZPASS+"' --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS+" --ami-id="+AMI+" --arch-id="+ARCH print "nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command print "" @@ -297,7 +307,7 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): for host in publicDNS: keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path) if not keystat: - executeValidScript(SSHKEY, host["hostname"], host["hwp"], BID, ARCH, AMI, REGION, RHEL) + executeValidScript(SSHKEY, host["hostname"], host["hwp"], BID, ARCH, AMI, REGION, RHEL, SKIPLIST) else: print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" else: @@ -326,6 +336,6 @@ def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): for host in publicDNS: keystat = rhui_lib.putfile(host["hostname"], SSHKEY, l_path, f_path) if not keystat: - executeValidScript(SSHKEY, host["hostname"],host["hwp"], BID, ARCH, AMI, REGION, RHEL) + executeValidScript(SSHKEY, host["hostname"],host["hwp"], BID, ARCH, AMI, REGION, RHEL, SKIPLIST) else: print "The Amazon node : "+host["hostname"]+" is not accessible, waited for 210 sec. Skipping and proceeding with the next Profile" diff --git a/src/image_validation.sh b/src/image_validation.sh index 913ed4b..aa95382 100755 --- a/src/image_validation.sh +++ b/src/image_validation.sh @@ -22,10 +22,8 @@ MEM_HWP=0 # try to pushd to a `valid' source tree [ -z $BASEDIR ] && BASEDIR=/root/valid/src [ -d $BASEDIR ] || BASEDIR=$PWD -set -e -pushd $BASEDIR +pushd $BASEDIR > /dev/null source testlib.sh -set +e function list_tests(){ # return the list of defined tests @@ -137,13 +135,8 @@ for i in $* ;; esac done - # initialize testlib -set -e -set -x _testlib_init -set +x -set +e if [[ -z $IMAGEID ]] || [[ -z $RHELV ]] || [[ -z $yum_test ]] || [[ -z $BUG_USERNAME ]] || [[ -z $BUG_PASSWORD ]] || [[ -z $MEM_HWP ]]; then usage From ba51632c8aab3b64ffdf22efae85599efd46d3e6 Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Thu, 15 Dec 2011 09:29:22 -0500 Subject: [PATCH 32/33] moved REPO --- README | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README b/README index 8ab250f..0fe974b 100644 --- a/README +++ b/README @@ -1,6 +1,7 @@ -This script will run through some basic sanity tests for a Red Hat Enterprise Linux image -A valid Red Hat bugzilla username and password will be required at the end of the script -http://bugzilla.redhat.com/ - - -USAGE image_validation --help +MOVED TO https://github.com/RedHatQE/valid +MOVED TO https://github.com/RedHatQE/valid +MOVED TO https://github.com/RedHatQE/valid +MOVED TO https://github.com/RedHatQE/valid +MOVED TO https://github.com/RedHatQE/valid +MOVED TO https://github.com/RedHatQE/valid +MOVED TO https://github.com/RedHatQE/valid \ No newline at end of file From 1f15b8fed4484cccf1ef21255cbeecce60a406c2 Mon Sep 17 00:00:00 2001 From: wes hayutin Date: Fri, 2 Mar 2012 17:47:20 -0500 Subject: [PATCH 33/33] added stupid install script for rhui --- src/installRHUI.sh | 139 ++++++++++++++++++++++++++ src/testRegion.py | 243 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 382 insertions(+) create mode 100644 src/installRHUI.sh create mode 100755 src/testRegion.py diff --git a/src/installRHUI.sh b/src/installRHUI.sh new file mode 100644 index 0000000..9bb25a8 --- /dev/null +++ b/src/installRHUI.sh @@ -0,0 +1,139 @@ +#!/bin/bash + +## ASSUMES RHUI DVD in /root ### +## Run on the rhua and each cds ## +## +## example ./script.sh rhua xvdk +## example ./script.sh cds xvdf (xvdf for 6.0 rhel or so I've seen) + +## CHANGE ME #### +export rhua=host.internal +export cds1=host.internal +export cds2=host.internal +## CHANGE ME #### + + + +export server="$1" +export device="$2" + +if [ "$server" == "rhua" ]; then + echo "RHUI Selected" + mkdir /var/lib/pulp + ls /var/lib/pulp +fi +if [ "$server" == "cds" ]; then + echo "CDS Selected" + mkdir /var/lib/pulp-cds + ls /var/lib/pulp-cds +fi + +iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT +iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 5674 -j ACCEPT + +/etc/init.d/iptables save +/etc/init.d/iptables restart + +fdisk /dev/$device << EOF +n +p +1 +1 +54823 +p +w +EOF + +export partition=1 +mkfs.ext4 /dev/$device$partition + +if [ "$server" == "rhua" ]; then + echo "/dev/$device$partition /var/lib/pulp ext4 defaults 1 1" >> /etc/fstab + mount -a + mount +fi +if [ "$server" == "cds" ]; then + echo "/dev/$device$partition /var/lib/pulp-cds ext4 defaults 1 1" >> /etc/fstab + mount -a + mount +fi + +if [ "$server" == "rhua" ]; then + mkdir -p pem && pushd pem + openssl req -new -x509 -extensions v3_ca -keyout ca.key -subj '/C=US/ST=NC/L=Raleigh/CN=localhost' -out ca.crt -days 365 + echo 10 > ca.srl + openssl genrsa -out server.key 2048 + + for node in $rhua $cds1 $cds2 ; do + echo -ne "\n\n\n## set CN for $server\n==" + openssl req -new -key server.key -subj '/C=US/ST=NC/L=Raleigh/CN='$node'' -out $node.csr + openssl x509 -req -days 365 -CA ca.crt -CAkey ca.key -in $node.csr -out $node.crt + done +fi + +mkdir /tmp/mnt +mount -o loop /root/RH* /tmp/mnt/ +pushd /tmp/mnt/ +if [ "$server" == "rhua" ]; then + ./install_RHUA.sh ;./install_tools.sh +fi +if [ "$server" == "cds" ]; then + ./install_CDS.sh +fi + +popd + +nss-db-gen + +#/etc/pulp/pulp.conf +#/etc/pulp/consumer/consumer.conf +#/etc/pulp/client.conf +#host = localhost.localdomain + +if [ "$server" == "rhua" ]; then + perl -npe 's/server_name: localhost/server_name: $rhui/g' -i /etc/pulp/pulp.conf; + perl -npe 's/host = localhost.localdomain/host = $rhui/g' -i /etc/pulp/client.conf; + perl -npe 's/host = localhost.localdomain/host = $rhui/g' -i /etc/pulp/consumer/consumer.conf; +fi + +if [ "$server" == "cds" ]; then + perl -npe 's/host = localhost.localdomain/host = $rhui/g' -i /etc/pulp/cds.conf; +fi + +export cert=.crt + +cat > /root/answers.txt < "+BASEDIR+"/nohup.out") + + +def getConnection(key, secret, region): + """establish a connection with ec2""" + reg = boto.ec2.get_region(region, aws_access_key_id=key, + aws_secret_access_key=secret) + return reg.connect( + aws_access_key_id=key, aws_secret_access_key=secret) + +#east# reservation = ec2conn.run_instances('ami-8c8a7de5', instance_type='t1.micro', key_name='cloude-key') +#block_device_map +#'/dev/sda=:20' + +def startInstance(ec2connection, hardwareProfile): + conn_region = ec2connection + map = BlockDeviceMapping() + t = EBSBlockDeviceType() + t.size = '15' + #map = {'DeviceName':'/dev/sda','VolumeSize':'15'} + map['/dev/sda1'] = t + + #blockDeviceMap = [] + #blockDeviceMap.append( {'DeviceName':'/dev/sda', 'Ebs':{'VolumeSize' : '100'} }) + + if ARCH == 'i386' and RHEL == '6.1': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'x86_64' and RHEL == '6.1': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'i386': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map ) + elif ARCH == 'x86_64': + reservation = conn_region.run_instances(AMI, instance_type=hardwareProfile, key_name=SSHKEYNAME, block_device_map=map) + else: + print "arch type is neither i386 or x86_64.. will exit" + exit(1) + + myinstance = reservation.instances[0] + + time.sleep(5) + while(not myinstance.update() == 'running'): + time.sleep(5) + print myinstance.update() + + instanceDetails = myinstance.__dict__ + pprint(instanceDetails) + #region = instanceDetails['placement'] + #print 'region =' + region + publicDNS = instanceDetails['public_dns_name'] + print 'public hostname = ' + publicDNS + + + # check for console output here to make sure ssh is up + return publicDNS + +def executeValidScript(SSHKEY, publicDNS,hwp,BZ): + filepath = BASEDIR+"/*" + serverpath = "/root/valid/src" + commandPath = "/root/valid/src" + + + if NOGIT: + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/valid/src") + print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"/n" + os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) + else: + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" yum -y install git") + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" git clone git://github.com/weshayutin/valid.git") + + + + # COPY KERNEL if there + serverpath = "/root/kernel" + os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" mkdir -p /root/kernel") + if ARCH == 'i386': + filepath = BASEDIR+"/kernel/i386/*" + print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"/n" + os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) + if ARCH == 'x86_64': + filepath = BASEDIR+"/kernel/x86_64/*" + print "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath+"/n" + os.system("scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " -r " + filepath + " root@"+publicDNS+":"+serverpath) + + + +# command = commandPath+"/image_validation.sh --imageID="+IGNORE+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"] + command = commandPath+"/image_validation.sh --imageID="+IGNORE+AMI+"_"+REGION+"_"+hwp["name"]+" --RHEL="+RHEL+" --full-yum-suite=yes --skip-questions=yes --bugzilla-username="+BZUSER+" --bugzilla-password="+BZPASS+" --bugzilla-num="+BZ+ " --memory="+hwp["memory"]+" --public-dns="+publicDNS + + print "nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command + print "" + os.system("nohup ssh -n -f -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i "+SSHKEY+ " root@"+publicDNS+" "+command) + + + +def printValues(hwp): + print "+++++++" + print AMI + print REGION + print SSHKEY + print RHEL + print hwp + print "+++++++\n" + +def myfunction(string, sleeptime,lock,SSHKEY,publicDNS): + #entering critical section + lock.acquire() + print string," Now Sleeping after Lock acquired for ",sleeptime + time.sleep(sleeptime) + + print string," Now releasing lock and then sleeping again" + lock.release() + + #exiting critical section + time.sleep(sleeptime) # why? + +# Define hwp +m1Small = {"name":"m1.small","memory":"1700000","cpu":"1","arch":"i386"} +m1Large = {"name":"m1.large","memory":"7500000","cpu":"2","arch":"x86_64"} +m1Xlarge = {"name":"m1.xlarge","memory":"15000000","cpu":"4","arch":"x86_64"} +t1Micro = {"name":"t1.micro","memory":"600000","cpu":"1","arch":"both"} +m2Xlarge = {"name":"m2.2xlarge","memory":"17100000","cpu":"2","arch":"x86_64"} +m22Xlarge = {"name":"m2.2xlarge","memory":"34200000","cpu":"4","arch":"x86_64"} +m24Xlarge = {"name":"m2.4xlarge","memory":"68400000","cpu":"8","arch":"x86_64"} +c1Medium = {"name":"c1.medium","memory":"1700000","cpu":"2","arch":"i386"} +c1Xlarge = {"name":"c1.xlarge","memory":"7000000","cpu":"8","arch":"x86_64"} + + +#Use all hwp types for ec2 memory tests, other hwp tests +#hwp_i386 = [c1Medium, t1Micro , m1Small ] +#hwp_x86_64 = [m1Xlarge, t1Micro , m1Large , m2Xlarge , m22Xlarge , m24Xlarge , c1Xlarge] +hwp_x86_64 = [m1Xlarge] + +#Use just one hwp for os tests +hwp_i386 = [c1Medium] +#hwp_x86_64 = [m1Xlarge,m22Xlarge] + + + +publicDNS = [] + +if ARCH == 'i386': + for hwp in hwp_i386: + printValues(hwp) + myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) + this_hostname = startInstance(myConn, hwp["name"]) + map = {"hostname":this_hostname,"hwp":hwp} + publicDNS.append(map) + + +elif ARCH == 'x86_64': + for hwp in hwp_x86_64: + printValues(hwp) + myConn = getConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION) + this_hostname = startInstance(myConn, hwp["name"]) + map = {"hostname":this_hostname,"hwp":hwp} + publicDNS.append(map) + +lock = thread.allocate_lock() +print "sleep for 130 seconds" +time.sleep(130) +for host in publicDNS: + + executeValidScript(SSHKEY, host["hostname"],host["hwp"],BZ)