diff --git a/CICD/heat/server_rebuild.sh b/CICD/heat/server_rebuild.sh index 2e9aa620462721d45081e2d06d721078bb5883ff..004206023c61b779a9fef1b0968a09d40a94e72b 100755 --- a/CICD/heat/server_rebuild.sh +++ b/CICD/heat/server_rebuild.sh @@ -38,12 +38,15 @@ host_group_mapping=$(openstack server list --long -f json | python3 -c "import j # all available ansible_host_groups available_groups=$(echo $host_group_mapping | python3 -c "import json,sys;mapping=json.load(sys.stdin);output=[];[output.extend(v) for v in mapping.values()];print(output)" | tr -d "[',]") +echo "available groups are $available_groups" # if the first input parameter is all then rebuild all groups if [[ "$1" == "all" ]]; then NODETYPES=$available_groups fi echo "going to update group $NODETYPES" -server_list=$(echo $host_group_mapping | python3 -c "import json,sys;mapping=json.load(sys.stdin);avail_groups='$available_groups'.split();print([k for k in mapping.keys() if len(set(mapping[k]).intersection(set(avail_groups))) > 0])" | tr -d "[,]'" | xargs -n1 | sort -u) +server_list=$(echo $host_group_mapping | python3 -c "import json,sys;mapping=json.load(sys.stdin);node_types='$NODETYPES'.split();output=[k for k in mapping.keys() if len(set(mapping[k]).intersection(set(node_types))) > 0];print(output)" | tr -d "[,]'" | xargs -n1 | sort -u) + +echo "server list is $server_list" rebuild_func(){ echo "rebuilding server $1" openstack server rebuild --wait $1