Skip to content

Commit

Permalink
modifications in setup_devstack.sh based on the current contrail setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonymous committed Oct 15, 2014
1 parent 91ac95c commit 598d588
Showing 1 changed file with 74 additions and 53 deletions.
127 changes: 74 additions & 53 deletions setup_devstack.sh
Original file line number Diff line number Diff line change
@@ -1,63 +1,84 @@
#!/bin/bash

echo -e "Devstack Branch you want to setup: \n [ex: stable/havana]"

read dvstk


DEVSTACK_CLONE_URL="https://github.com/openstack-dev/devstack.git"
DEVSTACK_CLONE_BRANCH=""
DEVSTACK_CLONE_BRANCH="$dvstk"
CONTRAIL_DIR=`pwd`
DEVSTACK_CLONE_DIR=$CONTRAIL_DIR/../
DEVSTACK_DIR=$DEVSTACK_CLONE_DIR/devstack
RECLONE=${RECLONE:-False}

#echo $RECLONE

if [[ "$RECLONE" == "True" ]]; then
echo "Removing the current devstack and recloning again"
sudo rm -r $DEVSTACK_DIR
fi
if [[ -d $DEVSTACK_DIR ]]; then
echo "devstack is already cloned using that devstack to work"
else
if [[ $DEVSTACK_CLONE_BRANCH ]];then
echo "cloning the branch $DEVSTACK_CLONE_BRANCH"
CLONE_BRANCH="-b $DEVSTACK_CLONE_BRANCH"

Clone_Devstack () {
if [ "$RECLONE" = "True" ]; then
echo "Removing the current devstack and recloning again"
sudo rm -r $DEVSTACK_DIR
fi
cd $DEVSTACK_CLONE_DIR
git clone $CLONE_BRANCH $DEVSTACK_CLONE_URL
fi
cd $CONTRAIL_DIR


if [[ -f $DEVSTACK_DIR/lib/neutron_thirdparty/contrail ]]; then
echo "file already exist"
else
cp contrail $DEVSTACK_DIR/lib/neutron_plugins/
fi
cd $CONTRAIL_DIR

if [[ -f $DEVSTACK_DIR/localrc ]]; then
echo "localrc is already new"
else
cp samples/localrc-multinode-server $DEVSTACK_DIR/localrc
fi

function replace_in_file()
{
file=$1
regexp=$2
replace=$3
sed -in 's|.*\b'"$regexp"'.*\b|'"$replace"'|g' $file
if [ -d $DEVSTACK_DIR ]; then
echo "devstack is already cloned using that devstack to work"
else
if [ $DEVSTACK_CLONE_BRANCH ];then
echo "cloning the branch $DEVSTACK_CLONE_BRANCH"
CLONE_BRANCH="-b $DEVSTACK_CLONE_BRANCH"
fi
cd $DEVSTACK_CLONE_DIR
git clone $CLONE_BRANCH $DEVSTACK_CLONE_URL
fi

}

Changes_Devstack_localrc () {
cd $CONTRAIL_DIR

#checks if there is devstack folder cloned or not
if [ -d $DEVSTACK_DIR ] ; then
if [ -f $DEVSTACK_DIR/lib/neutron_plugins/opencontrail ]; then
echo "opencontrail plugin file is already new in devstack"
else
cp $CONTRAIL_DIR/devstack/lib/neutron_plugins/opencontrail $DEVSTACK_DIR/lib/neutron_plugins/
fi
if [ -f $DEVSTACK_DIR/localrc ]; then
echo "localrc is already new"
else
cp $CONTRAIL_DIR/devstack/samples/localrc-all $DEVSTACK_DIR/localrc
fi
cd $DEVSTACK_DIR
if [ -f $DEVSTACK_DIR/localrc ]; then
# Changes in $DEVSTACK_DIR/localrc
sed -i '/ADMIN_PASSWORD/ a USE_SCREENS=True' $DEVSTACK_DIR/localrc
grep -q "Q_PLUGIN=opencontrail" $DEVSTACK_DIR/localrc
[ $? -eq 1 ] && sed -i '/ADMIN_PASSWORD/ a Q_PLUGIN=opencontrail' $DEVSTACK_DIR/localrc
sed -i 's/^#*GIT_BASE/GIT_BASE/g' $DEVSTACK_DIR/localrc
sed -i 's/^#*NOVA_VIF_DRIVER/NOVA_VIF_DRIVER/g' $DEVSTACK_DIR/localrc
sed -i "s/^HOST_IP=.*/HOST_IP=`ifconfig | head -n2 | tail -1 | cut -d: -f2 | cut -d' ' -f1`/" $DEVSTACK_DIR/localrc
if [ -f $CONTRAIL_DIR/localrc ] ; then
ENABLE_BINARY=`grep "CONTRAIL_DEFAULT_INSTALL" $CONTRAIL_DIR/localrc | cut -d'=' -f2`

#Changes regarding Q_PLUGIN
if [ "$ENABLE_BINARY" = "True" ]; then
[ `grep "^ *LAUNCHPAD_BRANCH=PPA" $CONTRAIL_DIR/localrc` ] && sed -i "s/.*Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2.*/#Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2/" ./localrc || sed -i "s/.*#Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2.*/Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2/" ./localrc
else
sed -i "s/.*Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2.*/#Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2/" ./localrc
fi
fi
fi

fi

}

Setup_Devstack () {

file=$DEVSTACK_DIR/stackrc

sudo grep -q ^"CONTRAIL_GIT_BASE" $file
value=$?
if [[ $value -eq 1 ]]; then
sed -i '206 a\CONTRAIL_GIT_BASE=${CONTRAIL_GIT_BASE:-https://github.com/juniper}\' $file
fi
replace_in_file $file "NEUTRON_REPO" "#NEUTRON_REPO"
replace_in_file $file "NEUTRON_BRANCH" "#NEUTRON_BRANCH"
sudo grep -q ^"NEUTRON_REPO" $file
value=$?
if [[ $value -eq 1 ]]; then
sed -i '207 a\NEUTRON_REPO=${NEUTRON_REPO:-${CONTRAIL_GIT_BASE}/neutron.git}\' $file
sed -i '208 a\NEUTRON_BRANCH=${CONTRAIL_NEUTRON_BRANCH:-contrail/havana}\' $file
fi
Clone_Devstack #Cloning devstack into the directory where contrail-installer presents
Changes_Devstack_localrc #Changing localrc in devstack
}

Setup_Devstack

echo "Devstack $dvstk : setup completed successfully"

0 comments on commit 598d588

Please sign in to comment.