summaryrefslogtreecommitdiffstats
path: root/lib/parse-functions.sh
diff options
context:
space:
mode:
authorMichael Chapman <michapma@redhat.com>2016-09-08 12:44:39 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-08 12:44:40 +0000
commitdba76d80546f04dc22ddbf4dc70d4cc7206716f0 (patch)
treedeb40a25d7e10bdca4e7b1f3962639bd5725047f /lib/parse-functions.sh
parenta7accc442ec95252077d716b229d84ef86cb23ce (diff)
parent51510a96718c909cbcbf02256c440dbdceab7227 (diff)
Merge "moving inventory file parsing to python"
Diffstat (limited to 'lib/parse-functions.sh')
-rwxr-xr-xlib/parse-functions.sh86
1 files changed, 8 insertions, 78 deletions
diff --git a/lib/parse-functions.sh b/lib/parse-functions.sh
index 9c2ebff5..40cdb826 100755
--- a/lib/parse-functions.sh
+++ b/lib/parse-functions.sh
@@ -65,7 +65,7 @@ parse_network_settings() {
done
fi
- if output=$(python3.4 -B $LIB/python/apex_python_utils.py parse-net-settings -s $NETSETS $net_isolation_arg -e $CONFIG/network-environment.yaml $parse_ext); then
+ if output=$(python3 -B $LIB/python/apex_python_utils.py parse-net-settings -s $NETSETS $net_isolation_arg -e $CONFIG/network-environment.yaml $parse_ext); then
echo -e "${blue}${output}${reset}"
eval "$output"
else
@@ -88,7 +88,7 @@ parse_network_settings() {
##parses deploy settings yaml into globals
parse_deploy_settings() {
local output
- if output=$(python3.4 -B $LIB/python/apex_python_utils.py parse-deploy-settings -f $DEPLOY_SETTINGS_FILE); then
+ if output=$(python3 -B $LIB/python/apex_python_utils.py parse-deploy-settings -f $DEPLOY_SETTINGS_FILE); then
echo -e "${blue}${output}${reset}"
eval "$output"
else
@@ -99,85 +99,15 @@ parse_deploy_settings() {
}
##parses baremetal yaml settings into compatible json
-##writes the json to $CONFIG/instackenv_tmp.json
+##writes the json to undercloud:instackenv.json
##params: none
##usage: parse_inventory_file
parse_inventory_file() {
- local inventory=$(parse_yaml $INVENTORY_FILE)
- local node_list
- local node_prefix="node"
- local node_count=0
- local node_total
- local inventory_list
-
- # detect number of nodes
- for entry in $inventory; do
- if echo $entry | grep -Eo "^nodes_node[0-9]+_" > /dev/null; then
- this_node=$(echo $entry | grep -Eo "^nodes_node[0-9]+_")
- if [[ "$inventory_list" != *"$this_node"* ]]; then
- inventory_list+="$this_node "
- fi
- fi
- done
-
- inventory_list=$(echo $inventory_list | sed 's/ $//')
-
- for node in $inventory_list; do
- ((node_count+=1))
- done
-
- node_total=$node_count
-
- if [[ "$node_total" -lt 5 && "$ha_enabled" == "True" ]]; then
- echo -e "${red}ERROR: You must provide at least 5 nodes for HA baremetal deployment${reset}"
- exit 1
- elif [[ "$node_total" -lt 2 ]]; then
- echo -e "${red}ERROR: You must provide at least 2 nodes for non-HA baremetal deployment${reset}"
- exit 1
- fi
-
- eval $(parse_yaml $INVENTORY_FILE) || {
- echo "${red}Failed to parse inventory.yaml. Aborting.${reset}"
- exit 1
- }
-
- instackenv_output="
-{
- \"nodes\" : [
-
-"
- node_count=0
- for node in $inventory_list; do
- ((node_count+=1))
- node_output="
- {
- \"pm_password\": \"$(eval echo \${${node}ipmi_pass})\",
- \"pm_type\": \"$(eval echo \${${node}pm_type})\",
- \"mac\": [
- \"$(eval echo \${${node}mac_address})\"
- ],
- \"cpu\": \"$(eval echo \${${node}cpus})\",
- \"memory\": \"$(eval echo \${${node}memory})\",
- \"disk\": \"$(eval echo \${${node}disk})\",
- \"arch\": \"$(eval echo \${${node}arch})\",
- \"pm_user\": \"$(eval echo \${${node}ipmi_user})\",
- \"pm_addr\": \"$(eval echo \${${node}ipmi_ip})\",
- \"capabilities\": \"$(eval echo \${${node}capabilities})\"
-"
- instackenv_output+=${node_output}
- if [ $node_count -lt $node_total ]; then
- instackenv_output+=" },"
- else
- instackenv_output+=" }"
- fi
- done
-
- instackenv_output+='
- ]
-}
-'
- #Copy instackenv.json to undercloud for baremetal
- echo -e "{blue}Parsed instackenv JSON:\n${instackenv_output}${reset}"
+ if [ "$virtual" == "TRUE" ]; then inv_virt="--virtual"; fi
+ if [[ "$ha_enabled" == "True" ]]; then inv_ha="--ha"; fi
+ instackenv_output=$(python3 -B $LIB/python/apex_python_utils.py parse-inventory -f $INVENTORY_FILE $inv_virt $inv_ha)
+ #Copy instackenv.json to undercloud
+ echo -e "${blue}Parsed instackenv JSON:\n${instackenv_output}${reset}"
ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
cat > instackenv.json << EOF
$instackenv_output