#!/bin/bash
pwd_path_0="/home/qa-deploy-utils"
pwd_path="/home/qa-deploy-utils/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/get_env_ip.sh`

if [ -n "$1" ];then
	project_path=$1
fi

response=$(curl -X GET -H "Authorization: Basic cmFiYml0X2FkbWluOmFiYzEyMzQ=" "http://172.16.1.231:15672/api/definitions")

for ip_last_num in $project_path
do
	IP_host=`sh $pwd_path_0/get-ip.sh $ip_last_num`
	echo curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic cWE6cWF0ZXN0" -d $response "http://$IP_host:15672/api/definitions"
	curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic cWE6cWF0ZXN0" -d $response "http://$IP_host:15672/api/definitions"
	if [ $? != 0 ];then
		echo "curl $IP_host failed"
		exit -1
	fi
done