-
Notifications
You must be signed in to change notification settings - Fork 2
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
#166
Open
kdvalin
wants to merge
11
commits into
main
Choose a base branch
from
feature/bootc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cf6edb6
Feat: Add optstring parsing script to reduce duplication
kdvalin 21b3c79
Feat: Add image/package mode flags for os_vendor field
kdvalin f049751
Fix: remove old code from alternate image mode impelmentations
kdvalin 67341b5
Fix: remove debug code from os_vendor validation
kdvalin 7df2f65
Added GPL license header to parse_opstring.sh
kdvalin eb4bfc5
Fix (bootc): Update kit_upload_directory when not specified to a writ…
kdvalin 8b6f968
Refactor: Move optstring parsing to new utils folder
kdvalin ef1743d
Fix (bootc): Dynamically make tmp file for osargs to allow for multip…
kdvalin 7330b13
Doc (bootc): Added docs for Image Mode
kdvalin 848d374
Fix (bootc): Remove debug statements
kdvalin fd9dbd0
Fix (bootc): Update osarg temp file naming
kdvalin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -232,7 +232,7 @@ fi | |
|
||
# | ||
# Generate report of test status. | ||
# | ||
# | ||
process_results() | ||
{ | ||
if [ $gl_first_invocation -eq 1 ]; then | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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 | ||
|
@@ -727,7 +727,7 @@ set_image_type() | |
} | ||
|
||
# | ||
# General setup | ||
# General setup | ||
# | ||
general_setup() | ||
{ | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 _. | ||
# | ||
|
@@ -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 | ||
|
@@ -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="" | ||
# | ||
|
@@ -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. | ||
# | ||
|
@@ -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. | ||
# | ||
|
@@ -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}" | ||
} | ||
|
@@ -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" | ||
|
@@ -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" | ||
|
@@ -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}" | ||
} | ||
|
||
|
@@ -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" | ||
fi | ||
;; | ||
*) | ||
cleanup_and_exit "Error $mode is an unknown mode, valid options are: 'package' and 'image'" 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to remove the temp file on failure. |
||
;; | ||
esac | ||
rm $arg_file | ||
} | ||
|
||
# | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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() | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -2702,7 +2732,7 @@ run_scenario() | |
done | ||
fi | ||
|
||
|
||
# | ||
# Have the line now, run the command. | ||
# | ||
|
@@ -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> | ||
|
@@ -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: | ||
# | ||
|
@@ -3109,7 +3139,7 @@ handle_test_defs() | |
} | ||
|
||
# | ||
# Usage information. | ||
# Usage information. | ||
# | ||
usage() | ||
{ | ||
|
@@ -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" | ||
|
@@ -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 | ||
|
@@ -3572,7 +3607,7 @@ set_general_value() | |
# | ||
# Does not return | ||
# | ||
show_test_version $2 | ||
show_test_version $2 | ||
;; | ||
--tests) | ||
if [[ $gl_test_list == "" ]]; then | ||
|
@@ -3736,7 +3771,7 @@ grab_cli_data() | |
|
||
# | ||
# If no options provided, then usage message. | ||
# | ||
# | ||
if [ $# -eq 1 ]; then | ||
usage "0" | ||
fi | ||
|
@@ -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 | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double [[, not single