8a542ef8ec
Learning the Ansible API for this migration. Very simple script that will use the browbeat checks + Added Pbench start/stop 01/11/16 + Moved ansible to config 01/11/16 + Adding ansible hosts option 01/11/16 + Connmon added (start/stop) still nothing with results 01/12/16 + New Rally YAML format... (nova example) 01/12/16 + Create results directory 01/12/16 + Created lib with classes 01/13/16 + Updated Scenarios 01/14/16 + Updated other workloads to new format 01/15/16 + Switched to dict get method 01/15/16 + Removed pyc files and updated 01/15/16 + updated genhost file 01/15/16 + Update Ansible for connmon finished pbench work 01/15/16 + Catch if user tries to run without Ansible or Ansible2 01/26/16 + Minor changes 01/26/16 + Bug fix... 01/27/16 + (akrzos) added keystone yamls and browbeat-complete.yaml + Moved BrowbeatRally to Rally and broke connmon out of Tools + (akrzos) Implemented per Rally test scenario task args. + Updated Docs, removed old browbeat.sh + (akrzos) Cleaned up lib/Rally.py and added cinder scenarios to browbeat configs. + Fix Connmon install issue + (akrzos) Added parameters to neutron task yamls + (akrzos) Changed connmon to stop logging immediately after rally task completes. Change-Id: I338c3463e25f38c2ec7667c7dfc8b5424acba8c2
129 lines
5.4 KiB
Bash
Executable File
129 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
if [ ! $# -ge 2 ]; then
|
|
echo "Usage: ./gen_hostfiles.sh <ospd_ip_address> <ssh_config_file> <OPTIONAL pbench_host_file> "
|
|
echo "Generates ssh config file to use OSP undercloud host as a jumpbox and creates ansible inventory file."
|
|
exit
|
|
fi
|
|
ospd_ip_address=$1
|
|
ansible_inventory_file='hosts'
|
|
ssh_config_file=$2
|
|
pbench_host_file=$3
|
|
|
|
# "Hackish" copy ssh key to self if we are on directly on the undercloud machine:
|
|
if [[ "${ospd_ip_address}" == "localhost" ]]; then
|
|
cat ~stack/.ssh/id_rsa.pub >> ~stack/.ssh/authorized_keys
|
|
sudo bash -c "cat ~stack/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys"
|
|
fi
|
|
|
|
nodes=$(ssh -t -o "StrictHostKeyChecking no" stack@${ospd_ip_address} ". ~/stackrc; nova list | grep -i -E 'active|running'")
|
|
|
|
controller_id=$(ssh -t -o "StrictHostKeyChecking no" stack@${ospd_ip_address} ". ~/stackrc; heat resource-show overcloud Controller | grep physical_resource_id" | awk '{print $4}')
|
|
compute_id=$(ssh -t -o "StrictHostKeyChecking no" stack@${ospd_ip_address} ". ~/stackrc; heat resource-show overcloud Compute | grep physical_resource_id" | awk '{print $4}')
|
|
controller_ids=$(ssh -t -o "StrictHostKeyChecking no" stack@${ospd_ip_address} ". ~/stackrc; heat resource-list ${controller_id} | grep -i controller" | awk '{print $2}')
|
|
compute_ids=$(ssh -t -o "StrictHostKeyChecking no" stack@${ospd_ip_address} ". ~/stackrc; heat resource-list ${compute_id} | grep -i compute" | awk '{print $2}')
|
|
|
|
controller_uuids=()
|
|
for controller in ${controller_ids}
|
|
do
|
|
controller_uuids+=$(ssh -t -o "StrictHostKeyChecking no" stack@${ospd_ip_address} ". ~/stackrc; heat resource-show ${controller_id} ${controller} | grep -i nova_server_resource" | awk '{print $4}')
|
|
done
|
|
compute_uuids=()
|
|
for compute in ${compute_ids}
|
|
do
|
|
compute_uuids+=$(ssh -t -o "StrictHostKeyChecking no" stack@${ospd_ip_address} ". ~/stackrc; heat resource-show ${compute_id} ${compute} | grep -i nova_server_resource" | awk '{print $4}')
|
|
done
|
|
|
|
echo ""
|
|
echo "---------------------------"
|
|
echo "Creating ssh config file:"
|
|
echo "---------------------------"
|
|
echo ""
|
|
|
|
echo "# Generate by gen_hostfile.sh from browbeat" | tee ${ssh_config_file}
|
|
echo "" | tee -a ${ssh_config_file}
|
|
echo "Host undercloud-stack" | tee -a ${ssh_config_file}
|
|
echo " Hostname ${ospd_ip_address}" | tee -a ${ssh_config_file}
|
|
echo " User stack" | tee -a ${ssh_config_file}
|
|
echo " IdentityFile ~/.ssh/id_rsa" | tee -a ${ssh_config_file}
|
|
echo " StrictHostKeyChecking no" | tee -a ${ssh_config_file}
|
|
echo " UserKnownHostsFile=/dev/null" | tee -a ${ssh_config_file}
|
|
echo "" | tee -a ${ssh_config_file}
|
|
echo "Host undercloud-root" | tee -a ${ssh_config_file}
|
|
echo " Hostname ${ospd_ip_address}" | tee -a ${ssh_config_file}
|
|
echo " User root" | tee -a ${ssh_config_file}
|
|
echo " IdentityFile ~/.ssh/id_rsa" | tee -a ${ssh_config_file}
|
|
echo " StrictHostKeyChecking no" | tee -a ${ssh_config_file}
|
|
echo " UserKnownHostsFile=/dev/null" | tee -a ${ssh_config_file}
|
|
|
|
echo "[hosts]" > ${pbench_host_file}
|
|
compute_hn=()
|
|
controller_hn=()
|
|
ceph_hn=()
|
|
IFS=$'\n'
|
|
for line in $nodes; do
|
|
uuid=$(echo $line | awk '{print $2}')
|
|
host=$(echo $line | awk '{print $4}')
|
|
IP=$(echo $line | awk '{print $12}' | cut -d "=" -f2)
|
|
if grep -q $uuid <<< {$controller_uuids}; then
|
|
controller_hn+=("$host")
|
|
elif grep -q $uuid <<< {$compute_uuids}; then
|
|
compute_hn+=("$host")
|
|
else
|
|
ceph_hn+=("$host")
|
|
fi
|
|
echo "" | tee -a ${ssh_config_file}
|
|
echo "# pbench specific configuration, force user to be root on target" | tee -a ${ssh_config_file}
|
|
echo "Host ${IP}" | tee -a ${ssh_config_file}
|
|
echo " User root" | tee -a ${ssh_config_file}
|
|
echo "" | tee -a ${ssh_config_file}
|
|
echo "Host ${host}" | tee -a ${ssh_config_file}
|
|
echo " ProxyCommand ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=60 -i ~/.ssh/id_rsa stack@${ospd_ip_address} -W ${IP}:22" | tee -a ${ssh_config_file}
|
|
echo " User heat-admin" | tee -a ${ssh_config_file}
|
|
echo " IdentityFile ~/.ssh/heat-admin-id_rsa" | tee -a ${ssh_config_file}
|
|
echo " StrictHostKeyChecking no" | tee -a ${ssh_config_file}
|
|
echo " UserKnownHostsFile=/dev/null" | tee -a ${ssh_config_file}
|
|
echo "${IP}" >> ${pbench_host_file}
|
|
done
|
|
|
|
|
|
echo ""
|
|
echo "---------------------------"
|
|
echo "Creating ansible inventory file:"
|
|
echo "---------------------------"
|
|
echo ""
|
|
echo "[undercloud]" | tee ${ansible_inventory_file}
|
|
echo "${ospd_ip_address}" | tee -a ${ansible_inventory_file}
|
|
if [[ ${#controller_hn} -gt 0 ]]; then
|
|
echo "" | tee -a ${ansible_inventory_file}
|
|
echo "[controller]" | tee -a ${ansible_inventory_file}
|
|
for ct in ${controller_hn[@]}; do
|
|
echo "${ct}" | tee -a ${ansible_inventory_file}
|
|
done
|
|
fi
|
|
if [[ ${#compute_hn} -gt 0 ]]; then
|
|
echo "" | tee -a ${ansible_inventory_file}
|
|
echo "[compute]" | tee -a ${ansible_inventory_file}
|
|
for c in ${compute_hn[@]}; do
|
|
echo "${c}" | tee -a ${ansible_inventory_file}
|
|
done
|
|
fi
|
|
if [[ ${#ceph_hn} -gt 0 ]]; then
|
|
echo "" | tee -a ${ansible_inventory_file}
|
|
echo "[ceph]" | tee -a ${ansible_inventory_file}
|
|
for ceph in ${ceph_hn[@]}; do
|
|
echo "${ceph}" | tee -a ${ansible_inventory_file}
|
|
done
|
|
fi
|
|
echo "---------------------------"
|
|
|
|
# Before referencing a host in ~/.ssh/config, ensure correct permissions on ssh config file
|
|
chmod 0600 ${ssh_config_file}
|
|
|
|
# Copy heat-admin key so we can use jumpbox
|
|
echo ""
|
|
echo "---------------------------"
|
|
echo "Copying heat-admin key to local machine(~/.ssh/heat-admin-id_rsa) to for use with ssh config file"
|
|
echo "---------------------------"
|
|
echo ""
|
|
scp undercloud-root:/home/stack/.ssh/id_rsa ~/.ssh/heat-admin-id_rsa
|