From e1c18b3c63df27b2029a23818f50a6fc4e3afe59 Mon Sep 17 00:00:00 2001 From: "juraj.linkes" Date: Thu, 15 Jun 2017 15:00:15 +0200 Subject: Post apex updates Removed setting nova and neutron debugs. Added sourcing of overcloudrc. Also minor refactor. Change-Id: Ifb835fa81a19d98bda4a2c6f955abda3699946d3 Signed-off-by: juraj.linkes --- scripts/post_apex.sh | 58 ++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 27 deletions(-) (limited to 'scripts') diff --git a/scripts/post_apex.sh b/scripts/post_apex.sh index 6f5b2f8..eb37fe3 100755 --- a/scripts/post_apex.sh +++ b/scripts/post_apex.sh @@ -1,19 +1,24 @@ #!/bin/bash -. $(dirname "$0")/lib.sh -undercloud_ip=`arp -a | grep $(virsh domiflist undercloud | grep default | awk '{print $5}') | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"` -#echo $undercloud_ip +SCRIPT_DIR=$(dirname "$0") +. $SCRIPT_DIR/lib.sh +UNDERCLOUD_IP=$(arp -a | grep $(virsh domiflist undercloud | grep default | awk '{print $5}') \ + | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") +#echo $UNDERCLOUD_IP # copy rc file to jumphost echo "Copying overcloud rc to jumphost to $overcloudrc_path" -scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$undercloud_ip:/home/stack/overcloudrc $overcloudrc_path 2> /dev/null +scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$UNDERCLOUD_IP:/home/stack/overcloudrc.v3 \ + $overcloudrc_path &> /dev/null -# copy jumphost root key to undercloud vm - needs $undercloud_ip +# copy jumphost root key to undercloud vm - needs $UNDERCLOUD_IP echo "Copying root's public ssh key to undercloud vm" -scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /root/.ssh/id_rsa.pub root@$undercloud_ip:/home/stack/id_rsa_jumphost_root.pub 2> /dev/null +scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /root/.ssh/id_rsa.pub \ + root@$UNDERCLOUD_IP:/home/stack/id_rsa_jumphost_root.pub &> /dev/null # copy key copying script to undercloud vm echo "Copying ssh setup script to undercloud vm" -scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null `dirname $0`/copy_keys.sh root@$undercloud_ip:/home/stack 2> /dev/null +scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $SCRIPT_DIR/copy_keys.sh \ + root@$UNDERCLOUD_IP:/home/stack &> /dev/null #overcloud_dir="/root/.overcloud" #node_list_filename="$overcloud_dir/node_list" @@ -21,15 +26,16 @@ scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null `dirname $0`/cop sed -i "/$NODE_PATTERN/d" /etc/hosts OIFS="$IFS" IFS=$'\n' -nova_list=`ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null stack@$undercloud_ip ". stackrc && nova list | tail -n+4 | head -n-1 | sed 's/ //g'" 2> /dev/null` +nova_list=$(ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null stack@$UNDERCLOUD_IP \ + ". stackrc && nova list | tail -n+4 | head -n-1 | sed 's/ //g'" 2> /dev/null) node_list=($nova_list) IFS="$OIFS" for node in "${node_list[@]}" do echo - node_fields=`echo $node | cut -d "|" -f 3,7` - node_name=`echo $node_fields | cut -d "|" -f 1` - node_ip=`echo $node_fields | cut -d "=" -f 2` + node_fields=$(echo $node | cut -d "|" -f 3,7) + node_name=$(echo $node_fields | cut -d "|" -f 1) + node_ip=$(echo $node_fields | cut -d "=" -f 2) echo "Adding $node_name to /etc/hosts" echo $node_ip $node_name >> /etc/hosts echo "Removing $node_ip from known hosts" @@ -37,23 +43,20 @@ do echo "Removing $node_name from known hosts" sed -i "/$node_name/d" /root/.ssh/known_hosts echo "Setting up ssh keys on $node_name for root" - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null stack@$undercloud_ip "/home/stack/copy_keys.sh $node_ip &" 2> /dev/null + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null stack@$UNDERCLOUD_IP \ + "/home/stack/copy_keys.sh $node_ip &" &> /dev/null echo "Copying overcloudrc to $node_name" - scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $overcloudrc_path heat-admin@$node_ip:. 2> /dev/null - ssh -oStrictHostKeyChecking=no heat-admin@$node_ip 'sudo cp /home/heat-admin/overcloudrc /root' 2> /dev/null + scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $overcloudrc_path heat-admin@$node_ip:. &> /dev/null + ssh -oStrictHostKeyChecking=no heat-admin@$node_ip 'sudo cp /home/heat-admin/overcloudrc /root' &> /dev/null echo "Cloning fds repo on $node_name to $overcloud_fds_repo_loc" - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $node_name 'git clone https://gerrit.opnfv.org/gerrit/p/fds.git $overcloud_fds_repo_loc' 2> /dev/null - if [[ $node_name = *'controller'* ]] + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $node_name \ + 'git clone https://gerrit.opnfv.org/gerrit/p/fds.git $overcloud_fds_repo_loc' &> /dev/null + if [[ $(ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$node_ip \ + 'grep -c ". /root/overcloudrc" /root/.bashrc' 2> /dev/null) -eq 0 ]] then - echo "Setting debugs for nova and neutron on $node_name" - ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?debug *=.*$/debug=True/" /etc/nova/nova.conf' 2> /dev/null - ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?verbose *=.*$/verbose=True/" /etc/nova/nova.conf' 2> /dev/null - ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?debug *=.*$/debug=True/" /etc/neutron/neutron.conf' 2> /dev/null - ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?verbose *=.*$/verbose=True/" /etc/neutron/neutron.conf' 2> /dev/null - else - echo "Setting debugs for nova on $node_name" - ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?debug *=.*$/debug=True/" /etc/nova/nova.conf' 2> /dev/null - ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?verbose *=.*$/verbose=True/" /etc/nova/nova.conf' 2> /dev/null + echo "Setting up . /root/overcloudrc in .bashrc on $node_name" + ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$node_ip \ + 'echo ". /root/overcloudrc" >> /root/.bashrc' &> /dev/null fi done . $overcloudrc_path @@ -78,10 +81,11 @@ then echo "Downloading cirros image to $image_loc" wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -O $image_loc fi - openstack image create --disk-format qcow2 --container-format bare --public --property hw_mem_page_size=large --file $image_loc cirros-0.3.4 + openstack image create --disk-format qcow2 --container-format bare --public --property hw_mem_page_size=large \ + --file $image_loc cirros-0.3.4 else echo "Image cirros-0.3.4 is already configured" fi echo -echo "Post-apex script is finished. If you want the nova and neutron debug configurations to take effect, you'll need to restart the services manually." +echo "Post-apex script is done." -- cgit 1.2.3-korg