Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add Image/Package Mode feature to os_vendor #102

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
105 changes: 70 additions & 35 deletions bin/burden
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export ANSIBLE_ROLES_PATH=$HOME/.ansible/collections/ansible_collections/pbench/
# cloud_numb_networks: Number of networks we are creating
# test_iterations: How many times are we to run the test. Each iteration is a full run of the tests,
# deletion of the cloud image, and recreation of the cloud image.
# user_parent_home_dir: Parent home directory of the user executing the tests (who is logged into the
# user_parent_home_dir: Parent home directory of the user executing the tests (who is logged into the
# test system).
# user_running: Who is running Zathras
# test_user: User name that is executing the test on the test system (ec2-user, root etc)
Expand Down Expand Up @@ -232,7 +232,7 @@ fi

#
# Generate report of test status.
#
#
process_results()
{
if [ $gl_first_invocation -eq 1 ]; then
Expand Down Expand Up @@ -482,7 +482,7 @@ grab_a_field()
str_val=`echo $1 | sed "s/\"//g" | sed "s/,$//g"`
#
# Check to make sure not going beyond last field.
#
#
res="${str_val//[^${2}]}"
len=`echo $res | wc -c`
if [ $len -lt $3 ]; then
Expand Down Expand Up @@ -585,7 +585,7 @@ find_test_def_field()
break;
fi
#
# Get the field name, and if it is what we are looking for,
# Get the field name, and if it is what we are looking for,
# process it.
#
field_val=$(grab_a_field "${line}" ":" 1)
Expand Down Expand Up @@ -627,7 +627,7 @@ create_test_run_file()
look_for=$1
found=0


#
# We want the yaml file, not the converted version.
while IFS= read -r line
Expand Down Expand Up @@ -727,7 +727,7 @@ set_image_type()
}

#
# General setup
# General setup
#
general_setup()
{
Expand Down Expand Up @@ -764,7 +764,7 @@ obtain_zone()
aws_number_zones=0
declare -a aws_zones
for i in `cat aws_zones`
do
do
aws_zones[${aws_number_zones}]=$i
let "aws_number_zones=$aws_number_zones+1"
done
Expand Down Expand Up @@ -1181,7 +1181,7 @@ add_local_config_info()
#
# Cloud systems, we use the utility grab_disks. This utility shows
# what disks are not in use. We do not do this for local systems,
# as disks that are not currently mounted may have information that the
# as disks that are not currently mounted may have information that the
# user wants.
#
echo "storage: grab_disks" >> ansible_run_vars.yml
Expand Down Expand Up @@ -1262,7 +1262,7 @@ azure_specific_os_version()
echo " cloud_publisher: ${azpublisher}" >> ansible_vars_main.yml
echo " cloud_os_version: ${azversion}" >> ansible_vars_main.yml
#
# Because the sku may contain an _, and ansible when it replaces the
# Because the sku may contain an _, and ansible when it replaces the
# variables in the tfvars.j2 file later will unquote _.
# After the envars file is created, we remove the '_' to be _.
#
Expand Down Expand Up @@ -1332,7 +1332,7 @@ retrieve_spot_from_config()
gl_spot_cap=$gl_base_cost
#
# We will default to 5 intervals
#
#
gl_spot_increment=`echo "scale=2;((($gl_spot_cap - $gl_spot_price)*1.5)/5.00)" | bc`

elif [[ $gl_system_type == "gcp" ]]; then
Expand Down Expand Up @@ -1851,7 +1851,7 @@ create_ansible_options()
add_local_config_info $ct_config
cd $gl_top_dir
#
# Reset everything for the next round.
# Reset everything for the next round.
#
gl_disks_asking_for=""
#
Expand Down Expand Up @@ -2028,7 +2028,7 @@ update_the_image()
}

#
# We could put this on each line in the appropriate function, but if
# We could put this on each line in the appropriate function, but if
# in the future we decide to change the output of this, we only have to
# do it in one place.
#
Expand All @@ -2038,15 +2038,15 @@ report_util_version()
}

#
# Package checking operations. For each required package, we have a function that will check for
# Package checking operations. For each required package, we have a function that will check for
# the package, and report any issues.
#
check_for_yq()
{
which yq 2> /dev/null
if [[ $? -eq 1 ]]; then
cleanup_and_exit "yq needs to be installed, to use the --test_def, please install." 1
fi
fi
#
# yq spits version out to stderr.
#
Expand All @@ -2060,7 +2060,7 @@ check_for_jq()
which jq 2> /dev/null
if [[ $? -eq 1 ]]; then
cleanup_and_exit "jq needs to be installed, to use the --test_def, please install.\nyum install jq\n"
fi
fi
jq_version=`jq --version`
report_util_version jq_version "${jq_version}"
}
Expand All @@ -2070,7 +2070,7 @@ check_for_ansible()
which ansible 2> /dev/null
if [[ $? -eq 1 ]]; then
cleanup_and_exit "Ansible is not installed, please install.\ndnf install -y ansible" 1
fi
fi
ansible_version=`ansible --version | grep ^ansible | awk '{print $2}'`
echo "Running with ansible version: ${ansible_version}"
echo "Zathras developed using ansible version: 2.9.6"
Expand All @@ -2083,7 +2083,7 @@ check_for_python()
which python 2> /dev/null
if [[ $? -eq 1 ]]; then
cleanup_and_exit "python is not installed, please install." 1
fi
fi
python_version=`python --version`
echo "Running with python version: ${python_version}"
echo "Zathras developed using python version: 3.7.4"
Expand All @@ -2104,7 +2104,7 @@ check_for_boto()
boto_version=`pip3 list --format="columns" | grep -F boto`
if [[ $? -eq 1 ]]; then
cleanup_and_exit "boto modules need to be installed.\npip3 install -U boto --user" 1
fi
fi
report_util_version boto_version "${boto_version}"
}

Expand Down Expand Up @@ -2189,16 +2189,46 @@ verify_test_def_file()
verify_os_vendor()
{
os_vendor_found=0
os_name=$(echo "$1" | awk -F ":" '{ print $1 }')
os_args=$(echo "$1" | awk -F ":" '{ print $2 }')

for os_vendor_check in $gl_valid_os_vendors;
for os_vendor_check in $gl_valid_os_vendors;
do
if [[ $1 == $os_vendor_check ]]; then
if [[ $os_name == $os_vendor_check ]]; then
os_vendor_found=1
gl_os_vendor=$os_name
fi
done
if [[ $os_vendor_found -eq 0 ]]; then
cleanup_and_exit "Error: $1, is an unrecognized OS vendor. Possible values are: $gl_valid_os_vendors" 1
fi

if [ -n "$os_args" ]; then
process_os_args "$os_args"
fi
}

process_os_args() {
arg_file=$(mktemp zath_os_args.XXXXX)
$UTILS_DIR/parse_optstring.sh "$1" > $arg_file
mode=$(yq -r .mode $arg_file)

case $mode in
"package")
gl_no_packages=0
;;
# Image mode is Read only root, /root is writeable
"image")
gl_no_packages=1
if [ "$gl_kit_upload_directory" == $value_not_set ]; then # Allow the user to overwrite this default
gl_kit_upload_directory="/root"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/root issues with public cloud.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe SSH into host to figure out user directory

fi
;;
*)
cleanup_and_exit "Error $mode is an unknown mode, valid options are: 'package' and 'image'" 1
;;
esac
rm $arg_file
}

#
Expand All @@ -2208,7 +2238,7 @@ verify_system_type()
{
sys_type_found=0

for sys_type in $gl_valid_system_types;
for sys_type in $gl_valid_system_types;
do
if [[ $1 == $sys_type ]]; then
sys_type_found=1
Expand Down Expand Up @@ -2279,7 +2309,7 @@ verify_java_version()
for ask_for in $1;
do
found=0
for version in $java_vers;
for version in $java_vers;
do
if [[ $version == $ask_for ]]; then
found=1
Expand All @@ -2289,7 +2319,7 @@ verify_java_version()
cleanup_and_exit "Error: unknown java version $1, known versions are: $java_vers" 1
fi
done

}

obtain_network_info()
Expand Down Expand Up @@ -2328,14 +2358,14 @@ verify_host_config()
fi
if [[ $gl_system_type == "gcp" ]]; then
gcloud compute machine-types describe $vm_instance > /dev/null
if [[ $? -ne 0 ]]; then
if [[ $? -ne 0 ]]; then
cleanup_and_exit "Error: GCP, unknown instance" 1 $vm_instance
fi
fi
if [[ $gl_system_type == "azure" ]]; then
# change eastus to be a value
az vm list-sizes --location "${gl_cloud_region}" | grep -o $vm_instance
if [[ $? -ne 0 ]]; then
if [[ $? -ne 0 ]]; then
cleanup_and_exit "Error: azure, unknown instance $vm_instance" 1
fi
fi
Expand Down Expand Up @@ -2507,7 +2537,7 @@ convert_scenario_file()
fi
#
# Check to make sure we have the proper number of host configs
#
#
sc_cnt=`grep host_config $tmp_run_file | wc -l`
ps_cnt=`grep host_config parse_file.tmp | wc -l`
if [ $ps_cnt != $sc_cnt ]; then
Expand Down Expand Up @@ -2664,7 +2694,7 @@ run_scenario()
if [[ $arg_value == *"--}"* ]]; then
continue
fi
if [[ $arg_value == *"--host_config"* ]]; then
if [[ $arg_value == *"--host_config"* ]]; then
argument=`echo $arg_value | cut -d' ' -f 2`
test_cli=$test_cli" --host_config \"${argument}\""
fi
Expand Down Expand Up @@ -2702,7 +2732,7 @@ run_scenario()
done
fi


#
# Have the line now, run the command.
#
Expand Down Expand Up @@ -2786,7 +2816,7 @@ verify_test_configuration()
bail_out=0
#
# First, make sure the test name is unique. This protects
# against
# against
# test_defs:
# test1:
# < test info>
Expand Down Expand Up @@ -2937,7 +2967,7 @@ process_test_template_data()
# We have an order that is expected for certain things. Put it all in that order as
# indicated by the file entry_order.
# Format of the entry_order file
#
#
# ^ test
# ^ test_template:
#
Expand Down Expand Up @@ -3109,7 +3139,7 @@ handle_test_defs()
}

#
# Usage information.
# Usage information.
#
usage()
{
Expand Down Expand Up @@ -3281,6 +3311,11 @@ usage()
echo " Burden will select the right ami for the designated host."
echo " --create_only: Only do the VM creation and OS install action."
echo " --os_vendor <os vendor>: currently rhel, ubuntu, amazon"
echo " --os_type <os type>: currently $gl_valid_os_types (default $value_not_set)"
echo " Additional options can be supplied in this format <os type>:<option1>=<value1>&<option2>=<value2>"
echo " Supported Options:"
echo " mode=<mode name>"
echo " Set to image or package (default), image sets kit_uploadt_location to /root by default and enables --no_packages"
echo " --terminate_cloud: If 1, terminate the cloud instance, if 0 leave the cloud image running."
echo " Default is to terminate"
echo " --use_spot: uses spot pricing based on the contents of config/spot_price.cfg. Default is not"
Expand Down Expand Up @@ -3379,7 +3414,7 @@ set_general_value()
verify_data verify_java_version $2
fi
shift_by=2
;;
;;
--kit_upload_directory)
echo "$1 $2" >> $gl_cli_supplied_options
gl_kit_upload_directory=$2
Expand Down Expand Up @@ -3572,7 +3607,7 @@ set_general_value()
#
# Does not return
#
show_test_version $2
show_test_version $2
;;
--tests)
if [[ $gl_test_list == "" ]]; then
Expand Down Expand Up @@ -3736,7 +3771,7 @@ grab_cli_data()

#
# If no options provided, then usage message.
#
#
if [ $# -eq 1 ]; then
usage "0"
fi
Expand Down Expand Up @@ -4098,7 +4133,7 @@ if [[ "${gl_scenario_to_run}" == *"https:"* ]] || [[ "${gl_scenario_to_run}" ==
fi

#
# Set up the various config files, if everything is started from this
# Set up the various config files, if everything is started from this
# process.
#
if [[ $gl_scenario_to_run != "" ]]; then
Expand Down
Loading