From 56cdd395d56aa21186167a8b121cf993df255179 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 27 Jul 2015 14:33:34 -0400 Subject: [PATCH] extract setup_multinode_connectivity This extracts the logic of setup_multinode_connectivity into it's own function, so that it can be adapted to be used in the grenade case later on. Change-Id: I001e8ddd0eaf974e3cda2c1389c1c833af22323d --- devstack-vm-gate.sh | 115 +++++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/devstack-vm-gate.sh b/devstack-vm-gate.sh index 66828608..507ae23c 100755 --- a/devstack-vm-gate.sh +++ b/devstack-vm-gate.sh @@ -60,6 +60,64 @@ function setup_ssh { -a "src=/etc/nodepool/id_rsa dest='$path/id_rsa' mode=0400" } +function setup_multinode_connectivity { + set -x # for now enabling debug and do not turn it off + setup_localrc "new" "sub_localrc" "sub" + PRIMARY_NODE=`cat /etc/nodepool/primary_node_private` + SUB_NODES=`cat /etc/nodepool/sub_nodes_private` + if [[ "$DEVSTACK_GATE_NEUTRON" -ne '1' ]]; then + # TODO (clarkb): figure out how to make bridge setup sane with ansible. + ovs_gre_bridge "br_pub" $PRIMARY_NODE "True" 1 \ + $FLOATING_HOST_PREFIX $FLOATING_HOST_MASK \ + $SUB_NODES + ovs_gre_bridge "br_flat" $PRIMARY_NODE "False" 128 \ + $SUB_NODES + cat <>"$BASE/new/devstack/sub_localrc" +FLAT_INTERFACE=br_flat +PUBLIC_INTERFACE=br_pub +MULTI_HOST=True +EOF + cat <>"$BASE/new/devstack/localrc" +FLAT_INTERFACE=br_flat +PUBLIC_INTERFACE=br_pub +MULTI_HOST=True +EOF + elif [[ "$DEVSTACK_GATE_NEUTRON_DVR" -eq '1' ]]; then + ovs_gre_bridge "br-ex" $PRIMARY_NODE "True" 1 \ + $FLOATING_HOST_PREFIX $FLOATING_HOST_MASK \ + $SUB_NODES + fi + + echo "Preparing cross node connectivity" + setup_ssh $BASE/new/.ssh + setup_ssh ~root/.ssh + # TODO (clarkb) ansiblify the /etc/hosts and known_hosts changes + # set up ssh_known_hosts by IP and /etc/hosts + for NODE in $SUB_NODES; do + ssh-keyscan $NODE >> /tmp/tmp_ssh_known_hosts + echo $NODE `remote_command $NODE hostname | tr -d '\r'` >> /tmp/tmp_hosts + done + ssh-keyscan `cat /etc/nodepool/primary_node_private` >> /tmp/tmp_ssh_known_hosts + echo `cat /etc/nodepool/primary_node_private` `hostname` >> /tmp/tmp_hosts + cat /tmp/tmp_hosts | sudo tee --append /etc/hosts + + # set up ssh_known_host files based on hostname + for HOSTNAME in `cat /tmp/tmp_hosts | cut -d' ' -f2`; do + ssh-keyscan $HOSTNAME >> /tmp/tmp_ssh_known_hosts + done + $ANSIBLE all --sudo -f 5 -i "$WORKSPACE/inventory" -m copy \ + -a "src=/tmp/tmp_ssh_known_hosts dest=/etc/ssh/ssh_known_hosts mode=0444" + + for NODE in $SUB_NODES; do + remote_copy_file /tmp/tmp_hosts $NODE:/tmp/tmp_hosts + remote_command $NODE "cat /tmp/tmp_hosts | sudo tee --append /etc/hosts > /dev/null" + cp sub_localrc /tmp/tmp_sub_localrc + echo "HOST_IP=$NODE" >> /tmp/tmp_sub_localrc + remote_copy_file /tmp/tmp_sub_localrc $NODE:$BASE/new/devstack/localrc + remote_copy_file local.conf $NODE:$BASE/new/devstack/local.conf + done +} + function setup_localrc { local localrc_oldnew=$1; local localrc_file=$2 @@ -497,63 +555,8 @@ else setup_localrc "new" "localrc" "primary" if [[ "$DEVSTACK_GATE_TOPOLOGY" != "aio" ]]; then - set -x # for now enabling debug and do not turn it off echo -e "[[post-config|\$NOVA_CONF]]\n[libvirt]\ncpu_mode=custom\ncpu_model=gate64" >> local.conf - setup_localrc "new" "sub_localrc" "sub" - PRIMARY_NODE=`cat /etc/nodepool/primary_node_private` - SUB_NODES=`cat /etc/nodepool/sub_nodes_private` - if [[ "$DEVSTACK_GATE_NEUTRON" -ne '1' ]]; then - # TODO (clarkb): figure out how to make bridge setup sane with ansible. - ovs_gre_bridge "br_pub" $PRIMARY_NODE "True" 1 \ - $FLOATING_HOST_PREFIX $FLOATING_HOST_MASK \ - $SUB_NODES - ovs_gre_bridge "br_flat" $PRIMARY_NODE "False" 128 \ - $SUB_NODES - cat <>"$BASE/new/devstack/sub_localrc" -FLAT_INTERFACE=br_flat -PUBLIC_INTERFACE=br_pub -MULTI_HOST=True -EOF - cat <>"$BASE/new/devstack/localrc" -FLAT_INTERFACE=br_flat -PUBLIC_INTERFACE=br_pub -MULTI_HOST=True -EOF - elif [[ "$DEVSTACK_GATE_NEUTRON_DVR" -eq '1' ]]; then - ovs_gre_bridge "br-ex" $PRIMARY_NODE "True" 1 \ - $FLOATING_HOST_PREFIX $FLOATING_HOST_MASK \ - $SUB_NODES - fi - - echo "Preparing cross node connectivity" - setup_ssh $BASE/new/.ssh - setup_ssh ~root/.ssh - # TODO (clarkb) ansiblify the /etc/hosts and known_hosts changes - # set up ssh_known_hosts by IP and /etc/hosts - for NODE in $SUB_NODES; do - ssh-keyscan $NODE >> /tmp/tmp_ssh_known_hosts - echo $NODE `remote_command $NODE hostname | tr -d '\r'` >> /tmp/tmp_hosts - done - ssh-keyscan `cat /etc/nodepool/primary_node_private` >> /tmp/tmp_ssh_known_hosts - echo `cat /etc/nodepool/primary_node_private` `hostname` >> /tmp/tmp_hosts - cat /tmp/tmp_hosts | sudo tee --append /etc/hosts - - # set up ssh_known_host files based on hostname - for HOSTNAME in `cat /tmp/tmp_hosts | cut -d' ' -f2`; do - ssh-keyscan $HOSTNAME >> /tmp/tmp_ssh_known_hosts - done - $ANSIBLE all --sudo -f 5 -i "$WORKSPACE/inventory" -m copy \ - -a "src=/tmp/tmp_ssh_known_hosts dest=/etc/ssh/ssh_known_hosts mode=0444" - - for NODE in $SUB_NODES; do - remote_copy_file /tmp/tmp_hosts $NODE:/tmp/tmp_hosts - remote_command $NODE "cat /tmp/tmp_hosts | sudo tee --append /etc/hosts > /dev/null" - cp sub_localrc /tmp/tmp_sub_localrc - echo "HOST_IP=$NODE" >> /tmp/tmp_sub_localrc - remote_copy_file /tmp/tmp_sub_localrc $NODE:$BASE/new/devstack/localrc - remote_copy_file local.conf $NODE:$BASE/new/devstack/local.conf - done - + setup_multinode_connectivity fi # Make the workspace owned by the stack user # It is not clear if the ansible file module can do this for us