From 5f87b4c0e0860bed8f89b130878ce7902c8b5502 Mon Sep 17 00:00:00 2001 From: billsung Date: Fri, 27 Jul 2018 17:16:24 +0800 Subject: [PATCH] Just modify run.sh/setupIFTdriver.sh --- README.md | 1 + run_test.sh | 29 +---------------------------- setupIFTdriver.sh | 42 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index bb3f795..fbcfdfa 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ It manages storage by Infortrend CLI tool. ## How to setup and use +- If Cinder runs on Ubuntu, run `. setupIFTDriver.sh` to quick update Cinder-volume with this Cinder Driver. - Please check our [user manual](https://github.com/infortrend-openstack/openstack-cinder-manaul). # Run Test diff --git a/run_test.sh b/run_test.sh index 9886651..2f521ab 100644 --- a/run_test.sh +++ b/run_test.sh @@ -2,8 +2,6 @@ export CINDER_DIR=./cinder export CINDER_REPO_URL="https://git.openstack.org/openstack/cinder" -export INFORTREND_TEST_DIR="cinder/tests/unit/volume/drivers/infortrend" -export INFORTREND_DRIVER_DIR="cinder/volume/drivers/infortrend" echo "Running Flake8..." flake8 infortrend/ @@ -26,32 +24,7 @@ else echo "Skip Cloning cinder." fi -if [ ! -d "$CINDER_DIR/$INFORTREND_DRIVER_DIR" ]; then - mkdir $CINDER_DIR/$INFORTREND_DRIVER_DIR -fi - -if [ ! -d "$CINDER_DIR/$INFORTREND_TEST_DIR" ]; then - mkdir $CINDER_DIR/$INFORTREND_TEST_DIR -fi - -echo "Copy ./infortrend/*" -cp ./infortrend/* $CINDER_DIR/$INFORTREND_DRIVER_DIR/ -r -echo "Copy ./test/infortrend/*" -cp ./test/infortrend/* $CINDER_DIR/$INFORTREND_TEST_DIR/ -r - -if grep "infortrend" -q "$CINDER_DIR/cinder/opts.py"; then - echo "Driver opts already set." -else - echo "Setup infortrend opts/exceptions.." - source setupIFTdriver.sh -fi - -sed -i '125 ifrom cinder.volume.drivers.infortrend.raidcmd_cli import common_cli as \\\n cinder_volume_drivers_infortrend' ./cinder/cinder/opts.py -sed -i '305 i\\ cinder_volume_drivers_infortrend.infortrend_opts,' ./cinder/cinder/opts.py -echo '# Infortrend Driver' >> ./cinder/cinder/exception.py -echo 'class InfortrendCliException(CinderException):' >> ./cinder/cinder/exception.py -echo ' message = _("Infortrend CLI exception: %(err)s Param: %(param)s "' >> ./cinder/cinder/exception.py -echo ' "(Return Code: %(rc)s) (Output: %(out)s)")' >> ./cinder/cinder/exception.py +source setupIFTdriver.sh $CINDER_DIR cd $CINDER_DIR diff --git a/setupIFTdriver.sh b/setupIFTdriver.sh index 7fa1f71..9aa66d1 100644 --- a/setupIFTdriver.sh +++ b/setupIFTdriver.sh @@ -1,10 +1,36 @@ #!/bin/bash -export BASE=./cinder/cinder/ - -sed -i '131 ifrom cinder.volume.drivers.infortrend.raidcmd_cli import common_cli as \\\n cinder_volume_drivers_infortrend' $BASE/opts.py -sed -i '325 i\\ cinder_volume_drivers_infortrend.infortrend_opts,' $BASE/opts.py -echo '# Infortrend Driver' >> $BASE/exception.py -echo 'class InfortrendCliException(CinderException):' >> $BASE/exception.py -echo ' message = _("Infortrend CLI exception: %(err)s Param: %(param)s "' >> $BASE/exception.py -echo ' "(Return Code: %(rc)s) (Output: %(out)s)")' >> $BASE/exception.py +export INFORTREND_TEST_DIR="tests/unit/volume/drivers/infortrend" +export INFORTREND_DRIVER_DIR="volume/drivers/infortrend" + +if [ -z "${1}" ]; then + export BASE=/usr/lib/python2.7/dist-packages/cinder +else + export BASE=${1}/cinder +fi + +if [ ! -d "$BASE/$INFORTREND_DRIVER_DIR" ]; then + mkdir $BASE/$INFORTREND_DRIVER_DIR +fi + +if [ ! -d "$BASE/$INFORTREND_TEST_DIR" ]; then + mkdir $BASE/$INFORTREND_TEST_DIR +fi + +echo "Copying ./infortrend/* to $BASE/$INFORTREND_DRIVER_DIR/" +cp ./infortrend/* $BASE/$INFORTREND_DRIVER_DIR/ -r +echo "Copying ./test/infortrend/* to $BASE/$INFORTREND_TEST_DIR/" +cp ./test/infortrend/* $BASE/$INFORTREND_TEST_DIR/ -r + +if grep "infortrend" -q "$BASE/opts.py"; then + echo "Skip adding IFT opts/exceptions." +else + # 131 & 325 will need to change as if opts.py/exceptions.py is updated + echo "Setup infortrend opts/exceptions.." + sed -i '131 ifrom cinder.volume.drivers.infortrend.raidcmd_cli import common_cli as \\\n cinder_volume_drivers_infortrend' $BASE/opts.py + sed -i '325 i\\ cinder_volume_drivers_infortrend.infortrend_opts,' $BASE/opts.py + echo '# Infortrend Driver' >> $BASE/exception.py + echo 'class InfortrendCliException(CinderException):' >> $BASE/exception.py + echo ' message = _("Infortrend CLI exception: %(err)s Param: %(param)s "' >> $BASE/exception.py + echo ' "(Return Code: %(rc)s) (Output: %(out)s)")' >> $BASE/exception.py +fi