Involve virtualenv into localrc

This commit is contained in:
John Hua 2015-07-27 13:51:57 +08:00
parent 0f3847740a
commit 0c1709ae55
4 changed files with 30 additions and 16 deletions

View File

@ -1,34 +1,44 @@
source localrc
ACTION=${1:-"all"}
TMP="/tmp"
[ -e "$VIRENV_PATH/bin/activate" ] || virtualenv "$VIRENV_PATH"
source $VIRENV_PATH/bin/activate
function deploy_release {
scp cleardb.py root@$FUELMASTER:$PLUGIN_PATH
ssh root@$FUELMASTER dockerctl copy cleardb.py nailgun:/tmp/cleardb.py
scp cleardb.py root@$FUELMASTER:$TMP
ssh root@$FUELMASTER dockerctl copy "$TMP/cleardb.py" nailgun:/tmp/cleardb.py
ssh root@$FUELMASTER dockerctl shell nailgun /tmp/cleardb.py
ssh root@$FUELMASTER rm "$TMP/cleardb.py"
cat base_release.yaml > newrelease.yaml
echo '- pk: 9' >> newrelease.yaml
echo ' extend: *base_release' >> newrelease.yaml
cat xs_release.yaml >> newrelease.yaml
scp newrelease.yaml root@$FUELMASTER:$PLUGIN_PATH
ssh root@$FUELMASTER dockerctl copy newrelease.yaml nailgun:/tmp/newrelease.yaml
scp newrelease.yaml root@$FUELMASTER:$TMP
ssh root@$FUELMASTER dockerctl copy "$TMP/newrelease.yaml" nailgun:/tmp/newrelease.yaml
ssh root@$FUELMASTER dockerctl shell nailgun manage.py loaddata /tmp/newrelease.yaml
ssh root@$FUELMASTER fuel rel --sync-deployment-tasks --dir /etc/puppet/
rm newrelease.yaml
ssh root@$FUELMASTER rm "$TMP/newrelease.yaml"
}
function deploy_plugin {
fpb --check xenserver-fuel-plugin
fpb --build xenserver-fuel-plugin
scp xenserver-fuel-plugin/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm root@$FUELMASTER:$PLUGIN_PATH
scp xenserver-fuel-plugin/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm root@$FUELMASTER:$TMP
#ssh root@$FUELMASTER fuel plugins --remove xenserver-fuel-plugin==$VERSION
if ssh root@$FUELMASTER fuel plugins --list | grep xenserver-fuel-plugin; then
ssh root@$FUELMASTER fuel plugins --update "$TMP/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm"
else
ssh root@$FUELMASTER fuel plugins --install "$TMP/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm"
fi
ssh root@$FUELMASTER fuel plugins --remove xenserver-fuel-plugin==$VERSION
ssh root@$FUELMASTER fuel plugins --install $PLUGIN_PATH/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm
ssh root@$FUELMASTER fuel plugins --list
ssh root@$FUELMASTER rm "$TMP/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm"
}
case $ACTION in
"release") deploy_release ;;

View File

@ -32,12 +32,10 @@ tar -vxf %{SOURCE0} -C %{name}-%{version}
cd %{name}-%{version}
mkdir -p %{buildroot}/var/www/nailgun/plugins/
cp -r ${ name } %{buildroot}/var/www/nailgun/plugins/
date >> /tmp/post-xenserver-fuel-plugin-installed.log
%%clean
rm -rf %{buildroot}
%%files
/var/www/nailgun/plugins/${ name }
%post
date >> /tmp/post-xenserver-fuel-plugin-installed.log

View File

@ -1,7 +1,9 @@
set -x
VIRENV_PATH=${1:-"../../MOS"}
FPB_PATH=${2:-"../../fuel-plugins"}
ACTION=${1:-"install"}
cd ..
source localrc
[ -e "$VIRENV_PATH/bin/activate" ] || virtualenv "$VIRENV_PATH"
@ -9,10 +11,13 @@ source $VIRENV_PATH/bin/activate
[ -e "$FPB_PATH" ] || git clone "https://github.com/stackforge/fuel-plugins.git" "$FPB_PATH"
if [[ $ACTION == "overwrite" ]] ; then
cp plugin_rpm.spec.mako "$FPB_PATH/fuel_plugin_builder/fuel_plugin_builder/templates/v2/build/plugin_rpm.spec.mako"
fi
if [[ -z `pip show fuel-plugin-builder` ]] ; then
cp plugin_rpm.spec.mako "$FPB_PATH/fuel_plugin_builder/fuel_plugin_builder/templates/v2/build/plugin_rpm.spec.mako"
sudo pip install -e "$FPB_PATH/fuel_plugin_builder"
fi
#echo `which fpb`
echo `which fpb`

View File

@ -1,3 +1,4 @@
VERSION="0.0.3"
FUELMASTER="HOST_OF_FUEL_MASTER"
PLUGIN_PATH="~"
VIRENV_PATH="../MOS"
FPB_PATH="../fuel-plugins"